Search in sources :

Example 6 with KeyValue

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);
}
Also used : KeyValue(org.vcell.util.document.KeyValue) User(org.vcell.util.document.User) Element(org.jdom.Element) VersionFlag(org.vcell.util.document.VersionFlag) Version(org.vcell.util.document.Version) RedistributionVersion(cbit.vcell.solvers.mb.MovingBoundarySolverOptions.RedistributionVersion) SimulationVersion(org.vcell.util.document.SimulationVersion) VCellSoftwareVersion(org.vcell.util.document.VCellSoftwareVersion) SpeciesContext(cbit.vcell.model.SpeciesContext) DataContext(cbit.vcell.data.DataContext) ReactionContext(cbit.vcell.mapping.ReactionContext) RDFXMLContext(org.vcell.pathway.persistence.RDFXMLContext) SimulationContext(cbit.vcell.mapping.SimulationContext) OutputFunctionContext(cbit.vcell.solver.OutputFunctionContext) ParameterContext(cbit.vcell.mapping.ParameterContext) GroupAccess(org.vcell.util.document.GroupAccess) SimpleDateFormat(java.text.SimpleDateFormat)

Example 7 with KeyValue

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;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) KeyValue(org.vcell.util.document.KeyValue) Membrane(cbit.vcell.model.Membrane) Structure(cbit.vcell.model.Structure) Feature(cbit.vcell.model.Feature)

Example 8 with KeyValue

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);
}
Also used : VCPixelClass(cbit.image.VCPixelClass) KeyValue(org.vcell.util.document.KeyValue)

Example 9 with KeyValue

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;
}
Also used : User(org.vcell.util.document.User) KeyValue(org.vcell.util.document.KeyValue) Element(org.jdom.Element) ArrayList(java.util.ArrayList) FieldDataSymbol(cbit.vcell.data.FieldDataSymbol) DataSymbol(cbit.vcell.data.DataSymbol) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) Iterator(java.util.Iterator) DataSymbolType(cbit.vcell.data.DataSymbol.DataSymbolType) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) FieldDataSymbol(cbit.vcell.data.FieldDataSymbol)

Example 10 with KeyValue

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;
}
Also used : KeyValue(org.vcell.util.document.KeyValue) CSGNode(cbit.vcell.geometry.CSGNode) VolumeRegionObject(cbit.vcell.mapping.spatial.VolumeRegionObject) PointObject(cbit.vcell.mapping.spatial.PointObject) SpatialObject(cbit.vcell.mapping.spatial.SpatialObject) SurfaceRegionObject(cbit.vcell.mapping.spatial.SurfaceRegionObject) CSGObject(cbit.vcell.geometry.CSGObject) CSGObject(cbit.vcell.geometry.CSGObject)

Aggregations

KeyValue (org.vcell.util.document.KeyValue)325 DataAccessException (org.vcell.util.DataAccessException)92 User (org.vcell.util.document.User)68 ResultSet (java.sql.ResultSet)57 Statement (java.sql.Statement)52 ObjectNotFoundException (org.vcell.util.ObjectNotFoundException)44 SQLException (java.sql.SQLException)43 BigString (org.vcell.util.BigString)40 BigDecimal (java.math.BigDecimal)38 VCSimulationIdentifier (cbit.vcell.solver.VCSimulationIdentifier)37 BioModel (cbit.vcell.biomodel.BioModel)36 Simulation (cbit.vcell.solver.Simulation)33 XmlParseException (cbit.vcell.xml.XmlParseException)33 PropertyVetoException (java.beans.PropertyVetoException)33 Vector (java.util.Vector)33 Connection (java.sql.Connection)32 ArrayList (java.util.ArrayList)31 File (java.io.File)29 SimulationContext (cbit.vcell.mapping.SimulationContext)28 VCSimulationDataIdentifier (cbit.vcell.solver.VCSimulationDataIdentifier)24