Search in sources :

Example 26 with PropertyVetoException

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

the class XmlReader method getBioEvents.

public BioEvent[] getBioEvents(SimulationContext simContext, Element bioEventsElement) throws XmlParseException {
    Iterator<Element> bioEventsIterator = bioEventsElement.getChildren(XMLTags.BioEventTag, vcNamespace).iterator();
    Vector<BioEvent> bioEventsVector = new Vector<BioEvent>();
    while (bioEventsIterator.hasNext()) {
        Element bEventElement = (Element) bioEventsIterator.next();
        BioEvent newBioEvent = null;
        String name = unMangle(bEventElement.getAttributeValue(XMLTags.NameAttrTag));
        Element triggerElement = bEventElement.getChild(XMLTags.TriggerTag, vcNamespace);
        if (triggerElement != null && triggerElement.getText().length() > 0) {
            // 
            // read legacy VCell 5.3 style trigger and delay elements
            // 
            // <Trigger>(t>3.0)</Trigger>
            // <Delay UseValuesFromTriggerTime="true">3.0</Delay>     [optional]
            // 
            Expression triggerExpression = unMangleExpression(triggerElement.getText());
            // read <Delay>
            Expression delayDurationExpression = null;
            boolean useValuesFromTriggerTime = true;
            Element delayElement = bEventElement.getChild(XMLTags.DelayTag, vcNamespace);
            if (delayElement != null) {
                useValuesFromTriggerTime = Boolean.valueOf(delayElement.getAttributeValue(XMLTags.UseValuesFromTriggerTimeAttrTag)).booleanValue();
                delayDurationExpression = unMangleExpression((delayElement.getText()));
            }
            newBioEvent = new BioEvent(name, TriggerType.GeneralTrigger, useValuesFromTriggerTime, simContext);
            try {
                newBioEvent.setParameterValue(BioEventParameterType.GeneralTriggerFunction, triggerExpression);
                if (delayDurationExpression != null) {
                    newBioEvent.setParameterValue(BioEventParameterType.TriggerDelay, delayDurationExpression);
                }
            } catch (ExpressionBindingException | PropertyVetoException e) {
                e.printStackTrace();
                throw new XmlParseException("failed to read trigger or delay expressions in bioEvent " + name + ": " + e.getMessage(), e);
            }
        } else if (triggerElement != null && triggerElement.getText().length() == 0) {
            // 
            // read legacy first-pass VCell 5.4 style trigger and delay elements
            // 
            // <Trigger>
            // <TriggerParameters triggerClass="TriggerGeneral">
            // (t > 500.0)
            // </TriggerParameters>
            // </Trigger>
            // <Delay UseValuesFromTriggerTime="true">3.0</Delay>     [optional]
            // 
            final String TriggerParametersTag = "TriggerParameters";
            final String TriggerClassAttrTag = "triggerClass";
            final String TriggerClassAttrValue_TriggerGeneral = "TriggerGeneral";
            Element triggerParametersElement = triggerElement.getChild(TriggerParametersTag, vcNamespace);
            Expression triggerExpression = null;
            String triggerClass = triggerParametersElement.getAttributeValue(TriggerClassAttrTag);
            if (triggerClass.equals(TriggerClassAttrValue_TriggerGeneral)) {
                triggerExpression = unMangleExpression(triggerParametersElement.getText());
            } else {
                // not general trigger (just make it never happen, user will have to edit "t > -1")
                triggerExpression = Expression.relational(">", new Expression(simContext.getModel().getTIME(), simContext.getModel().getNameScope()), new Expression(-1.0));
            }
            // read <Delay>
            Expression delayDurationExpression = null;
            boolean useValuesFromTriggerTime = true;
            Element delayElement = bEventElement.getChild(XMLTags.DelayTag, vcNamespace);
            if (delayElement != null) {
                useValuesFromTriggerTime = Boolean.valueOf(delayElement.getAttributeValue(XMLTags.UseValuesFromTriggerTimeAttrTag)).booleanValue();
                delayDurationExpression = unMangleExpression((delayElement.getText()));
            }
            newBioEvent = new BioEvent(name, TriggerType.GeneralTrigger, useValuesFromTriggerTime, simContext);
            try {
                newBioEvent.setParameterValue(BioEventParameterType.GeneralTriggerFunction, triggerExpression);
                if (delayDurationExpression != null) {
                    newBioEvent.setParameterValue(BioEventParameterType.TriggerDelay, delayDurationExpression);
                }
            } catch (ExpressionBindingException | PropertyVetoException e) {
                e.printStackTrace();
                throw new XmlParseException("failed to read trigger or delay expressions in bioEvent " + name + ": " + e.getMessage(), e);
            }
        } else {
            // 
            // VCell 5.4 style bioevent parameters
            // 
            // 
            TriggerType triggerType = TriggerType.fromXmlName(bEventElement.getAttributeValue(XMLTags.BioEventTriggerTypeAttrTag));
            boolean bUseValuesFromTriggerTime = Boolean.parseBoolean(bEventElement.getAttributeValue(XMLTags.UseValuesFromTriggerTimeAttrTag));
            newBioEvent = new BioEvent(name, triggerType, bUseValuesFromTriggerTime, simContext);
            Iterator<Element> paramElementIter = bEventElement.getChildren(XMLTags.ParameterTag, vcNamespace).iterator();
            ArrayList<LocalParameter> parameters = new ArrayList<LocalParameter>();
            boolean bHasGeneralTriggerParam = false;
            while (paramElementIter.hasNext()) {
                Element paramElement = paramElementIter.next();
                // Get parameter attributes
                String paramName = paramElement.getAttributeValue(XMLTags.NameAttrTag);
                Expression exp = unMangleExpression(paramElement.getText());
                String roleStr = paramElement.getAttributeValue(XMLTags.ParamRoleAttrTag);
                BioEventParameterType parameterType = BioEventParameterType.fromRoleXmlName(roleStr);
                if (parameterType == BioEventParameterType.GeneralTriggerFunction) {
                    bHasGeneralTriggerParam = true;
                }
                VCUnitDefinition unit = simContext.getModel().getUnitSystem().getInstance_TBD();
                String unitSymbol = paramElement.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
                if (unitSymbol != null) {
                    unit = simContext.getModel().getUnitSystem().getInstance(unitSymbol);
                }
                parameters.add(newBioEvent.createNewParameter(paramName, parameterType, exp, unit));
            }
            if (!bHasGeneralTriggerParam) {
                parameters.add(newBioEvent.createNewParameter(BioEventParameterType.GeneralTriggerFunction.getDefaultName(), BioEventParameterType.GeneralTriggerFunction, // computed as needed
                null, simContext.getModel().getUnitSystem().getInstance_DIMENSIONLESS()));
            }
            try {
                newBioEvent.setParameters(parameters.toArray(new LocalParameter[0]));
            } catch (PropertyVetoException | ExpressionBindingException e) {
                e.printStackTrace();
                throw new XmlParseException("failed to read parameters in bioEvent " + name + ": " + e.getMessage(), e);
            }
        }
        ArrayList<BioEvent.EventAssignment> eventAssignmentList = new ArrayList<BioEvent.EventAssignment>();
        Iterator<Element> iter = bEventElement.getChildren(XMLTags.EventAssignmentTag, vcNamespace).iterator();
        while (iter.hasNext()) {
            Element eventAssignmentElement = iter.next();
            try {
                String varname = eventAssignmentElement.getAttributeValue(XMLTags.EventAssignmentVariableAttrTag);
                Expression assignExp = unMangleExpression(eventAssignmentElement.getText());
                SymbolTableEntry target = simContext.getEntry(varname);
                BioEvent.EventAssignment eventAssignment = newBioEvent.new EventAssignment(target, assignExp);
                eventAssignmentList.add(eventAssignment);
            } catch (ExpressionException e) {
                e.printStackTrace(System.out);
                throw new XmlParseException(e);
            }
        }
        try {
            newBioEvent.setEventAssignmentsList(eventAssignmentList);
        } catch (PropertyVetoException e1) {
            e1.printStackTrace(System.out);
            throw new XmlParseException(e1);
        }
        try {
            newBioEvent.bind();
        } catch (ExpressionBindingException e) {
            e.printStackTrace(System.out);
            throw new XmlParseException(e);
        }
        bioEventsVector.add(newBioEvent);
    }
    return ((BioEvent[]) BeanUtils.getArray(bioEventsVector, BioEvent.class));
}
Also used : TriggerType(cbit.vcell.mapping.BioEvent.TriggerType) EventAssignment(cbit.vcell.math.Event.EventAssignment) Element(org.jdom.Element) ArrayList(java.util.ArrayList) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) ExpressionException(cbit.vcell.parser.ExpressionException) PropertyVetoException(java.beans.PropertyVetoException) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) Expression(cbit.vcell.parser.Expression) BioEventParameterType(cbit.vcell.mapping.BioEvent.BioEventParameterType) Iterator(java.util.Iterator) BioEvent(cbit.vcell.mapping.BioEvent) Vector(java.util.Vector)

