Search in sources :

Example 11 with SimulationInfo

use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.

the class ResultSetCrawler method scanUserDirectory.

/**
 * Insert the method's description here.
 * Creation date: (2/2/01 3:40:29 PM)
 */
private static void scanUserDirectory(File userDir, ExternalDataIdentifier[] extDataIDArr, SimulationInfo[] simulationInfos, File outputDir, final boolean bScanOnly, AmplistorUtils.AmplistorCredential amplistorCredential) throws Exception {
    File outputFile = null;
    java.io.PrintWriter writer = null;
    try {
        long timestamp = new Date().getTime();
        outputFile = new File(outputDir, "ResultSetCrawler_" + userDir.getName() + "_" + timestamp + ".txt");
        writer = new java.io.PrintWriter(new java.io.FileOutputStream(outputFile));
        final PrintWriter pw = writer;
        pw.println("scanning directory : " + userDir.getPath());
        if (lg.isTraceEnabled())
            lg.trace("scanning directory : " + userDir.getPath());
        // 
        // gather list of keys that should be retained.
        // 
        final HashSet<KeyValue> referencedKeys = new HashSet<KeyValue>();
        for (ExternalDataIdentifier extDataId : extDataIDArr) {
            referencedKeys.add(extDataId.getKey());
        }
        for (SimulationInfo simulationInfo : simulationInfos) {
            referencedKeys.add(simulationInfo.getSimulationVersion().getVersionKey());
        }
        if (amplistorCredential != null) {
            try {
                if (bScanOnly) {
                    ArrayList<String> shouldBeDeleted = AmplistorUtils.deleteSimFilesNotInHash(AmplistorUtils.DEFAULT_AMPLI_SERVICE_VCELL_URL + userDir.getName(), referencedKeys, bScanOnly, amplistorCredential);
                    for (String fileName : shouldBeDeleted) {
                        pw.println("Should delete Amplistor " + fileName);
                        if (lg.isTraceEnabled())
                            lg.trace("Should delete Amplistor " + fileName);
                    }
                } else {
                    ArrayList<String> wasDeleted = AmplistorUtils.deleteSimFilesNotInHash(AmplistorUtils.DEFAULT_AMPLI_SERVICE_VCELL_URL + userDir.getName(), referencedKeys, bScanOnly, amplistorCredential);
                    for (String fileName : wasDeleted) {
                        pw.println("deleted Amplistor " + fileName);
                        if (lg.isTraceEnabled())
                            lg.trace("deleted Amplistor " + fileName);
                    }
                }
            } catch (Exception e) {
                if (lg.isTraceEnabled())
                    lg.trace("Amplistor delete failed url=" + AmplistorUtils.DEFAULT_AMPLI_SERVICE_VCELL_URL + userDir.getName() + " : " + e.getMessage());
                pw.println("Amplistor delete failed url=" + AmplistorUtils.DEFAULT_AMPLI_SERVICE_VCELL_URL + userDir.getName() + " : " + e.getMessage());
            }
        }
        final HashMap<KeyValue, Integer> deletedKeyMap = new HashMap<KeyValue, Integer>();
        // 
        // visit each file and delete it on the fly (through a FileFilter)
        // 
        FileFilter fileVisitor = new FileFilter() {

            @Override
            public boolean accept(File file) {
                String filename = file.getName();
                String[] parts = filename.split("\\_|\\.");
                if (parts.length > 0 && parts[0].equals("SimID")) {
                    if (parts.length > 1) {
                        String simkeyString = parts[1];
                        try {
                            KeyValue simKey = new KeyValue(simkeyString);
                            if (!referencedKeys.contains(simKey)) {
                                Integer count = deletedKeyMap.get(simKey);
                                if (count == null) {
                                    deletedKeyMap.put(simKey, 1);
                                    count = 1;
                                } else {
                                    deletedKeyMap.put(simKey, 1 + count.intValue());
                                }
                                if (bScanOnly) {
                                    pw.println("Should delete file(" + count + ") with key " + simKey + " : " + file.getPath());
                                    if (lg.isTraceEnabled())
                                        lg.trace("Should delete file(" + count + ") with key " + simKey + " : " + file.getPath());
                                } else {
                                    pw.println("deleted file(" + simKey + ":" + count + ") " + file.getPath());
                                    if (lg.isTraceEnabled())
                                        lg.trace("deleted file(" + simKey + ":" + count + ") " + file.getPath());
                                    file.delete();
                                }
                            }
                        } catch (Exception e) {
                            if (lg.isTraceEnabled())
                                lg.trace("failed to process file " + file.getPath() + ": " + e.getMessage());
                        }
                    }
                }
                return false;
            }
        };
        // 
        // visit all of the files and delete if bScanOnly=false
        // 
        userDir.listFiles(fileVisitor);
        pw.println("done scanning directory : " + userDir.getPath());
        if (lg.isTraceEnabled())
            lg.trace("done scanning directory : " + userDir.getPath());
    } finally {
        if (writer != null) {
            writer.close();
        }
        if (lg.isTraceEnabled())
            lg.trace("User " + userDir.getName() + ", See " + outputFile.getAbsolutePath() + " for details");
    }
}
Also used : PrintWriter(java.io.PrintWriter) KeyValue(org.vcell.util.document.KeyValue) HashMap(java.util.HashMap) Date(java.util.Date) DataAccessException(org.vcell.util.DataAccessException) SQLException(java.sql.SQLException) ExternalDataIdentifier(org.vcell.util.document.ExternalDataIdentifier) FileFilter(java.io.FileFilter) File(java.io.File) PrintWriter(java.io.PrintWriter) HashSet(java.util.HashSet) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 12 with SimulationInfo

