Search in sources :

Example 6 with History

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

the class PublicV2ApiServiceDelegatorTest method validateRecord.

private void validateRecord(Record record) {
    assertNotNull(record);
    assertEquals("/" + ORCID, record.getPath());
    validatePerson(record.getPerson());
    validateActivities(record.getActivitiesSummary());
    assertNotNull(record.getHistory());
    assertEquals(OrcidType.USER, record.getOrcidType());
    assertNotNull(record.getPreferences());
    assertEquals(Locale.EN, record.getPreferences().getLocale());
    History history = record.getHistory();
    assertTrue(history.getClaimed());
    assertNotNull(history.getCompletionDate());
    assertEquals(CreationMethod.INTEGRATION_TEST, history.getCreationMethod());
    assertNull(history.getDeactivationDate());
    assertNotNull(history.getLastModifiedDate());
    assertNotNull(history.getLastModifiedDate().getValue());
    assertNotNull(history.getSource());
    assertEquals("APP-5555555555555555", history.getSource().retrieveSourcePath());
    assertNotNull(history.getSubmissionDate());
    assertNotNull(record.getOrcidIdentifier());
    OrcidIdentifier id = record.getOrcidIdentifier();
    assertEquals("0000-0000-0000-0003", id.getPath());
}
Also used : OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) History(org.orcid.jaxb.model.record_v2.History)

Example 7 with History

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

the class ValidateV2RC2SamplesTest 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;
        }
        return result;
    } catch (IOException e) {
        throw new RuntimeException("Error reading notification from classpath", e);
    }
}
Also used : Email(org.orcid.jaxb.model.record_rc2.Email) InputStreamReader(java.io.InputStreamReader) Keyword(org.orcid.jaxb.model.record_rc2.Keyword) Address(org.orcid.jaxb.model.record_rc2.Address) OtherNames(org.orcid.jaxb.model.record_rc2.OtherNames) CreditName(org.orcid.jaxb.model.record_rc2.CreditName) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) IOException(java.io.IOException) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) History(org.orcid.jaxb.model.record_rc2.History) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc2.ActivitiesSummary) Deprecated(org.orcid.jaxb.model.record_rc2.Deprecated) Biography(org.orcid.jaxb.model.record_rc2.Biography) ResearcherUrl(org.orcid.jaxb.model.record_rc2.ResearcherUrl)

Example 8 with History

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

the class RDFMessageBodyWriterV2 method describeAccount.