Example 27 with PropertyVetoException

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

the class XmlReader method getSimulation.

/**
 * This method returns a Simulation object from a XML element.
 * Creation date: (4/26/2001 12:14:30 PM)
 * @return cbit.vcell.solver.Simulation
 * @param param org.jdom.Element
 * @exception cbit.vcell.xml.XmlParseException The exception description.
 */
Simulation getSimulation(Element param, MathDescription mathDesc) throws XmlParseException {
    // retrive metadata (if any)
    SimulationVersion simulationVersion = getSimulationVersion(param.getChild(XMLTags.VersionTag, vcNamespace));
    // create new simulation
    Simulation simulation = null;
    if (simulationVersion != null) {
        simulation = new Simulation(simulationVersion, mathDesc);
    } else {
        simulation = new Simulation(mathDesc);
    }
    // set attributes
    String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
    try {
        simulation.setName(name);
        // String annotation = param.getAttributeValue(XMLTags.AnnotationAttrTag);
        // if (annotation!=null) {
        // simulation.setDescription(unMangle(annotation));
        // }
        // Add Annotation
        String annotationText = param.getChildText(XMLTags.AnnotationTag, vcNamespace);
        if (annotationText != null && annotationText.length() > 0) {
            simulation.setDescription(unMangle(annotationText));
        }
    } catch (java.beans.PropertyVetoException e) {
        throw new XmlParseException(e);
    }
    // Retrieve MathOverrides
    simulation.setMathOverrides(getMathOverrides(param.getChild(XMLTags.MathOverridesTag, vcNamespace), simulation));
    // Retrieve SolverTaskDescription
    try {
        simulation.setSolverTaskDescription(getSolverTaskDescription(param.getChild(XMLTags.SolverTaskDescriptionTag, vcNamespace), simulation));
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException("A PropertyVetoException was fired when setting the SolverTaskDescroiption object to the Simulation object " + name, e);
    }
    Element dataProcessingInstructionsElement = param.getChild(XMLTags.DataProcessingInstructionsTag, vcNamespace);
    if (dataProcessingInstructionsElement != null) {
        String scriptName = dataProcessingInstructionsElement.getAttributeValue(XMLTags.DataProcessingScriptNameAttrTag);
        String scriptInput = dataProcessingInstructionsElement.getText();
        simulation.setDataProcessingInstructions(new DataProcessingInstructions(scriptName, scriptInput));
    }
    // Retrieve MeshEspecification (if any)
    Element tempElement = param.getChild(XMLTags.MeshSpecTag, vcNamespace);
    if (tempElement != null) {
        try {
            simulation.setMeshSpecification(getMeshSpecification(tempElement, mathDesc.getGeometry()));
        } catch (java.beans.PropertyVetoException e) {
            e.printStackTrace();
            throw new XmlParseException("A ProperyVetoException was fired when setting the MeshSpecification to a new Simulation!", e);
        }
    }
    return simulation;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) SimulationVersion(org.vcell.util.document.SimulationVersion) Simulation(cbit.vcell.solver.Simulation) DataProcessingInstructions(cbit.vcell.solver.DataProcessingInstructions) Element(org.jdom.Element)

