use of org.orcid.jaxb.model.record_rc2.OtherNames in project ORCID-Source by ORCID.
the class ValidateV2_1SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
} else if (Works.class.equals(type)) {
result = (Works) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
use of org.orcid.jaxb.model.record_rc2.OtherNames in project ORCID-Source by ORCID.
the class WorkspaceController method setOtherNamesFormJson.
@RequestMapping(value = "/my-orcid/otherNamesForms.json", method = RequestMethod.POST)
@ResponseBody
public OtherNamesForm setOtherNamesFormJson(@RequestBody OtherNamesForm onf) throws NoSuchRequestHandlingMethodException {
onf.setErrors(new ArrayList<String>());
ProfileEntity profile = profileEntityCacheManager.retrieve(getEffectiveUserOrcid());
Visibility defaultVisibility = Visibility.valueOf(profile.getActivitiesVisibilityDefault());
if (onf != null) {
Iterator<OtherNameForm> it = onf.getOtherNames().iterator();
while (it.hasNext()) {
OtherNameForm form = it.next();
if (PojoUtil.isEmpty(form.getContent())) {
it.remove();
continue;
}
if (form.getContent().length() > SiteConstants.MAX_LENGTH_255) {
form.setContent(form.getContent().substring(0, SiteConstants.MAX_LENGTH_255));
}
//Set default visibility in case it is null
if (form.getVisibility() == null || form.getVisibility().getVisibility() == null) {
form.setVisibility(defaultVisibility);
}
copyErrors(form, onf);
}
if (onf.getErrors().size() > 0) {
return onf;
}
OtherNames otherNames = onf.toOtherNames();
otherNameManager.updateOtherNames(getEffectiveUserOrcid(), otherNames);
}
return onf;
}
use of org.orcid.jaxb.model.record_rc2.OtherNames in project ORCID-Source by ORCID.
the class WorkspaceController method getOtherNamesFormJson.
@RequestMapping(value = "/my-orcid/otherNamesForms.json", method = RequestMethod.GET)
@ResponseBody
public OtherNamesForm getOtherNamesFormJson(HttpServletRequest request) throws NoSuchRequestHandlingMethodException {
long lastModifiedTime = getLastModifiedTime(getCurrentUserOrcid());
OtherNames otherNames = otherNameManager.getOtherNames(getCurrentUserOrcid(), lastModifiedTime);
OtherNamesForm form = OtherNamesForm.valueOf(otherNames);
//Set the default visibility
ProfileEntity profile = profileEntityCacheManager.retrieve(getCurrentUserOrcid());
if (profile != null && profile.getActivitiesVisibilityDefault() != null) {
form.setVisibility(Visibility.valueOf(profile.getActivitiesVisibilityDefault()));
}
return form;
}
use of org.orcid.jaxb.model.record_rc2.OtherNames in project ORCID-Source by ORCID.
the class Api2_0_rc2_LastModifiedDatesHelper method calculateLatest.
public static XMLGregorianCalendar calculateLatest(OtherNames otherNames) {
XMLGregorianCalendar latest = null;
if (otherNames != null && otherNames.getOtherNames() != null && !otherNames.getOtherNames().isEmpty()) {
latest = otherNames.getOtherNames().get(0).getLastModifiedDate().getValue();
for (OtherName otherName : otherNames.getOtherNames()) {
if (latest.compare(otherName.getLastModifiedDate().getValue()) == -1) {
latest = otherName.getLastModifiedDate().getValue();
}
}
otherNames.setLastModifiedDate(new LastModifiedDate(latest));
}
return latest;
}
use of org.orcid.jaxb.model.record_rc2.OtherNames in project ORCID-Source by ORCID.
the class OtherNameManagerTest method getAllTest.
@Test
public void getAllTest() {
String orcid = "0000-0000-0000-0003";
OtherNames elements = otherNameManager.getOtherNames(orcid, System.currentTimeMillis());
assertNotNull(elements);
assertNotNull(elements.getOtherNames());
assertEquals(5, elements.getOtherNames().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
for (OtherName element : elements.getOtherNames()) {
if (13 == element.getPutCode()) {
found1 = true;
} else if (14 == element.getPutCode()) {
found2 = true;
} else if (15 == element.getPutCode()) {
found3 = true;
} else if (16 == element.getPutCode()) {
found4 = true;
} else if (17 == element.getPutCode()) {
found5 = true;
} else {
fail("Invalid put code found: " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
assertTrue(found5);
}
Aggregations