use of sql dates

This commit is contained in:
Michele Artini 2024-06-26 11:44:11 +02:00
parent 6965742b77
commit 84bdffc3f4
2 changed files with 12 additions and 10 deletions

View File

@ -1,7 +1,7 @@
package eu.dnetlib.openaire.funders.domain.db;
import java.io.Serializable;
import java.time.LocalDate;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
@ -16,12 +16,14 @@ import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.vladmihalcea.hibernate.type.array.DateArrayType;
import com.vladmihalcea.hibernate.type.array.StringArrayType;
@Entity
@Table(name = "funders_view")
@TypeDefs({
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "date-array", typeClass = DateArrayType.class),
})
public class FunderDbEntry implements Serializable {
@ -47,7 +49,7 @@ public class FunderDbEntry implements Serializable {
private String country;
@Column(name = "registrationdate")
private LocalDate registrationDate;
private Date registrationDate;
@Column(name = "registered")
private Boolean registered;
@ -68,9 +70,9 @@ public class FunderDbEntry implements Serializable {
@Transient
private List<FunderDatasource> datasources = new ArrayList<FunderDatasource>();
@Type(type = "string-array")
@Column(name = "aggregationdates", columnDefinition = "text[]")
private String[] aggregationDates;
@Type(type = "date-array")
@Column(name = "aggregationdates", columnDefinition = "date[]")
private Date[] aggregationDates;
public String getId() {
return id;
@ -120,11 +122,11 @@ public class FunderDbEntry implements Serializable {
this.country = country;
}
public LocalDate getRegistrationDate() {
public Date getRegistrationDate() {
return registrationDate;
}
public void setRegistrationDate(final LocalDate registrationDate) {
public void setRegistrationDate(final Date registrationDate) {
this.registrationDate = registrationDate;
}
@ -168,11 +170,11 @@ public class FunderDbEntry implements Serializable {
this.datasources = datasources;
}
public String[] getAggregationDates() {
public Date[] getAggregationDates() {
return aggregationDates;
}
public void setAggregationDates(final String[] aggregationDates) {
public void setAggregationDates(final Date[] aggregationDates) {
this.aggregationDates = aggregationDates;
}

View File

@ -33,7 +33,7 @@ CREATE OR REPLACE VIEW funders_view AS SELECT
o.dateofcollection AS registrationdate,
o.registered_funder AS registered,
array_remove(array_agg(DISTINCT s.id||' @=@ '||s.officialname||' @=@ '||s.eosc_datasource_type), NULL) AS datasources,
array_remove(array_agg(DISTINCT sf.last_aggregation_date::text ORDER BY sf.last_aggregation_date::text DESC), NULL) AS aggregationdates,
array_remove(array_agg(DISTINCT sf.last_aggregation_date ORDER BY sf.last_aggregation_date DESC), NULL) AS aggregationdates,
array_remove(array_agg(DISTINCT pids.issuertype||' @=@ '||pids.pid), NULL) AS pids
FROM
dsm_organizations o