Example 28 with PropertyVetoException

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

the class XmlReader method readParameters.

private void readParameters(List<Element> parameterElements, ParameterContext parameterContext, HashMap<String, ParameterRoleEnum> roleHash, ParameterRoleEnum userDefinedRole, HashSet<String> xmlRolesTagsToIgnore, Model model) throws XmlParseException {
    String contextName = parameterContext.getNameScope().getName();
    try {
        // 
        // prepopulate varHash with reserved symbols
        // 
        VariableHash varHash = new VariableHash();
        addResevedSymbols(varHash, model);
        // 
        for (Element xmlParam : parameterElements) {
            String parsedParamName = unMangle(xmlParam.getAttributeValue(XMLTags.NameAttrTag));
            String parsedRoleString = xmlParam.getAttributeValue(XMLTags.ParamRoleAttrTag);
            String parsedExpressionString = xmlParam.getText();
            // 
            if (xmlRolesTagsToIgnore.contains(parsedRoleString)) {
                varHash.removeVariable(parsedParamName);
                continue;
            }
            Expression paramExp = null;
            if (parsedExpressionString.trim().length() > 0) {
                paramExp = unMangleExpression(parsedExpressionString);
            }
            if (varHash.getVariable(parsedParamName) == null) {
                Domain domain = null;
                varHash.addVariable(new Function(parsedParamName, paramExp, domain));
            } else {
                if (model.getReservedSymbolByName(parsedParamName) != null) {
                    varHash.removeVariable(parsedParamName);
                    Domain domain = null;
                    varHash.addVariable(new Function(parsedParamName, paramExp, domain));
                }
            }
            // 
            // get the parameter for this xml role string
            // 
            ParameterRoleEnum paramRole = roleHash.get(parsedRoleString);
            if (paramRole == null) {
                throw new XmlParseException("parameter '" + parsedParamName + "' has unexpected role '" + parsedRoleString + "' in '" + contextName + "'");
            }
            // 
            if (paramRole != userDefinedRole) {
                LocalParameter paramWithSameRole = parameterContext.getLocalParameterFromRole(paramRole);
                if (paramWithSameRole == null) {
                    throw new XmlParseException("can't find parameter with role '" + parsedRoleString + "' in '" + contextName + "'");
                }
                // 
                if (!paramWithSameRole.getName().equals(parsedParamName)) {
                    // 
                    // first rename other parameters with same name
                    // 
                    LocalParameter paramWithSameNameButDifferentRole = parameterContext.getLocalParameterFromName(parsedParamName);
                    if (paramWithSameNameButDifferentRole != null) {
                        // 
                        // find available name
                        // 
                        int n = 0;
                        String newName = parsedParamName + "_" + n++;
                        while (parameterContext.getEntry(newName) != null) {
                            newName = parsedParamName + "_" + n++;
                        }
                        parameterContext.renameLocalParameter(parsedParamName, newName);
                    }
                    // 
                    // then rename parameter with correct role
                    // 
                    parameterContext.renameLocalParameter(paramWithSameRole.getName(), parsedParamName);
                }
            }
        }
        // 
        // create unresolved parameters for all unresolved symbols
        // 
        String unresolvedSymbol = varHash.getFirstUnresolvedSymbol();
        while (unresolvedSymbol != null) {
            try {
                Domain domain = null;
                // will turn into an UnresolvedParameter.
                varHash.addVariable(new Function(unresolvedSymbol, new Expression(0.0), domain));
            } catch (MathException e) {
                e.printStackTrace(System.out);
                throw new XmlParseException(e.getMessage());
            }
            parameterContext.addUnresolvedParameter(unresolvedSymbol);
            unresolvedSymbol = varHash.getFirstUnresolvedSymbol();
        }
        // 
        // in topological order, add parameters to model (getting units also).
        // note that all pre-defined parameters already have the correct names
        // here we set expressions on pre-defined parameters and add user-defined parameters
        // 
        Variable[] sortedVariables = varHash.getTopologicallyReorderedVariables();
        ModelUnitSystem modelUnitSystem = model.getUnitSystem();
        for (int i = sortedVariables.length - 1; i >= 0; i--) {
            if (sortedVariables[i] instanceof Function) {
                Function paramFunction = (Function) sortedVariables[i];
                Element xmlParam = null;
                for (int j = 0; j < parameterElements.size(); j++) {
                    Element tempParam = (Element) parameterElements.get(j);
                    if (paramFunction.getName().equals(unMangle(tempParam.getAttributeValue(XMLTags.NameAttrTag)))) {
                        xmlParam = tempParam;
                        break;
                    }
                }
                if (xmlParam == null) {
                    // must have been an unresolved parameter
                    continue;
                }
                String symbol = xmlParam.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
                VCUnitDefinition unit = null;
                if (symbol != null) {
                    unit = modelUnitSystem.getInstance(symbol);
                }
                LocalParameter tempParam = parameterContext.getLocalParameterFromName(paramFunction.getName());
                if (tempParam == null) {
                    tempParam = parameterContext.addLocalParameter(paramFunction.getName(), new Expression(0.0), userDefinedRole, unit, userDefinedRole.getDescription());
                    parameterContext.setParameterValue(tempParam, paramFunction.getExpression(), true);
                } else {
                    if (tempParam.getExpression() != null) {
                        // if the expression is null, it should remain null.
                        parameterContext.setParameterValue(tempParam, paramFunction.getExpression(), true);
                    }
                    tempParam.setUnitDefinition(unit);
                }
            }
        }
    } catch (PropertyVetoException | ExpressionException | MathException e) {
        e.printStackTrace(System.out);
        throw new XmlParseException("Exception while setting parameters for '" + contextName + "': " + e.getMessage(), e);
    }
}
Also used : FilamentVariable(cbit.vcell.math.FilamentVariable) OutsideVariable(cbit.vcell.math.OutsideVariable) StochVolVariable(cbit.vcell.math.StochVolVariable) RandomVariable(cbit.vcell.math.RandomVariable) VolumeRandomVariable(cbit.vcell.math.VolumeRandomVariable) VolumeParticleVariable(cbit.vcell.math.VolumeParticleVariable) VolumeRegionVariable(cbit.vcell.math.VolumeRegionVariable) InsideVariable(cbit.vcell.math.InsideVariable) VolVariable(cbit.vcell.math.VolVariable) MembraneRegionVariable(cbit.vcell.math.MembraneRegionVariable) PointVariable(cbit.vcell.math.PointVariable) MembraneRandomVariable(cbit.vcell.math.MembraneRandomVariable) MembraneParticleVariable(cbit.vcell.math.MembraneParticleVariable) ParticleVariable(cbit.vcell.math.ParticleVariable) MemVariable(cbit.vcell.math.MemVariable) FilamentRegionVariable(cbit.vcell.math.FilamentRegionVariable) Variable(cbit.vcell.math.Variable) VariableHash(cbit.vcell.math.VariableHash) Element(org.jdom.Element) ExpressionException(cbit.vcell.parser.ExpressionException) LocalParameter(cbit.vcell.mapping.ParameterContext.LocalParameter) PropertyVetoException(java.beans.PropertyVetoException) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction) Function(cbit.vcell.math.Function) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) Expression(cbit.vcell.parser.Expression) MathException(cbit.vcell.math.MathException) MembraneSubDomain(cbit.vcell.math.MembraneSubDomain) CompartmentSubDomain(cbit.vcell.math.CompartmentSubDomain) FilamentSubDomain(cbit.vcell.math.FilamentSubDomain) PointSubDomain(cbit.vcell.math.PointSubDomain) Domain(cbit.vcell.math.Variable.Domain) ParameterRoleEnum(cbit.vcell.mapping.ParameterContext.ParameterRoleEnum) ModelUnitSystem(cbit.vcell.model.ModelUnitSystem)

