Search in sources :

Example 1 with Xmlproducer

use of cbit.vcell.xml.Xmlproducer in project vcell by virtualcell.

the class BioModelEditorApplicationsPanel method compareButtonPressed.

private void compareButtonPressed() {
    int[] rows = table.getSelectedRows();
    if (rows == null || rows.length != 2) {
        return;
    }
    try {
        SimulationContext simContext1 = tableModel.getValueAt(rows[0]);
        SimulationContext simContext2 = tableModel.getValueAt(rows[1]);
        BioModel bioModel = simContext1.getBioModel();
        MathMappingCallback callback = new MathMappingCallback() {

            @Override
            public void setProgressFraction(float fractionDone) {
                Thread.dumpStack();
                System.out.println("---> stdout mathMapping: progress = " + (fractionDone * 100.0) + "% done");
            }

            @Override
            public void setMessage(String message) {
                Thread.dumpStack();
                System.out.println("---> stdout mathMapping: message = " + message);
            }

            @Override
            public boolean isInterrupted() {
                return false;
            }
        };
        simContext1.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
        simContext2.refreshMathDescription(callback, NetworkGenerationRequirements.ComputeFullStandardTimeout);
        Xmlproducer xmlProducer = new Xmlproducer(false);
        String simContext1XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext1, bioModel));
        String simContext2XML = XmlUtil.xmlToString(xmlProducer.getXML(simContext2, bioModel));
        DiffConfiguration comparisonSetting = DiffConfiguration.COMPARE_DOCS_OTHER;
        XmlTreeDiff diffTree = XmlHelper.compareMerge(simContext1XML, simContext2XML, comparisonSetting, true);
        String baselineDesc = "application " + simContext1.getName();
        String modifiedDesc = "application " + simContext2.getName();
        TMLPanel comparePanel = new TMLPanel();
        comparePanel.setXmlTreeDiff(diffTree);
        comparePanel.setBaselineVersionDescription(baselineDesc);
        comparePanel.setModifiedVersionDescription(modifiedDesc);
        ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(this);
        String title = "comparing application " + simContext1.getName() + " and " + simContext2.getName();
        ChildWindow childWindow = childWindowManager.addChildWindow(comparePanel, diffTree, title, true);
        childWindow.setSize(new Dimension(600, 600));
        childWindow.show();
    } catch (XmlParseException e) {
        e.printStackTrace();
        DialogUtils.showErrorDialog(this, "failed to compare applications: \n\n" + e.getMessage());
    }
}
Also used : DiffConfiguration(cbit.xml.merge.XmlTreeDiff.DiffConfiguration) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) Xmlproducer(cbit.vcell.xml.Xmlproducer) XmlTreeDiff(cbit.xml.merge.XmlTreeDiff) ChildWindowManager(cbit.vcell.client.ChildWindowManager) Dimension(java.awt.Dimension) XmlParseException(cbit.vcell.xml.XmlParseException) SimulationContext(cbit.vcell.mapping.SimulationContext) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) TMLPanel(cbit.xml.merge.gui.TMLPanel) BioModel(cbit.vcell.biomodel.BioModel)

Example 2 with Xmlproducer

use of cbit.vcell.xml.Xmlproducer in project vcell by virtualcell.

the class ModelTable method getSQLValueList.

/**
 * This method was created in VisualAge.
 * @return java.lang.String
 * @param key KeyValue
 * @param modelName java.lang.String
 */
public String getSQLValueList(Model model, String rbm, Version version) {
    Xmlproducer xmlProducer = new Xmlproducer(false);
    String modelUnitSystemXML = TokenMangler.getSQLEscapedString(XmlUtil.xmlToString(xmlProducer.getXML(model.getUnitSystem())));
    StringBuffer buffer = new StringBuffer();
    buffer.append("(");
    buffer.append(getVersionGroupSQLValue(version) + ",");
    buffer.append("'" + modelUnitSystemXML + "'" + ",");
    if (rbm == null) {
        buffer.append("null,null");
    } else if (DbDriver.varchar2_CLOB_is_Varchar2_OK(rbm)) {
        buffer.append("null" + "," + DbDriver.INSERT_VARCHAR2_HERE);
    } else {
        buffer.append(DbDriver.INSERT_CLOB_HERE + "," + "null");
    }
    buffer.append(")");
    return buffer.toString();
}
Also used : Xmlproducer(cbit.vcell.xml.Xmlproducer)

