Search in sources :

Example 36 with CreditName

use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.

the class SetUpClientsAndUsers method createUser.

private void createUser(Map<String, String> params) throws Exception {
    // Create it
    OrcidProfile orcidProfile = new OrcidProfile();
    orcidProfile.setOrcidIdentifier(new OrcidIdentifier(params.get(ORCID)));
    orcidProfile.setType(OrcidType.fromValue(params.get(ORCID_TYPE)));
    if (params.get(MEMBER_TYPE) != null) {
        orcidProfile.setGroupType(MemberType.fromValue(params.get(MEMBER_TYPE)));
    }
    orcidProfile.setPassword(params.get(PASSWORD));
    OrcidInternal internal = new OrcidInternal();
    Preferences preferences = new Preferences();
    ActivitiesVisibilityDefault visibilityDefaults = new ActivitiesVisibilityDefault();
    visibilityDefaults.setValue(Visibility.PUBLIC);
    preferences.setActivitiesVisibilityDefault(visibilityDefaults);
    internal.setPreferences(preferences);
    orcidProfile.setOrcidInternal(internal);
    Email email = new Email(params.get(EMAIL));
    email.setCurrent(true);
    email.setPrimary(true);
    email.setVerified(true);
    email.setVisibility(Visibility.PUBLIC);
    List<Email> emails = new ArrayList<Email>();
    emails.add(email);
    ContactDetails contactDetails = new ContactDetails();
    contactDetails.setEmail(emails);
    org.orcid.jaxb.model.message.PersonalDetails personalDetails = new org.orcid.jaxb.model.message.PersonalDetails();
    org.orcid.jaxb.model.message.CreditName creditName = new org.orcid.jaxb.model.message.CreditName(params.get(CREDIT_NAME));
    creditName.setVisibility(OrcidVisibilityDefaults.NAMES_DEFAULT.getVisibility());
    personalDetails.setCreditName(creditName);
    personalDetails.setFamilyName(new org.orcid.jaxb.model.message.FamilyName(params.get(FAMILY_NAMES)));
    personalDetails.setGivenNames(new org.orcid.jaxb.model.message.GivenNames(params.get(GIVEN_NAMES)));
    OrcidBio bio = new OrcidBio();
    bio.setContactDetails(contactDetails);
    bio.setPersonalDetails(personalDetails);
    bio.setBiography(new Biography(params.get(BIO), OrcidVisibilityDefaults.BIOGRAPHY_DEFAULT.getVisibility()));
    orcidProfile.setOrcidBio(bio);
    OrcidHistory history = new OrcidHistory();
    history.setClaimed(new Claimed(true));
    history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(new Date())));
    history.setCreationMethod(CreationMethod.DIRECT);
    orcidProfile.setOrcidHistory(history);
    orcidProfileManager.createOrcidProfile(orcidProfile, false, false);
    if (params.containsKey(LOCKED)) {
        orcidProfileManager.lockProfile(params.get(ORCID), LockReason.SPAM.getLabel(), null);
    }
    if (params.containsKey(DEVELOPER_TOOLS)) {
        profileEntityManager.enableDeveloperTools(params.get(ORCID));
    }
}
Also used : Email(org.orcid.jaxb.model.message.Email) OrcidBio(org.orcid.jaxb.model.message.OrcidBio) OrcidInternal(org.orcid.jaxb.model.message.OrcidInternal) ArrayList(java.util.ArrayList) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidProfile(org.orcid.jaxb.model.message.OrcidProfile) ContactDetails(org.orcid.jaxb.model.message.ContactDetails) OrcidIdentifier(org.orcid.jaxb.model.message.OrcidIdentifier) Biography(org.orcid.jaxb.model.message.Biography) ActivitiesVisibilityDefault(org.orcid.jaxb.model.message.ActivitiesVisibilityDefault) Preferences(org.orcid.jaxb.model.message.Preferences) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Claimed(org.orcid.jaxb.model.message.Claimed) Date(java.util.Date) LocalDate(java.time.LocalDate) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory)

Example 37 with CreditName

use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getNameMapperFacade.

public MapperFacade getNameMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ClassMapBuilder<Name, RecordNameEntity> nameClassMap = mapperFactory.classMap(Name.class, RecordNameEntity.class);
    addV2DateFields(nameClassMap);
    nameClassMap.field("creditName.content", "creditName");
    nameClassMap.field("givenNames.content", "givenNames");
    nameClassMap.field("familyName.content", "familyName");
    nameClassMap.field("path", "profile.id");
    nameClassMap.byDefault();
    nameClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) RecordNameEntity(org.orcid.persistence.jpa.entities.RecordNameEntity) SourceName(org.orcid.jaxb.model.common_v2.SourceName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name)

Example 38 with CreditName

use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.

the class RecordNameManagerTest method testCreateRecordName.