Example 29 with PropertyVetoException

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

the class XmlReader method getRbmReactionRule.

private ReactionRule getRbmReactionRule(Element reactionRuleElement, Model newModel) throws XmlParseException {
    String n = reactionRuleElement.getAttributeValue(XMLTags.NameAttrTag);
    if (n == null || n.isEmpty()) {
        System.out.println("XMLReader: getRbmReactionRule: name is missing.");
        return null;
    }
    try {
        boolean reversible = Boolean.valueOf(reactionRuleElement.getAttributeValue(XMLTags.RbmReactionRuleReversibleTag));
        // get 1st structure if attribute missing
        String structureName = reactionRuleElement.getAttributeValue(XMLTags.StructureAttrTag, newModel.getStructures()[0].getName());
        Structure structure = newModel.getStructure(structureName);
        ReactionRule reactionRule = new ReactionRule(newModel, n, structure, reversible);
        // we ignore this, name and label are the same thing for now
        String reactionRuleLabel = reactionRuleElement.getAttributeValue(XMLTags.RbmReactionRuleLabelTag);
        // 
        // old style kinetics placed parameter values as attributes
        // look for attributes named ("MassActionKf","MassActionKr","MichaelisMentenKcat","MichaelisMentenKm","SaturableKs","SaturableVmax")
        String[] oldKineticsAttributes = new String[] { XMLTags.RbmMassActionKfAttrTag_DEPRECATED, XMLTags.RbmMassActionKrAttrTag_DEPRECATED, XMLTags.RbmMichaelisMentenKcatAttrTag_DEPRECATED, XMLTags.RbmMichaelisMentenKmAttrTag_DEPRECATED, XMLTags.RbmSaturableKsAttrTag_DEPRECATED, XMLTags.RbmSaturableVmaxAttrTag_DEPRECATED };
        boolean bOldKineticsFound = false;
        for (String oldKineticsAttribute : oldKineticsAttributes) {
            if (reactionRuleElement.getAttribute(oldKineticsAttribute) != null) {
                bOldKineticsFound = true;
            }
        }
        if (bOldKineticsFound) {
            readOldRbmKineticsAttributes(reactionRuleElement, reactionRule);
        } else {
            Element kineticsElement = reactionRuleElement.getChild(XMLTags.KineticsTag, vcNamespace);
            if (kineticsElement != null) {
                String kineticLawTypeString = kineticsElement.getAttributeValue(XMLTags.KineticsTypeAttrTag);
                RbmKineticLaw.RateLawType rateLawType = null;
                if (XMLTags.RbmKineticTypeMassAction.equals(kineticLawTypeString)) {
                    rateLawType = RateLawType.MassAction;
                } else if (XMLTags.RbmKineticTypeMichaelisMenten.equals(kineticLawTypeString)) {
                    rateLawType = RateLawType.MichaelisMenten;
                } else if (XMLTags.RbmKineticTypeSaturable.equals(kineticLawTypeString)) {
                    rateLawType = RateLawType.Saturable;
                } else {
                    throw new RuntimeException("unexpected rate law type " + kineticLawTypeString);
                }
                reactionRule.setKineticLaw(new RbmKineticLaw(reactionRule, rateLawType));
                List<Element> parameterElements = kineticsElement.getChildren(XMLTags.ParameterTag, vcNamespace);
                HashMap<String, ParameterRoleEnum> roleHash = new HashMap<String, ParameterContext.ParameterRoleEnum>();
                roleHash.put(XMLTags.RbmMassActionKfRole, RbmKineticLawParameterType.MassActionForwardRate);
                roleHash.put(XMLTags.RbmMassActionKrRole, RbmKineticLawParameterType.MassActionReverseRate);
                roleHash.put(XMLTags.RbmMichaelisMentenKcatRole, RbmKineticLawParameterType.MichaelisMentenKcat);
                roleHash.put(XMLTags.RbmMichaelisMentenKmRole, RbmKineticLawParameterType.MichaelisMentenKm);
                roleHash.put(XMLTags.RbmSaturableVmaxRole, RbmKineticLawParameterType.SaturableVmax);
                roleHash.put(XMLTags.RbmSaturableKsRole, RbmKineticLawParameterType.SaturableKs);
                roleHash.put(XMLTags.RbmUserDefinedRole, RbmKineticLawParameterType.UserDefined);
                HashSet<String> xmlRolesToIgnore = new HashSet<String>();
                xmlRolesToIgnore.add(XMLTags.RbmRuleRateRole);
                ParameterContext parameterContext = reactionRule.getKineticLaw().getParameterContext();
                readParameters(parameterElements, parameterContext, roleHash, RbmKineticLawParameterType.UserDefined, xmlRolesToIgnore, newModel);
            }
        }
        Element e1 = reactionRuleElement.getChild(XMLTags.RbmReactantPatternsListTag, vcNamespace);
        getRbmReactantPatternsList(e1, reactionRule, newModel);
        Element e2 = reactionRuleElement.getChild(XMLTags.RbmProductPatternsListTag, vcNamespace);
        getRbmProductPatternsList(e2, reactionRule, newModel);
        reactionRule.checkMatchConsistency();
        return reactionRule;
    } catch (PropertyVetoException | ExpressionException ex) {
        ex.printStackTrace(System.out);
        throw new RuntimeException("failed to parse kinetics for reaction rule '" + n + "': " + ex.getMessage(), ex);
    }
}
Also used : ReactionRule(cbit.vcell.model.ReactionRule) HashMap(java.util.HashMap) Element(org.jdom.Element) RbmKineticLaw(cbit.vcell.model.RbmKineticLaw) ExpressionException(cbit.vcell.parser.ExpressionException) PropertyVetoException(java.beans.PropertyVetoException) ParameterContext(cbit.vcell.mapping.ParameterContext) RateLawType(cbit.vcell.model.RbmKineticLaw.RateLawType) Structure(cbit.vcell.model.Structure) ParameterRoleEnum(cbit.vcell.mapping.ParameterContext.ParameterRoleEnum) HashSet(java.util.HashSet)

