use of cbit.vcell.mapping.IllegalMappingException in project vcell by virtualcell.
the class StructureMappingTableModel method setValueAt.
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
if (rowIndex < 0 || rowIndex >= getRowCount()) {
throw new RuntimeException("StructureMappingTableModel.setValueAt(), row = " + rowIndex + " out of range [" + 0 + "," + (getRowCount() - 1) + "]");
}
if (columnIndex < 0 || columnIndex >= getColumnCount()) {
throw new RuntimeException("StructureMappingTableModel.setValueAt(), column = " + columnIndex + " out of range [" + 0 + "," + (getColumnCount() - 1) + "]");
}
StructureMapping structureMapping = getValueAt(rowIndex);
Structure structure = structureMapping.getStructure();
if (bNonSpatial) {
switch(columnIndex) {
case NONSPATIAL_COLUMN_SIZE:
{
try {
Expression exp = null;
if (aValue instanceof String) {
exp = new Expression((String) aValue);
} else if (aValue instanceof Double) {
exp = new Expression(((Double) aValue).doubleValue());
}
// if the input volumn is null, leave it as it was.
if (exp != null) {
// for old ode model, once one size is input, solve the rest. if it is unnamed compartment(the only one), we don't need to solve anything
if (!getGeometryContext().getSimulationContext().isStoch() && getGeometryContext().isAllSizeSpecifiedNull() && getGeometryContext().isAllVolFracAndSurfVolSpecified() && getGeometryContext().getStructureMappings().length > 1) {
structureMapping.getSizeParameter().setExpression(exp);
double size;
try {
size = exp.evaluateConstant();
VCUnitDefinition volumeUnit = getGeometryContext().getSimulationContext().getModel().getUnitSystem().getVolumeUnit();
StructureSizeSolver.updateAbsoluteStructureSizes(getGeometryContext().getSimulationContext(), structure, size, volumeUnit);
fireTableRowsUpdated(0, getRowCount());
} catch (ExpressionException ex) {
ex.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, "Size of Feature " + structure.getName() + " can not be solved as constant!");
} catch (Exception ex) {
ex.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, ex.getMessage());
}
} else {
structureMapping.getSizeParameter().setExpression(exp);
// set fraction in stoch math description, because these might be used when copy from stoch app to ode app.
if (getGeometryContext().isAllSizeSpecifiedPositive()) /*&& !getGeometryContext().getSimulationContext().isStoch()*/
{
try {
StructureSizeSolver.updateRelativeStructureSizes(getGeometryContext().getSimulationContext());
} catch (Exception ex) {
ex.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, ex.getMessage());
}
}
}
}
} catch (ExpressionException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, "expression error\n" + e.getMessage());
}
break;
}
}
} else {
switch(columnIndex) {
case SPATIAL_COLUMN_SUBDOMAIN:
{
GeometryClass geometryClass = null;
if (aValue instanceof String) {
String svname = (String) aValue;
geometryClass = getGeometryContext().getGeometry().getGeometryClass(svname);
} else if (aValue instanceof GeometryClass) {
geometryClass = (GeometryClass) aValue;
}
if (geometryClass != null) {
try {
getGeometryContext().assignStructure(structure, geometryClass);
} catch (PropertyVetoException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, e.getMessage());
} catch (IllegalMappingException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, e.getMessage());
} catch (MappingException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, e.getMessage());
}
}
break;
}
case SPATIAL_COLUMN_SIZERATIO:
try {
Expression exp = null;
if (aValue instanceof String) {
exp = new Expression((String) aValue);
} else if (aValue instanceof Double) {
exp = new Expression(((Double) aValue).doubleValue());
}
if (exp != null) {
structureMapping.getUnitSizeParameter().setExpression(exp);
StructureSizeSolver.updateUnitStructureSizes(getGeometryContext().getSimulationContext(), structureMapping.getGeometryClass());
}
} catch (ExpressionException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(ownerTable, "expression error\n" + e.getMessage());
}
break;
case SPATIAL_COLUMN_X_MINUS:
{
if (aValue != null) {
structureMapping.setBoundaryConditionTypeXm(new BoundaryConditionType((String) aValue));
}
break;
}
case SPATIAL_COLUMN_X_PLUS:
{
if (aValue != null) {
structureMapping.setBoundaryConditionTypeXp(new BoundaryConditionType((String) aValue));
}
break;
}
case SPATIAL_COLUMN_Y_MINUS:
{
if (aValue != null) {
structureMapping.setBoundaryConditionTypeYm(new BoundaryConditionType((String) aValue));
}
break;
}
case SPATIAL_COLUMN_Y_PLUS:
{
if (aValue != null) {
structureMapping.setBoundaryConditionTypeYp(new BoundaryConditionType((String) aValue));
}
break;
}
case SPATIAL_COLUMN_Z_MINUS:
{
if (aValue != null) {
structureMapping.setBoundaryConditionTypeZm(new BoundaryConditionType((String) aValue));
}
break;
}
case SPATIAL_COLUMN_Z_PLUS:
{
if (aValue != null) {
structureMapping.setBoundaryConditionTypeZp(new BoundaryConditionType((String) aValue));
}
break;
}
}
}
}
use of cbit.vcell.mapping.IllegalMappingException 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;
}
use of cbit.vcell.mapping.IllegalMappingException in project vcell by virtualcell.
the class StructureMappingCartoonTool method menuAction.
protected void menuAction(Shape shape, String menuAction) {
//
if (shape == null) {
return;
}
//
if (menuAction.equals(CartoonToolEditActions.Delete.MENU_ACTION)) {
if (shape instanceof StructureMappingShape) {
try {
StructureMapping sm = (StructureMapping) ((StructureMappingShape) shape).getModelObject();
getStructureMappingCartoon().getGeometryContext().assignStructure(sm.getStructure(), null);
getStructureMappingCartoon().refreshAll();
} catch (IllegalMappingException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(getGraphPane(), e.getMessage());
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(getGraphPane(), e.getMessage());
} catch (MappingException e) {
e.printStackTrace(System.out);
PopupGenerator.showErrorDialog(getGraphPane(), e.getMessage());
}
}
} else {
// default action is to ignore
System.out.println("unsupported menu action '" + menuAction + "' on shape '" + shape + "'");
}
}
Aggregations