Search in sources :

Example 21 with Activity

use of org.sbolstandard.core2.Activity in project libSBOLj by SynBioDex.

the class SBOLDocument method updateReferences.

// TODO: need to update persistentIdentities too
private void updateReferences(URI originalIdentity, URI newIdentity) throws SBOLValidationException {
    for (TopLevel topLevel : getTopLevels()) {
        for (URI wasDerivedFrom : topLevel.getWasDerivedFroms()) {
            if (wasDerivedFrom.equals(originalIdentity)) {
                topLevel.removeWasDerivedFrom(originalIdentity);
                topLevel.addWasDerivedFrom(newIdentity);
            }
        }
        for (URI wasGeneratedBy : topLevel.getWasGeneratedBys()) {
            if (wasGeneratedBy.equals(originalIdentity)) {
                topLevel.removeWasGeneratedBy(originalIdentity);
                topLevel.addWasGeneratedBy(newIdentity);
            }
        }
        for (URI attachmentURI : topLevel.getAttachmentURIs()) {
            if (attachmentURI.equals(originalIdentity)) {
                topLevel.removeAttachment(originalIdentity);
                topLevel.addAttachment(newIdentity);
            }
        }
    }
    for (Collection collection : getCollections()) {
        for (URI memberURI : collection.getMemberURIs()) {
            if (memberURI.equals(originalIdentity)) {
                collection.removeMember(originalIdentity);
                collection.addMember(newIdentity);
            }
        }
        updateReferences(collection, originalIdentity, newIdentity);
    }
    for (ComponentDefinition componentDefinition : getComponentDefinitions()) {
        updateReferences(componentDefinition, originalIdentity, newIdentity);
        for (Component component : componentDefinition.getComponents()) {
            if (component.getDefinitionURI().equals(originalIdentity)) {
                component.setDefinition(newIdentity);
                for (MapsTo mapsTo : component.getMapsTos()) {
                    ComponentDefinition cd = getComponentDefinition(newIdentity);
                    if (cd != null) {
                        String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
                        URI newURI = URIcompliance.createCompliantURI(cd.getPersistentIdentity().toString(), displayId, cd.getVersion());
                        mapsTo.setRemote(newURI);
                    }
                }
            }
            updateReferences(component, originalIdentity, newIdentity);
            for (MapsTo mapsTo : component.getMapsTos()) {
                updateReferences(mapsTo, originalIdentity, newIdentity);
            }
        }
        for (SequenceAnnotation sa : componentDefinition.getSequenceAnnotations()) {
            for (Location loc : sa.getLocations()) {
                updateReferences(loc, originalIdentity, newIdentity);
            }
            updateReferences(sa, originalIdentity, newIdentity);
        }
        for (SequenceConstraint sc : componentDefinition.getSequenceConstraints()) {
            updateReferences(sc, originalIdentity, newIdentity);
        }
        for (URI sequenceURI : componentDefinition.getSequenceURIs()) {
            if (sequenceURI.equals(originalIdentity)) {
                componentDefinition.removeSequence(originalIdentity);
                componentDefinition.addSequence(newIdentity);
            }
        }
    }
    for (ModuleDefinition moduleDefinition : getModuleDefinitions()) {
        updateReferences(moduleDefinition, originalIdentity, newIdentity);
        for (FunctionalComponent functionalComponent : moduleDefinition.getFunctionalComponents()) {
            if (functionalComponent.getDefinitionURI().equals(originalIdentity)) {
                functionalComponent.setDefinition(newIdentity);
                for (MapsTo mapsTo : functionalComponent.getMapsTos()) {
                    ComponentDefinition cd = getComponentDefinition(newIdentity);
                    if (cd != null) {
                        String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
                        URI newURI = URIcompliance.createCompliantURI(cd.getPersistentIdentity().toString(), displayId, cd.getVersion());
                        mapsTo.setRemote(newURI);
                    }
                }
            }
            updateReferences(functionalComponent, originalIdentity, newIdentity);
            for (MapsTo mapsTo : functionalComponent.getMapsTos()) {
                updateReferences(mapsTo, originalIdentity, newIdentity);
            }
        }
        for (Module module : moduleDefinition.getModules()) {
            if (module.getDefinitionURI().equals(originalIdentity)) {
                module.setDefinition(newIdentity);
                for (MapsTo mapsTo : module.getMapsTos()) {
                    ModuleDefinition md = getModuleDefinition(newIdentity);
                    if (md != null) {
                        String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
                        URI newURI = URIcompliance.createCompliantURI(md.getPersistentIdentity().toString(), displayId, md.getVersion());
                        mapsTo.setRemote(newURI);
                    }
                }
            }
            updateReferences(module, originalIdentity, newIdentity);
            for (MapsTo mapsTo : module.getMapsTos()) {
                updateReferences(mapsTo, originalIdentity, newIdentity);
            }
        }
        for (Interaction interaction : moduleDefinition.getInteractions()) {
            updateReferences(interaction, originalIdentity, newIdentity);
            for (Participation participation : interaction.getParticipations()) {
                updateReferences(participation, originalIdentity, newIdentity);
            }
        }
        for (URI modelURI : moduleDefinition.getModelURIs()) {
            if (modelURI.equals(originalIdentity)) {
                moduleDefinition.removeModel(originalIdentity);
                moduleDefinition.addModel(newIdentity);
            }
        }
    }
    for (Model model : getModels()) {
        updateReferences(model, originalIdentity, newIdentity);
    }
    for (Attachment attachment : getAttachments()) {
        updateReferences(attachment, originalIdentity, newIdentity);
    }
    for (Implementation implementation : getImplementations()) {
        if (implementation.isSetBuilt() && implementation.getBuiltURI().equals(originalIdentity)) {
            implementation.setBuilt(newIdentity);
        }
        updateReferences(implementation, originalIdentity, newIdentity);
    }
    for (Sequence sequence : getSequences()) {
        updateReferences(sequence, originalIdentity, newIdentity);
    }
    for (GenericTopLevel genericTopLevel : getGenericTopLevels()) {
        updateReferences(genericTopLevel, originalIdentity, newIdentity);
    }
    for (CombinatorialDerivation combinatorialDerivation : getCombinatorialDerivations()) {
        updateReferences(combinatorialDerivation, originalIdentity, newIdentity);
        if (combinatorialDerivation.getTemplateURI().equals(originalIdentity)) {
            combinatorialDerivation.setTemplate(newIdentity);
            ComponentDefinition cd = getComponentDefinition(newIdentity);
            if (cd != null) {
                for (VariableComponent variableComponent : combinatorialDerivation.getVariableComponents()) {
                    String displayId = URIcompliance.extractDisplayId(variableComponent.getVariableURI());
                    URI newURI = URIcompliance.createCompliantURI(cd.getPersistentIdentity().toString(), displayId, cd.getVersion());
                    variableComponent.setVariable(newURI);
                }
            }
        }
        for (VariableComponent variableComponent : combinatorialDerivation.getVariableComponents()) {
            updateReferences(variableComponent, originalIdentity, newIdentity);
        }
    }
    for (Activity activity : getActivities()) {
        updateReferences(activity, originalIdentity, newIdentity);
        for (Association association : activity.getAssociations()) {
            if (association.getAgentURI().equals(originalIdentity)) {
                association.setAgent(newIdentity);
            }
            if (association.isSetPlan() && association.getPlanURI().equals(originalIdentity)) {
                association.setPlan(newIdentity);
            }
            updateReferences(association, originalIdentity, newIdentity);
        }
        for (Usage usage : activity.getUsages()) {
            if (usage.getEntityURI().equals(originalIdentity)) {
                usage.setEntity(newIdentity);
            }
            updateReferences(usage, originalIdentity, newIdentity);
        }
    }
    for (Agent agent : getAgents()) {
        updateReferences(agent, originalIdentity, newIdentity);
    }
    for (Plan plan : getPlans()) {
        updateReferences(plan, originalIdentity, newIdentity);
    }
}
Also used : URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) URI(java.net.URI)