private Individual describeAccount(Record record, OntModel m, Individual person) {
    String orcidURI = record.getOrcidIdentifier().getUri();
    String orcidPublicationsUri = orcidURI + "#workspace-works";
    Individual publications = m.createIndividual(orcidPublicationsUri, FOAF.Document);
    // list of publications
    // (anchor in the HTML rendering - foaf:publications goes to a foaf:Document - not to an
    // RDF list of publications - although we should probably also have that)
    person.addProperty(FOAF.publications, publications);
    String orcidAccountUri = orcidURI + "#orcid-id";
    Individual account = m.createIndividual(orcidAccountUri, FOAF.OnlineAccount);
    person.addProperty(FOAF.account, account);
    Individual webSite = null;
    if (baseUri != null) {
        webSite = m.createIndividual(baseUri, null);
        account.addProperty(FOAF.accountServiceHomepage, webSite);
    }
    String orcId = record.getOrcidIdentifier().getPath();
    account.addProperty(FOAF.accountName, orcId);
    account.addLabel(orcId, null);
    // The current page is the foaf:PersonalProfileDocument - this assumes
    // we have done a 303 See Other redirect to the RDF resource, so that it
    // differs from the ORCID uri.
    // for example:
    // 
    // GET http://orcid.org/0000-0003-4654-1403
    // Accept: text/turtle
    // 
    // HTTP/1.1 303 See Other
    // Location: https://pub.orcid.org/experimental_rdf_v1/0000-0001-9842-9718
    String profileUri;
    if (getUriInfo() != null) {
        profileUri = getUriInfo().getAbsolutePath().toASCIIString();
    } else {
        // Some kind of fallback, although the PersonalProfiledocument should be an
        // information resource without #anchor
        profileUri = orcidURI + "#personalProfileDocument";
    }
    Individual profileDoc = m.createIndividual(profileUri, FOAF.PersonalProfileDocument);
    profileDoc.addProperty(FOAF.primaryTopic, person);
    History history = record.getHistory();
    if (history != null) {
        if (history.getClaimed()) {
            // Set account as PersonalProfileDocument
            profileDoc.addProperty(FOAF.maker, person);
        }
        // Who made the profile?
        switch(history.getCreationMethod()) {
            case DIRECT:
            case MEMBER_REFERRED:
            case WEBSITE:
                profileDoc.addProperty(PAV.createdBy, person);
                profileDoc.addProperty(PROV.wasAttributedTo, person);
                if (webSite != null && (history.getCreationMethod() == CreationMethod.WEBSITE || history.getCreationMethod() == CreationMethod.DIRECT)) {
                    profileDoc.addProperty(PAV.createdWith, webSite);
                }
                break;
            case API:
                Individual api = m.createIndividual(MEMBER_API, PROV.SoftwareAgent);
                profileDoc.addProperty(PAV.importedBy, api);
                if (history.getClaimed()) {
                    profileDoc.addProperty(PAV.curatedBy, person);
                }
                break;
            default:
                // Some unknown agent!
                profileDoc.addProperty(PAV.createdWith, m.createIndividual(null, PROV.Agent));
        }
        if (history.getLastModifiedDate() != null) {
            Literal when = calendarAsLiteral(history.getLastModifiedDate().getValue(), m);
            profileDoc.addLiteral(PAV.lastUpdateOn, when);
            profileDoc.addLiteral(PROV.generatedAtTime, when);
        }
        if (history.getSubmissionDate() != null) {
            profileDoc.addLiteral(PAV.createdOn, calendarAsLiteral(history.getSubmissionDate().getValue(), m));
        }
        if (history.getCompletionDate() != null) {
            profileDoc.addLiteral(PAV.contributedOn, calendarAsLiteral(history.getCompletionDate().getValue(), m));
        }
        if (history.getDeactivationDate() != null) {
            profileDoc.addLiteral(PROV.invalidatedAtTime, calendarAsLiteral(history.getDeactivationDate().getValue(), m));
        }
    }
    return profileDoc;
}
Also used : Individual(org.apache.jena.ontology.Individual) Literal(org.apache.jena.rdf.model.Literal) History(org.orcid.jaxb.model.record_v2.History)

Example 9 with History

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

the class WorkflowClientLongPollAsyncHelper method getInstanceCloseEventAsync.

/**
 * Returns an instance closing event, potentially waiting for workflow to complete.
 */
