use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getVersion.
/**
* This method returns a Version object from an XML representation.
* Creation date: (3/16/2001 3:41:24 PM)
* @return cbit.sql.Version
* @param param org.jdom.Element
*/
private Version getVersion(Element xmlVersion) throws XmlParseException {
if (xmlVersion == null) {
return null;
}
// determine if it should be processed using the 'fromVersionable'
if (xmlVersion.getAttributeValue(XMLTags.FromVersionableTag) == null || Boolean.valueOf(xmlVersion.getAttributeValue(XMLTags.FromVersionableTag)).booleanValue() || this.readKeysFlag == false) {
// this came from a versionable object, so skip! Or it should not explicitly import the information inside the Version
return null;
}
// Read all the attributes
// *name
String name = unMangle(xmlVersion.getAttributeValue(XMLTags.NameAttrTag));
// *key
String temp = xmlVersion.getAttributeValue(XMLTags.KeyValueAttrTag);
KeyValue key = new KeyValue(temp);
// *owner
Element tempElement = xmlVersion.getChild(XMLTags.OwnerTag, vcNamespace);
User owner = new User(unMangle(tempElement.getAttributeValue(XMLTags.NameAttrTag)), new KeyValue(tempElement.getAttributeValue(XMLTags.IdentifierAttrTag)));
// *access
GroupAccess groupAccess = getGroupAccess(xmlVersion.getChild(XMLTags.GroupAccessTag, vcNamespace));
// *Branchpointref
temp = xmlVersion.getAttributeValue(XMLTags.BranchPointRefTag);
KeyValue branchpointref = null;
if (temp != null) {
branchpointref = new KeyValue(temp);
}
// *BranchID
java.math.BigDecimal branchId = new java.math.BigDecimal(xmlVersion.getAttributeValue(XMLTags.BranchIdAttrTag));
// *Flag
temp = xmlVersion.getAttributeValue(XMLTags.FlagAttrTag);
VersionFlag flag = VersionFlag.fromInt(Integer.parseInt(temp));
// *Date
java.util.Date date = null;
temp = xmlVersion.getAttributeValue(XMLTags.DateAttrTag);
if (temp != null) {
try {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(BeanUtils.vcDateFormat, Locale.US);
date = simpleDateFormat.parse(temp);
} catch (java.text.ParseException e) {
e.printStackTrace();
throw new XmlParseException("Invalid date:" + temp, e);
}
}
// *Annotation
String annotation = null;
String annotationText = xmlVersion.getChildText(XMLTags.AnnotationTag, vcNamespace);
if (annotationText != null && annotationText.length() > 0) {
annotation = unMangle(annotationText);
}
// Create and return the version object
return new Version(key, name, owner, groupAccess, branchpointref, branchId, date, flag, annotation);
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getMembrane.
/**
* This method returns a Membrane object from a XML element.
* Creation date: (4/4/2001 4:17:32 PM)
* @return cbit.vcell.model.Membrane
* @param param org.jdom.Element
*/
private Membrane getMembrane(Model model, Element param, List<Structure> featureList) throws XmlParseException {
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
Membrane newmembrane = null;
// retrieve the key if there is one
KeyValue key = null;
String stringkey = param.getAttributeValue(XMLTags.KeyValueAttrTag);
if (stringkey != null && stringkey.length() > 0 && this.readKeysFlag) {
key = new KeyValue(stringkey);
}
// try to create new Membrane named "name"
try {
newmembrane = new Membrane(key, name);
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("An error occurred while trying to create the Membrane object " + name, e);
}
// set inside feature
String infeaturename = unMangle(param.getAttributeValue(XMLTags.InsideFeatureTag));
String outfeaturename = unMangle(param.getAttributeValue(XMLTags.OutsideFeatureTag));
String posFeatureName = unMangle(param.getAttributeValue(XMLTags.PositiveFeatureTag));
String negFeatureName = unMangle(param.getAttributeValue(XMLTags.NegativeFeatureTag));
Feature infeatureref = null;
Feature outfeatureref = null;
Feature posFeature = null;
Feature negFeature = null;
for (Structure s : featureList) {
String sname = s.getName();
if (sname.equals(infeaturename)) {
infeatureref = (Feature) s;
}
if (sname.equals(outfeaturename)) {
outfeatureref = (Feature) s;
}
if (sname.equals(posFeatureName)) {
posFeature = (Feature) s;
}
if (sname.equals(negFeatureName)) {
negFeature = (Feature) s;
}
}
// set inside and outside features
if (infeatureref != null) {
model.getStructureTopology().setInsideFeature(newmembrane, infeatureref);
}
if (outfeatureref != null) {
model.getStructureTopology().setOutsideFeature(newmembrane, outfeatureref);
}
// set positive & negative features
if (posFeature != null) {
model.getElectricalTopology().setPositiveFeature(newmembrane, posFeature);
}
if (negFeature != null) {
model.getElectricalTopology().setNegativeFeature(newmembrane, negFeature);
}
// set MemVoltName
if (param.getAttribute(XMLTags.MemVoltNameTag) == null) {
throw new XmlParseException("Error reading membrane Voltage Name!");
}
String memvoltName = unMangle(param.getAttributeValue(XMLTags.MemVoltNameTag));
try {
newmembrane.getMembraneVoltage().setName(memvoltName);
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("Error setting the membrane Voltage Name", e);
}
return newmembrane;
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getPixelClass.
/**
* This method returns a VCImageRegion from a XML Representation.
* Creation date: (5/2/2001 12:17:05 PM)
* @return cbit.image.VCImageRegion
* @param param org.jdom.Element
*/
private VCPixelClass getPixelClass(Element param) {
// Read attributes
String pixelClassName = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
int pixelvalue = Integer.parseInt(param.getAttributeValue(XMLTags.ImagePixelValueTag));
// retrieve the key if there is one
KeyValue key = null;
String stringkey = param.getAttributeValue(XMLTags.KeyValueAttrTag);
if (stringkey != null && stringkey.length() > 0 && this.readKeysFlag) {
key = new KeyValue(stringkey);
}
return new VCPixelClass(key, pixelClassName, pixelvalue);
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getDataSymbols.
private ArrayList<DataSymbol> getDataSymbols(Element dataContextElement, DataContext dataContext, ModelUnitSystem modelUnitSystem) {
ArrayList<DataSymbol> dataSymbolsList = new ArrayList<DataSymbol>();
// iterate over fieldDatasymbols. When other dataSymbol types are implemented, repeat this loop.
Iterator dataSymbolsElementIter = dataContextElement.getChildren(XMLTags.FieldDataSymbolTag, vcNamespace).iterator();
while (dataSymbolsElementIter.hasNext()) {
Element dataSymbolElement = (Element) dataSymbolsElementIter.next();
String dataSymbolName = unMangle(dataSymbolElement.getAttributeValue(XMLTags.DataSymbolNameTag));
DataSymbolType dataSymbolType = DataSymbolType.fromDatabaseName(unMangle(dataSymbolElement.getAttributeValue(XMLTags.DataSymbolTypeTag)));
String symbol = dataSymbolElement.getAttributeValue(XMLTags.VCUnitDefinitionAttrTag);
VCUnitDefinition vcUnitDefinition = null;
if (symbol != null) {
vcUnitDefinition = modelUnitSystem.getInstance(symbol);
}
// ExternalDataIdentifier dataSetID in FieldDataSymbol
Element dataSetIDElement = dataSymbolElement.getChild(XMLTags.ExternalDataIdentifierTag, vcNamespace);
String name = unMangle(dataSetIDElement.getAttributeValue(XMLTags.NameAttrTag));
String key = unMangle(dataSetIDElement.getAttributeValue(XMLTags.KeyValueAttrTag));
String userID = unMangle(dataSetIDElement.getAttributeValue(XMLTags.OwnerNameAttrTag));
String userKey = unMangle(dataSetIDElement.getAttributeValue(XMLTags.OwnerKeyAttrTag));
User owner = new User(userID, new KeyValue(userKey));
ExternalDataIdentifier edi = new ExternalDataIdentifier(new KeyValue(key), owner, name);
// ---
String fieldItemName = unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemNameTag));
String fieldItemType = unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemTypeTag));
double fieldItemTime = Double.parseDouble(unMangle(dataSymbolElement.getAttributeValue(XMLTags.FieldItemTimeTag)));
FieldDataSymbol fds = new FieldDataSymbol(dataSymbolName, dataSymbolType, dataContext, vcUnitDefinition, edi, fieldItemName, fieldItemType, fieldItemTime);
dataSymbolsList.add(fds);
}
return dataSymbolsList;
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getCSGObject.
public CSGObject getCSGObject(Element param, KeyValue keyFromDB) throws XmlParseException {
// retrieve the attributes
String name = param.getAttributeValue(XMLTags.NameAttrTag);
int handle = Integer.parseInt(param.getAttributeValue(XMLTags.HandleAttrTag));
// process the key
KeyValue key = null;
String temp = param.getAttributeValue(XMLTags.KeyValueAttrTag);
if (temp != null && temp.length() > 0 && this.readKeysFlag) {
key = new KeyValue(temp);
}
if (keyFromDB != null) {
key = keyFromDB;
}
// Retrieve CSGObject CSGNode - CSGObject element should have one child (the root node of the CSGObject)
Object[] elements = param.getChildren().toArray();
if (elements.length > 1) {
throw new XmlParseException("CSGObject subvolume element cannot have more than one child element");
}
CSGNode csgRootNode = getCSGNode((Element) elements[0]);
// Create the CSGObject
CSGObject newCSGObjectSubvol = new CSGObject(key, name, handle);
newCSGObjectSubvol.setRoot(csgRootNode);
return newCSGObjectSubvol;
}
Aggregations