@Override public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((date == null) ? 0 : date.hashCode()); result = prime * result + ((primaryRecord == null) ? 0 : primaryRecord.hashCode()); return result; } }
DeprecatedDate dd = new DeprecatedDate(); String dateString = params.get(OrcidDeprecatedException.DEPRECATED_DATE); dd.setValue(DateUtils.convertToXMLGregorianCalendar(dateString, false)); depreciatedError.setDate(dd);
private OrcidDeprecated getOrcidDeprecated(ProfileEntity profileEntity) { OrcidDeprecated orcidDeprecated = null; if (profileEntity.getPrimaryRecord() != null) { orcidDeprecated = new OrcidDeprecated(); orcidDeprecated.setDate(new DeprecatedDate(toXMLGregorianCalendar(profileEntity.getDeprecatedDate()))); PrimaryRecord primaryRecord = new PrimaryRecord(); OrcidIdentifier orcidIdentifier = new OrcidIdentifier(getOrcidIdBase(profileEntity.getPrimaryRecord().getId())); primaryRecord.setOrcidIdentifier(orcidIdentifier); orcidDeprecated.setPrimaryRecord(primaryRecord); } return orcidDeprecated; }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; OrcidDeprecated other = (OrcidDeprecated) obj; if(date == null){ if(other.getDate() != null) return false; } if(!date.equals(other.getDate())) return false; if(primaryRecord == null){ if(other.getPrimaryRecord() != null) return false; } if(!primaryRecord.equals(other.getPrimaryRecord())) return false; return true; }
private Response getOrcidMessageResponse(OrcidMessage orcidMessage, String requestedOrcid) { boolean isProfileDeprecated = false; if (orcidMessage == null) { Map<String, String> params = new HashMap<String, String>(); params.put("orcid", requestedOrcid); throw new OrcidNotFoundException(params); } OrcidProfile orcidProfile = orcidMessage.getOrcidProfile(); if (orcidProfile != null) { orcidProfile.setOrcidInternal(null); // If profile is deprecated if (orcidMessage.getOrcidProfile().getOrcidDeprecated() != null) { isProfileDeprecated = true; } } Response response = null; if (isProfileDeprecated) { Map<String, String> params = new HashMap<String, String>(); params.put(OrcidDeprecatedException.ORCID, orcidProfile.getOrcidDeprecated().getPrimaryRecord().getOrcidIdentifier().getUri()); if (orcidProfile.getOrcidDeprecated().getDate() != null) { XMLGregorianCalendar deprecatedDate = orcidProfile.getOrcidDeprecated().getDate().getValue(); params.put(OrcidDeprecatedException.DEPRECATED_DATE, deprecatedDate.toString()); } throw new OrcidDeprecatedException(params); } else { orcidMessageUtil.setSourceName(orcidMessage); response = Response.ok(orcidMessage).build(); } return response; }