@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((createdDate == null) ? 0 : createdDate.hashCode()); result = prime * result + ((lastModifiedDate == null) ? 0 : lastModifiedDate.hashCode()); result = prime * result + ((path == null) ? 0 : path.hashCode()); result = prime * result + ((putCode == null) ? 0 : putCode.hashCode()); result = prime * result + ((value == null) ? 0 : value.hashCode()); result = prime * result + ((relationship == null) ? 0 : relationship.hashCode()); result = prime * result + ((source == null) ? 0 : source.hashCode()); result = prime * result + ((url == null) ? 0 : url.hashCode()); result = prime * result + ((visibility == null) ? 0 : visibility.hashCode()); return result; } @Override
@JsonValue public String jsonValue() { return this.name(); }
public String convertTo(FundingExternalIdentifiers messagePojo) { JSONFundingExternalIdentifiers fundingExternalIdentifiers = new JSONFundingExternalIdentifiers(); if (messagePojo != null) { for (FundingExternalIdentifier fundingExternalIdentifier : messagePojo.getFundingExternalIdentifier()) { JSONExternalIdentifier jsonExternalIdentifier = new JSONExternalIdentifier(); if (fundingExternalIdentifier.getType() != null) { jsonExternalIdentifier.setType(fundingExternalIdentifier.getType().value()); } if (fundingExternalIdentifier.getUrl() != null) { jsonExternalIdentifier.setUrl(new JSONUrl(fundingExternalIdentifier.getUrl().getValue())); } if (!PojoUtil.isEmpty(fundingExternalIdentifier.getValue())) { jsonExternalIdentifier.setValue(fundingExternalIdentifier.getValue()); } jsonExternalIdentifier.setRelationship(Relationship.SELF.value()); fundingExternalIdentifiers.getFundingExternalIdentifier().add(jsonExternalIdentifier); } } return JsonUtils.convertToJsonString(fundingExternalIdentifiers); }
@Override public ExternalIDs convertFrom(String source, Type<ExternalIDs> destinationType) { JSONFundingExternalIdentifiers fundingExternalIdentifiers = JsonUtils.readObjectFromJsonString(source, JSONFundingExternalIdentifiers.class); ExternalIDs externalIDs = new ExternalIDs(); for (JSONExternalIdentifier externalIdentifier : fundingExternalIdentifiers.getFundingExternalIdentifier()) { ExternalID id = new ExternalID(); if (externalIdentifier.getType() == null) { id.setType(FundingExternalIdentifierType.GRANT_NUMBER.value()); } else { id.setType(externalIdentifier.getType().toLowerCase()); } if (externalIdentifier.getUrl() != null && !PojoUtil.isEmpty(externalIdentifier.getUrl().getValue())) { Url url = new Url(externalIdentifier.getUrl().getValue()); id.setUrl(url); } if (!PojoUtil.isEmpty(externalIdentifier.getValue())) { id.setValue(externalIdentifier.getValue()); } if (externalIdentifier.getRelationship() != null) { id.setRelationship(Relationship.fromValue(conv.convertFrom(externalIdentifier.getRelationship(), null))); } externalIDs.getExternalIdentifier().add(id); } return externalIDs; }
public static Relationship fromValue(String v) { for (Relationship c : Relationship.values()) { if (c.value.equals(v)) { return c; } } throw new IllegalArgumentException(v); }
@Override public String convertTo(ExternalIDs source, Type<String> destinationType) { JSONFundingExternalIdentifiers jsonFundingExternalIdentifiers = new JSONFundingExternalIdentifiers(); for (ExternalID externalID : source.getExternalIdentifier()) { JSONExternalIdentifier jsonExternalIdentifier = new JSONExternalIdentifier(); if (externalID.getType() != null) { jsonExternalIdentifier.setType(conv.convertTo(externalID.getType(), null)); } if (externalID.getUrl() != null) { jsonExternalIdentifier.setUrl(new JSONUrl(externalID.getUrl().getValue())); } if (!PojoUtil.isEmpty(externalID.getValue())) { jsonExternalIdentifier.setValue(externalID.getValue()); } if (externalID.getRelationship() != null) { jsonExternalIdentifier.setRelationship(conv.convertTo(externalID.getRelationship().value(), null)); } jsonFundingExternalIdentifiers.getFundingExternalIdentifier().add(jsonExternalIdentifier); } return JsonUtils.convertToJsonString(jsonFundingExternalIdentifiers); }
@Override public ExternalIDs convertFrom(String source, Type<ExternalIDs> destinationType) { JSONWorkExternalIdentifiers workExternalIdentifiers = JsonUtils.readObjectFromJsonString(source, JSONWorkExternalIdentifiers.class); ExternalIDs externalIDs = new ExternalIDs(); for (JSONWorkExternalIdentifier workExternalIdentifier : workExternalIdentifiers.getWorkExternalIdentifier()) { if(workExternalIdentifier.getRelationship() == null || !org.orcid.jaxb.model.common.Relationship.VERSION_OF.name().equals(workExternalIdentifier.getRelationship())) { ExternalID id = new ExternalID(); if (workExternalIdentifier.getWorkExternalIdentifierType() == null) { id.setType(WorkExternalIdentifierType.OTHER_ID.value()); } else { id.setType(conv.convertFrom(workExternalIdentifier.getWorkExternalIdentifierType(), null)); } if (workExternalIdentifier.getWorkExternalIdentifierId() != null) { id.setValue(workExternalIdentifier.getWorkExternalIdentifierId().content); } if (workExternalIdentifier.getUrl() != null) { id.setUrl(new Url(workExternalIdentifier.getUrl().getValue())); } if (workExternalIdentifier.getRelationship() != null) { id.setRelationship(Relationship.fromValue(conv.convertFrom(workExternalIdentifier.getRelationship(), null))); } externalIDs.getExternalIdentifier().add(id); } } return externalIDs; }
@Override @JsonIgnore public boolean isGroupAble() { //Dont group if it is a part-of identifier if(Relationship.PART_OF.equals(relationship)) return false; // Dont groups works where the external id is empty if (this.getValue() == null || this.getValue().isEmpty()) return false; return true; }
@Override public String convertTo(ExternalIDs source, Type<String> destinationType) { JSONWorkExternalIdentifiers jsonWorkExternalIdentifiers = new JSONWorkExternalIdentifiers(); for (ExternalID externalID : source.getExternalIdentifier()) { JSONWorkExternalIdentifier jsonWorkExternalIdentifier = new JSONWorkExternalIdentifier(); if (externalID.getType() != null) { jsonWorkExternalIdentifier.setWorkExternalIdentifierType(conv.convertTo(externalID.getType(), null)); } if (externalID.getUrl() != null) { jsonWorkExternalIdentifier.setUrl(new JSONUrl(externalID.getUrl().getValue())); } if (!PojoUtil.isEmpty(externalID.getValue())) { jsonWorkExternalIdentifier.setWorkExternalIdentifierId(new WorkExternalIdentifierId(externalID.getValue())); } if (externalID.getRelationship() != null) { jsonWorkExternalIdentifier.setRelationship(conv.convertTo(externalID.getRelationship().value(), null)); } jsonWorkExternalIdentifiers.getWorkExternalIdentifier().add(jsonWorkExternalIdentifier); } return JsonUtils.convertToJsonString(jsonWorkExternalIdentifiers); }
@Override public ExternalID convertFrom(String source, Type<ExternalID> destinationType) { JSONWorkExternalIdentifier workExternalIdentifier = JsonUtils.readObjectFromJsonString(source, JSONWorkExternalIdentifier.class); ExternalID id = new ExternalID(); if (workExternalIdentifier.getWorkExternalIdentifierType() == null) { id.setType(WorkExternalIdentifierType.OTHER_ID.value()); } else { id.setType(conv.convertFrom(workExternalIdentifier.getWorkExternalIdentifierType(), null)); } if (workExternalIdentifier.getWorkExternalIdentifierId() != null) { id.setValue(workExternalIdentifier.getWorkExternalIdentifierId().content); } if (workExternalIdentifier.getUrl() != null) { id.setUrl(new Url(workExternalIdentifier.getUrl().getValue())); } if (workExternalIdentifier.getRelationship() != null) { id.setRelationship(Relationship.fromValue(conv.convertFrom(workExternalIdentifier.getRelationship(), null))); } return id; }
if (other.relationship != null) return false; } else if (!relationship.equals(other.relationship)) return false; if (source == null) {
@Override public String convertTo(ExternalID source, Type<String> destinationType) { JSONWorkExternalIdentifier jsonWorkExternalIdentifier = new JSONWorkExternalIdentifier(); if (source.getType() != null) { jsonWorkExternalIdentifier.setWorkExternalIdentifierType(conv.convertTo(source.getType(), null)); } if (source.getUrl() != null) { jsonWorkExternalIdentifier.setUrl(new JSONUrl(source.getUrl().getValue())); } if (!PojoUtil.isEmpty(source.getValue())) { jsonWorkExternalIdentifier.setWorkExternalIdentifierId(new WorkExternalIdentifierId(source.getValue())); } if (source.getRelationship() != null) { jsonWorkExternalIdentifier.setRelationship(conv.convertTo(source.getRelationship().value(), null)); } return JsonUtils.convertToJsonString(jsonWorkExternalIdentifier); }
private void addExternalIdsToExistingSet(Work work, Set<ExternalID> existingExternalIDs) { if(work != null && work.getExternalIdentifiers() != null && work.getExternalIdentifiers().getExternalIdentifier() != null) { for(ExternalID extId : work.getExternalIdentifiers().getExternalIdentifier()) { //Don't include PART_OF external ids if(!Relationship.PART_OF.equals(extId.getRelationship())) { existingExternalIDs.add(extId); } } } }
/** * Return the list of existing external identifiers for the given user where the source matches the given sourceId * * @param existingWorks * The list of existing works for the current user * @param sourceId * The client id we are evaluating * @return A set of all the existing external identifiers that belongs to the given user and to the given source id * */ private Set<ExternalID> buildExistingExternalIdsSet(List<Work> existingWorks, String sourceId) { Set<ExternalID> existingExternalIds = new HashSet<ExternalID>(); for(Work work : existingWorks) { //If it is the same source if(work.retrieveSourcePath().equals(sourceId)) { if(work.getExternalIdentifiers() != null && work.getExternalIdentifiers().getExternalIdentifier() != null) { for(ExternalID extId : work.getExternalIdentifiers().getExternalIdentifier()) { //Don't include PART_OF external ids if(!Relationship.PART_OF.equals(extId.getRelationship())) { existingExternalIds.add(extId); } } } } } return existingExternalIds; }
if(externalIdentifier.getRelationship() == null || !Relationship.SELF.equals(externalIdentifier.getRelationship())) { String message = "Relationship field should be self for person identifiers"; LOGGER.error(message);
for(ExternalID extId : work.getExternalIdentifiers().getExternalIdentifier()) { if(existingExternalIdentifiers.contains(extId) && Relationship.SELF.equals(extId.getRelationship())) { Map<String, String> params = new HashMap<String, String>(); params.put("clientName", SourceEntityUtils.getSourceName(sourceEntity));