Search in sources :

Example 16 with SubmissionDate

use of org.orcid.jaxb.model.message.SubmissionDate in project ORCID-Source by ORCID.

the class T2OrcidApiServiceVersionedDelegatorTest method testCreateProfileWithInvalidHistoryElements.

@Test
public void testCreateProfileWithInvalidHistoryElements() {
    OrcidMessage orcidMessage = createStubOrcidMessage();
    orcidMessage.setMessageVersion("1.2");
    //Claimed should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setClaimed(new Claimed(false));
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Claimed status should not be specified when creating a profile"));
    }
    //Creation method should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setCreationMethod(CreationMethod.API);
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Creation method should not be specified when creating a profile"));
    }
    //Completion date should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setCompletionDate(new CompletionDate());
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Completion date should not be specified when creating a profile"));
    }
    //Submission date should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setSubmissionDate(new SubmissionDate());
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Submission date should not be specified when creating a profile"));
    }
    //Last modified date should be null
    try {
        OrcidHistory history = new OrcidHistory();
        history.setLastModifiedDate(new LastModifiedDate());
        orcidMessage.getOrcidProfile().setOrcidHistory(history);
        t2OrcidApiServiceDelegatorLatest.createProfile(mockedUriInfo, orcidMessage);
    } catch (OrcidValidationException obe) {
        assertTrue(obe.getMessage().contains("Last modified date should not be specified when creating a profile"));
    }
}
Also used : LastModifiedDate(org.orcid.jaxb.model.message.LastModifiedDate) OrcidHistory(org.orcid.jaxb.model.message.OrcidHistory) OrcidMessage(org.orcid.jaxb.model.message.OrcidMessage) OrcidValidationException(org.orcid.core.exception.OrcidValidationException) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) CompletionDate(org.orcid.jaxb.model.message.CompletionDate) Claimed(org.orcid.jaxb.model.message.Claimed) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 17 with SubmissionDate

use of org.orcid.jaxb.model.message.SubmissionDate in project ORCID-Source by ORCID.

the class Jaxb2JpaAdapterImpl method setHistoryDetails.

private void setHistoryDetails(ProfileEntity profileEntity, OrcidHistory orcidHistory) {
    if (orcidHistory != null) {
        CompletionDate completionDate = orcidHistory.getCompletionDate();
        profileEntity.setCompletedDate(completionDate == null ? null : toDate(completionDate.getValue()));
        SubmissionDate submissionDate = orcidHistory.getSubmissionDate();
        profileEntity.setSubmissionDate(submissionDate == null ? null : toDate(submissionDate.getValue()));
        DeactivationDate deactivationDate = orcidHistory.getDeactivationDate();
        profileEntity.setDeactivationDate(deactivationDate == null ? null : toDate(deactivationDate.getValue()));
        profileEntity.setClaimed(orcidHistory.isClaimed());
        CreationMethod creationMethod = orcidHistory.getCreationMethod();
        profileEntity.setCreationMethod(creationMethod != null ? creationMethod.value() : null);
        Source source = orcidHistory.getSource();
        if (source != null) {
            SourceEntity sourceEntity = new SourceEntity();
            ClientDetailsEntity clientDetailsEntity = new ClientDetailsEntity();
            clientDetailsEntity.setId(source.retrieveSourcePath());
            sourceEntity.setSourceClient(clientDetailsEntity);
            profileEntity.setSource(sourceEntity);
        }
    }
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) CreationMethod(org.orcid.jaxb.model.message.CreationMethod) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) SubmissionDate(org.orcid.jaxb.model.message.SubmissionDate) CompletionDate(org.orcid.jaxb.model.message.CompletionDate) DeactivationDate(org.orcid.jaxb.model.message.DeactivationDate) Source(org.orcid.jaxb.model.message.Source)

Aggregations

SubmissionDate (org.orcid.jaxb.model.message.SubmissionDate)17 OrcidHistory (org.orcid.jaxb.model.message.OrcidHistory)16 Date (java.util.Date)13 Claimed (org.orcid.jaxb.model.message.Claimed)13 OrcidProfile (org.orcid.jaxb.model.message.OrcidProfile)13 Test (org.junit.Test)9 Source (org.orcid.jaxb.model.message.Source)9 ActivitiesVisibilityDefault (org.orcid.jaxb.model.message.ActivitiesVisibilityDefault)8 ApprovalDate (org.orcid.jaxb.model.message.ApprovalDate)8 Transactional (org.springframework.transaction.annotation.Transactional)8 OrcidBio (org.orcid.jaxb.model.message.OrcidBio)7 ContactDetails (org.orcid.jaxb.model.message.ContactDetails)6 Email (org.orcid.jaxb.model.message.Email)6 FundingTitle (org.orcid.jaxb.model.message.FundingTitle)6 OrcidInternal (org.orcid.jaxb.model.message.OrcidInternal)6 OrcidWork (org.orcid.jaxb.model.message.OrcidWork)6 Rollback (org.springframework.test.annotation.Rollback)6 ExternalIdReference (org.orcid.jaxb.model.message.ExternalIdReference)5 PersonalDetails (org.orcid.jaxb.model.message.PersonalDetails)5 Preferences (org.orcid.jaxb.model.message.Preferences)5