@Override public int compareTo(Keyword o) { if(o == null || o.getContent() == null) { return 1; } if(getContent() == null) { return -1; } return this.getContent().compareTo(o.getContent()); } }
private boolean isDuplicated(ProfileKeywordEntity existing, org.orcid.jaxb.model.record_v2.Keyword keyword, SourceEntity source) { if (!existing.getId().equals(keyword.getPutCode())) { String existingSourceId = existing.getElementSourceId(); if (!PojoUtil.isEmpty(existingSourceId) && existingSourceId.equals(SourceEntityUtils.getSourceId(source))) { if (existing.getKeywordName() != null && existing.getKeywordName().equals(keyword.getContent())) { return true; } } } return false; }
public static void validateKeyword(Keyword keyword, SourceEntity sourceEntity, boolean createFlag, boolean isApiRequest, Visibility originalVisibility) { if(createFlag) { if(keyword.getPutCode() != null) { Map<String, String> params = new HashMap<String, String>(); if (sourceEntity != null) { params.put("clientName", SourceEntityUtils.getSourceName(sourceEntity)); } throw new InvalidPutCodeException(params); } } else { if(keyword.getPutCode() == null) { Map<String, String> params = new HashMap<String, String>(); throw new PutCodeRequiredException(params); } } if(PojoUtil.isEmpty(keyword.getContent())) { String message = "Keyword cannot be null"; LOGGER.error(message); throw new OrcidValidationException(message); } //Check that we are not changing the visibility validateAndFixVisibility(keyword, createFlag, isApiRequest, originalVisibility); }
Map<String, String> params = new HashMap<String, String>(); params.put("type", "keyword"); params.put("value", keyword.getContent()); throw new OrcidDuplicatedElementException(params);
Map<String, String> params = new HashMap<String, String>(); params.put("type", "keyword"); params.put("value", keyword.getContent()); throw new OrcidDuplicatedElementException(params);
existingKeyword.setLastModified(new Date()); existingKeyword.setVisibility(updatedOrNew.getVisibility().name()); existingKeyword.setKeywordName(updatedOrNew.getContent()); existingKeyword.setDisplayIndex(updatedOrNew.getDisplayIndex()); profileKeywordDao.merge(existingKeyword);