Example 3 with Xmlproducer

use of cbit.vcell.xml.Xmlproducer in project vcell by virtualcell.

the class GlobalModelParameterTable method insertModelParameters.

public void insertModelParameters(Connection con, KeyFactory keyFactory, Model.ModelParameter[] modelParametersArr, KeyValue modelKey) throws DataAccessException, SQLException {
    String modelParameeterXML = null;
    if (modelParametersArr != null && modelParametersArr.length > 0) {
        Xmlproducer xmlProducer = new Xmlproducer(true);
        modelParameeterXML = XmlUtil.xmlToString(xmlProducer.getXML(modelParametersArr));
    }
    if (modelParameeterXML == null) {
        return;
    }
    final int MAX_CHARS = 3000;
    for (int i = 0; i < modelParameeterXML.length(); i += MAX_CHARS) {
        String modelParameeterXMLS = modelParameeterXML.substring(i, i + Math.min(MAX_CHARS, modelParameeterXML.length() - i));
        if (modelParameeterXMLS != null) {
            modelParameeterXMLS = org.vcell.util.TokenMangler.getSQLEscapedString(modelParameeterXMLS);
        }
        String modelParameeterXMLValues = GlobalModelParameterTable.table.getSQLValueList(modelKey, modelParameeterXMLS, keyFactory);
        String sql = "INSERT INTO " + GlobalModelParameterTable.table.getTableName() + " " + GlobalModelParameterTable.table.getSQLColumnList() + " VALUES " + modelParameeterXMLValues;
        // System.out.println(sql);
        DbDriver.updateCleanSQL(con, sql);
    }
}
Also used : Xmlproducer(cbit.vcell.xml.Xmlproducer)

Example 4 with Xmlproducer

use of cbit.vcell.xml.Xmlproducer in project vcell by virtualcell.

the class ApplicationMathTable method saveOutputFunctions.

private void saveOutputFunctions(Connection con, KeyValue mathModelRef, KeyValue simContextRef, ArrayList<AnnotatedFunction> outputFunctionsList, DatabaseSyntax dbSyntax, KeyFactory keyFactory) throws SQLException, DataAccessException {
    if (outputFunctionsList == null || outputFunctionsList.size() == 0) {
        return;
    }
    if (mathModelRef == null && simContextRef == null) {
        throw new DataAccessException("must have either mathmodel or simcontext reference for saving OutputFunctions");
    }
    if (mathModelRef != null && simContextRef != null) {
        throw new DataAccessException("OutputFunctions can be saved to either a mathmodel or simcontext, not both");
    }
    String outputFunctionsXML = XmlUtil.xmlToString((new Xmlproducer(false)).getXML(outputFunctionsList));
    String tableValues = null;
    if (DbDriver.varchar2_CLOB_is_Varchar2_OK(outputFunctionsXML)) {
        tableValues = "null" + "," + DbDriver.INSERT_VARCHAR2_HERE;
    } else {
        tableValues = DbDriver.INSERT_CLOB_HERE + "," + "null";
    }
    KeyValue newKey = keyFactory.getNewKey(con);
    String sql = "INSERT INTO " + ApplicationMathTable.table.getTableName() + " VALUES (" + newKey.toString() + "," + (simContextRef != null ? simContextRef.toString() : "NULL") + "," + tableValues + "," + (mathModelRef != null ? mathModelRef.toString() : "NULL") + ")";
    DbDriver.varchar2_CLOB_update(con, sql, outputFunctionsXML, ApplicationMathTable.table, newKey, ApplicationMathTable.table.outputFuncLarge, ApplicationMathTable.table.outputFuncSmall, dbSyntax);
}
Also used : KeyValue(org.vcell.util.document.KeyValue) Xmlproducer(cbit.vcell.xml.Xmlproducer) DataAccessException(org.vcell.util.DataAccessException)

