Search in sources :

Example 81 with SBOLValidationException

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

the class Attachment method copy.

/**
 * @throws SBOLValidationException
 *             if an SBOL validation rule violation occurred in any of the
 *             following constructors or 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)},</li>
 *             <li>{@link #setIdentity(URI)}</li>
 *             </ul>
 */
@Override
Attachment copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    Attachment 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 82 with SBOLValidationException

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

the class Collection 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
Collection copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    Collection 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 83 with SBOLValidationException

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

the class CombinatorialDerivation method addVariableComponent.

/**
 * Adds the given variable component to the list of variable components.
 *
 * @param variableComponent
 */
private void addVariableComponent(VariableComponent variableComponent) throws SBOLValidationException {
    variableComponent.setSBOLDocument(this.getSBOLDocument());
    variableComponent.setCombinatorialDerivation(this);
    ComponentDefinition template = this.getTemplate();
    if (template != null) {
        if (template.getComponent(variableComponent.getVariableURI()) == null) {
            throw new SBOLValidationException("sbol-13005", this);
        }
    }
    for (URI cdURI : variableComponent.getVariantDerivationURIs()) {
        if (this.getSBOLDocument() != null && this.getSBOLDocument().isComplete()) {
            CombinatorialDerivation cd = this.getSBOLDocument().getCombinatorialDerivation(cdURI);
            if (cd != null && this.getIdentity().equals(cd.getIdentity())) {
                throw new SBOLValidationException("sbol-13015", variableComponent);
            }
            Set<URI> visited = new HashSet<>();
            visited.add(this.getIdentity());
            try {
                SBOLValidate.checkCombinatorialDerivationCycle(this.getSBOLDocument(), cd, visited);
            } catch (SBOLValidationException e) {
                throw new SBOLValidationException("sbol-13015", variableComponent);
            }
        }
    }
    addChildSafely(variableComponent, variableComponents, "variableComponent");
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI) HashSet(java.util.HashSet)

Example 84 with SBOLValidationException

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

the class CombinatorialDerivation method copy.

/**
 * @throws SBOLValidationException
 *             if an SBOL validation rule violation occurred in any of the
 *             following constructors or 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)},</li>
 *             <li>{@link #setIdentity(URI)}</li>
 *             <li>{@link VariableComponent#setDisplayId(String)}</li>
 *             <li>{@link VariableComponent#updateCompliantURI(String, String, String)},</li>
 *             <li>{@link #addVariableComponent(VariableComponent)},</li>
 *             </ul>
 */
@Override
CombinatorialDerivation copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    CombinatorialDerivation 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);
    int count = 0;
    for (VariableComponent variableComponent : cloned.getVariableComponents()) {
        if (!variableComponent.isSetDisplayId())
            variableComponent.setDisplayId("variableComponent" + ++count);
        variableComponent.updateCompliantURI(cloned.getPersistentIdentity().toString(), variableComponent.getDisplayId(), version);
        cloned.removeChildSafely(variableComponent, cloned.variableComponents);
        cloned.addVariableComponent(variableComponent);
    }
    return cloned;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 85 with SBOLValidationException

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

the class FunctionalComponent method createMapsTo.

/**
 * Creates a child MapsTo instance for this module with the given arguments, and then adds to this module's list of mapsTos.
 * <p>
 * This method creates compliant local and remote URIs first.
 * The compliant local URI is created with this module's persistent identity URI, followed by
 * the given local component's display ID, followed by this module's version.
 * The compliant remote URI is created following the same pattern.
 * It then calls {@link #createMapsTo(String, RefinementType, URI, URI)} to create
 * a MapsTo instance.
 * <p>
 * This method automatically creates a local functional component if all of the following conditions are satisfied:
 * <ul>
 * <li>the associated SBOLDocument instance for this module is not {@code null};</li>
 * <li>if default functional components should be automatically created when not present for the associated SBOLDocument instance,
 * i.e., {@link SBOLDocument#isCreateDefaults} returns {@code true};</li>
 * <li>if this module's parent module definition exists; and</li>
 * <li>if this module's parent module definition does not already have a functional component
 * with the created compliant local functional component URI.</li>
 * </ul>
 * @param displayId the display ID of the mapsTo to be created
 * @param refinement the relationship between the local and remote functional components
 * @param localId the display ID of the local functional component
 * @param remoteId the display ID of the remote functional component
 * @return the created mapsTo
 * @throws SBOLValidationException if any of the following conditions is satisfied:
 * <ul>
 * <li>if either of the following SBOL validation rules was violated: 10204, 10206;</li>
 * <li>an SBOL validation rule violation occurred in {@link ModuleDefinition#createFunctionalComponent(String, AccessType, String, String, DirectionType)}; or</li>
 * <li>an SBOL validation rule violation occurred in {@link #createMapsTo(String, RefinementType, URI, URI)}.</li>
 * </ul>
 */
public MapsTo createMapsTo(String displayId, RefinementType refinement, String localId, String remoteId) throws SBOLValidationException {
    URI localURI = URIcompliance.createCompliantURI(moduleDefinition.getPersistentIdentity().toString(), localId, moduleDefinition.getVersion());
    if (this.getSBOLDocument() != null && this.getSBOLDocument().isCreateDefaults() && moduleDefinition != null && moduleDefinition.getFunctionalComponent(localURI) == null) {
        moduleDefinition.createFunctionalComponent(localId, AccessType.PUBLIC, localId, "", DirectionType.INOUT);
    }
    URI remoteURI = URIcompliance.createCompliantURI(getDefinition().getPersistentIdentity().toString(), remoteId, getDefinition().getVersion());
    return createMapsTo(displayId, refinement, localURI, remoteURI);
}
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