use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class OrcidInfo method getAffiliationsJson.
@RequestMapping(value = "/{orcid:(?:\\d{4}-){3,}\\d{3}[\\dX]}/affiliations.json")
@ResponseBody
public List<AffiliationForm> getAffiliationsJson(HttpServletRequest request, @PathVariable("orcid") String orcid, @RequestParam(value = "affiliationIds") String workIdsStr) {
List<AffiliationForm> affs = new ArrayList<AffiliationForm>();
Map<Long, Affiliation> affMap = activityManager.affiliationMap(orcid);
String[] affIds = workIdsStr.split(",");
for (String id : affIds) {
Affiliation aff = affMap.get(Long.valueOf(id));
validateVisibility(aff.getVisibility());
AffiliationForm form = AffiliationForm.valueOf(aff);
form.setCountryForDisplay(getMessage(buildInternationalizationKey(CountryIsoEntity.class, aff.getOrganization().getAddress().getCountry().name())));
if (form.getOrgDisambiguatedId() != null) {
OrgDisambiguated orgDisambiguated = orgDisambiguatedManager.findInDB(Long.parseLong(form.getOrgDisambiguatedId().getValue()));
form.setOrgDisambiguatedName(orgDisambiguated.getValue());
form.setOrgDisambiguatedUrl(orgDisambiguated.getUrl());
form.setOrgDisambiguatedCity(orgDisambiguated.getCity());
form.setOrgDisambiguatedRegion(orgDisambiguated.getRegion());
form.setOrgDisambiguatedCountry(orgDisambiguated.getCountry());
if (orgDisambiguated.getOrgDisambiguatedExternalIdentifiers() != null) {
form.setOrgDisambiguatedExternalIdentifiers(orgDisambiguated.getOrgDisambiguatedExternalIdentifiers());
}
}
affs.add(form);
}
return affs;
}
use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class WorksController method retriveWorkTypes.
/**
* Return a list of work types based on the work category provided as a
* parameter
*
* @param workCategoryName
* @return a map containing the list of types associated with that type and
* his localized name
*/
@RequestMapping(value = "/loadWorkTypes.json", method = RequestMethod.GET)
@ResponseBody
public List<KeyValue> retriveWorkTypes(@RequestParam(value = "workCategory") String workCategoryName) {
List<KeyValue> types = new ArrayList<KeyValue>();
WorkCategory workCategory = null;
if (!PojoUtil.isEmpty(workCategoryName))
workCategory = WorkCategory.fromValue(workCategoryName);
// Get work types based on category
if (workCategory != null) {
for (WorkType workType : workCategory.getSubTypes()) {
// Dont put work type UNDEFINED
if (!workType.equals(WorkType.UNDEFINED)) {
types.add(new KeyValue(workType.value(), getMessage(new StringBuffer("org.orcid.jaxb.model.record.WorkType.").append(workType.value()).toString())));
}
}
} else {
// Get all work types
for (WorkType workType : WorkType.values()) {
// Dont put work type UNDEFINED
if (!workType.equals(WorkType.UNDEFINED)) {
types.add(new KeyValue(workType.value(), getMessage(new StringBuffer("org.orcid.jaxb.model.record.WorkType.").append(workType.value()).toString())));
}
}
}
return types;
}
use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class WorksController method getWorkInfo.
/**
* Returns a blank work
*/
@RequestMapping(value = "/getWorkInfo.json", method = RequestMethod.GET)
@ResponseBody
public WorkForm getWorkInfo(@RequestParam(value = "workId") Long workId) {
Map<String, String> countries = retrieveIsoCountries();
Map<String, String> languages = lm.buildLanguageMap(localeManager.getLocale(), false);
if (workId == null)
return null;
Work work = workManager.getWork(this.getEffectiveUserOrcid(), workId);
if (work != null) {
WorkForm workForm = WorkForm.valueOf(work);
if (workForm.getPublicationDate() == null) {
initializePublicationDate(workForm);
} else {
if (workForm.getPublicationDate().getDay() == null) {
workForm.getPublicationDate().setDay(new String());
}
if (workForm.getPublicationDate().getMonth() == null) {
workForm.getPublicationDate().setMonth(new String());
}
if (workForm.getPublicationDate().getYear() == null) {
workForm.getPublicationDate().setYear(new String());
}
}
// Set country name
if (!PojoUtil.isEmpty(workForm.getCountryCode())) {
Text countryName = Text.valueOf(countries.get(workForm.getCountryCode().getValue()));
workForm.setCountryName(countryName);
}
// Set language name
if (!PojoUtil.isEmpty(workForm.getLanguageCode())) {
Text languageName = Text.valueOf(languages.get(workForm.getLanguageCode().getValue()));
workForm.setLanguageName(languageName);
}
// Set translated title language name
if (!(workForm.getTranslatedTitle() == null) && !StringUtils.isEmpty(workForm.getTranslatedTitle().getLanguageCode())) {
String languageName = languages.get(workForm.getTranslatedTitle().getLanguageCode());
workForm.getTranslatedTitle().setLanguageName(languageName);
}
if (workForm.getContributors() != null) {
for (Contributor contributor : workForm.getContributors()) {
if (!PojoUtil.isEmpty(contributor.getOrcid())) {
String contributorOrcid = contributor.getOrcid().getValue();
if (profileEntityManager.orcidExists(contributorOrcid)) {
// contributor is an ORCID user - visibility of user's name in record must be taken into account
ProfileEntity profileEntity = profileEntityCacheManager.retrieve(contributorOrcid);
String publicContributorCreditName = activityManager.getPublicCreditName(profileEntity);
contributor.setCreditName(Text.valueOf(publicContributorCreditName));
}
}
}
}
return workForm;
}
return null;
}
use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class WorkFormTest method getWork.
public static Work getWork() {
Work work = new Work();
work.setCountry(new Country(Iso3166Country.US));
Date date = new Date();
work.setCreatedDate(new CreatedDate(DateUtils.convertToXMLGregorianCalendar(date)));
work.setJournalTitle(new Title("Journal Title"));
work.setLanguageCode("EN");
work.setPublicationDate(new PublicationDate(new Year(2015), new Month(1), new Day(1)));
work.setPutCode(Long.valueOf("12345"));
work.setShortDescription("Short description");
work.setUrl(new Url("http://test.com"));
work.setVisibility(org.orcid.jaxb.model.v3.dev1.common.Visibility.LIMITED);
work.setWorkCitation(new org.orcid.jaxb.model.v3.dev1.record.Citation("Citation", CitationType.BIBTEX));
WorkContributors contributors = new WorkContributors();
org.orcid.jaxb.model.v3.dev1.common.Contributor contributor = new org.orcid.jaxb.model.v3.dev1.common.Contributor();
contributor.setCreditName(new CreditName("Credit name"));
contributor.setContributorOrcid(new ContributorOrcid("0000-0000-0000-0000"));
ContributorAttributes att = new ContributorAttributes();
att.setContributorRole(ContributorRole.ASSIGNEE);
att.setContributorSequence(SequenceType.FIRST);
contributor.setContributorAttributes(att);
contributors.getContributor().add(contributor);
work.setWorkContributors(contributors);
ExternalIDs weis = new ExternalIDs();
ExternalID wei = new ExternalID();
wei.setRelationship(Relationship.SELF);
wei.setUrl(new Url("http://test.com"));
wei.setValue("ID");
wei.setType(WorkExternalIdentifierType.AGR.value());
weis.getExternalIdentifier().add(wei);
work.setWorkExternalIdentifiers(weis);
WorkTitle workTitle = new WorkTitle();
workTitle.setTitle(new Title("Work Title"));
workTitle.setSubtitle(new Subtitle("Subtitle"));
TranslatedTitle translated = new TranslatedTitle("Translated", "US");
workTitle.setTranslatedTitle(translated);
work.setWorkTitle(workTitle);
work.setWorkType(WorkType.ARTISTIC_PERFORMANCE);
return work;
}
use of org.orcid.jaxb.model.v3.dev1.record.Name in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getGroupIdRecordMapperFacade.
public MapperFacade getGroupIdRecordMapperFacade() {
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
ClassMapBuilder<GroupIdRecord, GroupIdRecordEntity> classMap = mapperFactory.classMap(GroupIdRecord.class, GroupIdRecordEntity.class);
addV3CommonFields(classMap);
registerSourceConverters(mapperFactory, classMap);
classMap.field("name", "groupName");
classMap.field("groupId", "groupId");
classMap.field("description", "groupDescription");
classMap.field("type", "groupType");
classMap.register();
return mapperFactory.getMapperFacade();
}
Aggregations