Search in sources :

Example 1 with Filament

use of cbit.vcell.geometry.Filament in project vcell by virtualcell.

the class Xmlproducer method getXML.

/**
 * This method returns a XML representation of a Geometry object.
 * Creation date: (2/28/2001 5:51:36 PM)
 * @return Element
 * @param param cbit.vcell.geometry.Geometry
 */
public Element getXML(Geometry param) throws XmlParseException {
    Element geometry = new Element(XMLTags.GeometryTag);
    // Add attributes
    String name = param.getName();
    geometry.setAttribute(XMLTags.NameAttrTag, mangle(name));
    geometry.setAttribute(XMLTags.DimensionAttrTag, String.valueOf(param.getDimension()));
    // add Annotation
    if (param.getDescription() != null && param.getDescription().length() > 0) {
        Element annotationElem = new Element(XMLTags.AnnotationTag);
        annotationElem.setText(mangle(param.getDescription()));
        geometry.addContent(annotationElem);
    }
    // add sub-elements
    // Create extent subelement
    geometry.addContent(getXML(param.getExtent()));
    // Add Origin subelement
    Element origin = new Element(XMLTags.OriginTag);
    // Add Origin attributes
    origin.setAttribute(XMLTags.XAttrTag, String.valueOf(param.getOrigin().getX()));
    origin.setAttribute(XMLTags.YAttrTag, String.valueOf(param.getOrigin().getY()));
    origin.setAttribute(XMLTags.ZAttrTag, String.valueOf(param.getOrigin().getZ()));
    geometry.addContent(origin);
    // Add Image	subelement if there is.
    if (param.getGeometrySpec().getImage() != null) {
        try {
            geometry.addContent(getXML(param.getGeometrySpec().getImage()));
        } catch (XmlParseException e) {
            e.printStackTrace();
            throw new XmlParseException("A problem occurred when trying to get the Image for the geometry " + name, e);
        }
    }
    // Add subvolumes elements
    for (int i = 0; i < param.getGeometrySpec().getSubVolumes().length; i++) {
        geometry.addContent(getXML(param.getGeometrySpec().getSubVolumes(i)));
    }
    if (param.getDimension() > 0 && param.getGeometrySurfaceDescription() != null && param.getGeometrySurfaceDescription().getSurfaceClasses() != null) {
        // Add SurfaceClass elements
        for (int i = 0; i < param.getGeometrySurfaceDescription().getSurfaceClasses().length; i++) {
            geometry.addContent(getXML(param.getGeometrySurfaceDescription().getSurfaceClasses()[i]));
        }
    }
    // Add Filaments
    if (param.getDimension() > 0) {
        Filament[] filarray = param.getGeometrySpec().getFilamentGroup().getFilaments();
        for (int i = 0; i < filarray.length; i++) {
            geometry.addContent(getXML(filarray[i]));
        }
    }
    // Add Surface descriptions, if any
    GeometrySurfaceDescription gsd = param.getGeometrySurfaceDescription();
    if (gsd != null) {
        geometry.addContent(getXML(gsd));
    }
    // Add Metadata(version) if there is one
    if (param.getVersion() != null) {
        geometry.addContent(getXML(param.getVersion(), param));
    }
    return geometry;
}
Also used : Filament(cbit.vcell.geometry.Filament) GeometrySurfaceDescription(cbit.vcell.geometry.surface.GeometrySurfaceDescription) Element(org.jdom.Element)

Example 2 with Filament

use of cbit.vcell.geometry.Filament in project vcell by virtualcell.

the class GeomDbDriver method insertFilamentsSQL.

/**
 * This method was created in VisualAge.
 * @param vcimage cbit.image.VCImage
 * @param userid java.lang.String
 * @exception java.rmi.RemoteException The exception description.
 */
private void insertFilamentsSQL(Connection con, Geometry geom, KeyValue geomKey) throws SQLException, DataAccessException {
    String sql;
    Filament[] filaments = geom.getGeometrySpec().getFilamentGroup().getFilaments();
    for (int i = 0; i < filaments.length; i++) {
        // Iterate through Filaments
        KeyValue newFilamentKey = keyFactory.getNewKey(con);
        // 
        // Insert Filament
        // 
        Filament currentFilament = filaments[i];
        sql = "INSERT INTO " + filamentTable.getTableName() + " " + filamentTable.getSQLColumnList() + " VALUES " + filamentTable.getSQLValueList(newFilamentKey, currentFilament.getName(), geomKey);
        updateCleanSQL(con, sql);
        // 
        // Insert all Curves for this filament
        // 
        Curve[] curves = currentFilament.getCurves();
        for (int j = 0; j < curves.length; j += 1) {
            KeyValue newCurveKey = keyFactory.getNewKey(con);
            sql = "INSERT INTO " + curveTable.getTableName() + " " + curveTable.getSQLColumnList() + " VALUES " + curveTable.getSQLValueList(newCurveKey, newFilamentKey, dbSyntax);
            // 
            switch(dbSyntax) {
                case ORACLE:
                    {
                        updateCleanSQL(con, sql);
                        updateCleanLOB(con, curveTable.id.toString(), newCurveKey, curveTable.tableName, curveTable.curveData, CurveTable.encodeCurve(curves[j]), dbSyntax);
                        break;
                    }
                case POSTGRES:
                    {
                        updatePreparedCleanSQL(con, sql, CurveTable.encodeCurve(curves[j]));
                        break;
                    }
                default:
                    {
                        throw new RuntimeException("unexpected DatabaseSyntax " + dbSyntax);
                    }
            }
        }
    }
}
Also used : Filament(cbit.vcell.geometry.Filament) KeyValue(org.vcell.util.document.KeyValue) Curve(cbit.vcell.geometry.Curve)

Aggregations

Filament (cbit.vcell.geometry.Filament)2 Curve (cbit.vcell.geometry.Curve)1 GeometrySurfaceDescription (cbit.vcell.geometry.surface.GeometrySurfaceDescription)1 Element (org.jdom.Element)1 KeyValue (org.vcell.util.document.KeyValue)1