use of org.orcid.jaxb.model.record_v2.Address in project oxTrust by GluuFederation.
the class PatchUtil method removePatch.
public GluuCustomPerson removePatch(User source, GluuCustomPerson destination) throws Exception {
if (source == null) {
return null;
}
if (destination == null) {
log.trace(" creating a new GluuCustomPerson instant ");
destination = new GluuCustomPerson();
}
log.trace(" setting schemas ");
destination.setSchemas(source.getSchemas());
personService.addCustomObjectClass(destination);
log.trace(" setting userName ");
if (source.getUserName() != null && source.getUserName().length() > 0) {
destination.setUid(source.getUserName());
}
if (source.getName() != null) {
log.trace(" setting givenname ");
if (source.getName().getGivenName() != null) {
destination.setGivenName("");
}
log.trace(" setting famillyname ");
if (source.getName().getFamilyName() != null) {
destination.setSurname("");
}
log.trace(" setting middlename ");
if (source.getName().getMiddleName() != null) {
// destination.setAttribute("oxTrustMiddleName",
// source.getName().getMiddleName());
destination.setAttribute("middleName", "");
}
log.trace(" setting honor");
if (source.getName().getHonorificPrefix() != null) {
destination.setAttribute("oxTrusthonorificPrefix", "");
}
if (source.getName().getHonorificSuffix() != null) {
destination.setAttribute("oxTrusthonorificSuffix", "");
}
}
log.trace(" setting displayname ");
if (source.getDisplayName() != null) {
destination.setDisplayName(source.getDisplayName());
}
log.trace(" setting externalID ");
if (source.getExternalId() != null) {
destination.setAttribute("oxTrustExternalId", source.getExternalId());
}
log.trace(" setting nickname ");
if (source.getNickName() != null) {
// destination.setAttribute("oxTrustNickName",
// source.getNickName());
destination.setAttribute("nickname", "");
}
log.trace(" setting profileURL ");
if (source.getProfileUrl() != null) {
destination.setAttribute("oxTrustProfileURL", "");
}
// getting emails
log.trace(" setting emails ");
if (source.getEmails() != null && source.getEmails().size() > 0) {
List<Email> emails = copyUtils2.getAttributeListValue(destination, Email.class, "oxTrustEmail");
if (emails != null && emails.size() > 0) {
List<Email> newemails = source.getEmails();
Iterator<Email> emailsIt = emails.iterator();
Iterator<Email> newemailsIt = newemails.iterator();
while (emailsIt.hasNext()) {
Email email = emailsIt.next();
if (email != null && email.getType() != null) {
while (newemailsIt.hasNext()) {
Email newEmail = newemailsIt.next();
if (newEmail.getType() != null && newEmail.getType().getValue().equals(email.getType().getValue())) {
emailsIt.remove();
}
}
}
}
copyUtils2.setAttributeListValue(destination, emails, "oxTrustEmail");
}
}
// getting addresses
log.trace(" setting addresses ");
if (source.getAddresses() != null && source.getAddresses().size() > 0) {
List<Address> addresses = copyUtils2.getAttributeListValue(destination, Address.class, "oxTrustAddresses");
if (addresses != null && addresses.size() > 0) {
List<Address> newaddresses = source.getAddresses();
Iterator<Address> addressesIt = addresses.iterator();
Iterator<Address> newaddressesIt = newaddresses.iterator();
while (addressesIt.hasNext()) {
Address address = addressesIt.next();
if (address != null && address.getType() != null) {
while (newaddressesIt.hasNext()) {
Address newaddress = newaddressesIt.next();
if (newaddress.getType().getValue() != null && newaddress.getType().getValue().equals(address.getType().getValue())) {
addressesIt.remove();
}
}
}
}
copyUtils2.setAttributeListValue(destination, addresses, "oxTrustAddresses");
}
}
// getting phone numbers;
log.trace(" setting phoneNumbers ");
if (source.getPhoneNumbers() != null && source.getPhoneNumbers().size() > 0) {
List<PhoneNumber> phoneNumbers = copyUtils2.getAttributeListValue(destination, PhoneNumber.class, "oxTrustPhoneValue");
if (phoneNumbers != null && phoneNumbers.size() > 0) {
List<PhoneNumber> newPhoneNumbers = source.getPhoneNumbers();
Iterator<PhoneNumber> phoneNumbersIt = phoneNumbers.iterator();
Iterator<PhoneNumber> newPhoneNumbersIt = newPhoneNumbers.iterator();
while (phoneNumbersIt.hasNext()) {
PhoneNumber phoneNumber = phoneNumbersIt.next();
while (newPhoneNumbersIt.hasNext()) {
PhoneNumber newPhoneNumber = newPhoneNumbersIt.next();
if (newPhoneNumber.getType() != null && newPhoneNumber.getType().getValue().equals(phoneNumber.getType().getValue())) {
phoneNumbersIt.remove();
}
}
}
copyUtils2.setAttributeListValue(destination, phoneNumbers, "oxTrustPhoneValue");
}
}
// getting ims
log.trace(" setting ims ");
if (source.getIms() != null && source.getIms().size() > 0) {
List<Im> ims = copyUtils2.getAttributeListValue(destination, Im.class, "oxTrustImsValue");
if (ims != null && ims.size() > 0) {
List<Im> newims = source.getIms();
Iterator<Im> imsIt = ims.iterator();
Iterator<Im> newimssIt = newims.iterator();
while (imsIt.hasNext()) {
Im im = imsIt.next();
if (im != null && im.getType() != null) {
while (newimssIt.hasNext()) {
Im newIm = newimssIt.next();
if (newIm.getType() != null && newIm.getType().getValue().equals(im.getType().getValue())) {
imsIt.remove();
}
}
}
}
copyUtils2.setAttributeListValue(destination, ims, "oxTrustImsValue");
}
}
// getting Photos
log.trace(" setting photos ");
if (source.getPhotos() != null && source.getPhotos().size() > 0) {
List<Photo> photos = copyUtils2.getAttributeListValue(destination, Photo.class, "oxTrustPhotos");
if (photos != null && photos.size() > 0) {
List<Photo> newPhotos = source.getPhotos();
Iterator<Photo> photosIt = photos.iterator();
Iterator<Photo> newphotosIt = newPhotos.iterator();
while (photosIt.hasNext()) {
Photo old = photosIt.next();
if (old != null && old.getType() != null) {
while (newphotosIt.hasNext()) {
Photo newelement = newphotosIt.next();
if (newelement.getType() != null && newelement.getType().getValue().equals(old.getType().getValue())) {
photosIt.remove();
}
}
}
}
copyUtils2.setAttributeListValue(destination, photos, "oxTrustPhotos");
}
}
if (source.getUserType() != null) {
destination.setAttribute("oxTrustUserType", "");
}
if (source.getTitle() != null) {
destination.setAttribute("oxTrustTitle", "");
}
if (source.getPreferredLanguage() != null) {
destination.setPreferredLanguage("");
}
if (source.getLocale() != null) {
// destination.setAttribute("oxTrustLocale", source.getLocale());
destination.setAttribute("locale", "");
}
if (source.getTimezone() != null) {
destination.setTimezone("");
}
if (source.isActive() != null) {
destination.setAttribute("oxTrustActive", source.isActive().toString());
}
if (source.getPassword() != null && source.getPassword().length() > 0) {
destination.setUserPassword(source.getPassword());
}
// getting user groups
log.trace(" setting groups ");
if (source.getGroups() != null && source.getGroups().size() > 0) {
List<String> members = destination.getMemberOf();
if (members != null || members.size() > 0) {
members.removeAll(source.getGroups());
}
destination.setMemberOf(members);
}
// getting roles
log.trace(" setting roles ");
if (source.getRoles() != null && source.getRoles().size() > 0) {
List<Role> roles = copyUtils2.getAttributeListValue(destination, Role.class, "oxTrustRole");
if (roles != null && roles.size() > 0) {
List<Role> newRoles = source.getRoles();
Iterator<Role> oldsIt = roles.iterator();
Iterator<Role> newsIt = newRoles.iterator();
while (oldsIt.hasNext()) {
Role old = oldsIt.next();
if (old != null && old.getType() != null) {
while (newsIt.hasNext()) {
Role newelement = newsIt.next();
if (newelement.getType() != null && newelement.getType().getValue().equals(old.getType().getValue())) {
oldsIt.remove();
}
}
}
}
copyUtils2.setAttributeListValue(destination, roles, "oxTrustRole");
}
}
// getting entitlements
log.trace(" setting entitlements ");
if (source.getEntitlements() != null && source.getEntitlements().size() > 0) {
List<Entitlement> entitlements = copyUtils2.getAttributeListValue(destination, Entitlement.class, "oxTrustEntitlements");
if (entitlements != null && entitlements.size() > 0) {
List<Entitlement> newEentitlements = source.getEntitlements();
Iterator<Entitlement> oldsIt = entitlements.iterator();
Iterator<Entitlement> newsIt = newEentitlements.iterator();
while (oldsIt.hasNext()) {
Entitlement old = oldsIt.next();
if (old != null && old.getType() != null) {
while (newsIt.hasNext()) {
Entitlement newelement = newsIt.next();
if (newelement.getType() != null && newelement.getType().getValue().equals(old.getType().getValue())) {
oldsIt.remove();
}
}
}
}
copyUtils2.setAttributeListValue(destination, entitlements, "oxTrustEntitlements");
}
}
// getting x509Certificates
log.trace(" setting certs ");
if (source.getX509Certificates() != null && source.getX509Certificates().size() > 0) {
List<X509Certificate> X509Certificates = copyUtils2.getAttributeListValue(destination, X509Certificate.class, "oxTrustx509Certificate");
if (X509Certificates != null && X509Certificates.size() > 0) {
List<X509Certificate> newX509Certificates = source.getX509Certificates();
Iterator<X509Certificate> oldsIt = X509Certificates.iterator();
Iterator<X509Certificate> newsIt = newX509Certificates.iterator();
while (oldsIt.hasNext()) {
X509Certificate old = oldsIt.next();
if (old != null && old.getType() != null) {
while (newsIt.hasNext()) {
X509Certificate newelement = newsIt.next();
if (newelement.getType() != null && newelement.getType().getValue().equals(old.getType().getValue())) {
oldsIt.remove();
}
}
}
}
copyUtils2.setAttributeListValue(destination, X509Certificates, "oxTrustx509Certificate");
}
}
log.trace(" setting extensions ");
if (source.getExtensions() != null && (source.getExtensions().size() > 0)) {
destination.setExtensions(source.getExtensions());
}
if (source.isActive() != null) {
copyUtils2.setGluuStatus(source, destination);
}
return destination;
}
use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.
the class Api2_0_rc4_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(Addresses addresses) {
if (addresses != null && addresses.getAddress() != null && !addresses.getAddress().isEmpty()) {
LastModifiedDate latest = null;
for (Address address : addresses.getAddress()) {
if (address.getLastModifiedDate() != null && address.getLastModifiedDate().after(latest)) {
latest = address.getLastModifiedDate();
}
}
addresses.setLastModifiedDate(latest);
}
}
use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.
the class AddressForm method toAddress.
public Address toAddress() {
Address address = new Address();
if (this.iso2Country != null && this.iso2Country.getValue() != null) {
Country country = new Country();
country.setValue(this.iso2Country.getValue().value());
address.setCountry(country);
}
if (this.visibility != null && this.visibility.getVisibility() != null) {
address.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(this.getVisibility().getVisibility().value()));
}
if (!PojoUtil.isEmpty(this.getPutCode())) {
address.setPutCode(Long.valueOf(this.getPutCode()));
}
if (displayIndex != null) {
address.setDisplayIndex(displayIndex);
} else {
address.setDisplayIndex(0L);
}
address.setSource(new Source(source));
return address;
}
use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromPublicAPI.
@Test
public void testViewRecordFromPublicAPI() {
ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
//Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
if (record.getActivitiesSummary() != null) {
//Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
//Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
//Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
//PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
//Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
}
}
//Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
//Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertEquals(Visibility.PUBLIC, o.getVisibility());
}
}
}
//Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
assertEquals(Visibility.PUBLIC, b.getVisibility());
}
}
//Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
//Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
//Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
}
}
use of org.orcid.jaxb.model.record_v2.Address in project ORCID-Source by ORCID.
the class PublicV2ApiServiceDelegatorTest method validatePerson.
private void validatePerson(Person person) {
assertNotNull(person);
assertNotNull(person.getLastModifiedDate());
assertNotNull(person.getLastModifiedDate().getValue());
assertNotNull(person.getAddresses());
assertEquals("/0000-0000-0000-0003/address", person.getAddresses().getPath());
assertNotNull(person.getAddresses().getLastModifiedDate());
assertNotNull(person.getAddresses().getLastModifiedDate().getValue());
assertEquals(1, person.getAddresses().getAddress().size());
Address address = person.getAddresses().getAddress().get(0);
assertEquals(Iso3166Country.US, address.getCountry().getValue());
assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
assertEquals(Long.valueOf(9), address.getPutCode());
assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
assertNotNull(person.getBiography());
assertEquals(Visibility.PUBLIC.value(), person.getBiography().getVisibility().value());
assertEquals("Biography for 0000-0000-0000-0003", person.getBiography().getContent());
assertNotNull(person.getBiography().getLastModifiedDate());
assertNotNull(person.getBiography().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/biography", person.getBiography().getPath());
assertNotNull(person.getEmails());
assertNotNull(person.getEmails().getLastModifiedDate());
assertNotNull(person.getEmails().getLastModifiedDate().getValue());
assertEquals(1, person.getEmails().getEmails().size());
Email email = person.getEmails().getEmails().get(0);
assertEquals("public_0000-0000-0000-0003@test.orcid.org", email.getEmail());
assertNotNull(email.getLastModifiedDate());
assertNotNull(email.getLastModifiedDate().getValue());
assertEquals("APP-5555555555555555", email.getSource().retrieveSourcePath());
assertEquals(Visibility.PUBLIC.value(), email.getVisibility().value());
assertNotNull(person.getExternalIdentifiers());
assertNotNull(person.getExternalIdentifiers().getLastModifiedDate());
assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/external-identifiers", person.getExternalIdentifiers().getPath());
assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
assertNotNull(extId);
assertNotNull(extId.getLastModifiedDate());
assertNotNull(extId.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(13), extId.getPutCode());
assertEquals("public_type", extId.getType());
assertNotNull(extId.getUrl());
assertEquals("http://ext-id/public_ref", extId.getUrl().getValue());
assertEquals(Visibility.PUBLIC.value(), extId.getVisibility().value());
assertEquals("/0000-0000-0000-0003/external-identifiers/13", extId.getPath());
assertEquals("APP-5555555555555555", extId.getSource().retrieveSourcePath());
assertNotNull(person.getKeywords());
assertNotNull(person.getKeywords().getLastModifiedDate());
assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
assertEquals(1, person.getKeywords().getKeywords().size());
assertNotNull(person.getKeywords().getLastModifiedDate());
assertEquals("/0000-0000-0000-0003/keywords", person.getKeywords().getPath());
Keyword keyword = person.getKeywords().getKeywords().get(0);
assertNotNull(keyword);
assertNotNull(keyword.getLastModifiedDate());
assertNotNull(keyword.getLastModifiedDate().getValue());
assertEquals(Long.valueOf(9), keyword.getPutCode());
assertEquals("PUBLIC", keyword.getContent());
assertEquals(Visibility.PUBLIC.value(), keyword.getVisibility().value());
assertEquals("/0000-0000-0000-0003/keywords/9", keyword.getPath());
assertEquals("APP-5555555555555555", keyword.getSource().retrieveSourcePath());
assertNotNull(person.getName());
assertNotNull(person.getName().getLastModifiedDate());
assertNotNull(person.getName().getLastModifiedDate().getValue());
assertEquals("Credit Name", person.getName().getCreditName().getContent());
assertEquals("Family Name", person.getName().getFamilyName().getContent());
assertEquals("Given Names", person.getName().getGivenNames().getContent());
assertEquals(Visibility.PUBLIC.value(), person.getName().getVisibility().value());
assertNotNull(person.getOtherNames());
assertEquals("/0000-0000-0000-0003/other-names", person.getOtherNames().getPath());
assertNotNull(person.getOtherNames().getLastModifiedDate());
assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
assertEquals(1, person.getOtherNames().getOtherNames().size());
OtherName otherName = person.getOtherNames().getOtherNames().get(0);
assertEquals("Other Name PUBLIC", otherName.getContent());
assertNotNull(otherName.getLastModifiedDate());
assertNotNull(otherName.getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/other-names/13", otherName.getPath());
assertEquals(Long.valueOf(13), otherName.getPutCode());
assertEquals("APP-5555555555555555", otherName.getSource().retrieveSourcePath());
assertEquals(Visibility.PUBLIC.value(), otherName.getVisibility().value());
assertNotNull(person.getResearcherUrls());
assertEquals(1, person.getResearcherUrls().getResearcherUrls().size());
assertNotNull(person.getResearcherUrls().getLastModifiedDate());
assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
assertEquals("/0000-0000-0000-0003/researcher-urls", person.getResearcherUrls().getPath());
ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
assertNotNull(rUrl);
assertNotNull(rUrl.getLastModifiedDate());
assertNotNull(rUrl.getLastModifiedDate().getValue());
assertNotNull(rUrl.getUrl());
assertEquals("http://www.researcherurl.com?id=13", rUrl.getUrl().getValue());
assertEquals("public_rurl", rUrl.getUrlName());
assertEquals(Visibility.PUBLIC.value(), rUrl.getVisibility().value());
assertEquals("/0000-0000-0000-0003/researcher-urls/13", rUrl.getPath());
assertEquals("APP-5555555555555555", rUrl.getSource().retrieveSourcePath());
assertEquals("/0000-0000-0000-0003/person", person.getPath());
}
Aggregations