Search in sources :

Example 1 with org.sbolstandard.core2

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

the class Activity 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
Activity copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    Activity 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 2 with org.sbolstandard.core2

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

the class Agent 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
Agent copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    Agent 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 3 with org.sbolstandard.core2

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

the class ComponentDefinition 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 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 Component#setDisplayId(String)}</li>
 * <li>{@link Component#updateCompliantURI(String, String, String)},</li>
 * <li>{@link #addComponent(Component)},</li>
 * <li>{@link SequenceConstraint#setDisplayId(String)}</li>
 * <li>{@link SequenceConstraint#updateCompliantURI(String, String, String)},</li>
 * <li>{@link #addSequenceConstraint(SequenceConstraint)},</li>
 * <li>{@link SequenceAnnotation#setDisplayId(String)}</li>
 * <li>{@link SequenceAnnotation#updateCompliantURI(String, String, String)}, or</li>
 * <li>{@link #addSequenceAnnotation(SequenceAnnotation)},</li>
 * </ul>
 */
@Override
ComponentDefinition copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    ComponentDefinition 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 (Component component : cloned.getComponents()) {
        if (!component.isSetDisplayId())
            component.setDisplayId("component" + ++count);
        component.updateCompliantURI(cloned.getPersistentIdentity().toString(), component.getDisplayId(), version);
        cloned.removeChildSafely(component, cloned.components);
        cloned.addComponent(component);
    }
    count = 0;
    for (SequenceConstraint sequenceConstraint : cloned.getSequenceConstraints()) {
        if (!sequenceConstraint.isSetDisplayId())
            sequenceConstraint.setDisplayId("sequenceConstraint" + ++count);
        sequenceConstraint.updateCompliantURI(cloned.getPersistentIdentity().toString(), sequenceConstraint.getDisplayId(), version);
        cloned.removeChildSafely(sequenceConstraint, cloned.sequenceConstraints);
        cloned.addSequenceConstraint(sequenceConstraint);
    }
    count = 0;
    for (SequenceAnnotation sequenceAnnotation : cloned.getSequenceAnnotations()) {
        if (!sequenceAnnotation.isSetDisplayId())
            sequenceAnnotation.setDisplayId("sequenceAnnotation" + ++count);
        sequenceAnnotation.updateCompliantURI(cloned.getPersistentIdentity().toString(), sequenceAnnotation.getDisplayId(), version);
        cloned.removeChildSafely(sequenceAnnotation, cloned.sequenceAnnotations);
        cloned.addSequenceAnnotation(sequenceAnnotation);
    }
    return cloned;
}
Also used : URI(java.net.URI) URIcompliance.createCompliantURI(org.sbolstandard.core2.URIcompliance.createCompliantURI)

Example 4 with org.sbolstandard.core2

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

the class Model 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
Model copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    Model 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 5 with org.sbolstandard.core2

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

the class GenericTopLevel method copy.

// /**
// * @param newDisplayId
// * @return
// */
// public GenericTopLevel copy(String newDisplayId) {
// GenericTopLevel cloned = (GenericTopLevel) this.deepCopy();
// cloned.updateCompliantURI(newDisplayId);
// return cloned;
// }
// 
// /**
// * Get a deep copy of the object first, and set its major version to the specified value, and minor version to "0".
// * @param newVersion
// * @return the copied {@link ComponentDefinition} instance with the specified major version.
// */
// public GenericTopLevel newVersion(String newVersion) {
// GenericTopLevel cloned = (GenericTopLevel) super.newVersion(newVersion);
// cloned.updateVersion(newVersion);
// return cloned;
// }
/* (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
GenericTopLevel copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
    GenericTopLevel 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)

Aggregations

URI (java.net.URI)8 URIcompliance.createCompliantURI (org.sbolstandard.core2.URIcompliance.createCompliantURI)8 ArrayList (java.util.ArrayList)1 QName (javax.xml.namespace.QName)1 org.sbolstandard.core2 (org.sbolstandard.core2)1