@Override public Map<String, String> writeXMLAttributes() { Map<String, String> attributes = super.writeXMLAttributes(); if (isSetValue()) { attributes.put("value", StringTools.toString(Locale.ENGLISH, getValue())); } if (isSetUnits()) { attributes.put("units", getUnits()); } if (isSetConstant() && (getLevel() > 1)) { attributes.put("constant", Boolean.toString(getConstant())); } return attributes; }
/** * Creates a new {@link ExplicitRule} * * @param parameter */ public ExplicitRule(Parameter parameter) { this((Variable) parameter); UnitDefinition ud = parameter.getDerivedUnitDefinition(); if ((ud != null) && ud.isSetId()) { unitsID = new String(ud.getId()); } else { unitsID = null; } }
@Override public boolean check(ValidationContext ctx, Parameter p) { Model m = p.getModel(); if (m != null && !p.isSetValue()) { boolean setByAssignment = false; if (p.isSetId()) { setByAssignment = m.getInitialAssignmentBySymbol(p.getId()) != null; if (!setByAssignment) { Rule r = m.getRuleByVariable(p.getId()); setByAssignment = r != null && r.isAssignment(); } } return setByAssignment; } return true; } };
@Override public boolean check(ValidationContext ctx, Parameter p) { if (p.isSetUnits()) { String units = p.getUnits(); Model m = p.getModel(); if (! (Unit.isUnitKind(units, ctx.getLevel(), ctx.getVersion()) || Unit.isPredefined(units, ctx.getLevel()) || (m != null && m.getUnitDefinition(units) != null))) { ValidationConstraint.logError(ctx, CORE_20701, p, p.getId(), p.getUnits()); return false; } } return true; } };
if (!param.isConstant()) { String shortMsg = MessageFormat.format("The attribute arrays:size of a Dimension object should point to a constant parameter but {0} has a non-constant value.", dim.toString()); if (param.getValue() % 1 != 0) { String shortMsg = "The attribute arrays:size of a Dimension object should point to a parameter containing an integer value."; logDimensionSizeValueInconsistency(shortMsg); if (param.getValue() < 0) { String shortMsg = MessageFormat.format("The attribute arrays:size of a Dimension object should point to a parameter that has a non-negative integer value but {0} has a negative value.", dim.toString()); logDimensionSizeValueInconsistency(shortMsg); ArraysSBasePlugin arraysSBasePlugin = (ArraysSBasePlugin) param.getExtension(ArraysConstants.shortLabel);
/** * Maps a dimension id to the size of the dimension object. * * @param model * @param arraysSBasePlugin * @return */ public static Map<String, Double> getDimensionSizes(Model model, ArraysSBasePlugin arraysSBasePlugin) { Map<String, Double> dimensionValue = new HashMap<String, Double>(); if (arraysSBasePlugin == null) { return dimensionValue; } for (Dimension dim : arraysSBasePlugin.getListOfDimensions()) { if (dim.isSetId()) { Parameter size = model.getParameter(dim.getSize()); if (size != null) { dimensionValue.put(dim.getId(), size.getValue()); } } } return dimensionValue; }
if(parameter.isSetPlugin(CompConstants.shortLabel)){ replaceElementsInModelDefinition(null, (CompSBasePlugin) parameter.getExtension(CompConstants.shortLabel)); parameter.unsetPlugin(CompConstants.shortLabel); targetModel.addParameter(parameter.clone());
/** * Gets the size of a Dimension object. * * @param model * @param dimension * @return */ public static int getSize(Model model, Dimension dimension) { if (dimension == null) { return 0; } String sizeRef = dimension.getSize(); Parameter param = model.getParameter(sizeRef); if (param == null || !param.isSetValue()) { throw new SBMLException(); } return (int) param.getValue(); }
String pid = p.getId(); boolean relevant = false; if (values.containsKey(atKI)) { double d = values.get(atKI).doubleValue(); if (d < p.getValue()) values.put(atKI, Double.valueOf(p.getValue())); } else { values.put(atKI, Double.valueOf(p.getValue())); if (values.containsKey(atKM)) { double d = values.get(atKM).doubleValue(); if (d < p.getValue()) values.put(atKM, Double.valueOf(p.getValue())); } else { values.put(atKM, Double.valueOf(p.getValue())); if (values.containsKey(atTN)) { double d = values.get(atTN).doubleValue(); if (d < p.getValue()) values.put(atTN, Double.valueOf(p.getValue())); } else { values.put(atTN, Double.valueOf(p.getValue()));
/** * Sets the conversionFactorID of this {@link Model} to the id of the * {@link Parameter} 'conversionFactor'. * * @param conversionFactor */ public void setConversionFactor(Parameter conversionFactor) { setConversionFactor( conversionFactor != null ? conversionFactor.getId() : null); }
Parameter param = (Parameter) contextObject; SpatialParameterPlugin spatialParam = null; if (param.getExtension(SpatialConstants.namespaceURI) != null) { spatialParam = (SpatialParameterPlugin) param.getExtension(SpatialConstants.namespaceURI); } else { spatialParam = new SpatialParameterPlugin(param); param.addExtension(SpatialConstants.namespaceURI, spatialParam);
@Override public boolean check(ValidationContext ctx, Model m) { if (m.isSetConversionFactor()) { Parameter fac = m.getConversionFactorInstance(); if (fac != null && !fac.isConstant()) { ValidationConstraint.logError(ctx, CORE_20705, m, m.getConversionFactor()); return false; } } return true; } };
int insertingPosition = 0; for (SBase element:variables) { if (!(element instanceof Parameter) || (!((Parameter)element).isSetValue())) { insertingPosition++; for (SBase element:variables) { if (!(element instanceof Parameter) || (!((Parameter) element).isSetValue())) { insertingPosition++;
@Override public Parameter clone() { return new Parameter(this); }
/** * @param arraysPlugin * @param node * @return */ private ASTNode constructVector(ArraysSBasePlugin arraysPlugin, ASTNode node) { Dimension dim = arraysPlugin.getDimensionByArrayDimension(0); Parameter p = model.getParameter(dim.getSize()); double size = p.getValue(); List<ASTNode> vector = new ArrayList<ASTNode>((int) size); for (int j = 0; j < size; ++j) { vector.add(node.clone()); } vector(vector); ASTNode vectorNode = getNode(); for (int i = 1; i < arraysPlugin.getDimensionCount(); ++i) { dim = arraysPlugin.getDimensionByArrayDimension(i); p = model.getParameter(dim.getSize()); size = p.getValue(); vector = new ArrayList<ASTNode>((int) size); for (int j = 0; j < size; ++j) { vector.add(vectorNode); } vector(vector); vectorNode = getNode(); } return vectorNode; }
/** * Removes the {@link Parameter} 'p' from the {@link #listOfLocalParameters} * of this {@link KineticLaw}. * * @param p * @return {@code true} if the operation was performed successfully. * @deprecated use {@link #removeLocalParameter(LocalParameter)} */ @Deprecated public boolean removeParameter(Parameter p) { return removeLocalParameter(p.getId()); }
@Override public boolean check(ValidationContext ctx, Species s) { if (s.isSetConversionFactor()) { Parameter fac = s.getConversionFactorInstance(); // don't report if the parameter is null, that's the job of CORE_20617 if (fac != null && !fac.isConstant()) { ValidationConstraint.logError(ctx, CORE_20705, s, s.getConversionFactor()); return false; } } return true; } };
/** * Creates a new {@link Parameter}. * * @param id * the id of the new element to create * @return the {@link Parameter} object created */ public Parameter createParameter(String id) { Parameter parameter = new Parameter(id, getLevel(), getVersion()); addParameter(parameter); return parameter; }
/** * @param arraysPlugin * @param quantity * @return */ private ASTNode constructVector(ArraysSBasePlugin arraysPlugin, Quantity quantity) { double value = quantity.getValue(); Dimension dim = arraysPlugin.getDimensionByArrayDimension(0); Parameter p = model.getParameter(dim.getSize()); double size = p.getValue(); List<ASTNode> vector = new ArrayList<ASTNode>((int) size); for (int j = 0; j < size; ++j) { vector.add(new ASTNode(value)); } vector(vector); ASTNode vectorNode = getNode(); for (int i = 1; i < arraysPlugin.getDimensionCount(); ++i) { dim = arraysPlugin.getDimensionByArrayDimension(i); p = model.getParameter(dim.getSize()); size = p.getValue(); vector = new ArrayList<ASTNode>((int) size); for (int j = 0; j < size; ++j) { vector.add(vectorNode); } vector(vector); vectorNode = getNode(); } return vectorNode; }