private boolean isDuplicated(ResearcherUrlEntity existing, ResearcherUrl newResearcherUrl, Source activeSource) { if (!existing.getId().equals(newResearcherUrl.getPutCode())) { //If they have the same source String existingSourceId = existing.getElementSourceId(); // If they have the same source if (!PojoUtil.isEmpty(existingSourceId) && SourceEntityUtils.isTheSameForDuplicateChecking(activeSource,existing)) { // If the url is the same if (existing.getUrl() != null && existing.getUrl().equals(newResearcherUrl.getUrl().getValue())) { return true; } } } return false; }
return; if(PojoUtil.isEmpty(researcherUrl.getUrl().getValue())) { String message = "Url field must not be empty"; LOGGER.error(message); throw new OrcidValidationException(message); } else { if(SiteConstants.URL_MAX_LENGTH < researcherUrl.getUrl().getValue().length()) { String message = "Url field must not be longer than " + SiteConstants.URL_MAX_LENGTH + " characters"; LOGGER.error(message);
@Override public PersonExternalIdentifier createExternalIdentifier(String orcid, PersonExternalIdentifier externalIdentifier, boolean isApiRequest) { Source activeSource = sourceManager.retrieveActiveSource(); // Validate external identifier PersonValidator.validateExternalIdentifier(externalIdentifier, activeSource, true, isApiRequest, null, requireRelationshipOnExternalIdentifier); // Validate it is not duplicated List<ExternalIdentifierEntity> existingExternalIdentifiers = externalIdentifierDao.getExternalIdentifiers(orcid, getLastModified(orcid)); for (ExternalIdentifierEntity existing : existingExternalIdentifiers) { if (isDuplicated(existing, externalIdentifier, activeSource)) { Map<String, String> params = new HashMap<String, String>(); params.put("type", "external-identifier"); params.put("value", externalIdentifier.getUrl().getValue()); throw new OrcidDuplicatedElementException(params); } } ExternalIdentifierEntity newEntity = jpaJaxbExternalIdentifierAdapter.toExternalIdentifierEntity(externalIdentifier); ProfileEntity profile = profileEntityCacheManager.retrieve(orcid); newEntity.setOwner(profile); newEntity.setDateCreated(new Date()); SourceEntityUtils.populateSourceAwareEntityFromSource(activeSource, newEntity); setIncomingPrivacy(newEntity, profile); DisplayIndexCalculatorHelper.setDisplayIndexOnNewEntity(newEntity, isApiRequest); externalIdentifierDao.persist(newEntity); return jpaJaxbExternalIdentifierAdapter.toExternalIdentifier(newEntity); }
throw new OrcidValidationException(message); } else { if(SiteConstants.URL_MAX_LENGTH < externalIdentifier.getUrl().getValue().length()) { String message = "Url must not be longer than " + SiteConstants.URL_MAX_LENGTH + " characters"; LOGGER.error(message);
Map<String, String> params = new HashMap<String, String>(); params.put("type", "external-identifier"); params.put("value", externalIdentifier.getUrl().getValue()); throw new OrcidDuplicatedElementException(params);
public static FundingExternalIdentifierForm valueOf(ExternalID fundingExternalIdentifier) { FundingExternalIdentifierForm result = new FundingExternalIdentifierForm(); if (fundingExternalIdentifier.getType() != null) result.setType(Text.valueOf(fundingExternalIdentifier.getType())); if (fundingExternalIdentifier.getUrl() != null && !PojoUtil.isEmpty(fundingExternalIdentifier.getUrl().getValue())) result.setUrl(Text.valueOf(fundingExternalIdentifier.getUrl().getValue())); if (!PojoUtil.isEmpty(fundingExternalIdentifier.getValue())) result.setValue(Text.valueOf(fundingExternalIdentifier.getValue())); if(fundingExternalIdentifier.getRelationship() != null) result.setRelationship(Text.valueOf(fundingExternalIdentifier.getRelationship().value())); return result; }
researchResourceItem.setUrl(item.getUrl().getValue());
@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 String convertTo(ExternalIDs source, Type<String> destinationType) { JSONExternalIdentifiers jsonExternalIdentifiers = new JSONExternalIdentifiers(); 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)); } jsonExternalIdentifiers.getExternalIdentifier().add(jsonExternalIdentifier); } return JsonUtils.convertToJsonString(jsonExternalIdentifiers); }
@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 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); }
form.setUrl(Text.valueOf(researcherUrl.getUrl().getValue()));
public ExternalID clone() { ExternalID id = new ExternalID(); id.type = this.getType(); id.value = this.getValue(); if (this.getNormalized() != null) id.setNormalized(this.getNormalized()); if (this.getNormalizedError() != null) id.setNormalizedError(this.getNormalizedError()); if (this.getUrl() != null) id.url = new Url(this.getUrl().getValue()); if (this.getRelationship() != null) id.relationship = this.getRelationship(); if (this.getNormalizedUrl() != null) id.setNormalizedUrl(this.getNormalizedUrl()); if (this.getNormalizedUrlError() != null) id.setNormalizedUrlError(this.getNormalizedUrlError()); return id; }
form.setUrl(extId.getUrl().getValue());
researchResource.setUrl(resource.getProposal().getUrl().getValue());
researchResource.setUrl(researchResourceSummary.getProposal().getUrl().getValue());
public static ActivityExternalIdentifier valueOf(ExternalID externalIdentifier) { ActivityExternalIdentifier wi = new ActivityExternalIdentifier(); if (externalIdentifier != null) { if (externalIdentifier.getValue() != null) wi.setExternalIdentifierId(Text.valueOf(externalIdentifier.getValue())); if (externalIdentifier.getType() != null) wi.setExternalIdentifierType(Text.valueOf(externalIdentifier.getType())); if(externalIdentifier.getRelationship() != null) wi.setRelationship(Text.valueOf(externalIdentifier.getRelationship().value())); if(externalIdentifier.getUrl() != null) wi.setUrl(Text.valueOf(externalIdentifier.getUrl().getValue())); if(externalIdentifier.getNormalized() != null){ wi.setNormalized(Text.valueOf(externalIdentifier.getNormalized().getValue())); wi.getNormalized().setRequired(false); } if(externalIdentifier.getNormalizedUrl() != null){ wi.setNormalizedUrl(Text.valueOf(externalIdentifier.getNormalizedUrl().getValue())); wi.getNormalizedUrl().setRequired(false); } } return wi; }
peerReviewForm.setUrl(Text.valueOf(peerReviewSummary.getUrl().getValue()));