openaire greph node ids
This commit is contained in:
parent
51be640db9
commit
75a27e1fbd
|
@ -17,6 +17,7 @@ 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;
|
||||||
|
@ -82,6 +83,8 @@ 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) {
|
||||||
|
@ -104,7 +107,9 @@ 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) {
|
||||||
return organizationInfoViewRepository.findById(id).get();
|
final OrganizationInfoView info = organizationInfoViewRepository.findById(id).get();
|
||||||
|
info.fillGraphNodeInfo(info.getId(), oaBaseUrl);
|
||||||
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/suggestionsInfo")
|
@GetMapping("/suggestionsInfo")
|
||||||
|
@ -148,12 +153,18 @@ public class OrganizationController extends AbstractDnetController {
|
||||||
@GetMapping("/duplicates")
|
@GetMapping("/duplicates")
|
||||||
public List<OpenaireDuplicateView> duplicates(@RequestParam final String id, final Authentication authentication) {
|
public List<OpenaireDuplicateView> duplicates(@RequestParam final String id, final Authentication authentication) {
|
||||||
if (UserInfo.isSuperAdmin(authentication) || userCountryRepository.verifyAuthorizationForId(id, UserInfo.getEmail(authentication))) {
|
if (UserInfo.isSuperAdmin(authentication) || userCountryRepository.verifyAuthorizationForId(id, UserInfo.getEmail(authentication))) {
|
||||||
return openaireDuplicateViewRepository.findByLocalId(id);
|
return listDuplicates(id);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("User not authorized");
|
throw new RuntimeException("User not authorized");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<OpenaireDuplicateView> listDuplicates(final String id) {
|
||||||
|
final List<OpenaireDuplicateView> list = openaireDuplicateViewRepository.findByLocalId(id);
|
||||||
|
list.forEach(d -> d.fillGraphNodeInfo(d.getOaOriginalId(), oaBaseUrl));
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/conflicts/byCountry/{country}")
|
@GetMapping("/conflicts/byCountry/{country}")
|
||||||
public Collection<Set<OrganizationConflict>> findConflictsByCountry(@PathVariable final String country, final Authentication authentication) {
|
public Collection<Set<OrganizationConflict>> findConflictsByCountry(@PathVariable final String country, final Authentication authentication) {
|
||||||
|
|
||||||
|
@ -222,7 +233,7 @@ public class OrganizationController extends AbstractDnetController {
|
||||||
|
|
||||||
if (b) {
|
if (b) {
|
||||||
databaseUtils.saveDuplicates(simrels, UserInfo.getEmail(authentication));
|
databaseUtils.saveDuplicates(simrels, UserInfo.getEmail(authentication));
|
||||||
return openaireDuplicateViewRepository.findByLocalId(simrels.get(0).getLocalId());
|
return listDuplicates(simrels.get(0).getLocalId());
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("User not authorized");
|
throw new RuntimeException("User not authorized");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package eu.dnetlib.organizations.model.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.codec.digest.DigestUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
public interface OpenaireGraphNode {
|
||||||
|
|
||||||
|
String getOaGraphId();
|
||||||
|
|
||||||
|
void setOaGraphId(String oaGraphId);
|
||||||
|
|
||||||
|
String getOaGraphUrl();
|
||||||
|
|
||||||
|
void setOaGraphUrl(String oaGraphUrl);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,15 +8,17 @@ 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;
|
||||||
|
|
||||||
import eu.dnetlib.organizations.model.OpenaireDuplicatePK;
|
import eu.dnetlib.organizations.model.OpenaireDuplicatePK;
|
||||||
|
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 {
|
public class OpenaireDuplicateView implements Serializable, OpenaireGraphNode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -86,6 +88,12 @@ public class OpenaireDuplicateView implements Serializable {
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
@ -246,4 +254,24 @@ public class OpenaireDuplicateView implements Serializable {
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,13 @@ 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;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "organizations_info_view")
|
@Table(name = "organizations_info_view")
|
||||||
public class OrganizationInfoView implements Serializable {
|
public class OrganizationInfoView implements Serializable, OpenaireGraphNode {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -45,6 +48,12 @@ public class OrganizationInfoView implements Serializable {
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
@ -117,4 +126,24 @@ public class OrganizationInfoView implements Serializable {
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,3 +48,4 @@ openorgs.support.pages = { "Ask a question": "https://www.openaire.eu/support/he
|
||||||
|
|
||||||
openaire.override.logout.url =
|
openaire.override.logout.url =
|
||||||
|
|
||||||
|
openaire.explore.organization.baseurl = https://explore.openaire.eu/search/organization?organizationId=
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
<div class="alert alert-success" ng-if="message">{{message}}</div>
|
<div class="alert alert-success" ng-if="message">{{message}}</div>
|
||||||
|
|
||||||
<p class="text-muted" ng-if="!message">
|
<p class="text-muted" ng-if="!message">
|
||||||
<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>
|
<b>ID: </b>{{info.id}}<br />
|
||||||
{{info.modifiedBy}}
|
<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/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
<td class="col-1 text-center small">{{sr.oaAcronym}}</td>
|
<td class="col-1 text-center small">{{sr.oaAcronym}}</td>
|
||||||
<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>
|
<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>
|
||||||
<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>
|
||||||
|
|
Loading…
Reference in New Issue