use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.

the class DatabaseServerImpl method getVersionInfos.

/**
 * This method was created in VisualAge.
 * @return GeometryInfo
 * @param key KeyValue
 * @exception org.vcell.util.DataAccessException The exception description.
 * @exception java.rmi.RemoteException The exception description.
 */
private VersionInfo[] getVersionInfos(User user, KeyValue key, VersionableType vType, boolean bAll, boolean bCheckPermission) throws DataAccessException {
    try {
        if (lg.isTraceEnabled())
            lg.trace("DatabaseServerImpl.getVersionInfos(User=" + user + ",vType=" + vType + ",bAll=" + bAll + ")");
        Vector<VersionInfo> vector = dbTop.getVersionableInfos(user, key, vType, bAll, bCheckPermission, true);
        if (vType.equals(VersionableType.BioModelMetaData)) {
            BioModelInfo[] bioModelInfos = new BioModelInfo[vector.size()];
            vector.copyInto(bioModelInfos);
            return bioModelInfos;
        } else if (vType.equals(VersionableType.Geometry)) {
            GeometryInfo[] geoInfos = new GeometryInfo[vector.size()];
            vector.copyInto(geoInfos);
            return geoInfos;
        } else if (vType.equals(VersionableType.MathModelMetaData)) {
            MathModelInfo[] mathInfos = new MathModelInfo[vector.size()];
            vector.copyInto(mathInfos);
            return mathInfos;
        } else if (vType.equals(VersionableType.VCImage)) {
            VCImageInfo[] imgInfos = new VCImageInfo[vector.size()];
            vector.copyInto(imgInfos);
            return imgInfos;
        } else if (vType.equals(VersionableType.Simulation)) {
            SimulationInfo[] simInfos = new SimulationInfo[vector.size()];
            vector.copyInto(simInfos);
            return simInfos;
        } else {
            throw new IllegalArgumentException("Wrong VersinableType vType:" + vType);
        }
    } catch (SQLException e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException(e.getMessage());
    } catch (ObjectNotFoundException e) {
        lg.error(e.getMessage(), e);
        throw new ObjectNotFoundException(e.getMessage());
    } catch (Throwable e) {
        lg.error(e.getMessage(), e);
        throw new DataAccessException(e.getMessage());
    }
}
Also used : SQLException(java.sql.SQLException) BioModelInfo(org.vcell.util.document.BioModelInfo) MathModelInfo(org.vcell.util.document.MathModelInfo) VersionInfo(org.vcell.util.document.VersionInfo) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 13 with SimulationInfo

use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.

the class EditTestCriteriaPanel method selectRefSimInfo.

/**
 * Comment
 */
private void selectRefSimInfo(java.awt.event.ActionEvent actionEvent) {
    SimulationInfo simInfo = getTestingFrameworkWindowManager().selectRefSimInfo(getReferenceMathModelInfo());
    if (simInfo != null) {
        setReferenceSimInfo(simInfo);
        getRefSimLabel().setText("<html>" + simInfo.getVersion().getName() + "<br>(SimulationKey:" + simInfo.getVersion().getVersionKey() + ")</html>");
    } else {
        PopupGenerator.showErrorDialog(this, "Reference SimInfo not selected!");
    }
}
Also used : SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 14 with SimulationInfo

