This commit is contained in:
Michele Artini 2024-02-19 10:57:39 +01:00
parent e5901a0181
commit 3eed737bad
5 changed files with 85 additions and 16 deletions

View File

@ -29,7 +29,7 @@ public class FundersApiController extends AbstractExporterController {
@Autowired @Autowired
private FunderDao fDao; private FunderDao fDao;
@RequestMapping(value = "/funders", produces = { @RequestMapping(value = "/funders/{page}/{size}", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, method = RequestMethod.GET)
@Operation(summary = "get basic information about funders", description = "basic information about funders: id, name, shortname, registration date") @Operation(summary = "get basic information about funders", description = "basic information about funders: id, name, shortname, registration date")
@ -56,7 +56,7 @@ public class FundersApiController extends AbstractExporterController {
return fDao.findFunder(id); return fDao.findFunder(id);
} }
@RequestMapping(value = "/funder/ids", produces = { @RequestMapping(value = "/funders/{page}/{size}/ids", produces = {
"application/json" "application/json"
}, method = RequestMethod.GET) }, method = RequestMethod.GET)
@Operation(summary = "get the list of funder ids", description = "get the list of funder ids") @Operation(summary = "get the list of funder ids", description = "get the list of funder ids")

View File

@ -1,15 +1,30 @@
package eu.dnetlib.openaire.funders.domain.db; package eu.dnetlib.openaire.funders.domain.db;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDate;
import java.util.List;
import javax.persistence.Column; import javax.persistence.Column;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import com.vladmihalcea.hibernate.type.array.StringArrayType;
import com.vladmihalcea.hibernate.type.json.JsonBinaryType;
import com.vladmihalcea.hibernate.type.json.JsonStringType;
@Entity @Entity
@Table(name = "funders") @Table(name = "funders_view")
@TypeDefs({
@TypeDef(name = "string-array", typeClass = StringArrayType.class),
@TypeDef(name = "json", typeClass = JsonStringType.class),
@TypeDef(name = "jsonb", typeClass = JsonBinaryType.class)
})
public class FunderDbEntry implements Serializable { public class FunderDbEntry implements Serializable {
private static final long serialVersionUID = 1290088460508203016L; private static final long serialVersionUID = 1290088460508203016L;
@ -34,10 +49,17 @@ public class FunderDbEntry implements Serializable {
private String country; private String country;
@Column(name = "registrationdate") @Column(name = "registrationdate")
private LocalDateTime registrationDate; private LocalDate registrationDate;
@Column(name = "registered") @Column(name = "registered")
private boolean registered; private Boolean registered;
@Type(type = "json")
@Column(name = "pids", columnDefinition = "jsonb")
private List<FunderPid> pids;
@Transient
private List<LocalDate> aggregationDates;
public String getId() { public String getId() {
return id; return id;
@ -87,20 +109,35 @@ public class FunderDbEntry implements Serializable {
this.country = country; this.country = country;
} }
public LocalDateTime getRegistrationDate() { public LocalDate getRegistrationDate() {
return registrationDate; return registrationDate;
} }
public void setRegistrationDate(final LocalDateTime registrationDate) { public void setRegistrationDate(final LocalDate registrationDate) {
this.registrationDate = registrationDate; this.registrationDate = registrationDate;
} }
public boolean isRegistered() { public Boolean getRegistered() {
return registered; return registered;
} }
public void setRegistered(final boolean registered) { public void setRegistered(final Boolean registered) {
this.registered = registered; this.registered = registered;
} }
public List<LocalDate> getAggregationDates() {
return aggregationDates;
}
public void setAggregationDates(final List<LocalDate> aggregationDates) {
this.aggregationDates = aggregationDates;
}
public List<FunderPid> getPids() {
return pids;
}
public void setPids(final List<FunderPid> pids) {
this.pids = pids;
}
} }

View File

@ -0,0 +1,29 @@
package eu.dnetlib.openaire.funders.domain.db;
import java.io.Serializable;
public class FunderPid implements Serializable {
private static final long serialVersionUID = 2145493560459874509L;
private String type;
private String value;
public String getType() {
return type;
}
public void setType(final String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(final String value) {
this.value = value;
}
}

View File

@ -27,7 +27,7 @@ openaire.exporter.enable.dsm = true
openaire.exporter.enable.community = true openaire.exporter.enable.community = true
openaire.exporter.enable.community.import = false openaire.exporter.enable.community.import = false
openaire.exporter.enable.context = true openaire.exporter.enable.context = true
openaire.exporter.enable.funders = false openaire.exporter.enable.funders = true
openaire.exporter.enable.project = true openaire.exporter.enable.project = true
openaire.exporter.enable.info = true openaire.exporter.enable.info = true

View File

@ -8,10 +8,13 @@ CREATE VIEW funders_view AS SELECT
o.logourl AS logourl, o.logourl AS logourl,
o.country AS country, o.country AS country,
o.dateofcollection AS registrationdate, o.dateofcollection AS registrationdate,
o.registered_funder AS registered o.registered_funder AS registered,
CASE WHEN count(pids.pid) = 0 THEN '[]'::jsonb ELSE jsonb_agg(jsonb_build_object('type', pids.issuertype,'value', pids.pid)) END AS pids
FROM FROM
dsm_organizations o dsm_organizations o
JOIN dsm_service_organization so ON (o.id = so.organization) JOIN dsm_service_organization so ON (o.id = so.organization)
JOIN dsm_services s ON (so.service = s.id) JOIN dsm_services s ON (so.service = s.id)
JOIN projects p ON (p.collectedfrom = s.id) JOIN projects p ON (p.collectedfrom = s.id)
GROUP BY o.id; LEFT OUTER JOIN dsm_organizationpids opids ON (o.id = opids.organization)
LEFT OUTER JOIN dsm_identities pids ON (opids.pid = pids.pid)
GROUP BY o.id;