Search in sources :

Example 1 with ReactionStepInfo

use of cbit.vcell.model.ReactionStepInfo in project vcell by virtualcell.

the class DictionaryDbDriver method getReactionStepInfos.

/**
 * Insert the method's description here.
 * Creation date: (4/18/2003 10:23:37 AM)
 */
public ReactionStepInfo[] getReactionStepInfos(Connection con, User user, KeyValue[] reactionStepKeys) throws SQLException {
    String sql = ReactStepTable.table.getSQLReactionStepInfosQuery(reactionStepKeys, user, dbSyntax);
    Statement stmt = con.createStatement();
    Vector<ReactionStepInfo> reactionStepInfoList = new Vector<ReactionStepInfo>();
    try {
        ResultSet rset = stmt.executeQuery(sql);
        while (rset.next()) {
            java.math.BigDecimal rxID = rset.getBigDecimal(ReactStepTable.table.id.toString());
            KeyValue rxKey = new KeyValue(rxID);
            String modelOwnerName = rset.getString(UserTable.table.userid.toString());
            java.math.BigDecimal modelOwnerID = rset.getBigDecimal(BioModelTable.table.ownerRef.toString());
            User owner = new User(modelOwnerName, new KeyValue(modelOwnerID));
            String bioModelName = rset.getString(ReactStepTable.RXIDDN_BIOMODEL_NAME_INDEX);
            String rxName = rset.getString(ReactStepTable.RXIDDN_REACTSTEP_NAME_INDEX);
            java.sql.Date bioModelDate = rset.getDate(BioModelTable.table.versionDate.toString());
            String structType = rset.getString(StructTable.table.structType.getUnqualifiedColName());
            ReactionStepInfo reactionStepInfo = new ReactionStepInfo(rxKey, owner, bioModelName, rxName, bioModelDate, structType);
            reactionStepInfoList.add(reactionStepInfo);
        }
    } finally {
        // Release resources include resultset
        stmt.close();
    }
    if (reactionStepInfoList.size() == 0) {
        return null;
    }
    return (ReactionStepInfo[]) BeanUtils.getArray(reactionStepInfoList, ReactionStepInfo.class);
}
Also used : BigDecimal(java.math.BigDecimal) KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) Statement(java.sql.Statement) ReactionStepInfo(cbit.vcell.model.ReactionStepInfo) ResultSet(java.sql.ResultSet) Vector(java.util.Vector)

Example 2 with ReactionStepInfo

use of cbit.vcell.model.ReactionStepInfo in project vcell by virtualcell.

the class DBReactionWizardPanel method configureRXParameterList.

/**
 * Comment
 */