Example 30 with PropertyVetoException

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

the class XmlReader method getReactionSpec.

/**
 * Insert the method's description here.
 * Creation date: (4/26/2001 4:13:26 PM)
 * @return cbit.vcell.mapping.ReactionSpec
 * @param param org.jdom.Element
 */
private ReactionSpec getReactionSpec(Element param, SimulationContext simulationContext) throws XmlParseException {
    ReactionSpec reactionspec = null;
    // retrieve the reactionstep reference
    String reactionstepname = unMangle(param.getAttributeValue(XMLTags.ReactionStepRefAttrTag));
    ReactionStep reactionstepref = (ReactionStep) simulationContext.getModel().getReactionStep(reactionstepname);
    if (reactionstepref == null) {
        throw new XmlParseException("The reference to the ReactionStep " + reactionstepname + ", could not be resolved!");
    }
    // Create the new SpeciesContextSpec
    reactionspec = new ReactionSpec(reactionstepref, simulationContext);
    // set the reactionMapping value
    String temp = param.getAttributeValue(XMLTags.ReactionMappingAttrTag);
    try {
        reactionspec.setReactionMapping(temp);
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException("A PropertyVetoException was fired when setting the reactionMapping value " + temp + ", in a reactionSpec object!", e);
    }
    return reactionspec;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ReactionSpec(cbit.vcell.mapping.ReactionSpec) ReactionStep(cbit.vcell.model.ReactionStep)

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