Search in sources :

Example 81 with PropertyVetoException

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

the class ServerDocumentManager method getBioModelUnresolved.

/**
 * Insert the method's description here.
 * Creation date: (11/14/00 4:02:44 PM)
 * @return cbit.vcell.biomodel.BioModel
 * @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
 */
// 
// this returns a BioModel that contains multiple instances of objects.
// 
public String getBioModelUnresolved(QueryHashtable dbc, User user, KeyValue bioModelKey) throws DataAccessException, XmlParseException, java.sql.SQLException {
    // 
    // get meta data associated with BioModel
    // 
    BioModelMetaData bioModelMetaData = dbServer.getDBTopLevel().getBioModelMetaData(dbc, user, bioModelKey);
    // 
    // get list of appropriate child components
    // 
    KeyValue modelKey = bioModelMetaData.getModelKey();
    KeyValue[] simKeys = getKeyArrayFromEnumeration(bioModelMetaData.getSimulationKeys());
    KeyValue[] scKeys = getKeyArrayFromEnumeration(bioModelMetaData.getSimulationContextKeys());
    Model model = dbServer.getDBTopLevel().getModel(dbc, user, modelKey);
    Simulation[] simArray = new Simulation[simKeys.length];
    for (int i = 0; i < simKeys.length; i++) {
        Simulation sim = dbServer.getDBTopLevel().getSimulation(dbc, user, simKeys[i]);
        // 
        try {
            simArray[i] = (Simulation) BeanUtils.cloneSerializable(sim);
        } catch (Throwable e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("exception cloning Simulation: " + e.getMessage());
        }
    }
    SimulationContext[] scArray = new SimulationContext[scKeys.length];
    for (int i = 0; i < scKeys.length; i++) {
        SimulationContext sc = dbServer.getDBTopLevel().getSimulationContext(dbc, user, scKeys[i]);
        // 
        try {
            scArray[i] = (SimulationContext) BeanUtils.cloneSerializable(sc);
            scArray[i].getModel().refreshDependencies();
            scArray[i].refreshDependencies();
            scArray[i].setModel(model);
        } catch (Throwable e) {
            e.printStackTrace(System.out);
            throw new RuntimeException("exception cloning Application: " + e.getMessage());
        }
        if (!scArray[i].getModel().getKey().compareEqual(modelKey)) {
            // throw new DataAccessException("simulationContext("+scKeys[i]+").model = "+scArray[i].getModel().getKey()+", BioModel.model = "+modelKey);
            System.out.println("simulationContext(" + scKeys[i] + ").model = " + scArray[i].getModel().getKey() + ", BioModel.model = " + modelKey);
        }
    }
    // 
    // create new BioModel according to loaded BioModelMetaData
    // 
    BioModel newBioModel = new BioModel(bioModelMetaData.getVersion());
    try {
        // newBioModel.setMIRIAMAnnotation(bioModelMetaData.getMIRIAMAnnotation());
        System.err.println("< < < < NEED TO GET VCMETADATA FROM METADATA TABLE ... METADATA IS EMPTY. > > > >");
        newBioModel.setModel(model);
        newBioModel.setSimulationContexts(scArray);
        // 
        for (int i = 0; i < simArray.length; i++) {
            boolean bMathFound = false;
            for (int j = 0; j < scArray.length; j++) {
                if (simArray[i].getMathDescription().getVersion().getVersionKey().compareEqual(scArray[j].getMathDescription().getVersion().getVersionKey())) {
                    simArray[i].setMathDescription(scArray[j].getMathDescription());
                    bMathFound = true;
                    break;
                }
            }
            if (!bMathFound) {
                System.out.println("<<<<WARNING>>>>> ClientDocumentManager.getBioModel(), Simulation " + simArray[i].getName() + " is orphaned, Math(" + simArray[i].getMathDescription().getName() + ") not found in Applications");
                simArray = (Simulation[]) BeanUtils.removeElement(simArray, simArray[i]);
                i--;
            }
        }
        newBioModel.setSimulations(simArray);
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace(System.out);
        throw new DataAccessException("PropertyVetoException caught " + e.getMessage());
    }
    // 
    // The BioModel is no longer cloned because the reference to this BioModel is no longer returned to the calling method.
    // the only possible side effect is the "BioModel:refreshDependencies()" method call.
    // this will reconnect internal listeners and other transient fields, and is not going to harm the cache integrity.
    // 
    // //
    // // clone BioModel (so that children can't be corrupted in the cache)
    // //
    // try {
    // newBioModel = (BioModel)BeanUtils.cloneSerializable(newBioModel);
    // }catch (Exception e){
    // e.printStackTrace(System.out);
    // throw new DataAccessException("BioModel clone failed: "+e.getMessage());
    // }
    newBioModel.refreshDependencies();
    // 
    return cbit.vcell.xml.XmlHelper.bioModelToXML(newBioModel);
}
Also used : KeyValue(org.vcell.util.document.KeyValue) BioModelMetaData(cbit.vcell.biomodel.BioModelMetaData) SimulationContext(cbit.vcell.mapping.SimulationContext) PropertyVetoException(java.beans.PropertyVetoException) Simulation(cbit.vcell.solver.Simulation) BioModel(cbit.vcell.biomodel.BioModel) MathModel(cbit.vcell.mathmodel.MathModel) BioModel(cbit.vcell.biomodel.BioModel) Model(cbit.vcell.model.Model) DataAccessException(org.vcell.util.DataAccessException)

