Search in sources :

Example 76 with SBOLValidationException

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

the class ModuleDefinition method createInteraction.

/**
 * Creates a child interaction for this module definition with
 * the given arguments, and then adds to this module definition's list of interactions.
 * <p>
 * This method first creates a compliant interaction URI. It starts with this module definition's
 * persistent identity, followed by the given display ID of the interaction to be created, and
 * ends with the version of this module definition.
 *
 * @param displayId The displayId identifier for this interaction
 * @param types The set of types to be added to the Interaction
 * @return the created Interaction instance
 * @throws SBOLValidationException if any of the following SBOL validation rules was violated:
 * 10201, 10202, 10204, 10206, 11902, 12003.
 */
public Interaction createInteraction(String displayId, Set<URI> types) throws SBOLValidationException {
    String URIprefix = this.getPersistentIdentity().toString();
    String version = this.getVersion();
    URI interactionURI = createCompliantURI(URIprefix, displayId, version);
    Interaction i = createInteraction(interactionURI, types);
    i.setPersistentIdentity(createCompliantURI(URIprefix, displayId, ""));
    i.setDisplayId(displayId);
    i.setVersion(version);
    return i;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 77 with SBOLValidationException

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

the class Plan method copy.

/* (non-Javadoc)
	 * @see org.sbolstandard.core2.abstract_classes.TopLevel#copy(java.lang.String, java.lang.String, java.lang.String)
	 */
/**
 * @throws SBOLValidationException if an SBOL validation rule violation occurred in
 * any of the following methods:
 * <ul>
 * <li>{@link #deepCopy()},</li>
 * <li>{@link URIcompliance#createCompliantURI(String, String, String)},</li>
 * <li>{@link #setDisplayId(String)},</li>
 * <li>{@link #setVersion(String)},</li>
 * <li>{@link #setWasDerivedFrom(URI)}, or</li>
 * <li>{@link #setIdentity(URI)}.</li>
 * </ul>
 */
@Override
Plan copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    Plan cloned = this.deepCopy();
    cloned.setPersistentIdentity(createCompliantURI(URIprefix, displayId, ""));
    cloned.setDisplayId(displayId);
    cloned.setVersion(version);
    URI newIdentity = createCompliantURI(URIprefix, displayId, version);
    if (!this.getIdentity().equals(newIdentity)) {
        cloned.addWasDerivedFrom(this.getIdentity());
    } else {
        cloned.setWasDerivedFroms(this.getWasDerivedFroms());
    }
    cloned.setIdentity(newIdentity);
    return cloned;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 78 with SBOLValidationException

use of org.sbolstandard.core2.SBOLValidationException 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 79 with SBOLValidationException

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

the class Activity method setWasInformedBys.

/**
 * @param wasInformedBys the wasInformedBys to set
 * @throws SBOLValidationException if an SBOL validation rule violation occurred in {@link #addWasInformedBy(URI)}
 */
public void setWasInformedBys(Set<URI> wasInformedBys) throws SBOLValidationException {
    clearWasInformedBys();
    if (wasInformedBys == null)
        return;
    for (URI wasInformedBy : wasInformedBys) {
        addWasInformedBy(wasInformedBy);
    }
    this.wasInformedBys = wasInformedBys;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 80 with SBOLValidationException

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

the class Association method copy.

void copy(Association association) throws SBOLValidationException {
    ((Identified) this).copy((Identified) association);
    this.setPlan(association.getPlanURI());
    for (URI role : association.getRoles()) {
        this.addRole(URI.create(role.toString()));
    }
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Aggregations

URI (java.net.URI)81 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)75 QName (javax.xml.namespace.QName)36 HashSet (java.util.HashSet)35 ArrayList (java.util.ArrayList)31 Literal (org.sbolstandard.core.datatree.Literal)30 StringifyQName (org.sbolstandard.core.io.json.StringifyQName)30 IdentifiableDocument (org.sbolstandard.core.datatree.IdentifiableDocument)17 Test (org.junit.Test)16 NestedDocument (org.sbolstandard.core.datatree.NestedDocument)13 ComponentDefinition (org.sbolstandard.core2.ComponentDefinition)9 SBOLDocument (org.sbolstandard.core2.SBOLDocument)9 ModuleDefinition (org.sbolstandard.core2.ModuleDefinition)6 Sequence (org.sbolstandard.core2.Sequence)5 Interaction (org.sbolstandard.core2.Interaction)4 GenericTopLevel (org.sbolstandard.core2.GenericTopLevel)3 MapsTo (org.sbolstandard.core2.MapsTo)3 Set (java.util.Set)2 Annotation (org.sbolstandard.core2.Annotation)2 GenericLocation (org.sbolstandard.core2.GenericLocation)2