use of cbit.vcell.mapping.spatial.processes.SpatialProcess.SpatialProcessParameterType 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]);
}
Aggregations