Search in sources :

Example 56 with PropertyVetoException

use of java.beans.PropertyVetoException in project vcell by virtualcell.

the class RulebasedTransformer method parseBngOutput.

private void parseBngOutput(SimulationContext simContext, Set<ReactionRule> fromReactions, BNGOutput bngOutput) {
    Model model = simContext.getModel();
    Document bngNFSimXMLDocument = bngOutput.getNFSimXMLDocument();
    bngRootElement = bngNFSimXMLDocument.getRootElement();
    Element modelElement = bngRootElement.getChild("model", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
    Element listOfReactionRulesElement = modelElement.getChild("ListOfReactionRules", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
    List<Element> reactionRuleChildren = new ArrayList<Element>();
    reactionRuleChildren = listOfReactionRulesElement.getChildren("ReactionRule", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
    for (Element reactionRuleElement : reactionRuleChildren) {
        ReactionRuleAnalysisReport rar = new ReactionRuleAnalysisReport();
        boolean bForward = true;
        String rule_id_str = reactionRuleElement.getAttributeValue("id");
        ruleElementMap.put(rule_id_str, reactionRuleElement);
        String rule_name_str = reactionRuleElement.getAttributeValue("name");
        String symmetry_factor_str = reactionRuleElement.getAttributeValue("symmetry_factor");
        Double symmetry_factor_double = Double.parseDouble(symmetry_factor_str);
        ReactionRule rr = null;
        if (rule_name_str.startsWith("_reverse_")) {
            bForward = false;
            rule_name_str = rule_name_str.substring("_reverse_".length());
            rr = model.getRbmModelContainer().getReactionRule(rule_name_str);
            RbmKineticLaw rkl = rr.getKineticLaw();
            try {
                if (symmetry_factor_double != 1.0 && fromReactions.contains(rr)) {
                    Expression expression = rkl.getLocalParameterValue(RbmKineticLawParameterType.MassActionReverseRate);
                    expression = Expression.div(expression, new Expression(symmetry_factor_double));
                    rkl.setLocalParameterValue(RbmKineticLawParameterType.MassActionReverseRate, expression);
                }
            } catch (ExpressionException | PropertyVetoException exc) {
                exc.printStackTrace();
                throw new RuntimeException("Unexpected transform exception: " + exc.getMessage());
            }
            rulesReverseMap.put(rr, rar);
        } else {
            rr = model.getRbmModelContainer().getReactionRule(rule_name_str);
            RbmKineticLaw rkl = rr.getKineticLaw();
            try {
                if (symmetry_factor_double != 1.0 && fromReactions.contains(rr)) {
                    Expression expression = rkl.getLocalParameterValue(RbmKineticLawParameterType.MassActionForwardRate);
                    expression = Expression.div(expression, new Expression(symmetry_factor_double));
                    rkl.setLocalParameterValue(RbmKineticLawParameterType.MassActionForwardRate, expression);
                }
            } catch (ExpressionException | PropertyVetoException exc) {
                exc.printStackTrace();
                throw new RuntimeException("Unexpected transform exception: " + exc.getMessage());
            }
            rulesForwardMap.put(rr, rar);
        }
        rar.symmetryFactor = symmetry_factor_double;
        System.out.println("rule id=" + rule_id_str + ", name=" + rule_name_str + ", symmetry factor=" + symmetry_factor_str);
        keyMap.put(rule_id_str, rr);
        Element listOfReactantPatternsElement = reactionRuleElement.getChild("ListOfReactantPatterns", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        List<Element> reactantPatternChildren = new ArrayList<Element>();
        reactantPatternChildren = listOfReactantPatternsElement.getChildren("ReactantPattern", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        for (int i = 0; i < reactantPatternChildren.size(); i++) {
            Element reactantPatternElement = reactantPatternChildren.get(i);
            String pattern_id_str = reactantPatternElement.getAttributeValue("id");
            ReactionRuleParticipant p = bForward ? rr.getReactantPattern(i) : rr.getProductPattern(i);
            SpeciesPattern sp = p.getSpeciesPattern();
            System.out.println("  reactant id=" + pattern_id_str + ", name=" + sp.toString());
            keyMap.put(pattern_id_str, sp);
            // list of molecules
            extractMolecules(sp, model, reactantPatternElement);
            // list of bonds (not implemented)
            extractBonds(reactantPatternElement);
        }
        Element listOfProductPatternsElement = reactionRuleElement.getChild("ListOfProductPatterns", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        List<Element> productPatternChildren = new ArrayList<Element>();
        productPatternChildren = listOfProductPatternsElement.getChildren("ProductPattern", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        for (int i = 0; i < productPatternChildren.size(); i++) {
            Element productPatternElement = productPatternChildren.get(i);
            String pattern_id_str = productPatternElement.getAttributeValue("id");
            ReactionRuleParticipant p = bForward ? rr.getProductPattern(i) : rr.getReactantPattern(i);
            SpeciesPattern sp = p.getSpeciesPattern();
            System.out.println("  product  id=" + pattern_id_str + ", name=" + sp.toString());
            keyMap.put(pattern_id_str, sp);
            extractMolecules(sp, model, productPatternElement);
            extractBonds(productPatternElement);
        }
        // extract the Map for this rule
        Element listOfMapElement = reactionRuleElement.getChild("Map", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        List<Element> mapChildren = new ArrayList<Element>();
        mapChildren = listOfMapElement.getChildren("MapItem", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        for (Element mapElement : mapChildren) {
            String target_id_str = mapElement.getAttributeValue("targetID");
            String source_id_str = mapElement.getAttributeValue("sourceID");
            System.out.println("Map: target=" + target_id_str + " source=" + source_id_str);
            RbmObject target_object = keyMap.get(target_id_str);
            RbmObject source_object = keyMap.get(source_id_str);
            if (target_object == null)
                System.out.println("!!! Missing map target  " + target_id_str);
            if (source_object == null)
                System.out.println("!!! Missing map source " + source_id_str);
            if (source_object != null) {
                // target_object may be null
                System.out.println("      target=" + target_object + " source=" + source_object);
                Pair<RbmObject, RbmObject> mapEntry = new Pair<RbmObject, RbmObject>(target_object, source_object);
                rar.objmappingList.add(mapEntry);
            }
            Pair<String, String> idmapEntry = new Pair<String, String>(target_id_str, source_id_str);
            rar.idmappingList.add(idmapEntry);
        }
        // ListOfOperations
        Element listOfOperationsElement = reactionRuleElement.getChild("ListOfOperations", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        List<Element> operationsChildren = new ArrayList<Element>();
        operationsChildren = listOfOperationsElement.getChildren("StateChange", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        System.out.println("ListOfOperations");
        for (Element operationsElement : operationsChildren) {
            String finalState_str = operationsElement.getAttributeValue("finalState");
            String site_str = operationsElement.getAttributeValue("site");
            RbmObject site_object = keyMap.get(site_str);
            if (site_object == null)
                System.out.println("!!! Missing map object " + site_str);
            if (site_object != null) {
                System.out.println("   finalState=" + finalState_str + " site=" + site_object);
                StateChangeOperation sco = new StateChangeOperation(finalState_str, site_str, site_object);
                rar.operationsList.add(sco);
            }
        }
        operationsChildren = listOfOperationsElement.getChildren("AddBond", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        for (Element operationsElement : operationsChildren) {
            String site1_str = operationsElement.getAttributeValue("site1");
            String site2_str = operationsElement.getAttributeValue("site2");
            RbmObject site1_object = keyMap.get(site1_str);
            RbmObject site2_object = keyMap.get(site2_str);
            if (site1_object == null)
                System.out.println("!!! Missing map object " + site1_str);
            if (site2_object == null)
                System.out.println("!!! Missing map object " + site2_str);
            if (site1_object != null && site2_object != null) {
                System.out.println("   site1=" + site1_object + " site2=" + site2_object);
                AddBondOperation abo = new AddBondOperation(site1_str, site2_str, site1_object, site2_object);
                rar.operationsList.add(abo);
            }
        }
        operationsChildren = listOfOperationsElement.getChildren("DeleteBond", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        for (Element operationsElement : operationsChildren) {
            String site1_str = operationsElement.getAttributeValue("site1");
            String site2_str = operationsElement.getAttributeValue("site2");
            RbmObject site1_object = keyMap.get(site1_str);
            RbmObject site2_object = keyMap.get(site2_str);
            if (site1_object == null)
                System.out.println("!!! Missing map object " + site1_str);
            if (site2_object == null)
                System.out.println("!!! Missing map object " + site2_str);
            if (site1_object != null && site2_object != null) {
                System.out.println("   site1=" + site1_object + " site2=" + site2_object);
                DeleteBondOperation dbo = new DeleteBondOperation(site1_str, site2_str, site1_object, site2_object);
                rar.operationsList.add(dbo);
            }
        }
        operationsChildren = listOfOperationsElement.getChildren("Add", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        for (Element operationsElement : operationsChildren) {
            String id_str = operationsElement.getAttributeValue("id");
            RbmObject id_object = keyMap.get(id_str);
            if (id_object == null)
                System.out.println("!!! Missing map object " + id_str);
            if (id_object != null) {
                System.out.println("   id=" + id_str);
                AddOperation ao = new AddOperation(id_str, id_object);
                rar.operationsList.add(ao);
            }
        }
        operationsChildren = listOfOperationsElement.getChildren("Delete", Namespace.getNamespace("http://www.sbml.org/sbml/level3"));
        for (Element operationsElement : operationsChildren) {
            String id_str = operationsElement.getAttributeValue("id");
            String delete_molecules_str = operationsElement.getAttributeValue("DeleteMolecules");
            RbmObject id_object = keyMap.get(id_str);
            if (id_object == null)
                System.out.println("!!! Missing map object " + id_str);
            int delete_molecules_int = 0;
            if (delete_molecules_str != null) {
                delete_molecules_int = Integer.parseInt(delete_molecules_str);
            }
            if (id_object != null) {
                System.out.println("   id=" + id_str + ", DeleteMolecules=" + delete_molecules_str);
                DeleteOperation dop = new DeleteOperation(id_str, id_object, delete_molecules_int);
                rar.operationsList.add(dop);
            }
        }
    }
    System.out.println("done parsing xml file");
}
Also used : Element(org.jdom.Element) ArrayList(java.util.ArrayList) Document(org.jdom.Document) ExpressionException(cbit.vcell.parser.ExpressionException) SpeciesPattern(org.vcell.model.rbm.SpeciesPattern) Pair(org.vcell.util.Pair) ReactionRule(cbit.vcell.model.ReactionRule) RbmKineticLaw(cbit.vcell.model.RbmKineticLaw) PropertyVetoException(java.beans.PropertyVetoException) Expression(cbit.vcell.parser.Expression) ReactionRuleParticipant(cbit.vcell.model.ReactionRuleParticipant) RbmObject(org.vcell.model.rbm.RbmObject) Model(cbit.vcell.model.Model)

Example 57 with PropertyVetoException

use of java.beans.PropertyVetoException in project vcell by virtualcell.

the class BNGExecutorServiceMultipass method preprocessInput.

// parse the compartmental bngl file and produce the "trick"
// where each molecule has an extra Site with the compartments as possible States
// a reserved name will be used for this Site
// 
private String preprocessInput(String cBngInputString) throws ParseException, PropertyVetoException, ExpressionBindingException {
    // take the cBNGL file (as string), parse it to recover the rules (we'll need them later)
    // and create the bngl string with the extra, fake site for the compartments
    BioModel bioModel = new BioModel(null);
    bioModel.setName("BngBioModel");
    model = new Model("model");
    bioModel.setModel(model);
    model.createFeature();
    simContext = bioModel.addNewSimulationContext("BioNetGen app", SimulationContext.Application.NETWORK_DETERMINISTIC);
    List<SimulationContext> appList = new ArrayList<SimulationContext>();
    appList.add(simContext);
    // set convention for initial conditions in generated application for seed species (concentration or count)
    BngUnitSystem bngUnitSystem = new BngUnitSystem(BngUnitOrigin.DEFAULT);
    InputStream is = new ByteArrayInputStream(cBngInputString.getBytes());
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    ASTModel astModel = RbmUtils.importBnglFile(br);
    if (astModel.hasCompartments()) {
        Structure struct = model.getStructure(0);
        if (struct != null) {
            try {
                model.removeStructure(struct);
            } catch (PropertyVetoException e) {
                e.printStackTrace();
            }
        }
    }
    BnglObjectConstructionVisitor constructionVisitor = null;
    constructionVisitor = new BnglObjectConstructionVisitor(model, appList, bngUnitSystem, true);
    astModel.jjtAccept(constructionVisitor, model.getRbmModelContainer());
    int numCompartments = model.getStructures().length;
    if (numCompartments == 0) {
        throw new RuntimeException("No structure present in the bngl file.");
    } else if (numCompartments == 1) {
        // for single compartment we don't need the 'trick'
        compartmentMode = CompartmentMode.hide;
    } else {
        compartmentMode = CompartmentMode.asSite;
    }
    // extract all polymer observables for special treatment at the end
    for (RbmObservable oo : model.getRbmModelContainer().getObservableList()) {
        if (oo.getSequence() == RbmObservable.Sequence.PolymerLengthEqual) {
            polymerEqualObservables.add(oo);
        } else if (oo.getSequence() == RbmObservable.Sequence.PolymerLengthGreater) {
            polymerGreaterObservables.add(oo);
        }
    }
    for (RbmObservable oo : polymerEqualObservables) {
        model.getRbmModelContainer().removeObservable(oo);
    }
    for (RbmObservable oo : polymerGreaterObservables) {
        model.getRbmModelContainer().removeObservable(oo);
    }
    // replace all reversible rules with 2 direct rules
    List<ReactionRule> newRRList = new ArrayList<>();
    for (ReactionRule rr : model.getRbmModelContainer().getReactionRuleList()) {
        if (rr.isReversible()) {
            ReactionRule rr1 = ReactionRule.deriveDirectRule(rr);
            newRRList.add(rr1);
            ReactionRule rr2 = ReactionRule.deriveInverseRule(rr);
            newRRList.add(rr2);
        } else {
            newRRList.add(rr);
        }
        model.getRbmModelContainer().removeReactionRule(rr);
    }
    // model.getRbmModelContainer().getReactionRuleList().clear();
    model.getRbmModelContainer().setReactionRules(newRRList);
    StringWriter bnglStringWriter = new StringWriter();
    PrintWriter writer = new PrintWriter(bnglStringWriter);
    writer.println(RbmNetworkGenerator.BEGIN_MODEL);
    writer.println();
    // RbmNetworkGenerator.writeCompartments(writer, model, null);
    RbmNetworkGenerator.writeParameters(writer, model.getRbmModelContainer(), false);
    RbmNetworkGenerator.writeMolecularTypes(writer, model, compartmentMode);
    RbmNetworkGenerator.writeSpeciesSortedAlphabetically(writer, model, simContext, compartmentMode);
    RbmNetworkGenerator.writeObservables(writer, model.getRbmModelContainer(), compartmentMode);
    // RbmNetworkGenerator.writeFunctions(writer, rbmModelContainer, ignoreFunctions);
    RbmNetworkGenerator.writeReactions(writer, model.getRbmModelContainer(), null, false, compartmentMode);
    writer.println(RbmNetworkGenerator.END_MODEL);
    writer.println();
    // we parse the real numbers from the bngl file provided by the caller, the nc in the simContext has the default ones
    NetworkConstraints realNC = extractNetworkConstraints(cBngInputString);
    simContext.getNetworkConstraints().setMaxMoleculesPerSpecies(realNC.getMaxMoleculesPerSpecies());
    simContext.getNetworkConstraints().setMaxIteration(realNC.getMaxIteration());
    RbmNetworkGenerator.generateNetworkEx(1, simContext.getNetworkConstraints().getMaxMoleculesPerSpecies(), writer, model.getRbmModelContainer(), simContext, NetworkGenerationRequirements.AllowTruncatedStandardTimeout);
    String sInputString = bnglStringWriter.toString();
    return sInputString;
}
Also used : InputStreamReader(java.io.InputStreamReader) ReactionRule(cbit.vcell.model.ReactionRule) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RbmObservable(cbit.vcell.model.RbmObservable) ArrayList(java.util.ArrayList) SimulationContext(cbit.vcell.mapping.SimulationContext) PropertyVetoException(java.beans.PropertyVetoException) BngUnitSystem(org.vcell.model.bngl.BngUnitSystem) BnglObjectConstructionVisitor(org.vcell.model.rbm.RbmUtils.BnglObjectConstructionVisitor) StringWriter(java.io.StringWriter) ByteArrayInputStream(java.io.ByteArrayInputStream) BioModel(cbit.vcell.biomodel.BioModel) ASTModel(org.vcell.model.bngl.ASTModel) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) BufferedReader(java.io.BufferedReader) Structure(cbit.vcell.model.Structure) ASTModel(org.vcell.model.bngl.ASTModel) PrintWriter(java.io.PrintWriter) NetworkConstraints(org.vcell.model.rbm.NetworkConstraints)

Example 58 with PropertyVetoException

use of java.beans.PropertyVetoException in project vcell by virtualcell.

the class SolverTaskDescription method propertyChange.

/**
 * This method gets called when a bound property is changed.
 * @param evt A PropertyChangeEvent object describing the event source
 *   and the property that has changed.
 */
public void propertyChange(java.beans.PropertyChangeEvent evt) {
    try {
        if (evt.getSource() == this && (evt.getPropertyName().equals(PROPERTY_SOLVER_DESCRIPTION))) {
            SolverDescription solverDescription = getSolverDescription();
            if (solverDescription.equals(SolverDescription.SundialsPDE) || solverDescription.isSemiImplicitPdeSolver() || solverDescription.isGibsonSolver()) {
                TimeBounds timeBounds = getTimeBounds();
                if (!(getOutputTimeSpec() instanceof UniformOutputTimeSpec)) {
                    // set to uniform output if it is not.
                    double outputTime = (timeBounds.getEndingTime() - timeBounds.getStartingTime()) / 20;
                    setOutputTimeSpec(new UniformOutputTimeSpec(outputTime));
                }
                if (solverDescription.equals(SolverDescription.SundialsPDE)) {
                    setErrorTolerance(ErrorTolerance.getDefaultSundialsErrorTolerance());
                    setDefaultTimeStep(TimeStep.getDefaultSundialsTimeStep());
                    if (sundialsPdeSolverOptions == null) {
                        sundialsPdeSolverOptions = new SundialsPdeSolverOptions();
                    }
                } else {
                    sundialsPdeSolverOptions = null;
                    setErrorTolerance(ErrorTolerance.getDefaultSemiImplicitErrorTolerance());
                }
            } else if (!solverDescription.supports(getOutputTimeSpec())) {
                setOutputTimeSpec(solverDescription.createOutputTimeSpec(this));
            }
            if (solverDescription.isNonSpatialStochasticSolver()) {
                if (fieldNonspatialStochOpt == null) {
                    setStochOpt(new NonspatialStochSimOptions());
                } else {
                    setStochOpt(new NonspatialStochSimOptions(fieldNonspatialStochOpt));
                }
                if (!solverDescription.equals(SolverDescription.StochGibson)) {
                    if (fieldNonspatialStochHybridOpt == null) {
                        setStochHybridOpt(new NonspatialStochHybridOptions());
                    }
                }
            } else if (solverDescription.isSpatialStochasticSolver()) {
                setTimeStep(TimeStep.getDefaultSmoldynTimeStep());
                if (smoldynSimulationOptions == null) {
                    smoldynSimulationOptions = new SmoldynSimulationOptions();
                }
            // setSmoldynDefaultTimeStep();
            }
            if (solverDescription.isNFSimSolver()) {
                if (nfsimSimulationOptions == null) {
                    nfsimSimulationOptions = new NFsimSimulationOptions();
                }
            }
            if (solverDescription.isChomboSolver()) {
                if (chomboSolverSpec == null && getSimulation() != null) {
                    chomboSolverSpec = new ChomboSolverSpec(ChomboSolverSpec.getDefaultMaxBoxSize(getSimulation().getMathDescription().getGeometry().getDimension()));
                }
                if (getOutputTimeSpec() == null || !(getOutputTimeSpec() instanceof UniformOutputTimeSpec)) {
                    double outputTime = getTimeBounds().getEndingTime() / 10;
                    setOutputTimeSpec(new UniformOutputTimeSpec(outputTime));
                }
                if (chomboSolverSpec != null && chomboSolverSpec.getTimeIntervalList().size() == 0) {
                    chomboSolverSpec.addTimeInterval(TimeInterval.getDefaultTimeInterval());
                }
            } else {
                chomboSolverSpec = null;
            }
            if (solverDescription.isMovingBoundarySolver()) {
                if (movingBoundarySolverOptions == null && getSimulation() != null) {
                    movingBoundarySolverOptions = new MovingBoundarySolverOptions();
                }
            } else {
                movingBoundarySolverOptions = null;
            }
        }
    } catch (PropertyVetoException e) {
        e.printStackTrace();
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) MovingBoundarySolverOptions(cbit.vcell.solvers.mb.MovingBoundarySolverOptions) ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec)

Example 59 with PropertyVetoException

use of java.beans.PropertyVetoException in project vcell by virtualcell.

the class ReactionStep method setKinetics.

/**
 * Sets the kinetics property (cbit.vcell.model.Kinetics) value.
 * @param kinetics The new value for the property.
 * @see #getKinetics
 */
public void setKinetics(Kinetics kinetics) {
    Kinetics oldValue = fieldKinetics;
    // 
    if (oldValue != null) {
        oldValue.removePropertyChangeListener(this);
        oldValue.removePropertyChangeListener(this);
        removePropertyChangeListener(oldValue);
        removePropertyChangeListener(oldValue);
    }
    fieldKinetics = kinetics;
    if (kinetics != null) {
        kinetics.removePropertyChangeListener(this);
        kinetics.addPropertyChangeListener(this);
        removePropertyChangeListener(kinetics);
        addPropertyChangeListener(kinetics);
    }
    // 
    try {
        KineticsParameter chargeValenceParameter = getKinetics().getChargeValenceParameter();
        if (kinetics.getKineticsDescription().isElectrical()) {
            if (getPhysicsOptions() == PHYSICS_MOLECULAR_ONLY) {
                if (chargeValenceParameter != null && !chargeValenceParameter.getExpression().isZero()) {
                    setPhysicsOptions(PHYSICS_MOLECULAR_AND_ELECTRICAL);
                } else {
                    setPhysicsOptions(PHYSICS_ELECTRICAL_ONLY);
                }
            }
        } else {
            if (getPhysicsOptions() == PHYSICS_ELECTRICAL_ONLY) {
                if (chargeValenceParameter != null && !chargeValenceParameter.getExpression().isZero()) {
                    setPhysicsOptions(PHYSICS_MOLECULAR_AND_ELECTRICAL);
                } else {
                    setPhysicsOptions(PHYSICS_MOLECULAR_ONLY);
                }
            }
        }
        if (getKinetics() != null) {
            if (chargeValenceParameter != null) {
                if (chargeValenceParameter.getExpression().isZero()) {
                    chargeValenceParameter.setExpression(new Expression(1.0));
                }
            }
        }
    } catch (PropertyVetoException e) {
        e.printStackTrace(System.out);
    }
    firePropertyChange(PROPERTY_NAME_KINETICS, oldValue, kinetics);
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) KineticsParameter(cbit.vcell.model.Kinetics.KineticsParameter) Expression(cbit.vcell.parser.Expression)

Example 60 with PropertyVetoException

use of java.beans.PropertyVetoException in project vcell by virtualcell.

the class RateRulesDisplayPanel method deleteButtonPressed.

@Override
protected void deleteButtonPressed() {
    int[] rows = table.getSelectedRows();
    ArrayList<RateRule> deleteList = new ArrayList<RateRule>();
    for (int r : rows) {
        if (r < tableModel.getRowCount()) {
            RateRule rateRule = tableModel.getValueAt(r);
            if (rateRule != null) {
                deleteList.add(rateRule);
            }
        }
    }
    try {
        for (RateRule rateRule : deleteList) {
            simulationContext.removeRateRule(rateRule);
        }
    } catch (PropertyVetoException ex) {
        ex.printStackTrace();
        DialogUtils.showErrorDialog(this, ex.getMessage());
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ArrayList(java.util.ArrayList) RateRule(cbit.vcell.mapping.RateRule)

Aggregations

PropertyVetoException (java.beans.PropertyVetoException)342 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)118 ActionReport (org.glassfish.api.ActionReport)64 Expression (cbit.vcell.parser.Expression)41 ExpressionException (cbit.vcell.parser.ExpressionException)40 ArrayList (java.util.ArrayList)40 Config (com.sun.enterprise.config.serverbeans.Config)31 ModelException (cbit.vcell.model.ModelException)26 Structure (cbit.vcell.model.Structure)25 Property (org.jvnet.hk2.config.types.Property)25 ModelVetoException (com.sun.jdo.api.persistence.model.ModelVetoException)24 List (java.util.List)24 Model (cbit.vcell.model.Model)22 DataAccessException (org.vcell.util.DataAccessException)19 SpeciesContext (cbit.vcell.model.SpeciesContext)18 ExpressionBindingException (cbit.vcell.parser.ExpressionBindingException)18 Resources (com.sun.enterprise.config.serverbeans.Resources)18 Element (org.jdom.Element)18 MathException (cbit.vcell.math.MathException)16 IOException (java.io.IOException)16