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

View File

@ -1,23 +1,42 @@
package eu.dnetlib.organizations.model.utils;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.Column;
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) {
final String oaGraphId = StringUtils.substringBefore(origId, "::") + "::"
+ DigestUtils.md5Hex(StringUtils.substringAfter(origId, "::"));
setOaGraphId(oaGraphId);
setOaGraphUrl(baseUrl + oaGraphId);
public void setOpenaireId(final String openaireId) {
this.openaireId = openaireId;
}
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.IdClass;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.hibernate.annotations.Type;
@ -18,7 +17,7 @@ import eu.dnetlib.organizations.model.utils.OpenaireGraphNode;
@Entity
@Table(name = "oa_duplicates_view")
@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")
private Boolean ecNutscode;
@Transient
private String oaGraphId;
@Transient
private String oaGraphUrl;
public String getLocalId() {
return localId;
}
@ -254,24 +247,4 @@ public class OpenaireDuplicateView implements Serializable, OpenaireGraphNode {
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.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import eu.dnetlib.organizations.model.utils.OpenaireGraphNode;
@Entity
@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")
private boolean note;
@Transient
private String oaGraphId;
@Transient
private String oaGraphUrl;
public String getId() {
return id;
}
@ -126,24 +119,4 @@ public class OrganizationInfoView implements Serializable, OpenaireGraphNode {
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.Table;
import eu.dnetlib.organizations.model.utils.OpenaireGraphNode;
@Entity
@Table(name = "persistent_orgs_view")
public class PersistentOrganizationView implements Serializable {
public class PersistentOrganizationView extends OpenaireGraphNode implements Serializable {
private static final long serialVersionUID = -8906936709574708538L;
@ -17,9 +19,6 @@ public class PersistentOrganizationView implements Serializable {
@Column(name = "id")
private String id;
@Column(name = "openaire_id")
private String openaireId;
@Column(name = "name")
private String name;
@ -37,14 +36,6 @@ public class PersistentOrganizationView implements Serializable {
this.id = id;
}
public String getOpenaireId() {
return openaireId;
}
public void setOpenaireId(final String openaireId) {
this.openaireId = openaireId;
}
public String getName() {
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" }
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_enterprise,
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
oa_duplicates d
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.modified_by,
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 c.id2) as n_conflicts,
count(DISTINCT n.note) > 0 as note
FROM organizations org
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 notes n ON (org.id = n.id)
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 notes n ON (org.id = n.id)
LEFT OUTER JOIN persistent_orgs po ON (org.id = po.id)
GROUP BY org.id;
CREATE VIEW organizations_simple_view AS SELECT
@ -684,6 +691,8 @@ ORDER BY o.name;
CREATE VIEW persistent_orgs_view AS SELECT
po.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.city,
o.country

View File

@ -6,7 +6,7 @@
<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>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>
<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-3 small">
<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.createdBy && sr.createdBy != 'dedupWf'"><br /><b>Added by:</b> {{sr.createdBy}}</span>
</td>