Example 82 with PropertyVetoException

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

the class SimulationContextDbDriver method getSimulationContextSQL.

/**
 * getModel method comment.
 */
private SimulationContext getSimulationContextSQL(QueryHashtable dbc, Connection con, User user, KeyValue simContextKey) throws /*, ReactStepDbDriver reactStepDB*/
SQLException, DataAccessException, IllegalMappingException, PropertyVetoException {
    SimulationContext simContext = null;
    String sql;
    Field[] f = { new cbit.sql.StarField(simContextTable), userTable.userid };
    Table[] t = { simContextTable, userTable };
    String condition = simContextTable.id.getQualifiedColName() + " = " + simContextKey + " AND " + simContextTable.ownerRef.getQualifiedColName() + " = " + userTable.id.getQualifiedColName();
    sql = DatabasePolicySQL.enforceOwnershipSelect(user, f, t, (OuterJoin) null, condition, null, dbSyntax);
    // System.out.println(sql);
    Statement stmt = con.createStatement();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        if (rset.next()) {
            simContext = simContextTable.getSimContext(dbc, con, user, rset, geomDB, modelDB, mathDescDB);
        } else {
            throw new ObjectNotFoundException("SimulationContext id=" + simContextKey + " not found for user '" + user + "'");
        }
    } finally {
        stmt.close();
    }
    DataSymbolTable.table.populateDataSymbols(con, simContextKey, simContext.getDataContext(), user, simContext.getModel().getUnitSystem());
    ArrayList<AnnotatedFunction> outputFunctionList = ApplicationMathTable.table.getOutputFunctionsSimcontext(con, simContextKey, dbSyntax);
    if (outputFunctionList != null) {
        OutputFunctionContext outputFnContext = simContext.getOutputFunctionContext();
        outputFnContext.setOutputFunctions(outputFunctionList);
    }
    SimContextTable.table.readAppComponents(con, simContext, dbSyntax);
    assignStimuliSQL(con, simContextKey, simContext);
    assignStructureMappingsSQL(dbc, con, simContextKey, simContext);
    assignSpeciesContextSpecsSQL(con, simContextKey, simContext);
    assignReactionSpecsSQL(con, simContextKey, simContext);
    for (GeometryClass gc : simContext.getGeometry().getGeometryClasses()) {
        try {
            StructureSizeSolver.updateUnitStructureSizes(simContext, gc);
        } catch (Exception e) {
            e.printStackTrace(System.out);
        }
    }
    simContext.getGeometryContext().enforceHierarchicalBoundaryConditions(simContext.getModel().getStructureTopology());
    simContext.getModel().refreshDependencies();
    assignAnalysisTasksSQL(con, simContextKey, simContext);
    // really needed to calculate MembraneMapping parameters that are not stored (inside/outside flux correction factors).
    simContext.refreshDependencies();
    return simContext;
}
Also used : GeometryClass(cbit.vcell.geometry.GeometryClass) Table(cbit.sql.Table) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) SimulationContext(cbit.vcell.mapping.SimulationContext) PropertyVetoException(java.beans.PropertyVetoException) DependencyException(org.vcell.util.DependencyException) RecordChangedException(cbit.sql.RecordChangedException) ExpressionBindingException(cbit.vcell.parser.ExpressionBindingException) PermissionException(org.vcell.util.PermissionException) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) IllegalMappingException(cbit.vcell.mapping.IllegalMappingException) SQLException(java.sql.SQLException) DataAccessException(org.vcell.util.DataAccessException) ExpressionException(cbit.vcell.parser.ExpressionException) MappingException(cbit.vcell.mapping.MappingException) MathException(cbit.vcell.math.MathException) OutputFunctionContext(cbit.vcell.solver.OutputFunctionContext) Field(cbit.sql.Field) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) OuterJoin(cbit.vcell.modeldb.DatabasePolicySQL.OuterJoin) ResultSet(java.sql.ResultSet) AnnotatedFunction(cbit.vcell.solver.AnnotatedFunction)

Example 83 with PropertyVetoException

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

the class SimulationContextDbDriver method assignAnalysisTasksSQL.

