/** * Returns the {@link SBase} with the given metaid in this * {@link SBMLDocument} or null * if no such {@link SBase} is found. * * <p>This method make use of {@link HashMap} so it is more efficient * to search for metaid than anywhere else down in the SBML hierarchy.</p> * * @param metaid * - the metaid of {@link SBase} to find * @return the {@link SBase} with the given metaid or null * @see #findSBase(String) */ @Override public SBase getElementByMetaId(String metaid) { return findSBase(metaid); }
/** * This updates the metaid of an SBase. * * @param doc * @param arraysPlugin * @param sbase * @param index */ private static void updateSBase(SBMLDocument doc, ArraysSBasePlugin arraysPlugin, SBase sbase, int index) { //TODO check if unique if (sbase.isSetMetaId()) { String metaId = sbase.getMetaId(); String appendId = "_" + index; while(doc.findSBase(metaId + appendId) != null) { appendId = "_" + appendId; } sbase.setMetaId(metaId+appendId); } }
/** * Gets the actual SBase instance referred by the {@code idRef} or {@code metaIdRef}, returns null * if nothing is found. * * @return the actual SBase instance referred by the {@code idRef} or {@code metaIdRef}, returns null * if nothing is found. */ public SBase getSBaseInstance() { SBase instance = null; if (isSetIdRef()) { Model model = getModel(); if (model != null) { instance = model.findNamedSBase(idRef); } } else if (isSetMetaIdRef()) { SBMLDocument doc = getSBMLDocument(); if (doc != null) { instance = doc.findSBase(metaIdRef); } } return instance; }
private void handlePorts(CompModelPlugin compModelPlugin, ListOf<Port> listOfPorts){ for (Port port : listOfPorts){ // Port object instance defines a port for a component in a model. // A port could be created by using the metaIdRef attribute // to identify the object for which a given Port instance is the port; // The question “what does this port correspond to?” would be answered by the value of the metaIdRef attribute. String idRef = port.getIdRef(); String metaIDRef = port.getMetaIdRef(); if(metaIDRef != null && !metaIDRef.isEmpty()){ SBase parentOfPort = compModelPlugin.getParent(); SBase sBase = compModelPlugin.getSBMLDocument().findSBase(idRef); addSBaseToModel(parentOfPort.getModel(), sBase); } else if(idRef != null && !idRef.isEmpty()){ SBase parentOfPort = compModelPlugin.getParent(); for (ModelDefinition modelDefinition : this.modelDefinitionListOf) { SBase sBase = modelDefinition.findNamedSBase(idRef); if(sBase != null){ addSBaseToModel(parentOfPort.getModel(), sBase); break; } } } // If a port references an object from a namespace that is not understood by the interpreter, // the interpreter must consider the port to be not understood as well. // If an interpreter cannot tell whether the referenced object does not // exist or if exists in an unparsed XML or SBML namespace, it may choose to display a warning to the user. } listOfPorts.removeFromParent(); }