use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.

the class EditTestCriteriaPanel method setbmAppSimInfo.

/**
 * Set the bmAppSimInfo to a new value.
 * @param newValue cbit.vcell.solver.SimulationInfo
 */
/* WARNING: THIS METHOD WILL BE REGENERATED. */
private void setbmAppSimInfo(SimulationInfo newValue) {
    if (ivjbmAppSimInfo != newValue) {
        try {
            SimulationInfo oldValue = getbmAppSimInfo();
            ivjbmAppSimInfo = newValue;
            firePropertyChange("referenceSimInfo", oldValue, newValue);
        // user code begin {1}
        // user code end
        } catch (java.lang.Throwable ivjExc) {
            // user code begin {2}
            // user code end
            handleException(ivjExc);
        }
    }
    ;
// user code begin {3}
// user code end
}
Also used : SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 15 with SimulationInfo

use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.

the class MathModelWindowManager method checkValidSimulationDataViewerFrames.

/**
 * Insert the method's description here.
 * Creation date: (7/20/2004 1:13:06 PM)
 */
private void checkValidSimulationDataViewerFrames() {
    SimulationWindow[] simWindows = (SimulationWindow[]) BeanUtils.getArray(simulationWindowsHash.elements(), SimulationWindow.class);
    Simulation[] sims = getMathModel().getSimulations();
    Hashtable<VCSimulationIdentifier, Simulation> hash = new Hashtable<VCSimulationIdentifier, Simulation>();
    for (int i = 0; i < sims.length; i++) {
        SimulationInfo simInfo = sims[i].getSimulationInfo();
        if (simInfo != null) {
            VCSimulationIdentifier vcSimulationIdentifier = simInfo.getAuthoritativeVCSimulationIdentifier();
            hash.put(vcSimulationIdentifier, sims[i]);
        }
    }
    for (int i = 0; i < simWindows.length; i++) {
        if (hash.containsKey(simWindows[i].getVcSimulationIdentifier())) {
            simWindows[i].resetSimulation((Simulation) hash.get(simWindows[i].getVcSimulationIdentifier()));
        } else {
            ChildWindowManager childWindowManager = ChildWindowManager.findChildWindowManager(getJPanel());
            ChildWindow childWindow = childWindowManager.getChildWindowFromContext(simWindows[i]);
            if (childWindow != null) {
                childWindow.close();
            }
        }
    }
}
Also used : VCSimulationIdentifier(cbit.vcell.solver.VCSimulationIdentifier) Simulation(cbit.vcell.solver.Simulation) Hashtable(java.util.Hashtable) SimulationWindow(cbit.vcell.client.desktop.simulation.SimulationWindow) ChildWindow(cbit.vcell.client.ChildWindowManager.ChildWindow) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Aggregations

SimulationInfo (cbit.vcell.solver.SimulationInfo)31 Simulation (cbit.vcell.solver.Simulation)12 SimulationStatus (cbit.vcell.server.SimulationStatus)8 Hashtable (java.util.Hashtable)8 BioModel (cbit.vcell.biomodel.BioModel)7 Vector (java.util.Vector)7 MathModel (cbit.vcell.mathmodel.MathModel)6 TestCriteriaNewBioModel (cbit.vcell.numericstest.TestCriteriaNewBioModel)6 DataAccessException (org.vcell.util.DataAccessException)6 BioModelInfo (org.vcell.util.document.BioModelInfo)6 MathModelInfo (org.vcell.util.document.MathModelInfo)6 TestCriteriaNewMathModel (cbit.vcell.numericstest.TestCriteriaNewMathModel)5 KeyValue (org.vcell.util.document.KeyValue)5 VCDocument (org.vcell.util.document.VCDocument)4 ChildWindow (cbit.vcell.client.ChildWindowManager.ChildWindow)3 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 TFGenerateReport (cbit.vcell.client.task.TFGenerateReport)3 Geometry (cbit.vcell.geometry.Geometry)3 EditTestCriteriaOPBioModel (cbit.vcell.numericstest.EditTestCriteriaOPBioModel)3 TestCaseNewBioModel (cbit.vcell.numericstest.TestCaseNewBioModel)3