@Test
public void testCreateRecordName() {
    Name name = new Name();
    long time = System.currentTimeMillis();
    name.setCreditName(new CreditName("Credit Name " + time));
    name.setFamilyName(new FamilyName("Family Name " + time));
    name.setGivenNames(new GivenNames("Given Names " + time));
    name.setVisibility(Visibility.PRIVATE);
    String orcid = "0000-0000-0000-0005";
    recordNameManager.createRecordName(orcid, name);
    Name newName = recordNameManager.getRecordName(orcid);
    assertNotNull(newName);
    assertEquals("Credit Name " + time, newName.getCreditName().getContent());
    assertEquals("Family Name " + time, newName.getFamilyName().getContent());
    assertEquals("Given Names " + time, newName.getGivenNames().getContent());
    assertEquals(Visibility.PRIVATE, newName.getVisibility());
}
Also used : FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) CreditName(org.orcid.jaxb.model.common_v2.CreditName) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) Name(org.orcid.jaxb.model.record_v2.Name) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 39 with CreditName

use of org.orcid.jaxb.model.record_v2.CreditName in project ORCID-Source by ORCID.

the class RDFWriterTest method fakeBio.

private Record fakeBio() throws DatatypeConfigurationException {
    Record r = new Record();
    r.setOrcidIdentifier(new OrcidIdentifier());
    r.getOrcidIdentifier().setPath("000-1337");
    r.getOrcidIdentifier().setUri("http://orcid.example.com/000-1337");
    r.setHistory(new History());
    r.getHistory().setCreationMethod(CreationMethod.WEBSITE);
    XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
    r.getHistory().setLastModifiedDate(new LastModifiedDate(value));
    r.getHistory().setClaimed(true);
    r.setPerson(new Person());
    r.getPerson().setBiography(new Biography());
    r.getPerson().setName(new Name());
    r.getPerson().getName().setFamilyName(new FamilyName("Doe"));
    r.getPerson().getName().setCreditName(new CreditName("John F Doe"));
    r.getPerson().getName().setGivenNames(new GivenNames("John"));
    r.getPerson().setOtherNames(new OtherNames());
    r.getPerson().getOtherNames().setOtherNames(new ArrayList<OtherName>());
    OtherName n = new OtherName();
    n.setContent("Johnny");
    n.setVisibility(Visibility.PUBLIC);
    OtherName n1 = new OtherName();
    n1.setContent("Mr Doe");
    n1.setVisibility(Visibility.PUBLIC);
    r.getPerson().getOtherNames().getOtherNames().add(n);
    r.getPerson().getOtherNames().getOtherNames().add(n1);
    r.getPerson().setResearcherUrls(new ResearcherUrls());
    r.getPerson().getResearcherUrls().setResearcherUrls(new ArrayList<ResearcherUrl>());
    ResearcherUrl anonymous = new ResearcherUrl();
    anonymous.setUrl(new Url("http://example.com/anon"));
    anonymous.setVisibility(Visibility.PUBLIC);
    r.getPerson().getResearcherUrls().getResearcherUrls().add(anonymous);
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/myPage", "homePage"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/foaf#me", "FOAF"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/webId", "webID"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/other", "other"));
    r.getPerson().setAddresses(new Addresses());
    r.getPerson().getAddresses().setAddress(new ArrayList<Address>());
    Address a = new Address();
    a.setCountry(new Country());
    a.getCountry().setValue(Iso3166Country.GB);
    r.getPerson().getAddresses().getAddress().add(a);
    r.getPerson().setEmails(new Emails());
    r.getPerson().getEmails().setEmails(new ArrayList<Email>());
    Email e = new Email();
    e.setEmail("john@example.org");
    e.setCurrent(true);
    Email e1 = new Email();
    e1.setEmail("doe@example.com");
    e1.setCurrent(true);
    r.getPerson().getEmails().getEmails().add(e);
    r.getPerson().getEmails().getEmails().add(e1);
    return r;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) History(org.orcid.jaxb.model.record_v2.History) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Record(org.orcid.jaxb.model.record_v2.Record) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Country(org.orcid.jaxb.model.common_v2.Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) Person(org.orcid.jaxb.model.record_v2.Person)

Aggregations

Test (org.junit.Test)17 CreditName (org.orcid.jaxb.model.common_v2.CreditName)16 Name (org.orcid.jaxb.model.record_v2.Name)10 CreditName (org.orcid.jaxb.model.record_v2.CreditName)9 FundingContributor (org.orcid.jaxb.model.record_v2.FundingContributor)9 FamilyName (org.orcid.jaxb.model.record_v2.FamilyName)8 GivenNames (org.orcid.jaxb.model.record_v2.GivenNames)8 IOException (java.io.IOException)5 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 Contributor (org.orcid.jaxb.model.common_v2.Contributor)5 ContributorEmail (org.orcid.jaxb.model.common_v2.ContributorEmail)5 Biography (org.orcid.jaxb.model.record_v2.Biography)4 Work (org.orcid.jaxb.model.record_v2.Work)4 WorkContributors (org.orcid.jaxb.model.record_v2.WorkContributors)4 ProfileEntity (org.orcid.persistence.jpa.entities.ProfileEntity)4 ContributorOrcid (org.orcid.jaxb.model.common_v2.ContributorOrcid)3 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)3 CreditName (org.orcid.jaxb.model.record_rc2.CreditName)3 CreditName (org.orcid.jaxb.model.record_rc4.CreditName)3