/** * Adds a Rule instance to the listOfRules of this Model. * * @param rule * @return {@code true} if the {@link #listOfRules} was changed as a * result of this call. */ public boolean addRule(Rule rule) { return getListOfRules().add(rule); }
/** * Gets the n<sup>th</sup> {@link Rule} of the listOfRules. * * @param n the index of the element to return * @return the n<sup>th</sup> {@link Rule} of the listOfRules. {@code null} if * it doesn't exist. */ public Rule getRule(int n) { return getListOfRules().get(n); }
@Override public int getNumObjects(ValidationContext ctx, Model m) { int count = 0; if (m.isSetListOfRules()) { for (Rule r : m.getListOfRules()) { if (r instanceof ExplicitRule) { count++; } } } return count; }
/** * Removes the i-th {@link Rule} of the {@link Model}. * * @param i * @return the removed element. */ public Rule removeRule(int i) { return getListOfRules().remove(i); }
/** * Removes a {@link Rule} from the {@link Model}. * * @param rule * the {@link Rule} to be removed. * @return {@code true} if the {@link Rule} was found and removed. */ public boolean removeRule(Rule rule) { return getListOfRules().remove(rule); }
/** * Removes the {@link Rule} of the {@link Model} with 'variableId' as * variable. * * @param variableId * @return the removed element. */ public Rule removeRule(String variableId) { return getListOfRules().removeFirst( new AssignmentVariableFilter(variableId)); }
@Override public String getNextObject(ValidationContext ctx, Model m, int n) { int count = 0; if (m.isSetListOfRules()) { for (Rule r : m.getListOfRules()) { if (r instanceof ExplicitRule) { if (count == n) { return ((ExplicitRule) r).getVariable(); } else { count++; } } } } return null; } };
@Override public boolean check(ValidationContext ctx, Model m) { Set<String> iaIds = new HashSet<String>(); if (m.isSetListOfInitialAssignments()) { for (InitialAssignment ia : m.getListOfInitialAssignments()) { // TODO - use the existing map and methods for this one iaIds.add(ia.getVariable()); } } if (m.isSetListOfRules()) { for (Rule r : m.getListOfRules()) { String id = null; if (r instanceof AssignmentRule) { id = ((AssignmentRule) r).getVariable(); } // Is the id already used by an InitialAssignment? if (id != null && id.trim().length() > 0 && iaIds.contains(id)) { return false; } } } return true; } };
for (Rule rule : model.getListOfRules()) {
/** * Searches for the first instance of {@link ExplicitRule} within this * {@link Model}'s {@link #listOfRules}, whose variable attribute is set to * the value passed to this method. * * @param variable the variable to search for. * @return {@code null} if no element with the required property exists. */ public ExplicitRule getRuleByVariable(String variable) { if (isSetListOfRules()) { Rule rule = getListOfRules().firstHit(new AssignmentVariableFilter(variable)); return (rule != null) && (rule instanceof ExplicitRule) ? (ExplicitRule) rule : null; } return null; }
@Override public boolean check(ValidationContext ctx, Model m) { if (m.isSetListOfRules() || m.isListOfRulesEmpty()) { return new UnknownElementValidationFunction<TreeNodeWithChangeSupport>().check(ctx, m.getListOfRules()); } return true; } };
@Override public boolean check(ValidationContext ctx, Model m) { if (m.isSetListOfRules() || m.isListOfRulesEmpty()) { return new UnknownAttributeValidationFunction<TreeNodeWithChangeSupport>().check(ctx, m.getListOfRules()); } return true; } };
for (Rule rule : m.getListOfRules()) { if (rule.isAssignment()) {
@Override public boolean check(ValidationContext ctx, EventAssignment ea) { Model m = ea.getModel(); if (m != null) { if (m.getRuleCount() > 0) { for (Rule r : m.getListOfRules()) { if (r.isAssignment()) { AssignmentRule ar = (AssignmentRule) r; if (ar.getVariable().equals(ea.getVariable())) { return false; } } } } } return true; } };
for (Rule r : m.getListOfRules()) { if (r instanceof AlgebraicRule) {
for (Rule r : m.getListOfRules()) { if (r instanceof AlgebraicRule) {
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; }
for (Rule r: m.getListOfRules())
mergeListsOfModels(previousModel.getListOfSpecies(), previousModel, mergedModel); mergeListsOfModels(previousModel.getListOfFunctionDefinitions(), previousModel, mergedModel); mergeListsOfModels(previousModel.getListOfRules(), previousModel, mergedModel); mergeListsOfModels(previousModel.getListOfEvents(), previousModel, mergedModel); mergeListsOfModels(previousModel.getListOfUnitDefinitions(), previousModel, mergedModel); mergeListsOfModels(currentModel.getListOfSpecies(), currentModel, mergedModel); mergeListsOfModels(currentModel.getListOfFunctionDefinitions(), currentModel, mergedModel); mergeListsOfModels(currentModel.getListOfRules(), currentModel, mergedModel); mergeListsOfModels(currentModel.getListOfEvents(), currentModel, mergedModel); mergeListsOfModels(currentModel.getListOfUnitDefinitions(), currentModel, mergedModel);
setListOfRules(model.getListOfRules().clone());