Example 5 with Xmlproducer

use of cbit.vcell.xml.Xmlproducer in project vcell by virtualcell.

the class SubVolumeTable method getSQLValueList.

/**
 * This method was created in VisualAge.
 * @return java.lang.String
 * @param key KeyValue
 * @param modelName java.lang.String
 */
public String getSQLValueList(InsertHashtable hash, KeyValue key, Geometry geom, SubVolume sv, KeyValue geomKey, int ordinalValue) throws DataAccessException {
    StringBuffer buffer = new StringBuffer();
    buffer.append("(");
    buffer.append(key + ",");
    buffer.append("'" + sv.getName() + "',");
    if (sv instanceof ImageSubVolume) {
        ImageSubVolume isv = (ImageSubVolume) sv;
        KeyValue pixelClassKey = hash.getDatabaseKey(isv.getPixelClass());
        if (pixelClassKey == null) {
            pixelClassKey = isv.getPixelClass().getKey();
        }
        if (pixelClassKey == null) {
            throw new DataAccessException("can't get a KeyValue for pixelClass while inserting an imageSubVolume");
        }
        buffer.append(pixelClassKey + ",");
    } else {
        buffer.append("null" + ",");
    }
    // buffer.append(geom.getKey() + ",");
    buffer.append(geomKey + ",");
    if (sv instanceof AnalyticSubVolume) {
        buffer.append("'" + TokenMangler.getSQLEscapedString(((AnalyticSubVolume) sv).getExpression().infix()) + "',");
    } else if (sv instanceof CSGObject) {
        Xmlproducer producer = new Xmlproducer(true);
        buffer.append("'" + TokenMangler.getSQLEscapedString(XmlUtil.xmlToString(producer.getXML((CSGObject) sv))) + "',");
    } else {
        buffer.append("null" + ",");
    }
    buffer.append(sv.getHandle() + ",");
    buffer.append(ordinalValue + ")");
    return buffer.toString();
}
Also used : KeyValue(org.vcell.util.document.KeyValue) Xmlproducer(cbit.vcell.xml.Xmlproducer) CSGObject(cbit.vcell.geometry.CSGObject) AnalyticSubVolume(cbit.vcell.geometry.AnalyticSubVolume) ImageSubVolume(cbit.vcell.geometry.ImageSubVolume) DataAccessException(org.vcell.util.DataAccessException)

Aggregations

Xmlproducer (cbit.vcell.xml.Xmlproducer)10 Element (org.jdom.Element)5 DataAccessException (org.vcell.util.DataAccessException)4 XmlParseException (cbit.vcell.xml.XmlParseException)2 BufferedOutputStream (java.io.BufferedOutputStream)2 SQLException (java.sql.SQLException)2 KeyValue (org.vcell.util.document.KeyValue)2 QueryHashtable (cbit.sql.QueryHashtable)1 ImageDataset (cbit.vcell.VirtualMicroscopy.ImageDataset)1 BioModel (cbit.vcell.biomodel.BioModel)1 ChildWindowManager (cbit.vcell.client.ChildWindowManager)1 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)1 AnalyticSubVolume (cbit.vcell.geometry.AnalyticSubVolume)1 CSGObject (cbit.vcell.geometry.CSGObject)1 ImageSubVolume (cbit.vcell.geometry.ImageSubVolume)1 AssignmentRule (cbit.vcell.mapping.AssignmentRule)1 BioEvent (cbit.vcell.mapping.BioEvent)1 RateRule (cbit.vcell.mapping.RateRule)1 ReactionRuleSpec (cbit.vcell.mapping.ReactionRuleSpec)1 SimulationContext (cbit.vcell.mapping.SimulationContext)1