private void configureRXParameterList(javax.swing.event.ListSelectionEvent listSelectionEvent) {
    // 
    final DefaultListModel<MapStringToObject> pndlm = (DefaultListModel<MapStringToObject>) getParameterNamesJList().getModel();
    // 
    if (lastReactionSelection == null || !lastReactionSelection.equals(getReactionsJList().getSelectedValue())) {
        lastReactionSelection = getReactionsJList().getSelectedValue();
        setReactionStep(null);
        setReactionDescription(null);
        // 
        pndlm.removeAllElements();
        // 
        if (getReactionsJList().getSelectedValue() instanceof String) {
            // User Reactions
            Vector<String> rxIDV = mapRXStringtoRXIDs.get(getReactionsJList().getSelectedValue());
            // String[] rxIDArr = (String[])rxIDV.toArray(new String[rxIDV.size()]);
            final KeyValue[] rxKeys = new KeyValue[rxIDV.size()];
            for (int i = 0; i < rxKeys.length; i++) {
                rxKeys[i] = new KeyValue(rxIDV.elementAt(i));
            }
            AsynchClientTask task1 = new AsynchClientTask("getting user reaction step infos", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                public void run(Hashtable<String, Object> hashTable) throws Exception {
                    ReactionStepInfo[] reactionStepInfos = getDocumentManager().getUserReactionStepInfos(rxKeys);
                    hashTable.put("reactionStepInfos", reactionStepInfos);
                }
            };
            AsynchClientTask task2 = new AsynchClientTask("getting user reaction step infos", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                public void run(Hashtable<String, Object> hashTable) {
                    ReactionStepInfo[] reactionStepInfos = (ReactionStepInfo[]) hashTable.get("reactionStepInfos");
                    for (int i = 0; reactionStepInfos != null && i < reactionStepInfos.length; i++) {
                        String structTypeName = (reactionStepInfos[i].getStructType().equals("feature") ? Structure.TYPE_NAME_FEATURE : (reactionStepInfos[i].getStructType().equals("membrane") ? Structure.TYPE_NAME_MEMBRANE : reactionStepInfos[i].getStructType()));
                        String descriptiveText = structTypeName + " " + reactionStepInfos[i].getOwner().getName() + " - " + "  " + reactionStepInfos[i].getBioModelName() + "  " + "(" + reactionStepInfos[i].getReactionName() + ")" + " " + reactionStepInfos[i].getBioModelVersionDate();
                        pndlm.addElement(new MapStringToObject(descriptiveText, /*reactionStepInfos[i].getDescriptiveText()*/
                        reactionStepInfos[i], getStructure().getTypeName().equals(structTypeName)));
                    }
                }
            };
            Hashtable<String, Object> hash = new Hashtable<String, Object>();
            AsynchClientTask[] taskArray = new AsynchClientTask[] { task1, task2 };
            ClientTaskDispatcher.dispatch(this, hash, taskArray);
        } else {
            // Dictionary ReactionDescription
            ReactionDescription dbfr = (ReactionDescription) getReactionsJList().getSelectedValue();
            getRXParticipantResolverPanel().setupRX(dbfr, getModel(), getStructure());
        }
    }
// if(pndlm.size() == 0){
// //Skip parameters if there are none
// ((java.awt.CardLayout)getCardLayoutJPanel().getLayout()).next(getCardLayoutJPanel());
// }
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) KeyValue(org.vcell.util.document.KeyValue) Hashtable(java.util.Hashtable) ReactionStepInfo(cbit.vcell.model.ReactionStepInfo) DefaultListModel(javax.swing.DefaultListModel) ReactionDescription(cbit.vcell.model.ReactionDescription)

Example 3 with ReactionStepInfo

use of cbit.vcell.model.ReactionStepInfo in project vcell by virtualcell.

the class DBReactionWizardPanel method parameterNameSelectionChanged.

/**
 * Comment
 */
