Search in sources :

Example 21 with History

use of org.geotoolkit.sml.xml.v100.History in project ORCID-Source by ORCID.

the class ValidateV2RC4SamplesTest method testMarshallHistory.

@Test
public void testMarshallHistory() throws JAXBException, SAXException, URISyntaxException {
    History object = (History) unmarshallFromPath("/record_2.0_rc4/samples/history-2.0_rc4.xml", History.class);
    marshall(object, "/record_2.0_rc4/history-2.0_rc4.xsd");
}
Also used : History(org.orcid.jaxb.model.record_rc4.History) Test(org.junit.Test)

Example 22 with History

use of org.geotoolkit.sml.xml.v100.History in project ORCID-Source by ORCID.

the class MongoMessageProcessorTest method testDeactivated.

@Test
public void testDeactivated() throws LockedRecordException, DeprecatedRecordException, DatatypeConfigurationException {
    Record deactivatedRecord = new Record();
    deactivatedRecord.setOrcidIdentifier(new OrcidIdentifier("http://orcid.org/" + this.orcid2));
    History h = new History();
    h.setDeactivationDate(new DeactivationDate());
    GregorianCalendar c = new GregorianCalendar();
    XMLGregorianCalendar date = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
    h.getDeactivationDate().setValue(date);
    deactivatedRecord.setHistory(h);
    when(mock_orcid20ApiClient.fetchPublicRecord(Matchers.any())).thenReturn(deactivatedRecord);
    LastModifiedMessage m = new LastModifiedMessage(this.orcid2, new Date());
    mongo.accept(m);
    // test db has entry for deactivated record
    Document d = new Document();
    d.put("_id", this.orcid2);
    assertEquals(col.count(d), 1);
    FindIterable<Document> it = col.find(d);
    assertEquals(it.first().get("status"), "deactivated");
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) LastModifiedMessage(org.orcid.utils.listener.LastModifiedMessage) GregorianCalendar(java.util.GregorianCalendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Record(org.orcid.jaxb.model.record_v2.Record) History(org.orcid.jaxb.model.record_v2.History) Document(org.bson.Document) DeactivationDate(org.orcid.jaxb.model.record_v2.DeactivationDate) Date(java.util.Date) DeactivationDate(org.orcid.jaxb.model.record_v2.DeactivationDate) Test(org.junit.Test)

Example 23 with History

use of org.geotoolkit.sml.xml.v100.History in project ORCID-Source by ORCID.

the class RecordManagerReadOnlyImpl method getHistory.

private History getHistory(String orcid) {
    History history = new History();
    ProfileEntity profile = profileEntityCacheManager.retrieve(orcid);
    history.setClaimed(profile.getClaimed());
    if (profile.getCompletedDate() != null) {
        history.setCompletionDate(new CompletionDate(DateUtils.convertToXMLGregorianCalendar(profile.getCompletedDate())));
    }
    if (!PojoUtil.isEmpty(profile.getCreationMethod())) {
        history.setCreationMethod(CreationMethod.fromValue(profile.getCreationMethod()));
    }
    if (profile.getDeactivationDate() != null) {
        history.setDeactivationDate(new DeactivationDate(DateUtils.convertToXMLGregorianCalendar(profile.getDeactivationDate())));
    }
    if (profile.getLastModified() != null) {
        history.setLastModifiedDate(new LastModifiedDate(DateUtils.convertToXMLGregorianCalendar(profile.getLastModified())));
    }
    if (profile.getSubmissionDate() != null) {
        history.setSubmissionDate(new SubmissionDate(DateUtils.convertToXMLGregorianCalendar(profile.getSubmissionDate())));
    }
    if (profile.getSource() != null) {
        history.setSource(new Source(profile.getSource().getSourceId()));
    }
    boolean verfiedEmail = false;
    boolean verfiedPrimaryEmail = false;
    Emails emails = emailManager.getEmails(orcid);
    if (emails != null) {
        for (Email email : emails.getEmails()) {
            if (email.isVerified()) {
                verfiedEmail = true;
                if (email.isPrimary()) {
                    verfiedPrimaryEmail = true;
                    break;
                }
            }
        }
    }
    history.setVerifiedEmail(verfiedEmail);
    history.setVerifiedPrimaryEmail(verfiedPrimaryEmail);
    return history;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Email(org.orcid.jaxb.model.record_v2.Email) Emails(org.orcid.jaxb.model.record_v2.Emails) History(org.orcid.jaxb.model.record_v2.History) SubmissionDate(org.orcid.jaxb.model.record_v2.SubmissionDate) CompletionDate(org.orcid.jaxb.model.record_v2.CompletionDate) DeactivationDate(org.orcid.jaxb.model.record_v2.DeactivationDate) ProfileEntity(org.orcid.persistence.jpa.entities.ProfileEntity) Source(org.orcid.jaxb.model.common_v2.Source)

Example 24 with History

use of org.geotoolkit.sml.xml.v100.History 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)

Example 25 with History

use of org.geotoolkit.sml.xml.v100.History in project sdk-java by temporalio.

the class WorkflowClientHelper method prettyPrintHistory.

/**
 * Returns workflow instance history in a human readable format.
 *
 * @param showWorkflowTasks when set to false workflow task events (command events) are not
 *     included
 * @param metricsScope
 */
public static String prettyPrintHistory(WorkflowServiceStubs service, String namespace, WorkflowExecution workflowExecution, boolean showWorkflowTasks, Scope metricsScope) {
    Iterator<HistoryEvent> events = getHistory(service, namespace, workflowExecution, metricsScope);
    History history = History.newBuilder().addAllEvents(() -> events).build();
    return new WorkflowExecutionHistory(history).toProtoText(showWorkflowTasks);
}
Also used : HistoryEvent(io.temporal.api.history.v1.HistoryEvent) WorkflowExecutionHistory(io.temporal.internal.common.WorkflowExecutionHistory) History(io.temporal.api.history.v1.History) WorkflowExecutionHistory(io.temporal.internal.common.WorkflowExecutionHistory)

Aggregations

Test (org.junit.Test)16 History (org.orcid.jaxb.model.record_v2.History)13 History (io.temporal.api.history.v1.History)9 HistoryEvent (io.temporal.api.history.v1.HistoryEvent)7 IOException (java.io.IOException)5 InputStreamReader (java.io.InputStreamReader)5 Reader (java.io.Reader)5 OrcidIdentifier (org.orcid.jaxb.model.common_v2.OrcidIdentifier)5 Email (org.orcid.jaxb.model.record_v2.Email)5 WorkflowExecutionHistory (io.temporal.internal.common.WorkflowExecutionHistory)4 Address (org.orcid.jaxb.model.record_v2.Address)4 Record (org.orcid.jaxb.model.record_v2.Record)4 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)4 WorkflowExecution (io.temporal.api.common.v1.WorkflowExecution)3 ArrayList (java.util.ArrayList)3 History (org.orcid.jaxb.model.record_rc2.History)3 History (org.orcid.jaxb.model.record_rc3.History)3 History (org.orcid.jaxb.model.record_rc4.History)3 WorkflowFailedException (io.temporal.client.WorkflowFailedException)2 WorkflowStub (io.temporal.client.WorkflowStub)2