use of org.sbolstandard.core2.ModuleDefinition in project libSBOLj by SynBioDex.
the class SBOLReader method parseModule.
/**
* @param module
* @param nested
* @return
* @throws SBOLValidationException if either of the following conditions is satisfied:
* <ul>
* <li>any of the following SBOL validation rules was violated:
* 10203, 10204, 10206, 10208, 10212, 10213, 11604, 11702; or
*</li>
* <li>an SBOL validation rule violation occurred in the following constructor or methods:
* <ul>
* <li>{@link #parseMapsTo(NestedDocument, boolean)},</li>
* <li>{@link Module#Module(URI, URI)},</li>
* <li>{@link Module#setDisplayId(String)},</li>
* <li>{@link Module#setVersion(String)},</li>
* <li>{@link Module#setWasDerivedFrom(URI)},</li>
* <li>{@link Identified#setAnnotations(List)}, or</li>
* <li>{@link Module#setMapsTos(Set)}.</li>
* </ul>
* </li>
* </ul>
*/
@SuppressWarnings("unchecked")
private static Module parseModule(SBOLDocument SBOLDoc, NestedDocument<QName> module, Map<URI, NestedDocument<QName>> nested) throws SBOLValidationException {
// URIcompliance.extractDisplayId(module.getIdentity());
String displayId = null;
String name = null;
String description = null;
// URI.create(URIcompliance.extractPersistentId(module.getIdentity()));
URI persistentIdentity = null;
String version = null;
URI definitionURI = null;
Set<URI> wasDerivedFroms = new HashSet<>();
Set<URI> wasGeneratedBys = new HashSet<>();
Set<MapsTo> mappings = new HashSet<>();
List<Annotation> annotations = new ArrayList<>();
for (NamedProperty<QName> namedProperty : module.getProperties()) {
if (namedProperty.getName().equals(Sbol2Terms.Identified.persistentIdentity)) {
if (!(namedProperty.getValue() instanceof Literal) || persistentIdentity != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
throw new SBOLValidationException("sbol-10203", module.getIdentity());
}
persistentIdentity = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
} else if (namedProperty.getName().equals(Sbol2Terms.Identified.version)) {
if (!(namedProperty.getValue() instanceof Literal) || version != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
throw new SBOLValidationException("sbol-10206", module.getIdentity());
}
version = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
} else if (namedProperty.getName().equals(Sbol2Terms.Identified.displayId)) {
if (!(namedProperty.getValue() instanceof Literal) || displayId != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
throw new SBOLValidationException("sbol-10204", module.getIdentity());
}
displayId = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
} else if (namedProperty.getName().equals(Sbol2Terms.Module.hasMapsTo)) {
if (namedProperty.getValue() instanceof NestedDocument) {
NestedDocument<QName> nestedDocument = ((NestedDocument<QName>) namedProperty.getValue());
if (nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.MapsTo.MapsTo)) {
throw new SBOLValidationException("sbol-11706", module.getIdentity());
}
mappings.add(parseMapsTo(((NestedDocument<QName>) namedProperty.getValue()), false));
} else {
URI uri = (URI) ((Literal<QName>) namedProperty.getValue()).getValue();
NestedDocument<QName> nestedDocument = nested.get(uri);
if (nestedDocument == null || nestedDocument.getType() == null || !nestedDocument.getType().equals(Sbol2Terms.MapsTo.MapsTo)) {
throw new SBOLValidationException("sbol-11706", module.getIdentity());
}
mappings.add(parseMapsTo(nested.get(uri), false));
}
} else if (namedProperty.getName().equals(Sbol2Terms.Module.hasMapping)) {
System.err.println("Warning: tag should be sbol:mapTo, not sbol:mapping.");
if (namedProperty.getValue() instanceof NestedDocument) {
mappings.add(parseMapsTo(((NestedDocument<QName>) namedProperty.getValue()), true));
} else {
URI uri = (URI) ((Literal<QName>) namedProperty.getValue()).getValue();
mappings.add(parseMapsTo(nested.get(uri), true));
}
} else if (namedProperty.getName().equals(Sbol2Terms.Module.hasDefinition)) {
if (definitionURI != null) {
throw new SBOLValidationException("sbol-11702", module.getIdentity());
}
if (namedProperty.getValue() instanceof Literal) {
if (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI)) {
throw new SBOLValidationException("sbol-11702", module.getIdentity());
}
definitionURI = URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString());
} else if (namedProperty.getValue() instanceof IdentifiableDocument) {
if (((IdentifiableDocument<QName>) namedProperty).getType().equals(Sbol2Terms.ModuleDefinition.ModuleDefinition)) {
ModuleDefinition moduleDefinition = parseModuleDefinition(SBOLDoc, (IdentifiableDocument<QName>) namedProperty.getValue(), nested);
definitionURI = moduleDefinition.getIdentity();
} else {
throw new SBOLValidationException("sbol-11702", module.getIdentity());
}
} else {
throw new SBOLValidationException("sbol-11702", module.getIdentity());
}
} else if (namedProperty.getName().equals(Sbol2Terms.Identified.title)) {
if (!(namedProperty.getValue() instanceof Literal) || name != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
throw new SBOLValidationException("sbol-10212", module.getIdentity());
}
name = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
} else if (namedProperty.getName().equals(Sbol2Terms.Identified.description)) {
if (!(namedProperty.getValue() instanceof Literal) || description != null || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof String))) {
throw new SBOLValidationException("sbol-10213", module.getIdentity());
}
description = ((Literal<QName>) namedProperty.getValue()).getValue().toString();
} else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasDerivedFrom)) {
if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
throw new SBOLValidationException("sbol-10208", module.getIdentity());
}
wasDerivedFroms.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
} else if (namedProperty.getName().equals(Sbol2Terms.Identified.wasGeneratedBy)) {
if (!(namedProperty.getValue() instanceof Literal) || (!(((Literal<QName>) namedProperty.getValue()).getValue() instanceof URI))) {
throw new SBOLValidationException("sbol-10221", module.getIdentity());
}
wasGeneratedBys.add(URI.create(((Literal<QName>) namedProperty.getValue()).getValue().toString()));
} else {
annotations.add(new Annotation(namedProperty));
}
}
Module submodule = new Module(module.getIdentity(), definitionURI);
if (persistentIdentity != null)
submodule.setPersistentIdentity(persistentIdentity);
if (version != null)
submodule.setVersion(version);
if (displayId != null)
submodule.setDisplayId(displayId);
if (!mappings.isEmpty())
submodule.setMapsTos(mappings);
if (name != null)
submodule.setName(name);
if (description != null)
submodule.setDescription(description);
submodule.setWasDerivedFroms(wasDerivedFroms);
submodule.setWasGeneratedBys(wasGeneratedBys);
if (!annotations.isEmpty())
submodule.setAnnotations(annotations);
return submodule;
}
use of org.sbolstandard.core2.ModuleDefinition in project libSBOLj by SynBioDex.
the class SBOLDocument method updateReferences.
// TODO: need to update persistentIdentities too
private void updateReferences(HashMap<URI, URI> uriMap) throws SBOLValidationException {
for (TopLevel topLevel : getTopLevels()) {
for (URI wasDerivedFrom : topLevel.getWasDerivedFroms()) {
if (uriMap.get(wasDerivedFrom) != null) {
topLevel.removeWasDerivedFrom(wasDerivedFrom);
topLevel.addWasDerivedFrom(uriMap.get(wasDerivedFrom));
}
}
for (URI wasGeneratedBy : topLevel.getWasGeneratedBys()) {
if (uriMap.get(wasGeneratedBy) != null) {
topLevel.removeWasGeneratedBy(wasGeneratedBy);
topLevel.addWasGeneratedBy(uriMap.get(wasGeneratedBy));
}
}
for (URI attachmentURI : topLevel.getAttachmentURIs()) {
if (uriMap.get(attachmentURI) != null) {
topLevel.removeAttachment(attachmentURI);
topLevel.addAttachment(uriMap.get(attachmentURI));
}
}
}
for (Collection collection : getCollections()) {
for (URI memberURI : collection.getMemberURIs()) {
if (uriMap.get(memberURI) != null) {
collection.removeMember(memberURI);
collection.addMember(uriMap.get(memberURI));
}
}
updateReferences(collection, uriMap);
}
for (ComponentDefinition componentDefinition : getComponentDefinitions()) {
updateReferences(componentDefinition, uriMap);
for (Component component : componentDefinition.getComponents()) {
if (uriMap.get(component.getDefinitionURI()) != null) {
component.setDefinition(uriMap.get(component.getDefinitionURI()));
for (MapsTo mapsTo : component.getMapsTos()) {
ComponentDefinition cd = getComponentDefinition(component.getDefinitionURI());
if (cd != null) {
String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
URI newURI = URIcompliance.createCompliantURI(cd.getPersistentIdentity().toString(), displayId, cd.getVersion());
mapsTo.setRemote(newURI);
}
}
}
updateReferences(component, uriMap);
for (MapsTo mapsTo : component.getMapsTos()) {
updateReferences(mapsTo, uriMap);
}
}
for (SequenceAnnotation sa : componentDefinition.getSequenceAnnotations()) {
for (Location loc : sa.getLocations()) {
updateReferences(loc, uriMap);
}
updateReferences(sa, uriMap);
}
for (SequenceConstraint sc : componentDefinition.getSequenceConstraints()) {
updateReferences(sc, uriMap);
}
for (URI sequenceURI : componentDefinition.getSequenceURIs()) {
if (uriMap.get(sequenceURI) != null) {
componentDefinition.removeSequence(sequenceURI);
componentDefinition.addSequence(uriMap.get(sequenceURI));
}
}
}
for (ModuleDefinition moduleDefinition : getModuleDefinitions()) {
updateReferences(moduleDefinition, uriMap);
for (FunctionalComponent functionalComponent : moduleDefinition.getFunctionalComponents()) {
if (uriMap.get(functionalComponent.getDefinitionURI()) != null) {
functionalComponent.setDefinition(uriMap.get(functionalComponent.getDefinitionURI()));
for (MapsTo mapsTo : functionalComponent.getMapsTos()) {
ComponentDefinition cd = getComponentDefinition(functionalComponent.getDefinitionURI());
if (cd != null) {
String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
URI newURI = URIcompliance.createCompliantURI(cd.getPersistentIdentity().toString(), displayId, cd.getVersion());
mapsTo.setRemote(newURI);
}
}
}
updateReferences(functionalComponent, uriMap);
for (MapsTo mapsTo : functionalComponent.getMapsTos()) {
updateReferences(mapsTo, uriMap);
}
}
for (Module module : moduleDefinition.getModules()) {
if (uriMap.get(module.getDefinitionURI()) != null) {
module.setDefinition(uriMap.get(module.getDefinitionURI()));
for (MapsTo mapsTo : module.getMapsTos()) {
ModuleDefinition md = getModuleDefinition(module.getDefinitionURI());
if (md != null) {
String displayId = URIcompliance.extractDisplayId(mapsTo.getRemoteURI());
URI newURI = URIcompliance.createCompliantURI(md.getPersistentIdentity().toString(), displayId, md.getVersion());
mapsTo.setRemote(newURI);
}
}
}
updateReferences(module, uriMap);
for (MapsTo mapsTo : module.getMapsTos()) {
updateReferences(mapsTo, uriMap);
}
}
for (Interaction interaction : moduleDefinition.getInteractions()) {
updateReferences(interaction, uriMap);
for (Participation participation : interaction.getParticipations()) {
updateReferences(participation, uriMap);
}
}
for (URI modelURI : moduleDefinition.getModelURIs()) {
if (uriMap.get(modelURI) != null) {
moduleDefinition.removeModel(modelURI);
moduleDefinition.addModel(uriMap.get(modelURI));
}
}
}
for (Model model : getModels()) {
updateReferences(model, uriMap);
}
for (Sequence sequence : getSequences()) {
updateReferences(sequence, uriMap);
}
for (Attachment attachment : getAttachments()) {
updateReferences(attachment, uriMap);
}
for (Implementation implementation : getImplementations()) {
if (implementation.isSetBuilt()) {
URI built = implementation.getBuiltURI();
if (uriMap.get(built) != null) {
implementation.setBuilt(uriMap.get(built));
}
}
updateReferences(implementation, uriMap);
}
for (GenericTopLevel genericTopLevel : getGenericTopLevels()) {
updateReferences(genericTopLevel, uriMap);
}
for (CombinatorialDerivation combinatorialDerivation : getCombinatorialDerivations()) {
updateReferences(combinatorialDerivation, uriMap);
if (uriMap.get(combinatorialDerivation.getTemplateURI()) != null) {
combinatorialDerivation.setTemplate(uriMap.get(combinatorialDerivation.getTemplateURI()));
ComponentDefinition cd = getComponentDefinition(combinatorialDerivation.getTemplateURI());
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, uriMap);
}
}
for (Activity activity : getActivities()) {
updateReferences(activity, uriMap);
for (Association association : activity.getAssociations()) {
if (uriMap.get(association.getAgentURI()) != null) {
association.setAgent(uriMap.get(association.getAgentURI()));
}
if (uriMap.get(association.getPlanURI()) != null) {
association.setPlan(uriMap.get(association.getPlanURI()));
}
updateReferences(association, uriMap);
}
for (Usage usage : activity.getUsages()) {
if (uriMap.get(usage.getEntityURI()) != null) {
usage.setEntity(uriMap.get(usage.getEntityURI()));
}
updateReferences(usage, uriMap);
}
}
for (Agent agent : getAgents()) {
updateReferences(agent, uriMap);
}
for (Plan plan : getPlans()) {
updateReferences(plan, uriMap);
}
}
use of org.sbolstandard.core2.ModuleDefinition in project libSBOLj by SynBioDex.
the class ModuleDefinition method flattenRecurse.
/**
* @return flattened ModuleDefinition
* @throws SBOLValidationException if either of the following condition is satisfied:
* <ul>
* <li>The following SBOL validation rule was violated: 10811; or</li>
*
* <li>if an SBOL validation rule violation occurred in any of the following methods:</li>
* <ul>
* <li>{@link #deepCopy()},</li>
* <li>{@link #flattenRecurse()},</li>
* <li>{@link FunctionalComponent#setDefinition(URI)},</li>
* <li>{@link FunctionalComponent#deepCopy()},</li>
* <li>{@link FunctionalComponent#updateCompliantURI(String, String, String)},</li>
* <li>{@link #addFunctionalComponent(FunctionalComponent)},</li>
* <li>{@link Participation#setParticipant(URI)},</li>
* <li>{@link #addInteraction(Interaction)}, or</li>
* <li>{@link Interaction#deepCopy()}.</li>
* </ul>
* </ul>
*/
private ModuleDefinition flattenRecurse() throws SBOLValidationException {
ModuleDefinition flatModuleDefinition = this.deepCopy();
for (Module module : this.getModules()) {
ModuleDefinition flatModule = module.getDefinition().flattenRecurse();
for (FunctionalComponent fc : flatModule.getFunctionalComponents()) {
boolean foundIt = false;
URI oldURI = fc.getIdentity();
URI newURI = null;
for (MapsTo mapsTo : module.getMapsTos()) {
if (mapsTo.getRemoteURI().equals(fc.getIdentity())) {
newURI = mapsTo.getLocalURI();
FunctionalComponent topFc = flatModuleDefinition.getFunctionalComponent(newURI);
if (mapsTo.getRefinement() == RefinementType.USEREMOTE) {
topFc.setDefinition(fc.getDefinitionURI());
} else if (mapsTo.getRefinement() == RefinementType.VERIFYIDENTICAL) {
if (!topFc.getDefinitionURI().equals(fc.getDefinitionURI())) {
// + "' are not identical.");
throw new SBOLValidationException("sbol-10811", mapsTo);
}
} else if (mapsTo.getRefinement() == RefinementType.MERGE) {
// TODO: merge?
}
foundIt = true;
break;
}
}
if (!foundIt) {
FunctionalComponent newFC = fc.deepCopy();
newFC.updateCompliantURI(this.getPersistentIdentity().toString(), module.getDisplayId() + "__" + fc.getDisplayId(), this.getVersion());
newURI = newFC.getIdentity();
flatModuleDefinition.addFunctionalComponent(newFC);
}
for (Interaction i : flatModule.getInteractions()) {
for (Participation p : i.getParticipations()) {
if (p.getParticipantURI().equals(oldURI)) {
p.setParticipant(newURI);
}
}
}
}
for (Interaction i : flatModule.getInteractions()) {
flatModuleDefinition.addInteraction(i.deepCopy());
}
}
flatModuleDefinition.clearModules();
return flatModuleDefinition;
}
use of org.sbolstandard.core2.ModuleDefinition 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);
}
}
use of org.sbolstandard.core2.ModuleDefinition 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);
}
Aggregations