/**
 * This method was created in VisualAge.
 * @param simContext cbit.vcell.mapping.SimulationContext
 */
private void assignAnalysisTasksSQL(Connection con, KeyValue simContextKey, SimulationContext simContext) throws SQLException, DataAccessException {
    String sql;
    AnalysisTaskXMLTable analysisTaskTable = AnalysisTaskXMLTable.table;
    sql = " SELECT " + analysisTaskTable.analysisTaskXML.toString() + " FROM " + analysisTaskTable.getTableName() + " WHERE " + analysisTaskTable.simContextRef + " = " + simContextKey + " ORDER BY " + // order-by to maintain order ... not really necessary
    analysisTaskTable.insertDate;
    Statement stmt = con.createStatement();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        while (rset.next()) {
            String analysisXML = (String) getLOB(rset, analysisTaskTable.analysisTaskXML, dbSyntax);
            org.jdom.Element rootElement = XmlUtil.stringToXML(analysisXML, null).getRootElement();
            cbit.vcell.modelopt.ParameterEstimationTask parameterEstimationTask = cbit.vcell.modelopt.ParameterEstimationTaskXMLPersistence.getParameterEstimationTask(rootElement, simContext);
            simContext.addAnalysisTask(parameterEstimationTask);
        }
    } catch (MathException | MappingException | PropertyVetoException | ExpressionException e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException(e.getMessage());
    } finally {
        if (stmt != null) {
            stmt.close();
        }
    }
}
Also used : PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) ExpressionException(cbit.vcell.parser.ExpressionException) IllegalMappingException(cbit.vcell.mapping.IllegalMappingException) MappingException(cbit.vcell.mapping.MappingException) PropertyVetoException(java.beans.PropertyVetoException) MathException(cbit.vcell.math.MathException) ResultSet(java.sql.ResultSet) DataAccessException(org.vcell.util.DataAccessException)

Example 84 with PropertyVetoException

use of java.beans.PropertyVetoException in project Payara by payara.

the class JmsHostWrapper method deepCopy.

public ConfigBeanProxy deepCopy(ConfigBeanProxy proxy) {
    JmsHostWrapper clone = new JmsHostWrapper();
    if (!(proxy instanceof JmsHost))
        return null;
    JmsHost host = (JmsHost) proxy;
    try {
        clone.setHost(host.getHost());
        clone.setPort(host.getPort());
        clone.setName(host.getName());
        clone.setAdminPassword(host.getAdminPassword());
        clone.setAdminUserName(host.getAdminUserName());
    } catch (PropertyVetoException e) {
    // todo : handle this exception
    }
    return null;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) JmsHost(com.sun.enterprise.connectors.jms.config.JmsHost)

Example 85 with PropertyVetoException

use of java.beans.PropertyVetoException in project Payara by payara.

the class SetEnvironmentWarningConfigurationCommand method execute.

@Override
public void execute(AdminCommandContext acc) {
    Config config = targetUtil.getConfig(target);
    ActionReport actionReport = acc.getActionReport();
    EnvironmentWarningConfiguration environmentWarningConfiguration = config.getExtensionByType(EnvironmentWarningConfiguration.class);
    if (environmentWarningConfiguration != null) {
        try {
            ConfigSupport.apply(new SingleConfigCode<EnvironmentWarningConfiguration>() {

                @Override
                public Object run(EnvironmentWarningConfiguration config) throws PropertyVetoException {
                    if (enabled != null) {
                        config.setEnabled(enabled);
                    }
                    if (message != null) {
                        config.setMessage(message);
                    }
                    if (backgroundColour != null) {
                        if (backgroundColour.matches("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$")) {
                            config.setBackgroundColour(backgroundColour);
                        } else {
                            throw new PropertyVetoException("Invalid data for background colour, must be a hex value.", new PropertyChangeEvent(config, "backgroundColour", config.getBackgroundColour(), backgroundColour));
                        }
                    }
                    if (textColour != null) {
                        if (textColour.matches("^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$")) {
                            config.setTextColour(textColour);
                        } else {
                            throw new PropertyVetoException("Invalid data for text colour, must be a hex value.", new PropertyChangeEvent(config, "textColour", config.getTextColour(), textColour));
                        }
                    }
                    return null;
                }
            }, environmentWarningConfiguration);
        } catch (TransactionFailure ex) {
            // Set failure
            actionReport.failure(Logger.getLogger(SetEnvironmentWarningConfigurationCommand.class.getName()), "Failed to update configuration", ex);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) PropertyChangeEvent(java.beans.PropertyChangeEvent) Config(com.sun.enterprise.config.serverbeans.Config) ActionReport(org.glassfish.api.ActionReport) EnvironmentWarningConfiguration(fish.payara.appserver.environment.warning.config.EnvironmentWarningConfiguration)

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