use of org.sbolstandard.core2.SBOLValidationException 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;
}
use of org.sbolstandard.core2.SBOLValidationException in project libSBOLj by SynBioDex.
the class Module method createMapsTo.
/**
* Creates a child mapsTo for this module with the given arguments, and then adds it to its 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 module'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)} with the given mapsTo's display ID, its refinement type,
* and the created compliant local and remote functional components' URIs.
* <p>
* This method calls {@link ModuleDefinition#createFunctionalComponent(String, AccessType, String, String, DirectionType)}
* to automatically create a local functional component with the given display ID of referenced local component definition,
* {@link AccessType#PUBLIC}, an empty version string, and {@link DirectionType#INOUT}, 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 in the associated SBOLDocument instance,
* i.e., {@link SBOLDocument#isCreateDefaults} returns {@code true};</li>
* <li>if this module's parent ModuleDefinition instance exists; and</li>
* <li>if this module's parent ModuleDefinition instance does not already have a functional component
* with the created compliant local URI.</li>
* </ul>
* This automatically created created functional component has the same display ID as its referenced component definition.
*
* @param displayId the display ID of the mapsTo to be created
* @param refinement the relationship between the local and remote 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 condition is satisfied:
* <ul>
* <li>if either of the following SBOL validation rules was violated: 10204, 10206;</li>
* <li>an SBOL validation exception occurred in {@link ModuleDefinition#createFunctionalComponent(String, AccessType, String, String, DirectionType)}; or</li>
* <li>an SBOL validation exception 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);
}
use of org.sbolstandard.core2.SBOLValidationException in project libSBOLj by SynBioDex.
the class ModuleDefinition 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 one 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)},</li>
* <li>{@link #setIdentity(URI)},</li>
* <li>{@link FunctionalComponent#setDisplayId(String)}</li>
* <li>{@link FunctionalComponent#updateCompliantURI(String, String, String)},</li>
* <li>{@link #addFunctionalComponent(FunctionalComponent)},</li>
* <li>{@link Module#setDisplayId(String)}</li>
* <li>{@link Module#updateCompliantURI(String, String, String)},</li>
* <li>{@link #addModule(Module)},</li>
* <li>{@link Interaction#setDisplayId(String)},</li>
* <li>{@link Interaction#updateCompliantURI(String, String, String)}, or</li>
* <li>{@link #addInteraction(Interaction)}.</li>
* </ul>
*/
@Override
ModuleDefinition copy(String URIprefix, String displayId, String version) throws SBOLValidationException {
ModuleDefinition 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 (FunctionalComponent component : cloned.getFunctionalComponents()) {
if (!component.isSetDisplayId())
component.setDisplayId("functionalComponent" + ++count);
component.updateCompliantURI(cloned.getPersistentIdentity().toString(), component.getDisplayId(), version);
cloned.removeChildSafely(component, cloned.functionalComponents);
cloned.addFunctionalComponent(component);
}
count = 0;
for (Module module : cloned.getModules()) {
if (!module.isSetDisplayId())
module.setDisplayId("module" + ++count);
module.updateCompliantURI(cloned.getPersistentIdentity().toString(), module.getDisplayId(), version);
cloned.removeChildSafely(module, cloned.modules);
cloned.addModule(module);
}
count = 0;
for (Interaction interaction : cloned.getInteractions()) {
if (!interaction.isSetDisplayId())
interaction.setDisplayId("interaction" + ++count);
interaction.updateCompliantURI(cloned.getPersistentIdentity().toString(), interaction.getDisplayId(), version);
cloned.removeChildSafely(interaction, cloned.interactions);
cloned.addInteraction(interaction);
}
return cloned;
}
use of org.sbolstandard.core2.SBOLValidationException in project libSBOLj by SynBioDex.
the class ModuleDefinition method copy.
void copy(ModuleDefinition moduleDefinition) throws SBOLValidationException {
((TopLevel) this).copy((TopLevel) moduleDefinition);
for (URI role : moduleDefinition.getRoles()) {
this.addRole(role);
}
for (FunctionalComponent component : moduleDefinition.getFunctionalComponents()) {
String displayId = URIcompliance.findDisplayId(component);
FunctionalComponent newComponent = this.createFunctionalComponent(displayId, component.getAccess(), component.getDefinitionURI(), component.getDirection());
newComponent.copy(component);
}
for (Module subModule : moduleDefinition.getModules()) {
String displayId = URIcompliance.findDisplayId(subModule);
Module newModule = this.createModule(displayId, subModule.getDefinitionURI());
newModule.copy(subModule);
}
for (Interaction interaction : moduleDefinition.getInteractions()) {
String displayId = URIcompliance.findDisplayId(interaction);
Interaction newInteraction = this.createInteraction(displayId, interaction.getTypes());
newInteraction.copy(interaction);
}
this.setModels(moduleDefinition.getModelURIs());
}
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 display ID of the interaction to be created
* @param type the type to be added to the interaction to be created
* @return the created interaction
* @throws SBOLValidationException if any of the following SBOL validation rules was violated:
* 10201, 10202, 10204, 10206, 11902, 12003.
*/
public Interaction createInteraction(String displayId, URI type) throws SBOLValidationException {
String URIprefix = this.getPersistentIdentity().toString();
String version = this.getVersion();
URI newInteractionURI = createCompliantURI(URIprefix, displayId, version);
HashSet<URI> types = new HashSet<URI>();
types.add(type);
Interaction i = createInteraction(newInteractionURI, types);
i.setPersistentIdentity(createCompliantURI(URIprefix, displayId, ""));
i.setDisplayId(displayId);
i.setVersion(version);
return i;
}
Aggregations