use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class ModelProcessSpecsTableModel method setSimulationContext.
/**
* Sets the simulationContext property (cbit.vcell.mapping.SimulationContext) value.
* @param simulationContext The new value for the property.
* @see #getSimulationContext
*/
public void setSimulationContext(SimulationContext simulationContext) {
SimulationContext oldValue = fieldSimulationContext;
if (oldValue != null) {
oldValue.removePropertyChangeListener(this);
ReactionContext reactionContext = oldValue.getReactionContext();
reactionContext.removePropertyChangeListener(this);
ReactionSpec[] oldReactionSpecs = reactionContext.getReactionSpecs();
for (int i = 0; i < oldReactionSpecs.length; i++) {
oldReactionSpecs[i].getReactionStep().removePropertyChangeListener(this);
oldReactionSpecs[i].removePropertyChangeListener(this);
}
ReactionRuleSpec[] oldReactionRuleSpecs = reactionContext.getReactionRuleSpecs();
for (int i = 0; i < oldReactionRuleSpecs.length; i++) {
oldReactionRuleSpecs[i].getReactionRule().removePropertyChangeListener(this);
oldReactionRuleSpecs[i].removePropertyChangeListener(this);
}
}
fieldSimulationContext = simulationContext;
refreshColumns();
if (simulationContext != null) {
simulationContext.addPropertyChangeListener(this);
ReactionContext reactionContext = fieldSimulationContext.getReactionContext();
reactionContext.addPropertyChangeListener(this);
ReactionSpec[] newReactionSpecs = reactionContext.getReactionSpecs();
for (int i = 0; i < newReactionSpecs.length; i++) {
newReactionSpecs[i].getReactionStep().addPropertyChangeListener(this);
newReactionSpecs[i].addPropertyChangeListener(this);
}
ReactionRuleSpec[] newReactionRuleSpecs = reactionContext.getReactionRuleSpecs();
for (int i = 0; i < newReactionRuleSpecs.length; i++) {
newReactionRuleSpecs[i].getReactionRule().addPropertyChangeListener(this);
newReactionRuleSpecs[i].addPropertyChangeListener(this);
}
}
firePropertyChange("simulationContext", oldValue, simulationContext);
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class SimulationContextDbDriver method assignReactionSpecsSQL.
/**
* This method was created in VisualAge.
* @param simContextKey cbit.sql.KeyValue
* @param simContext cbit.vcell.mapping.SimulationContext
*/
private void assignReactionSpecsSQL(Connection con, KeyValue simContextKey, SimulationContext simContext) throws SQLException, DataAccessException {
String sql;
sql = " SELECT " + "*" + " FROM " + reactionSpecTable.getTableName() + " WHERE " + reactionSpecTable.simContextRef + " = " + simContextKey + " ORDER BY " + reactionSpecTable.id;
// System.out.println("SimulationContextDbDriver.assignReactionSpecsSQL(), sql = "+sql);
Statement stmt = con.createStatement();
try {
ResultSet rset = stmt.executeQuery(sql);
while (rset.next()) {
KeyValue reactionStepRef = new KeyValue(rset.getBigDecimal(reactionSpecTable.reactionStepRef.toString()));
int mapping = rset.getInt(reactionSpecTable.mapping.toString());
//
ReactionSpec[] reactionSpecs = simContext.getReactionContext().getReactionSpecs();
for (int i = 0; i < reactionSpecs.length; i++) {
if (reactionSpecs[i].getReactionStep().getKey().compareEqual(reactionStepRef)) {
try {
reactionSpecs[i].setReactionMapping(mapping);
} catch (Exception e) {
throw new DataAccessException("Error setting ReactionSpec 'mapping' for SimulationContext:" + simContext.getVersion().getName() + " id=" + simContextKey);
}
break;
}
}
}
} finally {
stmt.close();
}
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class SimulationContextDbDriver method insertReactionSpecsSQL.
/**
* This method was created in VisualAge.
*/
private void insertReactionSpecsSQL(Connection con, KeyValue simContextKey, SimulationContext simContext, Model updatedModel) throws SQLException, DataAccessException {
String sql;
ReactionSpec[] reactionSpecs = simContext.getReactionContext().getReactionSpecs();
for (int i = 0; i < reactionSpecs.length; i++) {
//
KeyValue newReactionSpecKey = keyFactory.getNewKey(con);
KeyValue reactionStepKey = updatedModel.getReactionStep(reactionSpecs[i].getReactionStep().getName()).getKey();
//
sql = "INSERT INTO " + reactionSpecTable.getTableName() + " " + reactionSpecTable.getSQLColumnList() + " VALUES " + reactionSpecTable.getSQLValueList(newReactionSpecKey, simContextKey, reactionSpecs[i], reactionStepKey);
// System.out.println("SimulationContextDbDriver.insertReactionSpecsSQL(), sql = "+sql);
updateCleanSQL(con, sql);
}
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class ModelProcessSpecsTableModel method setValueAt.
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
ModelProcessSpec modelProcessSpec = getValueAt(rowIndex);
ColumnType columnType = columns.get(columnIndex);
try {
switch(columnType) {
case COLUMN_ENABLED:
{
boolean bEnabled = ((Boolean) aValue).booleanValue();
if (modelProcessSpec instanceof ReactionSpec) {
ReactionSpec reactionSpec = (ReactionSpec) modelProcessSpec;
if (bEnabled) {
reactionSpec.setReactionMapping(ReactionSpec.INCLUDED);
} else {
reactionSpec.setReactionMapping(ReactionSpec.EXCLUDED);
}
} else if (modelProcessSpec instanceof ReactionRuleSpec) {
ReactionRuleSpec reactionRuleSpec = (ReactionRuleSpec) modelProcessSpec;
if (bEnabled) {
reactionRuleSpec.setReactionRuleMapping(ReactionRuleMappingType.INCLUDED);
} else {
reactionRuleSpec.setReactionRuleMapping(ReactionRuleMappingType.EXCLUDED);
}
}
fireTableRowsUpdated(rowIndex, rowIndex);
break;
}
case COLUMN_FAST:
{
boolean bFast = ((Boolean) aValue).booleanValue();
if (modelProcessSpec instanceof ReactionSpec) {
ReactionSpec reactionSpec = (ReactionSpec) modelProcessSpec;
if (bFast) {
reactionSpec.setReactionMapping(ReactionSpec.FAST);
} else {
reactionSpec.setReactionMapping(ReactionSpec.INCLUDED);
}
}
fireTableRowsUpdated(rowIndex, rowIndex);
break;
}
}
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace(System.out);
}
}
use of cbit.vcell.mapping.ReactionSpec in project vcell by virtualcell.
the class KineticsTypeTemplatePanel method onSelectedObjectsChange.
@Override
protected void onSelectedObjectsChange(Object[] selectedObjects) {
if (selectedObjects == null || selectedObjects.length != 1) {
return;
}
if (selectedObjects[0] instanceof ReactionStep) {
setReactionStep((ReactionStep) selectedObjects[0]);
} else if (selectedObjects[0] instanceof ReactionSpec) {
setReactionStep(((ReactionSpec) selectedObjects[0]).getReactionStep());
} else if (selectedObjects[0] instanceof KineticsParameter) {
KineticsParameter kineticsParameter = (KineticsParameter) selectedObjects[0];
setReactionStep(kineticsParameter.getKinetics().getReactionStep());
for (int i = 0; i < getParameterTableModel().getRowCount(); i++) {
if (kineticsParameter == getParameterTableModel().getValueAt(i)) {
getScrollPaneTable().setRowSelectionInterval(i, i);
break;
}
}
} else {
setReactionStep(null);
}
}
Aggregations