use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getImageSubVolume.
/**
* This method returns an ImageSubVolume object from a XML representation.
* Creation date: (5/1/2001 5:26:17 PM)
* @return cbit.vcell.geometry.ImageSubVolume
* @param param org.jdom.Element
*/
private ImageSubVolume getImageSubVolume(Element param) throws XmlParseException {
// retrieve the attributes
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
int handle = Integer.parseInt(param.getAttributeValue(XMLTags.HandleAttrTag));
int imagePixelValue = Integer.parseInt(param.getAttributeValue(XMLTags.ImagePixelValueTag));
// Get the PixelClass from image (image should be a sibling of this subVolume element)
Element imageElement = ((Element) param.getParent()).getChild(XMLTags.ImageTag, vcNamespace);
if (imageElement == null) {
throw new XmlParseException("image not found in geometry corresponding to ImageSubVolume");
}
List<Element> pixelClassList = imageElement.getChildren(XMLTags.PixelClassTag, vcNamespace);
VCPixelClass pixelClass = null;
for (Element pixelClassElement : pixelClassList) {
VCPixelClass pc = getPixelClass(pixelClassElement);
if (pc.getPixel() == imagePixelValue) {
pixelClass = pc;
}
}
if (pixelClass == null) {
throw new XmlParseException("image pixelclass(pixel=" + imagePixelValue + ") not found while creating ImageSubVolume " + name);
}
// 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);
}
// Create the new Image SubVolume
ImageSubVolume newsubvolume = new ImageSubVolume(key, pixelClass, handle);
// set name
try {
newsubvolume.setName(name);
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("A propertyVetoException was generated when setting the name " + name + " to an ImageSubvolume object!", e);
}
return newsubvolume;
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getGroupAccess.
/**
* This method returns a GroupAccess object from an XML format.
* Creation date: (5/23/2003 7:27:10 PM)
* @return cbit.vcell.server.GroupAccess
* @param xmlGroup org.jdom.Element
*/
private GroupAccess getGroupAccess(Element xmlGroup) {
// guess the type of group
String temp = xmlGroup.getAttributeValue(XMLTags.TypeAttrTag);
java.math.BigDecimal type = new java.math.BigDecimal(temp);
if (type.equals(GroupAccess.GROUPACCESS_ALL)) {
// Type ALL
return new GroupAccessAll();
} else if (type.equals(GroupAccess.GROUPACCESS_NONE)) {
// Type NONE
return new GroupAccessNone();
} else {
// Type SOME
// Read attributes
// *groupid
temp = xmlGroup.getAttributeValue(XMLTags.TypeAttrTag);
java.math.BigDecimal groupid = new java.math.BigDecimal(temp);
// *hash
temp = xmlGroup.getAttributeValue(XMLTags.HashAttrTag);
java.math.BigDecimal hashcode = new java.math.BigDecimal(temp);
// *users
List<Element> userlist = xmlGroup.getChildren(XMLTags.UserTag, vcNamespace);
User[] userArray = new User[userlist.size()];
boolean[] booleanArray = new boolean[userlist.size()];
int counter = 0;
for (Element userElement : userlist) {
String userid = unMangle(userElement.getAttributeValue(XMLTags.NameAttrTag));
KeyValue key = new KeyValue(userElement.getAttributeValue(XMLTags.KeyValueAttrTag));
boolean hidden = Boolean.valueOf(userElement.getAttributeValue(XMLTags.HiddenTag)).booleanValue();
userArray[counter] = new User(userid, key);
booleanArray[counter] = hidden;
counter++;
}
// create and return the GroupAccess
return new GroupAccessSome(groupid, hashcode, userArray, booleanArray);
}
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getFluxReaction.
/**
* This method returns a FluxReaction object from a XML element.
* Creation date: (3/16/2001 11:52:02 AM)
* @return cbit.vcell.model.FluxReaction
* @param param org.jdom.Element
* @throws XmlParseException
* @throws PropertyVetoException
* @throws ModelException
* @throws Exception
*/
private FluxReaction getFluxReaction(Element param, Model model) throws XmlParseException, PropertyVetoException {
// retrieve the key if there is one
KeyValue key = null;
String keystring = param.getAttributeValue(XMLTags.KeyValueAttrTag);
if (keystring != null && keystring.length() > 0 && this.readKeysFlag) {
key = new KeyValue(keystring);
}
// resolve reference to the Membrane
String structureName = unMangle(param.getAttributeValue(XMLTags.StructureAttrTag));
Membrane structureref = (Membrane) model.getStructure(structureName);
if (structureref == null) {
throw new XmlParseException("The membrane " + structureName + " could not be resolved in the dictionnary!");
}
// -- Instantiate new FluxReaction --
FluxReaction fluxreaction = null;
String name = unMangle(param.getAttributeValue(XMLTags.NameAttrTag));
String reversibleAttributeValue = param.getAttributeValue(XMLTags.ReversibleAttrTag);
boolean bReversible = true;
if (reversibleAttributeValue != null) {
if (Boolean.TRUE.toString().equals(reversibleAttributeValue)) {
bReversible = true;
} else if (Boolean.FALSE.toString().equals(reversibleAttributeValue)) {
bReversible = false;
} else {
throw new RuntimeException("unexpected value " + reversibleAttributeValue + " for reversible flag for reaction " + name);
}
}
try {
fluxreaction = new FluxReaction(model, structureref, key, name, bReversible);
fluxreaction.setModel(model);
} catch (Exception e) {
e.printStackTrace();
throw new XmlParseException("An exception occurred while trying to create the FluxReaction " + name, e);
}
// resolve reference to the fluxCarrier
if (param.getAttribute(XMLTags.FluxCarrierAttrTag) != null) {
String speciesname = unMangle(param.getAttributeValue(XMLTags.FluxCarrierAttrTag));
Species specieref = model.getSpecies(speciesname);
if (specieref != null) {
Feature insideFeature = model.getStructureTopology().getInsideFeature(structureref);
try {
if (insideFeature != null) {
SpeciesContext insideSpeciesContext = model.getSpeciesContext(specieref, insideFeature);
fluxreaction.addProduct(insideSpeciesContext, 1);
}
Feature outsideFeature = model.getStructureTopology().getOutsideFeature(structureref);
if (outsideFeature != null) {
SpeciesContext outsideSpeciesContext = model.getSpeciesContext(specieref, outsideFeature);
fluxreaction.addReactant(outsideSpeciesContext, 1);
}
} catch (ModelException e) {
e.printStackTrace(System.out);
throw new XmlParseException(e.getMessage());
}
}
}
// Annotation
// String rsAnnotation = null;
// String annotationText = param.getChildText(XMLTags.AnnotationTag, vcNamespace);
// if (annotationText!=null && annotationText.length()>0) {
// rsAnnotation = unMangle(annotationText);
// }
// fluxreaction.setAnnotation(rsAnnotation);
// set the fluxOption
String fluxOptionString = null;
fluxOptionString = param.getAttributeValue(XMLTags.FluxOptionAttrTag);
if (fluxOptionString != null && fluxOptionString.length() > 0) {
try {
if (fluxOptionString.equals(XMLTags.FluxOptionElectricalOnly)) {
fluxreaction.setPhysicsOptions(FluxReaction.PHYSICS_ELECTRICAL_ONLY);
} else if (fluxOptionString.equals(XMLTags.FluxOptionMolecularAndElectrical)) {
fluxreaction.setPhysicsOptions(FluxReaction.PHYSICS_MOLECULAR_AND_ELECTRICAL);
} else if (fluxOptionString.equals(XMLTags.FluxOptionMolecularOnly)) {
fluxreaction.setPhysicsOptions(FluxReaction.PHYSICS_MOLECULAR_ONLY);
}
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace(System.out);
throw new XmlParseException("A propertyVetoException was fired when setting the fluxOption to the flux reaction " + name, e);
}
}
// Add Reactants, if any
try {
Iterator<Element> iterator = param.getChildren(XMLTags.ReactantTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element temp = iterator.next();
// Add Reactant to this SimpleReaction
fluxreaction.addReactionParticipant(getReactant(temp, fluxreaction, model));
}
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("Error adding a reactant to the reaction " + name + " : " + e.getMessage());
}
// Add Products, if any
try {
Iterator<Element> iterator = param.getChildren(XMLTags.ProductTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element temp = iterator.next();
// Add Product to this simplereaction
fluxreaction.addReactionParticipant(getProduct(temp, fluxreaction, model));
}
} catch (java.beans.PropertyVetoException e) {
e.printStackTrace();
throw new XmlParseException("Error adding a product to the reaction " + name + " : " + e.getMessage());
}
// Add Catalyst(Modifiers) (if there are)
Iterator<Element> iterator = param.getChildren(XMLTags.CatalystTag, vcNamespace).iterator();
while (iterator.hasNext()) {
Element temp = iterator.next();
fluxreaction.addReactionParticipant(getCatalyst(temp, fluxreaction, model));
}
// Add Kinetics
fluxreaction.setKinetics(getKinetics(param.getChild(XMLTags.KineticsTag, vcNamespace), fluxreaction, model));
// set the valence (for legacy support for "chargeCarrierValence" stored with reaction).
String valenceString = null;
try {
valenceString = unMangle(param.getAttributeValue(XMLTags.FluxCarrierValenceAttrTag));
if (valenceString != null && valenceString.length() > 0) {
KineticsParameter chargeValenceParameter = fluxreaction.getKinetics().getChargeValenceParameter();
if (chargeValenceParameter != null) {
chargeValenceParameter.setExpression(new Expression(Integer.parseInt(unMangle(valenceString))));
}
}
} catch (NumberFormatException e) {
e.printStackTrace();
throw new XmlParseException("A NumberFormatException was fired when setting the (integer) valence '" + valenceString + "' (integer) to the flux reaction " + name, e);
}
return fluxreaction;
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getReactant.
/**
* This method returns a Reactant object from a XML representation.
* Creation date: (5/4/2001 2:22:56 PM)
* @return cbit.vcell.model.Reactant
* @param param org.jdom.Element
* @exception cbit.vcell.xml.XmlParseException The exception description.
*/
private Reactant getReactant(Element param, ReactionStep reaction, Model model) throws XmlParseException {
// retrieve the key if there is one
String keystring = param.getAttributeValue(XMLTags.KeyValueAttrTag);
KeyValue key = null;
if (keystring != null && keystring.length() > 0 && this.readKeysFlag) {
key = new KeyValue(keystring);
}
String speccontref = unMangle(param.getAttributeValue(XMLTags.SpeciesContextRefAttrTag));
SpeciesContext speccont = model.getSpeciesContext(speccontref);
if (speccont == null) {
throw new XmlParseException("The reference to the SpecieContext " + speccontref + " for a SimpleReaction could not be resolved!");
}
// Retrieve Stoichiometry
int stoch = 1;
org.jdom.Attribute tempArg = param.getAttribute(XMLTags.StoichiometryAttrTag);
if (tempArg != null) {
String tempValue = tempArg.getValue();
if (tempValue.length() > 0)
stoch = Integer.parseInt(tempValue);
// param.getAttributeValue(XMLTags.StoichiometryAttrTag));
}
// return new Reactant(newkey, reaction, speccont, stoch);
return new Reactant(key, reaction, speccont, stoch);
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class XmlReader method getCatalyst.
/**
* This method returns a Catalyst object from a XML representation.
* Creation date: (5/4/2001 2:22:56 PM)
* @return cbit.vcell.model.Product
* @param param org.jdom.Element
* @exception cbit.vcell.xml.XmlParseException The exception description.
*/
private Catalyst getCatalyst(Element param, ReactionStep reaction, Model model) throws XmlParseException {
// retrieve the key if there is one
KeyValue key = null;
String keystring = param.getAttributeValue(XMLTags.KeyValueAttrTag);
if (keystring != null && keystring.length() > 0 && this.readKeysFlag) {
key = new KeyValue(keystring);
}
String speccontref = unMangle(param.getAttributeValue(XMLTags.SpeciesContextRefAttrTag));
SpeciesContext speccont = model.getSpeciesContext(speccontref);
if (speccont == null) {
throw new XmlParseException("The reference to the SpecieContext " + speccontref + " for a Catalyst could not be resolved!");
}
return new Catalyst(key, reaction, speccont);
}
Aggregations