use of org.vcell.util.document.VCDocument in project vcell by virtualcell.
the class MathVerifier method scan.
/**
* Insert the method's description here.
* Creation date: (2/2/01 3:40:29 PM)
*/
public void scan(User[] users, boolean bUpdateDatabase, KeyValue[] bioAndMathModelKeys) throws MathException, MappingException, SQLException, DataAccessException, ModelException, ExpressionException {
// java.util.Calendar calendar = java.util.GregorianCalendar.getInstance();
// // calendar.set(2002,java.util.Calendar.MAY,7+1);
// calendar.set(2002,java.util.Calendar.JULY,1);
// final java.util.Date fluxCorrectionOrDisablingBugFixDate = calendar.getTime();
// // calendar.set(2001,java.util.Calendar.JUNE,13+1);
// calendar.set(2002,java.util.Calendar.JANUARY,1);
// final java.util.Date totalVolumeCorrectionFixDate = calendar.getTime();
KeyValue[] sortedBioAndMathModelKeys = null;
if (bioAndMathModelKeys != null) {
sortedBioAndMathModelKeys = bioAndMathModelKeys.clone();
Arrays.sort(sortedBioAndMathModelKeys, keyValueCpmparator);
}
for (int i = 0; i < users.length; i++) {
User user = users[i];
BioModelInfo[] bioModelInfos0 = dbServerImpl.getBioModelInfos(user, false);
MathModelInfo[] mathModelInfos0 = dbServerImpl.getMathModelInfos(user, false);
if (lg.isTraceEnabled())
lg.trace("Testing user '" + user + "'");
Vector<VCDocumentInfo> userBioAndMathModelInfoV = new Vector<VCDocumentInfo>();
userBioAndMathModelInfoV.addAll(Arrays.asList(bioModelInfos0));
userBioAndMathModelInfoV.addAll(Arrays.asList(mathModelInfos0));
//
for (int j = 0; j < userBioAndMathModelInfoV.size(); j++) {
//
// if certain Bio or Math models are requested, then filter all else out
//
VCDocumentInfo documentInfo = userBioAndMathModelInfoV.elementAt(j);
KeyValue versionKey = documentInfo.getVersion().getVersionKey();
if (sortedBioAndMathModelKeys != null) {
int srch = Arrays.binarySearch(sortedBioAndMathModelKeys, versionKey, keyValueCpmparator);
if (srch < 0) {
continue;
}
}
if (!(documentInfo instanceof BioModelInfo)) {
continue;
}
//
if (skipHash.contains(versionKey)) {
System.out.println("skipping " + (documentInfo instanceof BioModelInfo ? "BioModel" : "MathModel") + " with key '" + versionKey + "'");
continue;
}
try {
//
// read in the BioModel and MathModel from the database
//
VCDocument vcDocumentFromDBCache = null;
BigString vcDocumentXMLFromDBCache = null;
try {
long startTime = System.currentTimeMillis();
if (documentInfo instanceof BioModelInfo) {
vcDocumentXMLFromDBCache = new BigString(dbServerImpl.getServerDocumentManager().getBioModelXML(new QueryHashtable(), user, versionKey, false));
vcDocumentFromDBCache = XmlHelper.XMLToBioModel(new XMLSource(vcDocumentXMLFromDBCache.toString()));
} else {
vcDocumentXMLFromDBCache = new BigString(dbServerImpl.getServerDocumentManager().getMathModelXML(new QueryHashtable(), user, versionKey, false));
vcDocumentFromDBCache = XmlHelper.XMLToMathModel(new XMLSource(vcDocumentXMLFromDBCache.toString()));
}
if (bUpdateDatabase && testFlag.equals(MathVerifier.MV_LOAD_XML)) {
updateLoadModelsStatTable_LoadTest(System.currentTimeMillis() - startTime, versionKey, null);
}
} catch (Exception e) {
lg.error(e.getMessage(), e);
if (bUpdateDatabase && testFlag.equals(MathVerifier.MV_LOAD_XML)) {
updateLoadModelsStatTable_LoadTest(0, versionKey, e);
}
}
if (testFlag.equals(MathVerifier.MV_LOAD_XML)) {
//
if (vcDocumentXMLFromDBCache != null) {
testDocumentLoad(bUpdateDatabase, user, documentInfo, vcDocumentFromDBCache);
}
} else if (testFlag.equals(MathVerifier.MV_DEFAULT)) {
//
if (vcDocumentFromDBCache instanceof BioModel) {
BioModel bioModel = (BioModel) vcDocumentFromDBCache;
checkMathForBioModel(vcDocumentXMLFromDBCache, bioModel, user, bUpdateDatabase);
}
}
} catch (Throwable e) {
// exception in whole BioModel
lg.error(e.getMessage(), e);
// can't update anything in database, since we don't know what simcontexts are involved
}
}
}
}
use of org.vcell.util.document.VCDocument in project vcell by virtualcell.
the class ClientRequestManager method openDocument.
public void openDocument(VCDocumentInfo documentInfo, TopLevelWindowManager requester, boolean inNewWindow) {
// need to check whether we opened this before and we still have it open
if (documentInfo == null) {
return;
}
String documentID = null;
if (documentInfo.getVersion() != null && documentInfo.getVersion().getVersionKey() != null) {
// CLEAN UP BOGUS VERSION in XmlInfo !!!
documentID = documentInfo.getVersion().getVersionKey().toString();
}
// see if we have this open
if (documentID != null && getMdiManager().haveWindow(documentID)) {
// already open, block it
getMdiManager().blockWindow(documentID);
// check for changes
VCDocument openedDoc = ((DocumentWindowManager) getMdiManager().getWindowManager(documentID)).getVCDocument();
boolean isChanged = true;
try {
isChanged = getDocumentManager().isChanged(openedDoc);
} catch (DataAccessException exc) {
// *maybe* something wrong trying to go to database, may not be able to load in the end, but warn anyway and try
String choice = PopupGenerator.showWarningDialog(requester, getUserPreferences(), UserMessage.warn_UnableToCheckForChanges, null);
if (choice.equals(UserMessage.OPTION_CANCEL)) {
// user canceled, just show existing document
getMdiManager().unBlockWindow(documentID);
getMdiManager().showWindow(documentID);
return;
}
}
// we managed to check
if (isChanged) {
// it changed, warn the user
String choice = PopupGenerator.showWarningDialog(requester, getUserPreferences(), UserMessage.choice_AlreadyOpened, null);
if (choice.equals(UserMessage.OPTION_CANCEL)) {
// user canceled, just show existing document
getMdiManager().unBlockWindow(documentID);
getMdiManager().showWindow(documentID);
return;
} else {
// user confirmed, close existing window first
getMdiManager().closeWindow(documentID);
// we are ready to try to get the new document
}
} else {
// nothing changed, just show that window
getMdiManager().unBlockWindow(documentID);
getMdiManager().showWindow(documentID);
return;
}
}
openAfterChecking(documentInfo, requester, inNewWindow);
}
use of org.vcell.util.document.VCDocument in project vcell by virtualcell.
the class TestingFrameworkWindowManager method generateTestCriteriaReport.
/**
* Insert the method's description here.
* Creation date: (8/18/2003 5:36:47 PM)
*/
private String generateTestCriteriaReport(TestCaseNew testCase, TestCriteriaNew testCriteria, Simulation testSim, TFGenerateReport.VCDocumentAndSimInfo userSelectedRefSimInfo) /*,VCDocument refDoc,VCDocument testDocument*/
{
if (testSim.getScanCount() != 1) {
throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
}
SimulationSymbolTable simSymbolTable = new SimulationSymbolTable(testSim, 0);
String simReportStatus = null;
String simReportStatusMessage = null;
StringBuffer reportTCBuffer = new StringBuffer();
VariableComparisonSummary[] failVarSummaries = null;
VariableComparisonSummary[] allVarSummaries = null;
double absErr = 0;
double relErr = 0;
if (testCriteria != null) {
absErr = testCriteria.getMaxAbsError().doubleValue();
relErr = testCriteria.getMaxRelError().doubleValue();
}
try {
VCDocument testDoc = null;
if (testCase instanceof TestCaseNewMathModel) {
MathModelInfo mmInfo = ((TestCaseNewMathModel) testCase).getMathModelInfo();
MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
testDoc = mathModel;
} else if (testCase instanceof TestCaseNewBioModel) {
TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
// bioTestCase.
BioModelInfo bmInfo = bioTestCase.getBioModelInfo();
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
testDoc = bioModel;
}
TFGenerateReport.VCDocumentAndSimInfo refVCDocumentAndSimInfo = null;
if (userSelectedRefSimInfo == null) {
SimulationInfo refSimInfo = testCriteria.getRegressionSimInfo();
if (refSimInfo != null) {
VCDocument refDoc = null;
if (testCriteria instanceof TestCriteriaNewMathModel) {
MathModelInfo mmInfo = ((TestCriteriaNewMathModel) testCriteria).getRegressionMathModelInfo();
MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
refDoc = mathModel;
} else if (testCriteria instanceof TestCriteriaNewBioModel) {
BioModelInfo bmInfo = ((TestCriteriaNewBioModel) testCriteria).getRegressionBioModelInfo();
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
refDoc = bioModel;
}
refVCDocumentAndSimInfo = new TFGenerateReport.VCDocumentAndSimInfo(refSimInfo, refDoc);
}
reportTCBuffer.append("\t\t" + testSim.getName() + (refVCDocumentAndSimInfo != null ? " (Using TestCrit RegrRefSim)" : "") + " : " + "\n");
} else {
refVCDocumentAndSimInfo = userSelectedRefSimInfo;
reportTCBuffer.append("\t\t" + testSim.getName() + " (Using UserDefined RegrRefSim '" + userSelectedRefSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier() + "') : " + "\n");
}
if (testCase.getType().equals(TestCaseNew.REGRESSION) && refVCDocumentAndSimInfo == null) {
reportTCBuffer.append("\t\t\tNo reference SimInfo, SimInfoKey=" + testCriteria.getSimInfo().getVersion().getName() + ". Cannot perform Regression Test!\n");
simReportStatus = TestCriteriaNew.TCRIT_STATUS_NOREFREGR;
} else {
VCDataIdentifier vcdID = new VCSimulationDataIdentifier(testSim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
DataManager simDataManager = getRequestManager().getDataManager(null, vcdID, testSim.isSpatial());
double[] timeArray = null;
// can be histogram, so there won't be time array
try {
timeArray = simDataManager.getDataSetTimes();
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
NonspatialStochSimOptions stochOpt = testSim.getSolverTaskDescription().getStochOpt();
if ((stochOpt == null || stochOpt.getNumOfTrials() == 1) && (timeArray == null || timeArray.length == 0)) {
reportTCBuffer.append("\t\t\tNO DATA : Simulation not run yet.\n");
simReportStatus = TestCriteriaNew.TCRIT_STATUS_NODATA;
} else {
// SPATIAL simulation
if (testSim.getMathDescription().isSpatial()) {
PDEDataManager pdeDataManager = (PDEDataManager) simDataManager;
// Get EXACT solution if test case type is EXACT, Compare with numerical
if (testCase.getType().equals(TestCaseNew.EXACT) || testCase.getType().equals(TestCaseNew.EXACT_STEADY)) {
SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResultsWithExact(simSymbolTable, pdeDataManager, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
// Failed var summaries
failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
// Get CONSTRUCTED solution if test case type is CONSTRUCTED, Compare with numerical
} else if (testCase.getType().equals(TestCaseNew.CONSTRUCTED)) {
SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResultsWithExact(simSymbolTable, pdeDataManager, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
// Failed var summaries
failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
} else if (testCase.getType().equals(TestCaseNew.REGRESSION)) {
Simulation refSim = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(refVCDocumentAndSimInfo.getSimInfo());
VCDataIdentifier refVcdID = new VCSimulationDataIdentifier(refVCDocumentAndSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier(), 0);
PDEDataManager refDataManager = (PDEDataManager) getRequestManager().getDataManager(null, refVcdID, refSim.isSpatial());
if (refSim.getScanCount() != 1) {
throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
}
SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, 0);
String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, refSimSymbolTable);
SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResults(simSymbolTable, pdeDataManager, refSimSymbolTable, refDataManager, varsToCompare, testCriteria.getMaxAbsError(), testCriteria.getMaxRelError(), refVCDocumentAndSimInfo.getVCDocument(), getDataInfoProvider(refVCDocumentAndSimInfo.getVCDocument(), refDataManager.getPDEDataContext(), refSim.getName()), testDoc, getDataInfoProvider(testDoc, pdeDataManager.getPDEDataContext(), testSim.getName()));
// Failed var summaries
failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
}
} else {
// NON-SPATIAL CASE
ODEDataManager odeDataManager = (ODEDataManager) simDataManager;
ODESolverResultSet numericalResultSet = odeDataManager.getODESolverResultSet();
// Get EXACT result set if test case type is EXACT, Compare with numerical
if (testCase.getType().equals(TestCaseNew.EXACT) || testCase.getType().equals(TestCaseNew.EXACT_STEADY)) {
ODESolverResultSet exactResultSet = MathTestingUtilities.getExactResultSet(testSim.getMathDescription(), timeArray, testSim.getSolverTaskDescription().getSensitivityParameter());
String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, simSymbolTable);
SimulationComparisonSummary simCompSummary_exact = MathTestingUtilities.compareResultSets(numericalResultSet, exactResultSet, varsToCompare, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
// Get all the variable comparison summaries and the failed ones to print out report for EXACT solution comparison.
failVarSummaries = simCompSummary_exact.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary_exact.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
// Get CONSTRUCTED result set if test case type is CONSTRUCTED , compare with numerical
} else if (testCase.getType().equals(TestCaseNew.CONSTRUCTED)) {
ODESolverResultSet constructedResultSet = MathTestingUtilities.getConstructedResultSet(testSim.getMathDescription(), timeArray);
String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, simSymbolTable);
SimulationComparisonSummary simCompSummary_constr = MathTestingUtilities.compareResultSets(numericalResultSet, constructedResultSet, varsToCompare, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
// Get all the variable comparison summaries and the failed ones to print out report for CONSTRUCTED solution comparison.
failVarSummaries = simCompSummary_constr.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary_constr.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
} else if (testCase.getType().equals(TestCaseNew.REGRESSION)) {
Simulation refSim = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(testCriteria.getRegressionSimInfo());
if (refSim.getScanCount() != 1) {
throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
}
SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, 0);
String[] varsToTest = getVariableNamesToCompare(simSymbolTable, refSimSymbolTable);
VCDataIdentifier refVcdID = new VCSimulationDataIdentifier(refVCDocumentAndSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier(), 0);
ODEDataManager refDataManager = (ODEDataManager) getRequestManager().getDataManager(null, refVcdID, refSim.isSpatial());
ODESolverResultSet referenceResultSet = refDataManager.getODESolverResultSet();
SimulationComparisonSummary simCompSummary_regr = null;
int interpolationOrder = 1;
SolverTaskDescription solverTaskDescription = refSim.getSolverTaskDescription();
if (solverTaskDescription.getOutputTimeSpec().isDefault() && ((DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec()).getKeepEvery() == 1) {
SolverDescription solverDescription = solverTaskDescription.getSolverDescription();
if ((!solverDescription.supportsAll(SolverDescription.DiscontinutiesFeatures)) || !refSim.getMathDescription().hasDiscontinuities()) {
interpolationOrder = solverDescription.getTimeOrder();
}
}
simCompSummary_regr = MathTestingUtilities.compareUnEqualResultSets(numericalResultSet, referenceResultSet, varsToTest, testCriteria.getMaxAbsError(), testCriteria.getMaxRelError(), interpolationOrder);
// Get all the variable comparison summaries and the failed ones to print out report for CONSTRUCTED solution comparison.
failVarSummaries = simCompSummary_regr.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary_regr.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
}
}
}
}
} catch (Throwable e) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_RPERROR;
simReportStatusMessage = e.getClass().getName() + " " + e.getMessage();
reportTCBuffer.append("\t\t" + simReportStatusMessage + "\n");
e.printStackTrace(System.out);
}
if (userSelectedRefSimInfo == null) {
try {
// Remove any test results already present for testCriteria
RemoveTestResultsOP removeResultsOP = new RemoveTestResultsOP(new BigDecimal[] { testCriteria.getTCritKey() });
// testResultsOPsVector.add(removeResultsOP);
getRequestManager().getDocumentManager().doTestSuiteOP(removeResultsOP);
// Create new AddTestREsultsOP object for the current simulation./testCriteria.
if (allVarSummaries != null) {
AddTestResultsOP testResultsOP = new AddTestResultsOP(testCriteria.getTCritKey(), allVarSummaries);
// testResultsOPsVector.add(testResultsOP);
// Write the testResults for simulation/TestCriteria into the database ...
getRequestManager().getDocumentManager().doTestSuiteOP(testResultsOP);
}
// Update report status
updateTCritStatus(testCriteria, simReportStatus, simReportStatusMessage);
} catch (Throwable e) {
reportTCBuffer.append("\t\tUpdate DB Results failed. " + e.getClass().getName() + " " + e.getMessage() + "\n");
try {
getRequestManager().getDocumentManager().doTestSuiteOP(new EditTestCriteriaOPReportStatus(testCriteria.getTCritKey(), TestCriteriaNew.TCRIT_STATUS_RPERROR, e.getClass().getName() + " " + e.getMessage()));
} catch (Throwable e2) {
// Nothing more can be done
}
}
}
return reportTCBuffer.toString();
}
use of org.vcell.util.document.VCDocument in project vcell by virtualcell.
the class VCellClientDataServiceImpl method getSimsFromOpenModels.
@Override
public List<SimulationDataSetRef> getSimsFromOpenModels() {
ArrayList<SimulationDataSetRef> simulationDataSetRefs = new ArrayList<SimulationDataSetRef>();
for (TopLevelWindowManager windowManager : vcellClient.getMdiManager().getWindowManagers()) {
Simulation[] simulations = null;
VCDocument modelDocument = null;
if (windowManager instanceof BioModelWindowManager) {
BioModelWindowManager selectedBioWindowManager = (BioModelWindowManager) windowManager;
BioModel bioModel = selectedBioWindowManager.getBioModel();
simulations = bioModel.getSimulations();
modelDocument = bioModel;
// simOwnerCount = bioModel.getNumSimulationContexts();
} else if (windowManager instanceof MathModelWindowManager) {
MathModelWindowManager selectedMathWindowManager = (MathModelWindowManager) windowManager;
MathModel mathModel = selectedMathWindowManager.getMathModel();
simulations = mathModel.getSimulations();
modelDocument = mathModel;
// simOwnerCount = 1;
}
if (simulations != null) {
for (Simulation simulation : simulations) {
if (!isVtkSupported(simulation)) {
continue;
}
Origin origin = simulation.getMathDescription().getGeometry().getOrigin();
Extent extent = simulation.getMathDescription().getGeometry().getExtent();
SimulationInfo simInfo = simulation.getSimulationInfo();
SimulationStatus simStatus = vcellClient.getRequestManager().getServerSimulationStatus(simInfo);
for (int jobIndex = 0; jobIndex < simulation.getScanCount(); jobIndex++) {
if (simStatus != null && simStatus.getHasData()) {
SimulationDataSetRef simulationDataSetReference = VCellClientDataServiceImpl.createSimulationDataSetRef(simulation, modelDocument, jobIndex, false);
simulationDataSetRefs.add(simulationDataSetReference);
}
}
}
}
}
File localSimDir = ResourceUtil.getLocalSimDir(User.tempUser.getName());
String[] simtaskFilenames = localSimDir.list((dir, name) -> (name.endsWith(".simtask.xml")));
for (String simtaskFilename : simtaskFilenames) {
try {
SimulationTask simTask = XmlHelper.XMLToSimTask(org.apache.commons.io.FileUtils.readFileToString(new File(localSimDir, simtaskFilename)));
VCDocument modelDocument = null;
SimulationDataSetRef simulationDataSetReference = VCellClientDataServiceImpl.createSimulationDataSetRef(simTask.getSimulation(), modelDocument, simTask.getSimulationJob().getJobIndex(), true);
simulationDataSetRefs.add(simulationDataSetReference);
} catch (ExpressionException | XmlParseException | IOException e) {
e.printStackTrace();
}
}
return simulationDataSetRefs;
}
use of org.vcell.util.document.VCDocument in project vcell by virtualcell.
the class DocumentWindow method showEditAnnotationWindow.
// /**
// * Comment
// */
// private void showBNGWindow() {
// getWindowManager().showBNGWindow();
// }
/**
* Comment
*/
private void showEditAnnotationWindow() {
try {
if (getWindowManager() != null) {
VCDocument vcDoc = getWindowManager().getVCDocument();
if (vcDoc != null) {
try {
// initialize fields - different for biomodel and mathmodel, geometry
String oldAnnotation = null;
if (vcDoc instanceof BioModel) {
oldAnnotation = ((BioModel) vcDoc).getVCMetaData().getFreeTextAnnotation((BioModel) vcDoc);
} else {
oldAnnotation = vcDoc.getDescription();
}
// show the editor
String newAnnotation = DialogUtils.showAnnotationDialog(this, oldAnnotation);
if (org.vcell.util.BeanUtils.triggersPropertyChangeEvent(oldAnnotation, newAnnotation)) {
// if VCDocument is a Biomodel, set the vcMetadata, else edit VCDoc.description for now
if (vcDoc instanceof BioModel) {
// update free text annotation in VCMetaData
VCMetaData vcMetaData = ((BioModel) vcDoc).getVCMetaData();
vcMetaData.setFreeTextAnnotation((BioModel) vcDoc, newAnnotation);
} else {
// Update VCDocument annotation
vcDoc.setDescription(newAnnotation);
}
}
} catch (UtilCancelException e) {
// Do Nothing
}
} else {
throw new Exception("No Document to Edit");
}
}
} catch (Throwable exc) {
exc.printStackTrace(System.out);
PopupGenerator.showErrorDialog(this, "Failed to edit annotation!\n" + exc.getMessage(), exc);
}
}
Aggregations