/** * Removes the n-th {@link UnitDefinition} of the {@link Model}. * * @param n * @return the removed element. */ public UnitDefinition removeUnitDefinition(int n) { return getListOfUnitDefinitions().remove(n); }
/** * Adds an {@link UnitDefinition} instance to the * {@link #listOfUnitDefinitions} of this {@link Model}. * * @param unitDefinition * @return {@code true} if the {@link #listOfUnitDefinitions} was changed * as a result of this call. */ public boolean addUnitDefinition(UnitDefinition unitDefinition) { return getListOfUnitDefinitions().add(unitDefinition); }
/** * Gets the n<sup>th</sup> {@link UnitDefinition} object in this {@link Model} * . * * @param n the index of the element to return * @return the n<sup>th</sup> {@link UnitDefinition} of this {@link Model}. * Returns * {@code null} if there are no {@link UnitDefinition}s defined * or if the index n is too big or lower than zero. */ public UnitDefinition getUnitDefinition(int n) { return getListOfUnitDefinitions().get(n); }
/** * Returns the number of {@link Unit}s of this {@link Model}. * * @return the number of {@link Unit}s of this {@link Model}. */ public int getUnitCount() { int count = 0; if (isSetListOfUnitDefinitions()) { for (UnitDefinition ud : getListOfUnitDefinitions()) { count += ud.getUnitCount(); } } return count; }
/** * Searches the first {@link UnitDefinition} within this {@link Model}'s * {@link #listOfUnitDefinitions} that * is identical to the given {@link UnitDefinition}. If no element can be * found that satisfies the method * {@link UnitDefinition#areIdentical(UnitDefinition, UnitDefinition)}, * {@code null} will be returned. * * @param unitDefinition a {@link UnitDefinition} * @return A {@link UnitDefinition} object that is already part of this * {@link Model}'s {@link #listOfUnitDefinitions} and satisfies the * condition of * {@link UnitDefinition#areIdentical(UnitDefinition, UnitDefinition)} * in comparison to the given {@link UnitDefinition}, or * {@code null} if no such element can be found. */ public UnitDefinition findIdentical(UnitDefinition unitDefinition) { return getListOfUnitDefinitions().firstHit( new IdenticalUnitDefinitionFilter(unitDefinition)); }
@Override public boolean check(ValidationContext ctx, Model m) { if (m.isSetListOfUnitDefinitions() || m.isListOfUnitDefinitionEmpty()) { return new UnknownAttributeValidationFunction<TreeNodeWithChangeSupport>().check(ctx, m.getListOfUnitDefinitions()); } return true; } };
/** * Sets the areaUnitsID of this {@link Model} to the id of the * {@link UnitDefinition} 'areaUnits'. * * @param areaUnits */ public void setAreaUnits(UnitDefinition areaUnits) { if (!getListOfUnitDefinitions().contains(areaUnits)) { addUnitDefinition(areaUnits); } setAreaUnits(areaUnits != null ? areaUnits.getId() : null); }
/** * Sets the volumeUnitsID of this {@link Model} to the id of the * {@link UnitDefinition} 'volumeUnits'. * * @param volumeUnits */ public void setVolumeUnits(UnitDefinition volumeUnits) { if (!getListOfUnitDefinitions().contains(volumeUnits)) { addUnitDefinition(volumeUnits); } setVolumeUnits(volumeUnits != null ? volumeUnits.getId() : null); }
/** * Sets the extentUnitsID of this {@link Model} to the id of the * {@link UnitDefinition} 'extentUnits'. * * @param extentUnits */ public void setExtentUnits(UnitDefinition extentUnits) { if (!getListOfUnitDefinitions().contains(extentUnits)) { addUnitDefinition(extentUnits); } setExtentUnits(extentUnits != null ? extentUnits.getId() : null); }
/** * Sets the substanceUnitsID of this {@link Model} to the id of * 'substanceUnits'. * * @param substanceUnits */ public void setSubstanceUnits(UnitDefinition substanceUnits) { if (!getListOfUnitDefinitions().contains(substanceUnits)) { addUnitDefinition(substanceUnits); } setSubstanceUnits(substanceUnits != null ? substanceUnits.getId() : null); }
@Override public boolean check(ValidationContext ctx, Model m) { if (m.isSetListOfUnitDefinitions() || m.isListOfUnitDefinitionEmpty()) { return new UnknownElementValidationFunction<TreeNodeWithChangeSupport>().check(ctx, m.getListOfUnitDefinitions()); } return true; } };
/** * Sets the lengthUnitsID of this {@link Model} to the id of the * UnitDefinition 'lengthUnits'. * * @param lengthUnits */ public void setLengthUnits(UnitDefinition lengthUnits) { if (!getListOfUnitDefinitions().contains(lengthUnits)) { addUnitDefinition(lengthUnits); } setLengthUnits(lengthUnits != null ? lengthUnits.getId() : null); }
/** * Sets the timeUnitsID of this {@link Model} to the id of the * {@link UnitDefinition} 'timeUnits'. * * @param timeUnits */ public void setTimeUnits(UnitDefinition timeUnits) { if (!getListOfUnitDefinitions().contains(timeUnits)) { addUnitDefinition(timeUnits); } setTimeUnits(timeUnits != null ? timeUnits.getId() : null); }
/** * Checks whether an identical {@link UnitDefinition} like the given * {@link UnitDefinition} is already in this {@link Model}'s * {@link #listOfUnitDefinitions}. If yes, the identifier of the identical * {@link UnitDefinition} will be returned. Otherwise, the given unit is added * to the {@link #listOfUnitDefinitions} and its identifier will be returned. * In any case, this method returns the identifier of a {@link UnitDefinition} * that is part of this {@link Model} at least after calling this method. * * @param units * The unit to be checked and added if no identical * {@link UnitDefinition} can be found. * @return */ public String addUnitDefinitionOrReturnIdenticalUnit(UnitDefinition units) { boolean contains = false; for (UnitDefinition ud : getListOfUnitDefinitions()) { if (UnitDefinition.areIdentical(ud, units)) { units = ud; contains = true; break; } } if (!contains) { addUnitDefinition(units); } return units.getId(); }
private Model flattenModel(Model modelOfSubmodel) { flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfReactions()); flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfCompartments()); flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfConstraints()); flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfEvents()); flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfFunctionDefinitions()); flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfParameters()); flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfRules()); flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfSpecies()); flattenSBaseList(modelOfSubmodel, modelOfSubmodel.getListOfUnitDefinitions()); return modelOfSubmodel; }
mergeListsOfModels(previousModel.getListOfRules(), previousModel, mergedModel); mergeListsOfModels(previousModel.getListOfEvents(), previousModel, mergedModel); mergeListsOfModels(previousModel.getListOfUnitDefinitions(), previousModel, mergedModel); mergeListsOfModels(previousModel.getListOfReactions(), previousModel, mergedModel); mergeListsOfModels(previousModel.getListOfParameters(), previousModel, mergedModel); mergeListsOfModels(currentModel.getListOfRules(), currentModel, mergedModel); mergeListsOfModels(currentModel.getListOfEvents(), currentModel, mergedModel); mergeListsOfModels(currentModel.getListOfUnitDefinitions(), currentModel, mergedModel); mergeListsOfModels(currentModel.getListOfReactions(), currentModel, mergedModel); mergeListsOfModels(currentModel.getListOfParameters(), currentModel, mergedModel);
ListOf<UnitDefinition> unitDefinitionListOf = sourceModel.getListOfUnitDefinitions().clone(); sourceModel.getListOfUnitDefinitions().removeFromParent();
setListOfUnitDefinitions(model.getListOfUnitDefinitions().clone());