use of org.orcid.jaxb.model.record_rc2.Activity in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setCatchEventsInfo.
public void setCatchEventsInfo(FlowElementsContainer container, Definitions def, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
List<FlowElement> flowElements = container.getFlowElements();
for (FlowElement fe : flowElements) {
if (fe instanceof CatchEvent) {
if (((CatchEvent) fe).getEventDefinitions().size() > 0) {
EventDefinition ed = ((CatchEvent) fe).getEventDefinitions().get(0);
if (ed instanceof SignalEventDefinition) {
SignalEventDefinition sed = (SignalEventDefinition) ed;
if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
String signalRef = sed.getSignalRef();
boolean shouldAddSignal = true;
List<RootElement> rootElements = def.getRootElements();
for (RootElement re : rootElements) {
if (re instanceof Signal) {
if (((Signal) re).getName().equals(signalRef)) {
shouldAddSignal = false;
break;
}
}
}
if (toAddSignals != null) {
for (Signal s : toAddSignals) {
if (s.getName().equals(signalRef)) {
shouldAddSignal = false;
break;
}
}
}
if (shouldAddSignal) {
Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
signal.setName(signalRef);
toAddSignals.add(signal);
}
}
} else if (ed instanceof ErrorEventDefinition) {
String errorCode = null;
String errorId = null;
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("erefname")) {
errorId = (String) entry.getValue();
errorCode = (String) entry.getValue();
}
}
Error err = this._errors.get(errorCode);
if (err == null) {
err = Bpmn2Factory.eINSTANCE.createError();
err.setId(errorId);
err.setErrorCode(errorCode);
this._errors.put(errorCode, err);
}
toAddErrors.add(err);
((ErrorEventDefinition) ed).setErrorRef(err);
} else if (ed instanceof EscalationEventDefinition) {
String escalationCode = null;
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("esccode")) {
escalationCode = (String) entry.getValue();
break;
}
}
Escalation escalation = this._escalations.get(escalationCode);
if (escalation == null) {
escalation = Bpmn2Factory.eINSTANCE.createEscalation();
escalation.setEscalationCode(escalationCode);
this._escalations.put(escalationCode, escalation);
}
toAddEscalations.add(escalation);
((EscalationEventDefinition) ed).setEscalationRef(escalation);
} else if (ed instanceof MessageEventDefinition) {
((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
} else if (ed instanceof CompensateEventDefinition) {
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("actrefname")) {
String activityNameRef = (String) entry.getValue();
// we have to iterate again through all flow elements
// in order to find our activity name
List<RootElement> re = def.getRootElements();
for (RootElement r : re) {
if (r instanceof Process) {
Process p = (Process) r;
List<FlowElement> fes = p.getFlowElements();
for (FlowElement f : fes) {
if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
((CompensateEventDefinition) ed).setActivityRef((Activity) f);
((Activity) f).setIsForCompensation(true);
}
}
}
}
}
}
}
}
} else if (fe instanceof FlowElementsContainer) {
setCatchEventsInfo((FlowElementsContainer) fe, def, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
}
}
}
use of org.orcid.jaxb.model.record_rc2.Activity in project kie-wb-common by kiegroup.
the class Bpmn2JsonUnmarshaller method setCatchEventsInfoForLanes.
public void setCatchEventsInfoForLanes(Lane lane, Definitions def, List<Signal> toAddSignals, Set<Error> toAddErrors, Set<Escalation> toAddEscalations, Set<Message> toAddMessages, Set<ItemDefinition> toAddItemDefinitions) {
List<FlowNode> laneFlowNodes = lane.getFlowNodeRefs();
for (FlowElement fe : laneFlowNodes) {
if (fe instanceof CatchEvent) {
if (((CatchEvent) fe).getEventDefinitions().size() > 0) {
EventDefinition ed = ((CatchEvent) fe).getEventDefinitions().get(0);
if (ed instanceof SignalEventDefinition) {
SignalEventDefinition sed = (SignalEventDefinition) ed;
if (sed.getSignalRef() != null && sed.getSignalRef().length() > 0) {
String signalRef = sed.getSignalRef();
boolean shouldAddSignal = true;
List<RootElement> rootElements = def.getRootElements();
for (RootElement re : rootElements) {
if (re instanceof Signal) {
if (((Signal) re).getName().equals(signalRef)) {
shouldAddSignal = false;
break;
}
}
}
if (toAddSignals != null) {
for (Signal s : toAddSignals) {
if (s.getName().equals(signalRef)) {
shouldAddSignal = false;
break;
}
}
}
if (shouldAddSignal) {
Signal signal = Bpmn2Factory.eINSTANCE.createSignal();
signal.setName(signalRef);
toAddSignals.add(signal);
}
}
} else if (ed instanceof ErrorEventDefinition) {
String errorCode = null;
String errorId = null;
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("erefname")) {
errorId = (String) entry.getValue();
errorCode = (String) entry.getValue();
}
}
Error err = this._errors.get(errorCode);
if (err == null) {
err = Bpmn2Factory.eINSTANCE.createError();
err.setId(errorId);
err.setErrorCode(errorCode);
this._errors.put(errorCode, err);
}
toAddErrors.add(err);
((ErrorEventDefinition) ed).setErrorRef(err);
} else if (ed instanceof EscalationEventDefinition) {
String escalationCode = null;
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("esccode")) {
escalationCode = (String) entry.getValue();
break;
}
}
Escalation escalation = this._escalations.get(escalationCode);
if (escalation == null) {
escalation = Bpmn2Factory.eINSTANCE.createEscalation();
escalation.setEscalationCode(escalationCode);
this._escalations.put(escalationCode, escalation);
}
toAddEscalations.add(escalation);
((EscalationEventDefinition) ed).setEscalationRef(escalation);
} else if (ed instanceof MessageEventDefinition) {
((MessageEventDefinition) ed).setMessageRef(extractMessage(ed, toAddMessages, toAddItemDefinitions));
} else if (ed instanceof CompensateEventDefinition) {
Iterator<FeatureMap.Entry> iter = ed.getAnyAttribute().iterator();
while (iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if (entry.getEStructuralFeature().getName().equals("actrefname")) {
String activityNameRef = (String) entry.getValue();
// we have to iterate again through all flow elements
// in order to find our activity name
List<RootElement> re = def.getRootElements();
for (RootElement r : re) {
if (r instanceof Process) {
Process p = (Process) r;
List<FlowElement> fes = p.getFlowElements();
for (FlowElement f : fes) {
if (f instanceof Activity && ((Activity) f).getName().equals(activityNameRef)) {
((CompensateEventDefinition) ed).setActivityRef((Activity) f);
((Activity) f).setIsForCompensation(true);
}
}
}
}
}
}
}
}
} else if (fe instanceof FlowElementsContainer) {
setCatchEventsInfo((FlowElementsContainer) fe, def, toAddSignals, toAddErrors, toAddEscalations, toAddMessages, toAddItemDefinitions);
}
}
}
use of org.orcid.jaxb.model.record_rc2.Activity in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromMemberAPI.
@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
String accessToken = getAccessToken();
assertNotNull(accessToken);
ClientResponse response = memberV2ApiClient.viewRecord(getUser1OrcidId(), accessToken);
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
// Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
// Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
// Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
// PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
// Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertNotNull(s.getVisibility());
Visibility v = s.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
}
}
}
}
}
}
}
// Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
// Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertNotNull(o.getVisibility());
Visibility v = o.getVisibility();
// If the visibility is PRIVATE the client should be the owner
if (Visibility.PRIVATE.equals(v)) {
assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
}
}
}
}
// Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
if (Visibility.PRIVATE.equals(b.getVisibility())) {
fail("Visibility is private");
}
}
}
// Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
fail("Email " + e.getEmail() + " is private");
}
}
}
}
// External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
if (Visibility.PRIVATE.equals(name.getVisibility())) {
fail("Name is private");
}
}
// Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
// Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertNotNull(e.getVisibility());
if (Visibility.PRIVATE.equals(e.getVisibility())) {
assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
}
}
}
}
}
}
use of org.orcid.jaxb.model.record_rc2.Activity in project ORCID-Source by ORCID.
the class RecordTest method testViewRecordFromPublicAPI.
@Test
public void testViewRecordFromPublicAPI() {
ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
assertNotNull(response);
assertEquals("invalid " + response, 200, response.getStatus());
Record record = response.getEntity(Record.class);
assertNotNull(record);
assertNotNull(record.getOrcidIdentifier());
assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
// Check the visibility of every activity that exists
if (record.getActivitiesSummary() != null) {
if (record.getActivitiesSummary() != null) {
// Educations
if (record.getActivitiesSummary().getEducations() != null) {
Educations e = record.getActivitiesSummary().getEducations();
if (e.getSummaries() != null) {
for (EducationSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
// Employments
if (record.getActivitiesSummary().getEmployments() != null) {
Employments e = record.getActivitiesSummary().getEmployments();
if (e.getSummaries() != null) {
for (EmploymentSummary s : e.getSummaries()) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
// Fundings
if (record.getActivitiesSummary().getFundings() != null) {
Fundings f = record.getActivitiesSummary().getFundings();
List<FundingGroup> groups = f.getFundingGroup();
if (groups != null) {
for (FundingGroup fGroup : groups) {
List<FundingSummary> summaries = fGroup.getFundingSummary();
if (summaries != null) {
for (FundingSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
// PeerReviews
if (record.getActivitiesSummary().getPeerReviews() != null) {
PeerReviews p = record.getActivitiesSummary().getPeerReviews();
List<PeerReviewGroup> groups = p.getPeerReviewGroup();
if (groups != null) {
for (PeerReviewGroup pGroup : groups) {
List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
if (summaries != null) {
for (PeerReviewSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
// Works
if (record.getActivitiesSummary().getWorks() != null) {
Works w = record.getActivitiesSummary().getWorks();
List<WorkGroup> groups = w.getWorkGroup();
if (groups != null) {
for (WorkGroup wGroup : groups) {
List<WorkSummary> summaries = wGroup.getWorkSummary();
if (summaries != null) {
for (WorkSummary s : summaries) {
assertNotNull(s.getSource());
assertEquals(Visibility.PUBLIC, s.getVisibility());
}
}
}
}
}
}
}
// Check the visibility of every biography elements that exists
if (record.getPerson() != null) {
// Address
if (record.getPerson().getAddresses() != null) {
Addresses addresses = record.getPerson().getAddresses();
List<Address> list = addresses.getAddress();
if (list != null) {
for (Address o : list) {
assertNotNull(o.getSource());
assertEquals(Visibility.PUBLIC, o.getVisibility());
}
}
}
// Biography
if (record.getPerson().getBiography() != null) {
Biography b = record.getPerson().getBiography();
if (b != null) {
assertNotNull(b.getVisibility());
assertEquals(Visibility.PUBLIC, b.getVisibility());
}
}
// Emails
if (record.getPerson().getEmails() != null) {
Emails emails = record.getPerson().getEmails();
List<Email> list = emails.getEmails();
if (list != null) {
for (Email e : list) {
assertNotNull(e.getVisibility());
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
// External identifiers
if (record.getPerson().getExternalIdentifiers() != null) {
PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
if (list != null) {
for (PersonExternalIdentifier e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
// Keywords
if (record.getPerson().getKeywords() != null) {
Keywords keywords = record.getPerson().getKeywords();
List<Keyword> list = keywords.getKeywords();
if (list != null) {
for (Keyword e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
// Name
if (record.getPerson().getName() != null) {
Name name = record.getPerson().getName();
assertEquals(Visibility.PUBLIC, name.getVisibility());
}
// Other names
if (record.getPerson().getOtherNames() != null) {
OtherNames otherNames = record.getPerson().getOtherNames();
List<OtherName> list = otherNames.getOtherNames();
if (list != null) {
for (OtherName e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
// Researcher urls
if (record.getPerson().getResearcherUrls() != null) {
ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
List<ResearcherUrl> list = rUrls.getResearcherUrls();
if (list != null) {
for (ResearcherUrl e : list) {
assertEquals(Visibility.PUBLIC, e.getVisibility());
}
}
}
}
}
use of org.orcid.jaxb.model.record_rc2.Activity in project libSBOLj by SynBioDex.
the class Provenance_SpecifyBuildOperations method specifyJoinOperation.
/**
* specifies a join operation, which joins two linear DNA constructs
*
* NOTE! at this point, we do not specify any further information
* about how to execute the join operation!
*
* @throws Exception
*/
public static void specifyJoinOperation() throws Exception {
// instantiate a document
SBOLDocument document = new SBOLDocument();
document.setDefaultURIprefix(BUILD_PREFIX);
// the first linear DNA construct
ComponentDefinition cdPart1 = document.createComponentDefinition("dna_part_1", LINEAR_DOUBLE_STRANDED_DNA);
cdPart1.setName("dna_part_1");
// the second linear DNA construct
ComponentDefinition cdPart2 = document.createComponentDefinition("dna_part_2", LINEAR_DOUBLE_STRANDED_DNA);
cdPart2.setName("dna_part_2");
// Create the generic top level entity for the join operation
Activity joinOperation = document.createActivity("join_" + cdPart1.getName() + "_with_" + cdPart2.getName());
joinOperation.setName("join(" + cdPart1.getName() + ", " + cdPart2.getName() + ")");
// specify the "inputs" to the join operation
joinOperation.createUsage("dna_part_1", cdPart1.getIdentity()).addRole(UPSTREAM);
joinOperation.createUsage("dna_part_2", cdPart2.getIdentity()).addRole(DOWNSTREAM);
// specify the "output" of the join operation
ComponentDefinition cdJoinedPart = document.createComponentDefinition("joined_dna_part", LINEAR_DOUBLE_STRANDED_DNA);
cdJoinedPart.setName("joined_dna_part");
cdJoinedPart.addWasGeneratedBy(joinOperation.getIdentity());
// serialize the document to a file
SBOLWriter.write(document, System.out);
}
Aggregations