private static CompletableFuture<HistoryEvent> getInstanceCloseEventAsync(WorkflowServiceStubs service, RootWorkflowClientHelper workflowClientHelper, final WorkflowExecution workflowExecution, ByteString pageToken, long timeout, TimeUnit unit) {
    // TODO: Interrupt service long poll call on timeout and on interrupt
    long start = System.currentTimeMillis();
    GetWorkflowExecutionHistoryRequest request = workflowClientHelper.newHistoryLongPollRequest(workflowExecution, pageToken);
    CompletableFuture<GetWorkflowExecutionHistoryResponse> response = getWorkflowExecutionHistoryAsync(service, request, timeout, unit);
    return response.thenComposeAsync((r) -> {
        if (timeout != 0 && System.currentTimeMillis() - start > unit.toMillis(timeout)) {
            throw CheckedExceptionWrapper.wrap(new TimeoutException("WorkflowId=" + workflowExecution.getWorkflowId() + ", runId=" + workflowExecution.getRunId() + ", timeout=" + timeout + ", unit=" + unit));
        }
        History history = r.getHistory();
        if (history.getEventsCount() == 0) {
            // Empty poll returned
            return getInstanceCloseEventAsync(service, workflowClientHelper, workflowExecution, pageToken, timeout, unit);
        }
        HistoryEvent event = history.getEvents(0);
        if (!WorkflowExecutionUtils.isWorkflowExecutionClosedEvent(event)) {
            throw new RuntimeException("Last history event is not completion event: " + event);
        }
        // Workflow called continueAsNew. Start polling the new generation with new runId.
        if (event.getEventType() == EventType.EVENT_TYPE_WORKFLOW_EXECUTION_CONTINUED_AS_NEW) {
            WorkflowExecution nextWorkflowExecution = WorkflowExecution.newBuilder().setWorkflowId(workflowExecution.getWorkflowId()).setRunId(event.getWorkflowExecutionContinuedAsNewEventAttributes().getNewExecutionRunId()).build();
            return getInstanceCloseEventAsync(service, workflowClientHelper, nextWorkflowExecution, r.getNextPageToken(), timeout, unit);
        }
        return CompletableFuture.completedFuture(event);
    });
}
Also used : GetWorkflowExecutionHistoryRequest(io.temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryRequest) WorkflowExecution(io.temporal.api.common.v1.WorkflowExecution) GetWorkflowExecutionHistoryResponse(io.temporal.api.workflowservice.v1.GetWorkflowExecutionHistoryResponse) History(io.temporal.api.history.v1.History) HistoryEvent(io.temporal.api.history.v1.HistoryEvent)

Example 10 with History

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

the class TestWorkflowStoreImpl method sendQueryTask.

@Override
public void sendQueryTask(ExecutionId executionId, TaskQueueId taskQueue, PollWorkflowTaskQueueResponse.Builder task) {
    lock.lock();
    try {
        HistoryStore historyStore = getHistoryStore(executionId);
        List<HistoryEvent> events = new ArrayList<>(historyStore.getEventsLocked());
        History.Builder history = History.newBuilder();
        PeekingIterator<HistoryEvent> iterator = Iterators.peekingIterator(events.iterator());
        long startedEventId = 0;
        long previousStaredEventId = 0;
        while (iterator.hasNext()) {
            HistoryEvent event = iterator.next();
            if (event.getEventType() == EventType.EVENT_TYPE_WORKFLOW_TASK_STARTED) {
                if (!iterator.hasNext() || iterator.peek().getEventType() == EventType.EVENT_TYPE_WORKFLOW_TASK_COMPLETED) {
                    previousStaredEventId = startedEventId;
                    startedEventId = event.getEventId();
                }
            } else if (WorkflowExecutionUtils.isWorkflowExecutionClosedEvent(event)) {
                previousStaredEventId = startedEventId;
                startedEventId = 0;
                if (iterator.hasNext()) {
                    throw Status.INTERNAL.withDescription("Unexpected event after the completion event: " + iterator.peek()).asRuntimeException();
                }
            }
        }
        task.setPreviousStartedEventId(previousStaredEventId);
        task.setStartedEventId(startedEventId);
        if (taskQueue.getTaskQueueName().equals(task.getWorkflowExecutionTaskQueue().getName())) {
            history.addAllEvents(events);
        } else {
            history.addAllEvents(new ArrayList<>());
        }
        task.setHistory(history);
    } finally {
        lock.unlock();
    }
    TaskQueue<PollWorkflowTaskQueueResponse.Builder> workflowTaskQueue = getWorkflowTaskQueueQueue(taskQueue);
    workflowTaskQueue.add(task);
}
Also used : ArrayList(java.util.ArrayList) HistoryEvent(io.temporal.api.history.v1.HistoryEvent) WorkflowExecutionHistory(io.temporal.internal.common.WorkflowExecutionHistory) History(io.temporal.api.history.v1.History)

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