/** * Sets hasOnlySubstanceUnits Boolean * * @param hasOnlySubstanceUnits the has only substance units value to be set * @throws PropertyNotAvailableException if Level < 2. */ public void setHasOnlySubstanceUnits(boolean hasOnlySubstanceUnits) { if (!isReadingInProgress() && getLevel() < 2) { throw new PropertyNotAvailableException( TreeNodeChangeEvent.hasOnlySubstanceUnits, this); } if (!isReadingInProgress() && hasOnlySubstanceUnits && isSetSpatialSizeUnits()) { String ud = isSetUnitsInstance() ? UnitDefinition.printUnits( getSpatialSizeUnitsInstance(), true) : getSpatialSizeUnits(); throw new SBMLException(MessageFormat.format( "Cannot define that species {0} with spatial size units {1} has only substance units.", toString(), ud)); } Boolean oldHasOnlySubstanceUnits = this.hasOnlySubstanceUnits; this.hasOnlySubstanceUnits = Boolean.valueOf(hasOnlySubstanceUnits); isSetHasOnlySubstanceUnits = true; firePropertyChange(TreeNodeChangeEvent.hasOnlySubstanceUnits, oldHasOnlySubstanceUnits, this.hasOnlySubstanceUnits); }
@Override public boolean check(ValidationContext ctx, Species s) { Compartment c = s.getCompartmentInstance(); boolean checkResult = true; if (c != null && c.getSpatialDimensions() == 3 && s.isSetSpatialSizeUnits()) { UnitDefinition def = s.getSpatialSizeUnitsInstance(); if (def == null) { checkResult = false; } boolean isVolume = checkResult && def.isVariantOfVolume(); if (checkResult && ctx.getLevel() == 2 && ctx.getLevel() == 1 && !isVolume) { checkResult = false; } if (checkResult && ctx.getLevel() >= 2 && (! (def.isVariantOfDimensionless() || isVolume))) { checkResult = false; } } if (!checkResult) { // report error ValidationConstraint.logError(ctx, CORE_20607, s, s.getId(), s.getCompartment(), s.getSpatialSizeUnits()); } return checkResult; } };
@Override public boolean check(ValidationContext ctx, Species s) { Compartment c = s.getCompartmentInstance(); boolean checkResult = true; if (c != null && c.getSpatialDimensions() == 1 && s.isSetSpatialSizeUnits()) { UnitDefinition def = s.getSpatialSizeUnitsInstance(); if (def == null) { checkResult = false; } boolean isLength = checkResult && def.isVariantOfLength(); if (ctx.getLevel() == 2 && ctx.getLevel() == 1 && !isLength) { checkResult = false; } if (ctx.getLevel() >= 2 && (! (def.isVariantOfDimensionless() || isLength)) ) { checkResult = false; } } if (!checkResult) { // report error ValidationConstraint.logError(ctx, CORE_20605, s, s.getId(), s.getCompartment(), s.getSpatialSizeUnits()); } return checkResult; } };
@Override public boolean check(ValidationContext ctx, Species s) { Compartment c = s.getCompartmentInstance(); boolean checkResult = true; if (c != null && c.getSpatialDimensions() == 2 && s.isSetSpatialSizeUnits()) { UnitDefinition def = s.getSpatialSizeUnitsInstance(); if (def == null) { checkResult = false; } boolean isArea = checkResult && def.isVariantOfArea(); if (ctx.getLevel() == 2 && ctx.getLevel() == 1 && !isArea) { checkResult = false; } if (ctx.getLevel() >= 2 && (! (def.isVariantOfDimensionless() || isArea))) { checkResult = false; } } if (!checkResult) { // report error ValidationConstraint.logError(ctx, CORE_20606, s, s.getId(), s.getCompartment(), s.getSpatialSizeUnits()); } return checkResult; } };