use of cbit.vcell.mapping.ParameterContext.LocalParameter in project vcell by virtualcell.
the class XmlReader method getSpatialProcesses.
public SpatialProcess[] getSpatialProcesses(SimulationContext simContext, Element spatialProcessesElement) throws XmlParseException {
Iterator<Element> spatialProcessElementIterator = spatialProcessesElement.getChildren(XMLTags.SpatialProcessTag, vcNamespace).iterator();
ArrayList<SpatialProcess> spatialProcessList = new ArrayList<SpatialProcess>();
while (spatialProcessElementIterator.hasNext()) {
Element spatialProcessElement = (Element) spatialProcessElementIterator.next();
SpatialProcess spatialProcess = null;
String name = unMangle(spatialProcessElement.getAttributeValue(XMLTags.NameAttrTag));
String type = unMangle(spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessTypeAttrTag));
if (type.equals(XMLTags.SpatialProcessTypeAttrValue_PointKinematics)) {
PointKinematics pointKinematics = new PointKinematics(name, simContext);
String pointObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessPointObjectAttrTag);
PointObject pointObject = (PointObject) simContext.getSpatialObject(pointObjectName);
pointKinematics.setPointObject(pointObject);
spatialProcess = pointKinematics;
} else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_PointLocation)) {
PointLocation pointLocation = new PointLocation(name, simContext);
String pointObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessPointObjectAttrTag);
PointObject pointObject = (PointObject) simContext.getSpatialObject(pointObjectName);
pointLocation.setPointObject(pointObject);
spatialProcess = pointLocation;
} else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_SurfaceKinematics)) {
SurfaceKinematics surfaceKinematics = new SurfaceKinematics(name, simContext);
String surfaceRegionObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessSurfaceObjectAttrTag);
SurfaceRegionObject surfaceRegionObject = (SurfaceRegionObject) simContext.getSpatialObject(surfaceRegionObjectName);
surfaceKinematics.setSurfaceRegionObject(surfaceRegionObject);
spatialProcess = surfaceKinematics;
} else if (type.equals(XMLTags.SpatialProcessTypeAttrValue_VolumeKinematics)) {
VolumeKinematics volumeKinematics = new VolumeKinematics(name, simContext);
String volumeRegionObjectName = spatialProcessElement.getAttributeValue(XMLTags.SpatialProcessVolumeObjectAttrTag);
VolumeRegionObject volumeRegionObject = (VolumeRegionObject) simContext.getSpatialObject(volumeRegionObjectName);
volumeKinematics.setVolumeRegionObject(volumeRegionObject);
spatialProcess = volumeKinematics;
}
// set parameters
Iterator<Element> paramElementIter = spatialProcessElement.getChildren(XMLTags.ParameterTag, vcNamespace).iterator();
ArrayList<LocalParameter> parameters = new ArrayList<LocalParameter>();
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);
SpatialProcessParameterType parameterType = SpatialProcessParameterType.fromRoleXmlName(roleStr);
VCUnitDefinition unit = simContext.getModel().getUnitSystem().getInstance_TBD();
String unitSymbol = paramElement.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
if (unitSymbol != null) {
unit = simContext.getModel().getUnitSystem().getInstance(unitSymbol);
}
parameters.add(spatialProcess.createNewParameter(paramName, parameterType, exp, unit));
}
try {
spatialProcess.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);
}
spatialProcessList.add(spatialProcess);
}
return spatialProcessList.toArray(new SpatialProcess[0]);
}
use of cbit.vcell.mapping.ParameterContext.LocalParameter in project vcell by virtualcell.
the class StimulusTable method getSQLValueList.
/**
* This method was created in VisualAge.
* @return java.lang.String
* @param key KeyValue
* @param modelName java.lang.String
*/
public String getSQLValueList(InsertHashtable hash, KeyValue Key, KeyValue simContextKey, ElectricalStimulus stimulus) throws DataAccessException {
KeyValue structureKey = hash.getDatabaseKey(stimulus.getElectrode().getFeature());
if (structureKey == null) {
structureKey = stimulus.getElectrode().getFeature().getKey();
if (structureKey == null) {
throw new DataAccessException("no key for structure " + stimulus.getElectrode().getFeature());
}
}
Expression exp = null;
int stimulusType = UNKNOWN_STIMULUS;
if (stimulus instanceof CurrentDensityClampStimulus) {
stimulusType = CURRENTDENSITY_CLAMP_STIMULUS;
LocalParameter currentDensityParameter = ((CurrentDensityClampStimulus) stimulus).getCurrentDensityParameter();
exp = currentDensityParameter.getExpression();
} else if (stimulus instanceof TotalCurrentClampStimulus) {
stimulusType = TOTALCURRENT_CLAMP_STIMULUS;
LocalParameter totalCurrentParameter = ((TotalCurrentClampStimulus) stimulus).getCurrentParameter();
exp = totalCurrentParameter.getExpression();
} else if (stimulus instanceof VoltageClampStimulus) {
stimulusType = VOLTAGE_CLAMP_STIMULUS;
LocalParameter voltageParameter = ((VoltageClampStimulus) stimulus).getVoltageParameter();
exp = voltageParameter.getExpression();
} else {
throw new DataAccessException("storage for Stimulus type " + stimulus.getClass().getName() + " not yet supported");
}
java.io.StringWriter esParameterWriter = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter(esParameterWriter);
stimulus.parameterVCMLWrite(pw);
pw.flush();
pw.close();
StringBuffer buffer = new StringBuffer();
buffer.append("(");
buffer.append(Key + ",");
buffer.append(structureKey + ",");
buffer.append(simContextKey + ",");
buffer.append("'" + stimulus.getName() + "',");
buffer.append(stimulusType + ",");
buffer.append("'" + TokenMangler.getSQLEscapedString(exp.infix()) + "',");
buffer.append(stimulus.getElectrode().getPosition().getX() + ",");
buffer.append(stimulus.getElectrode().getPosition().getY() + ",");
buffer.append(stimulus.getElectrode().getPosition().getZ() + ",");
buffer.append("'" + TokenMangler.getSQLEscapedString(esParameterWriter.getBuffer().toString()) + "'");
buffer.append(")");
return buffer.toString();
}
Aggregations