private void parameterNameSelectionChanged() {
    try {
        // 
        if (getParameterNamesJList().getSelectedValue() != null) {
            // final cbit.vcell.clientdb.DocumentManager docManager = getDocumentManager();
            // final javax.swing.JList jlist = getReactionsJList();
            final MapStringToObject parameNameMSO = (MapStringToObject) getParameterNamesJList().getSelectedValue();
            final KeyValue reactionStepKey = ((ReactionStepInfo) parameNameMSO.getToObject()).getReactionKey();
            // 
            final String RXSTEP_HASH_VALUE_KEY = "rxStep";
            AsynchClientTask searchReactions = new AsynchClientTask("Getting Full Reaction", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

                public void run(Hashtable<String, Object> hash) throws Exception {
                    Model reactionModel = getDocumentManager().getReactionStepAsModel(reactionStepKey);
                    ReactionStep rStep = reactionModel.getReactionStep(((ReactionStepInfo) parameNameMSO.getToObject()).getReactionName());
                    if (rStep != null) {
                        rStep.rebindAllToModel(reactionModel);
                        hash.put(RXSTEP_HASH_VALUE_KEY, rStep);
                    }
                }
            };
            // 
            AsynchClientTask updateRXParams = new AsynchClientTask("updateRXParams", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

                public void run(Hashtable<String, Object> hash) throws DataAccessException {
                    ReactionStep rStep = (ReactionStep) hash.get(RXSTEP_HASH_VALUE_KEY);
                    if (rStep != null) {
                        Kinetics.KineticsParameter[] kpArr = rStep.getKinetics().getKineticsParameters();
                        ReactionParticipant[] rpArr = rStep.getReactionParticipants();
                        // 
                        DefaultListModel<String> pvdlm = (DefaultListModel<String>) getParameterValuesJList().getModel();
                        pvdlm.removeAllElements();
                        for (int i = 0; i < kpArr.length; i += 1) {
                            pvdlm.addElement("Parameter - " + kpArr[i].getName().toString() + " = " + kpArr[i].getExpression().infix());
                        }
                        pvdlm.addElement("PhysicsOption=" + rStep.getPhysicsOptions());
                        for (int i = 0; i < rpArr.length; i += 1) {
                            String role = "Unknown";
                            if (rpArr[i] instanceof Reactant) {
                                role = "Reactant";
                            } else if (rpArr[i] instanceof Product) {
                                role = "Product";
                            } else if (rpArr[i] instanceof Catalyst) {
                                role = "Catalyst";
                            }
                            String fluxFlag = "";
                            // if(rStep instanceof FluxReaction){
                            // Membrane rStepStruct = (Membrane)rStep.getStructure();
                            // if(rpArr[i] instanceof Flux){
                            // if(rpArr[i].getStructure().equals(getModel().getStructureTopology().getOutsideFeature(rStepStruct))){
                            // fluxFlag = "Outside";
                            // }else{
                            // fluxFlag = "Inside";
                            // }
                            // }
                            // }
                            pvdlm.addElement("RXParticipant(" + role + ") " + fluxFlag + " " + (rpArr[i].getSpecies().getDBSpecies() != null ? "*" : "-") + " " + rpArr[i].getSpeciesContext().getName());
                        }
                    }
                    setReactionStep(rStep);
                    configureBFN();
                }
            };
            // 
            Hashtable<String, Object> hashTemp = new Hashtable<String, Object>();
            ClientTaskDispatcher.dispatch(this, hashTemp, new AsynchClientTask[] { searchReactions, updateRXParams }, true);
        } else {
            setReactionStep(null);
        }
    } catch (Exception e) {
        PopupGenerator.showErrorDialog(this, e.getMessage(), e);
    }
    // 
    configureBFN();
}
Also used : AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) KeyValue(org.vcell.util.document.KeyValue) ReactionStepInfo(cbit.vcell.model.ReactionStepInfo) Hashtable(java.util.Hashtable) DefaultListModel(javax.swing.DefaultListModel) Product(cbit.vcell.model.Product) Reactant(cbit.vcell.model.Reactant) UtilCancelException(org.vcell.util.UtilCancelException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) ReactionStep(cbit.vcell.model.ReactionStep) DefaultListSelectionModel(javax.swing.DefaultListSelectionModel) Model(cbit.vcell.model.Model) DefaultListModel(javax.swing.DefaultListModel) ReactionParticipant(cbit.vcell.model.ReactionParticipant) Catalyst(cbit.vcell.model.Catalyst)

Aggregations

ReactionStepInfo (cbit.vcell.model.ReactionStepInfo)3 KeyValue (org.vcell.util.document.KeyValue)3 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)2 Hashtable (java.util.Hashtable)2 DefaultListModel (javax.swing.DefaultListModel)2 Catalyst (cbit.vcell.model.Catalyst)1 Model (cbit.vcell.model.Model)1 Product (cbit.vcell.model.Product)1 Reactant (cbit.vcell.model.Reactant)1 ReactionDescription (cbit.vcell.model.ReactionDescription)1 ReactionParticipant (cbit.vcell.model.ReactionParticipant)1 ReactionStep (cbit.vcell.model.ReactionStep)1 BigDecimal (java.math.BigDecimal)1 ResultSet (java.sql.ResultSet)1 Statement (java.sql.Statement)1 Vector (java.util.Vector)1 DefaultListSelectionModel (javax.swing.DefaultListSelectionModel)1 DataAccessException (org.vcell.util.DataAccessException)1 UserCancelException (org.vcell.util.UserCancelException)1 UtilCancelException (org.vcell.util.UtilCancelException)1