This commit is contained in:
Michele Artini 2022-09-26 14:16:22 +02:00
parent 1ccb1c266f
commit 98b59cd0d5
9 changed files with 53 additions and 97 deletions

View File

@ -17,7 +17,6 @@ import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
import org.springframework.security.core.Authentication; import org.springframework.security.core.Authentication;
@ -83,8 +82,6 @@ public class OrganizationController extends AbstractDnetController {
private JournalEntryRepository journalEntryRepository; private JournalEntryRepository journalEntryRepository;
@Autowired @Autowired
private DatabaseUtils databaseUtils; private DatabaseUtils databaseUtils;
@Value("${openaire.explore.organization.baseurl}")
private String oaBaseUrl;
@PostMapping("/save") @PostMapping("/save")
public List<String> save(@RequestBody final OrganizationView org, final Authentication authentication) { public List<String> save(@RequestBody final OrganizationView org, final Authentication authentication) {
@ -107,9 +104,7 @@ public class OrganizationController extends AbstractDnetController {
@GetMapping("/info") @GetMapping("/info")
public OrganizationInfoView infoById(@RequestParam final String id, final Authentication authentication) { public OrganizationInfoView infoById(@RequestParam final String id, final Authentication authentication) {
final OrganizationInfoView info = organizationInfoViewRepository.findById(id).get(); return organizationInfoViewRepository.findById(id).get();
info.fillGraphNodeInfo(info.getId(), oaBaseUrl);
return info;
} }
@GetMapping("/suggestionsInfo") @GetMapping("/suggestionsInfo")
@ -160,9 +155,7 @@ public class OrganizationController extends AbstractDnetController {
} }
private List<OpenaireDuplicateView> listDuplicates(final String id) { private List<OpenaireDuplicateView> listDuplicates(final String id) {
final List<OpenaireDuplicateView> list = openaireDuplicateViewRepository.findByLocalId(id); return openaireDuplicateViewRepository.findByLocalId(id);
list.forEach(d -> d.fillGraphNodeInfo(d.getOaOriginalId(), oaBaseUrl));
return list;
} }
@GetMapping("/conflicts/byCountry/{country}") @GetMapping("/conflicts/byCountry/{country}")

View File

@ -1,23 +1,42 @@
package eu.dnetlib.organizations.model.utils; package eu.dnetlib.organizations.model.utils;
import org.apache.commons.codec.digest.DigestUtils; import javax.persistence.Column;
import org.apache.commons.lang3.StringUtils; import javax.persistence.MappedSuperclass;
public interface OpenaireGraphNode { @MappedSuperclass
public abstract class OpenaireGraphNode {
String getOaGraphId(); @Column(name = "openaire_id")
private String openaireId;
void setOaGraphId(String oaGraphId); @Column(name = "openaire_url")
private String openaireUrl;
String getOaGraphUrl(); @Column(name = "openaire_persistent")
private Boolean persistent = false;
void setOaGraphUrl(String oaGraphUrl); public String getOpenaireId() {
return openaireId;
}
default void fillGraphNodeInfo(final String origId, final String baseUrl) { public void setOpenaireId(final String openaireId) {
final String oaGraphId = StringUtils.substringBefore(origId, "::") + "::" this.openaireId = openaireId;
+ DigestUtils.md5Hex(StringUtils.substringAfter(origId, "::")); }
setOaGraphId(oaGraphId);
setOaGraphUrl(baseUrl + oaGraphId); public String getOpenaireUrl() {
return openaireUrl;
}
public void setOpenaireUrl(final String openaireUrl) {
this.openaireUrl = openaireUrl;
}
public Boolean getPersistent() {
return persistent;
}
public void setPersistent(final Boolean persistent) {
this.persistent = persistent;
} }
} }

View File

@ -8,7 +8,6 @@ import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.IdClass; import javax.persistence.IdClass;
import javax.persistence.Table; import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Type; import org.hibernate.annotations.Type;
@ -18,7 +17,7 @@ import eu.dnetlib.organizations.model.utils.OpenaireGraphNode;
@Entity @Entity
@Table(name = "oa_duplicates_view") @Table(name = "oa_duplicates_view")
@IdClass(OpenaireDuplicatePK.class) @IdClass(OpenaireDuplicatePK.class)
public class OpenaireDuplicateView implements Serializable, OpenaireGraphNode { public class OpenaireDuplicateView extends OpenaireGraphNode implements Serializable {
/** /**
* *
@ -88,12 +87,6 @@ public class OpenaireDuplicateView implements Serializable, OpenaireGraphNode {
@Column(name = "ec_nutscode") @Column(name = "ec_nutscode")
private Boolean ecNutscode; private Boolean ecNutscode;
@Transient
private String oaGraphId;
@Transient
private String oaGraphUrl;
public String getLocalId() { public String getLocalId() {
return localId; return localId;
} }
@ -254,24 +247,4 @@ public class OpenaireDuplicateView implements Serializable, OpenaireGraphNode {
this.ecNutscode = ecNutscode; this.ecNutscode = ecNutscode;
} }
@Override
public String getOaGraphId() {
return oaGraphId;
}
@Override
public void setOaGraphId(final String oaGraphId) {
this.oaGraphId = oaGraphId;
}
@Override
public String getOaGraphUrl() {
return oaGraphUrl;
}
@Override
public void setOaGraphUrl(final String oaGraphUrl) {
this.oaGraphUrl = oaGraphUrl;
}
} }

View File

@ -7,13 +7,12 @@ 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 eu.dnetlib.organizations.model.utils.OpenaireGraphNode; import eu.dnetlib.organizations.model.utils.OpenaireGraphNode;
@Entity @Entity
@Table(name = "organizations_info_view") @Table(name = "organizations_info_view")
public class OrganizationInfoView implements Serializable, OpenaireGraphNode { public class OrganizationInfoView extends OpenaireGraphNode implements Serializable {
/** /**
* *
@ -48,12 +47,6 @@ public class OrganizationInfoView implements Serializable, OpenaireGraphNode {
@Column(name = "note") @Column(name = "note")
private boolean note; private boolean note;
@Transient
private String oaGraphId;
@Transient
private String oaGraphUrl;
public String getId() { public String getId() {
return id; return id;
} }
@ -126,24 +119,4 @@ public class OrganizationInfoView implements Serializable, OpenaireGraphNode {
this.note = note; this.note = note;
} }
@Override
public String getOaGraphId() {
return oaGraphId;
}
@Override
public void setOaGraphId(final String oaGraphId) {
this.oaGraphId = oaGraphId;
}
@Override
public String getOaGraphUrl() {
return oaGraphUrl;
}
@Override
public void setOaGraphUrl(final String oaGraphUrl) {
this.oaGraphUrl = oaGraphUrl;
}
} }

View File

@ -7,9 +7,11 @@ import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import eu.dnetlib.organizations.model.utils.OpenaireGraphNode;
@Entity @Entity
@Table(name = "persistent_orgs_view") @Table(name = "persistent_orgs_view")
public class PersistentOrganizationView implements Serializable { public class PersistentOrganizationView extends OpenaireGraphNode implements Serializable {
private static final long serialVersionUID = -8906936709574708538L; private static final long serialVersionUID = -8906936709574708538L;
@ -17,9 +19,6 @@ public class PersistentOrganizationView implements Serializable {
@Column(name = "id") @Column(name = "id")
private String id; private String id;
@Column(name = "openaire_id")
private String openaireId;
@Column(name = "name") @Column(name = "name")
private String name; private String name;
@ -37,14 +36,6 @@ public class PersistentOrganizationView implements Serializable {
this.id = id; this.id = id;
} }
public String getOpenaireId() {
return openaireId;
}
public void setOpenaireId(final String openaireId) {
this.openaireId = openaireId;
}
public String getName() { public String getName() {
return name; return name;
} }

View File

@ -50,5 +50,3 @@ openaire.api.https.proxy = 10.19.65.35
openorgs.support.pages = { "Ask a question": "https://www.openaire.eu/support/helpdesk?view=ticket&layout=open", "FAQ": "https://www.openaire.eu/faqs" } openorgs.support.pages = { "Ask a question": "https://www.openaire.eu/support/helpdesk?view=ticket&layout=open", "FAQ": "https://www.openaire.eu/faqs" }
openaire.override.logout.url = openaire.override.logout.url =
openaire.explore.organization.baseurl = https://explore.openaire.eu/search/organization?organizationId=

View File

@ -471,7 +471,10 @@ CREATE VIEW oa_duplicates_view AS
o.ec_internationalorganization, o.ec_internationalorganization,
o.ec_enterprise, o.ec_enterprise,
o.ec_smevalidated, o.ec_smevalidated,
o.ec_nutscode o.ec_nutscode,
substr(d.oa_original_id, 1, 14)||md5(substr(d.oa_original_id, 15)) as openaire_id,
'https://explore.openaire.eu/search/organization?organizationId='||substr(d.oa_original_id, 1, 14)||md5(substr(d.oa_original_id, 15)) as openaire_url,
false as openaire_persistent
FROM FROM
oa_duplicates d oa_duplicates d
LEFT OUTER JOIN organizations o ON (o.id = d.oa_original_id) LEFT OUTER JOIN organizations o ON (o.id = d.oa_original_id)
@ -571,13 +574,17 @@ CREATE VIEW organizations_info_view AS SELECT
org.creation_date, org.creation_date,
org.modified_by, org.modified_by,
org.modification_date, org.modification_date,
substr(org.id, 1, 14)||md5(substr(org.id, 15)) as openaire_id,
'https://explore.openaire.eu/search/organization?organizationId='||substr(org.id, 1, 14)||md5(substr(org.id, 15)) as openaire_url,
count(po.id) > 0 as openaire_persistent,
count(DISTINCT d.oa_original_id) as n_duplicates, count(DISTINCT d.oa_original_id) as n_duplicates,
count(DISTINCT c.id2) as n_conflicts, count(DISTINCT c.id2) as n_conflicts,
count(DISTINCT n.note) > 0 as note count(DISTINCT n.note) > 0 as note
FROM organizations org FROM organizations org
LEFT OUTER JOIN oa_duplicates d ON (org.id = d.local_id AND d.reltype = 'suggested') LEFT OUTER JOIN oa_duplicates d ON (org.id = d.local_id AND d.reltype = 'suggested')
LEFT OUTER JOIN oa_conflicts c ON (org.id = c.id1 AND c.reltype = 'suggested') LEFT OUTER JOIN oa_conflicts c ON (org.id = c.id1 AND c.reltype = 'suggested')
LEFT OUTER JOIN notes n ON (org.id = n.id) LEFT OUTER JOIN notes n ON (org.id = n.id)
LEFT OUTER JOIN persistent_orgs po ON (org.id = po.id)
GROUP BY org.id; GROUP BY org.id;
CREATE VIEW organizations_simple_view AS SELECT CREATE VIEW organizations_simple_view AS SELECT
@ -684,6 +691,8 @@ ORDER BY o.name;
CREATE VIEW persistent_orgs_view AS SELECT CREATE VIEW persistent_orgs_view AS SELECT
po.id, po.id,
substr(po.id, 1, 14)||md5(substr(po.id,15)) as openaire_id, substr(po.id, 1, 14)||md5(substr(po.id,15)) as openaire_id,
'https://explore.openaire.eu/search/organization?organizationId='||substr(po.id, 1, 14)||md5(substr(po.id, 15)) as openaire_url,
true as openaire_persistent,
o.name, o.name,
o.city, o.city,
o.country o.country

View File

@ -6,7 +6,7 @@
<b>ID: </b>{{info.id}}<br /> <b>ID: </b>{{info.id}}<br />
<b>Created at</b> {{info.creationDate | date:'MMMM d, y HH:mm:ss'}} <b>by</b> {{info.createdBy}}<br /> <b>Created at</b> {{info.creationDate | date:'MMMM d, y HH:mm:ss'}} <b>by</b> {{info.createdBy}}<br />
<b>Modified at</b> {{info.modificationDate | date:'MMMM d, y HH:mm:ss'}} <b>by</b> {{info.modifiedBy}}<br /> <b>Modified at</b> {{info.modificationDate | date:'MMMM d, y HH:mm:ss'}} <b>by</b> {{info.modifiedBy}}<br />
<b>OA Graph Node ID: </b> {{info.oaGraphId}} <a href="{{info.oaGraphUrl}}" target="_blank">[try on OA Explore]</a><br/> <b>OA Graph Node ID: </b> {{info.openaireId}} <a href="{{info.openaireUrl}}" target="_blank">[try on OA Explore]</a><br/>
</p> </p>
<div class="card"> <div class="card">

View File

@ -36,7 +36,7 @@
<td class="col-2 text-center small"><img ng-src="resources/images/flags/{{sr.oaCountry}}.gif" /> {{sr.oaCountry}}</td> <td class="col-2 text-center small"><img ng-src="resources/images/flags/{{sr.oaCountry}}.gif" /> {{sr.oaCountry}}</td>
<td class="col-3 small"> <td class="col-3 small">
<b>Original Id:</b> <span class="text-monospace">{{sr.oaOriginalId}}</span><br /> <b>Original Id:</b> <span class="text-monospace">{{sr.oaOriginalId}}</span><br />
<b>OA Graph Node ID: </b> <span class="text-monospace">{{sr.oaGraphId}}</span> <a href="{{sr.oaGraphUrl}}" target="_blank">[try]</a> <b>OA Graph Node ID: </b> <span class="text-monospace">{{sr.openaireId}}</span> <a href="{{sr.openaireUrl}}" target="_blank">[try]</a>
<span ng-if="sr.oaCollectedFrom"><br /><b>Provenance:</b> {{sr.oaCollectedFrom}}</span> <span ng-if="sr.oaCollectedFrom"><br /><b>Provenance:</b> {{sr.oaCollectedFrom}}</span>
<span ng-if="sr.createdBy && sr.createdBy != 'dedupWf'"><br /><b>Added by:</b> {{sr.createdBy}}</span> <span ng-if="sr.createdBy && sr.createdBy != 'dedupWf'"><br /><b>Added by:</b> {{sr.createdBy}}</span>
</td> </td>