Search in sources :

Example 26 with Record

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

the class ValidateV2SamplesTest 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);
    }
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Address(org.orcid.jaxb.model.record_v2.Address) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) CreditName(org.orcid.jaxb.model.record_v2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_v2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_v2.Deprecated) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl)

Example 27 with Record

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

the class ValidateV2_1IdentifiersTest method testPeerReview.

/** Test both types of identifier here
     * 
     * @throws SAXException
     * @throws IOException
     * @throws JAXBException
     * @throws ParserConfigurationException
     */
@Test
public void testPeerReview() throws SAXException, IOException, JAXBException, ParserConfigurationException {
    PeerReview peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-2.1.xml", PeerReview.class);
    ExternalID id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    ExternalID subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
    Validator validator = getValidator("peer-review");
    validator.validate(marshall(PeerReview.class, peerReview));
    validator.validate(marshallToDOM(PeerReview.class, peerReview));
    //do the full record too
    peerReview = unmarshallFromPath("/record_2.1/samples/read_samples/peer-review-full-2.1.xml", PeerReview.class);
    id = peerReview.getExternalIdentifiers().getExternalIdentifier().get(0);
    assertEquals("source-work-id", id.getType());
    assertEquals("work:external-identifier-id", id.getValue());
    assertEquals(new Url("http://orcid.org"), id.getUrl());
    assertEquals(Relationship.SELF, id.getRelationship());
    subjectid = peerReview.getSubjectExternalIdentifier();
    assertEquals("doi", subjectid.getType());
    assertEquals("peer-review:subject-external-identifier-id", subjectid.getValue());
    assertEquals(new Url("http://orcid.org"), subjectid.getUrl());
    assertEquals(Relationship.SELF, subjectid.getRelationship());
}
Also used : ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) Url(org.orcid.jaxb.model.common_v2.Url) Validator(javax.xml.validation.Validator) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 28 with Record

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

the class PublicV2ApiServiceDelegatorImpl method viewRecord.

@Override
public Response viewRecord(String orcid) {
    Record record = recordManagerReadOnly.getPublicRecord(orcid);
    publicAPISecurityManagerV2.filter(record);
    if (record.getPerson() != null) {
        sourceUtilsReadOnly.setSourceName(record.getPerson());
    }
    if (record.getActivitiesSummary() != null) {
        ActivityUtils.cleanEmptyFields(record.getActivitiesSummary());
        sourceUtilsReadOnly.setSourceName(record.getActivitiesSummary());
    }
    ElementUtils.setPathToRecord(record, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(record);
    return Response.ok(record).build();
}
Also used : GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) Record(org.orcid.jaxb.model.record_v2.Record)

Example 29 with Record

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

the class MemberV2ApiServiceDelegator_ReadRecordTest method testViewRecordWrongScope.

@Test
public void testViewRecordWrongScope() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_PUBLIC);
    Response response = serviceDelegator.viewRecord(ORCID);
    // Verify everything inside is public
    Record record = (Record) response.getEntity();
    assertNotNull(record);
    assertEquals("/0000-0000-0000-0003", record.getPath());
    assertEquals("/0000-0000-0000-0003/activities", record.getActivitiesSummary().getPath());
    Utils.assertIsPublicOrSource(record.getActivitiesSummary(), SecurityContextTestUtils.DEFAULT_CLIENT_ID);
    assertEquals("/0000-0000-0000-0003/person", record.getPerson().getPath());
    Utils.assertIsPublicOrSource(record.getPerson(), SecurityContextTestUtils.DEFAULT_CLIENT_ID);
}
Also used : Response(javax.ws.rs.core.Response) GroupIdRecord(org.orcid.jaxb.model.groupid_v2.GroupIdRecord) Record(org.orcid.jaxb.model.record_v2.Record) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 30 with Record

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

the class EmailManagerTest method moveEmailToOtherAccountTest.

@Test
public void moveEmailToOtherAccountTest() {
    String email = "public@email.com";
    String from = "4444-4444-4444-4441";
    String to = "4444-4444-4444-4499";
    ProfileEntity destinationBefore = profileDao.find(to);
    Date beforeLastModified = destinationBefore.getLastModified();
    Map<String, String> map = emailManager.findOricdIdsByCommaSeparatedEmails(email);
    assertNotNull(map);
    assertEquals(from, map.get(email));
    emailManager.moveEmailToOtherAccount(email, from, to);
    ProfileEntity destinationAfter = profileDao.find(to);
    Date afterLastModified = destinationAfter.getLastModified();
    assertFalse(beforeLastModified.equals(afterLastModified));
    assertTrue(afterLastModified.getTime() > beforeLastModified.getTime());
    //Assert the email was moved
    map = emailManager.findOricdIdsByCommaSeparatedEmails(email);
    assertNotNull(map);
    assertEquals(to, map.get(email));
    //Assert the email is not anymore in the from record
    Emails emails = emailManager.getEmails(from, System.currentTimeMillis());
    for (Email e : emails.getEmails()) {
        assertFalse(email.equals(e.getEmail()));
    }
    //Assert the email belongs to the to record
    emails = emailManager.getEmails(to, System.currentTimeMillis());
    boolean found = false;
    for (Email e : emails.getEmails()) {
        if (email.equals(e.getEmail())) {
            found = true;
        }
    }
    assertTrue(found);
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Emails(org.orcid.jaxb.model.record_v2.Emails) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Date(java.util.Date) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Aggregations

Test (org.junit.Test)63 Record (org.orcid.jaxb.model.record_v2.Record)49 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)23 Email (org.orcid.jaxb.model.record_v2.Email)22 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)21 Address (org.orcid.jaxb.model.record_v2.Address)20 Keyword (org.orcid.jaxb.model.record_v2.Keyword)20 Person (org.orcid.jaxb.model.record_v2.Person)20 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)20 Record (nikita.model.noark5.v4.Record)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)19 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)19 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)19 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)19 OtherName (org.orcid.jaxb.model.record_v2.OtherName)18 Biography (org.orcid.jaxb.model.record_v2.Biography)17 Emails (org.orcid.jaxb.model.record_v2.Emails)17 Name (org.orcid.jaxb.model.record_v2.Name)17 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)17 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)16