Example 22 with Activity

use of org.sbolstandard.core2.Activity in project libSBOLj by SynBioDex.

the class Activity method copy.

void copy(Activity activity) throws SBOLValidationException {
    ((TopLevel) this).copy((TopLevel) activity);
    if (activity.isSetStartedAtTime()) {
        this.setStartedAtTime(activity.getStartedAtTime());
    }
    if (activity.isSetEndedAtTime()) {
        this.setEndedAtTime(activity.getEndedAtTime());
    }
    for (Association association : activity.getAssociations()) {
        String displayId = URIcompliance.findDisplayId(association);
        Association newAssociation = this.createAssociation(displayId, association.getAgentURI());
        newAssociation.copy(association);
    }
    for (Usage usage : activity.getUsages()) {
        String displayId = URIcompliance.findDisplayId(usage);
        Usage newUsage = this.createUsage(displayId, usage.getEntityURI());
        newUsage.copy(usage);
    }
    for (URI wasInformedBy : activity.getWasInformedByURIs()) {
        this.addWasInformedBy(URI.create(wasInformedBy.toString()));
    }
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 23 with Activity

use of org.sbolstandard.core2.Activity in project libSBOLj by SynBioDex.

the class Provenance_SpecifyBuildOperations method specifyCutOperation.

/**
 * specifies to perform a cut operation in order to linearize a vector using a restriction enzyme
 *
 * @throws Exception
 */
public static void specifyCutOperation() throws Exception {
    // instantiate a document
    SBOLDocument document = new SBOLDocument();
    document.setDefaultURIprefix(BUILD_PREFIX);
    ComponentDefinition vector = document.createComponentDefinition("vector", VECTOR_PLASMID);
    vector.setName("vector");
    ComponentDefinition enzyme = document.createComponentDefinition("restriction_enzyme", RESTRICTION_ENZYME);
    enzyme.setName("restriction_enzyme");
    // Create the generic top level entity for the cut operation
    Activity activity = document.createActivity("cut_" + vector.getName() + "_with_" + enzyme.getName());
    activity.setName("cut(" + vector.getName() + ", " + enzyme.getName() + ")");
    // Create the qualifiedUsage annotation to describe the inputs of the cut operation
    activity.createUsage("vector", vector.getIdentity()).addRole(VECTOR_PLASMID);
    activity.createUsage("enzyme", enzyme.getIdentity()).addRole(RESTRICTION_ENZYME);
    // the result of the cut operation
    ComponentDefinition linearized_vector = document.createComponentDefinition("linearized_vector", LINEAR_DOUBLE_STRANDED_DNA);
    linearized_vector.setName("linearized_vector");
    linearized_vector.addWasGeneratedBy(activity.getIdentity());
    // serialize the document to a file
    SBOLWriter.write(document, System.out);
}
Also used : SBOLDocument(org.sbolstandard.core2.SBOLDocument) Activity(org.sbolstandard.core2.Activity) ComponentDefinition(org.sbolstandard.core2.ComponentDefinition)

Aggregations

Activity (org.eclipse.bpmn2.Activity)9 CallActivity (org.eclipse.bpmn2.CallActivity)9 Entry (java.util.Map.Entry)7 CompensateEventDefinition (org.eclipse.bpmn2.CompensateEventDefinition)7 ConditionalEventDefinition (org.eclipse.bpmn2.ConditionalEventDefinition)7 ErrorEventDefinition (org.eclipse.bpmn2.ErrorEventDefinition)7 EscalationEventDefinition (org.eclipse.bpmn2.EscalationEventDefinition)7 EventDefinition (org.eclipse.bpmn2.EventDefinition)7 FlowElement (org.eclipse.bpmn2.FlowElement)7 MessageEventDefinition (org.eclipse.bpmn2.MessageEventDefinition)7 RootElement (org.eclipse.bpmn2.RootElement)7 SignalEventDefinition (org.eclipse.bpmn2.SignalEventDefinition)7 TimerEventDefinition (org.eclipse.bpmn2.TimerEventDefinition)7 SimpleFeatureMapEntry (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.SimpleFeatureMapEntry)7 FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)7 Escalation (org.eclipse.bpmn2.Escalation)6 FlowElementsContainer (org.eclipse.bpmn2.FlowElementsContainer)6 Signal (org.eclipse.bpmn2.Signal)6 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5