use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class FrapDataUtils method getVCSimulationIdentifierFromVCellSimulationData.
public static VCSimulationIdentifier getVCSimulationIdentifierFromVCellSimulationData(File vcellSimLogFile) {
final String SIMID_PREFIX = "SimID_";
String simulationKeyS = vcellSimLogFile.getName().substring(SIMID_PREFIX.length(), vcellSimLogFile.getName().indexOf('_', SIMID_PREFIX.length()));
KeyValue simulationKey = new KeyValue(simulationKeyS);
return new VCSimulationIdentifier(simulationKey, getDotUser());
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class MathModelWindowManager method simStatusChanged.
/**
* Insert the method's description here.
* Creation date: (5/14/2004 11:08:35 AM)
* @param newMathModel cbit.vcell.mathmodel.MathModel
*/
// private void setMathModel(MathModel newMathModel) {
// resetGeometryListeners((getMathModel() != null?(getMathModel().getMathDescription() != null?getMathModel().getMathDescription().getGeometry():null):null),
// (newMathModel != null?(newMathModel.getMathDescription() != null?newMathModel.getMathDescription().getGeometry():null):null));
//
// resetMathDescriptionListeners(
// (getMathModel() != null?getMathModel().getMathDescription():null),
// (newMathModel != null?newMathModel.getMathDescription():null));
// if (getMathModel() != null) {
// getMathModel().removePropertyChangeListener(this);
// }
// mathModel = newMathModel;
// if (getMathModel() != null) {
// getMathModel().addPropertyChangeListener(this);
// }
// }
// private void resetMathDescriptionListeners(MathDescription oldMathDescription,MathDescription newMathDescription){
// if(oldMathDescription != null){
// oldMathDescription.removePropertyChangeListener(this);
// }
// if(newMathDescription != null){
// newMathDescription.addPropertyChangeListener(this);
// }
// }
// /**
// * Insert the method's description here.
// * Creation date: (6/14/2004 10:55:40 PM)
// * @param newDocument cbit.vcell.document.VCDocument
// */
// private void showDataViewerPlotsFrame(final javax.swing.JInternalFrame plotFrame) {
// dataViewerPlotsFramesVector.add(plotFrame);
// showFrame(plotFrame);
// plotFrame.addInternalFrameListener(new javax.swing.event.InternalFrameAdapter() {
// public void internalFrameClosing(javax.swing.event.InternalFrameEvent e) {
// dataViewerPlotsFramesVector.remove(plotFrame);
// }
// });
// }
// /**
// * Insert the method's description here.
// * Creation date: (6/14/2004 10:55:40 PM)
// * @param newDocument cbit.vcell.document.VCDocument
// */
// public void showDataViewerPlotsFrames(javax.swing.JInternalFrame[] plotFrames) {
// for (int i = 0; i < plotFrames.length; i++){
// showDataViewerPlotsFrame(plotFrames[i]);
// }
// }
/**
* Insert the method's description here.
* Creation date: (6/9/2004 3:58:21 PM)
* @param newJobStatus cbit.vcell.messaging.db.SimulationJobStatus
* @param progress java.lang.Double
* @param timePoint java.lang.Double
*/
public void simStatusChanged(SimStatusEvent simStatusEvent) {
// ** events are only generated from server side job statuses **
KeyValue simKey = simStatusEvent.getVCSimulationIdentifier().getSimulationKey();
// do we have the sim?
Simulation[] sims = getMathModel().getSimulations();
if (sims == null) {
// we don't have it
return;
}
Simulation simulation = null;
for (int i = 0; i < sims.length; i++) {
if (simKey.equals(sims[i].getKey()) || ((sims[i].getSimulationVersion() != null) && simKey.equals(sims[i].getSimulationVersion().getParentSimulationReference()))) {
simulation = sims[i];
break;
}
}
if (simulation == null) {
// we don't have it
return;
}
// we have it; get current server side status
SimulationStatus simStatus = getRequestManager().getServerSimulationStatus(simulation.getSimulationInfo());
// if failed, notify
if (simStatusEvent.isNewFailureEvent()) {
String qualifier = "";
if (simulation.getScanCount() > 1) {
qualifier += "One job from ";
}
PopupGenerator.showErrorDialog(this, qualifier + "Simulation '" + simulation.getName() + "' failed\n" + simStatus.getDetails());
}
// update status display
ClientSimManager simManager = simulationWorkspace.getClientSimManager();
simManager.updateStatusFromServer(simulation);
// is there new data?
if (simStatusEvent.isNewDataEvent()) {
fireNewData(new DataEvent(this, new VCSimulationDataIdentifier(simulation.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), simStatusEvent.getJobIndex())));
}
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class TestingFrameworkWindowManager method addTestCases.
/**
* Insert the method's description here.
* Creation date: (4/10/2003 11:27:32 AM)
* @param testCase cbit.vcell.numericstestingframework.TestCase
*/
public String addTestCases(final TestSuiteInfoNew tsInfo, final TestCaseNew[] testCaseArray, int regrRefFlag, ClientTaskStatusSupport pp) {
if (tsInfo == null) {
throw new IllegalArgumentException("TestSuiteInfo cannot be null");
}
if (testCaseArray == null || testCaseArray.length == 0) {
throw new IllegalArgumentException("TestCases cannot be null / empty");
}
// make modifiable list
List<TestCaseNew> testCases = new ArrayList<>(Arrays.asList(testCaseArray));
StringBuffer errors = new StringBuffer();
// When a testCase (mathmodel/biomodel) is added to a testSuite, a new version of the mathModel/biomodel should be created.
// Also, the simulations in the original mathmodel/biomodel should be rid of their parent simulation reference.
pp.setMessage("Getting testSuite");
pp.setProgress(1);
TestSuiteNew testSuite = null;
try {
testSuite = getRequestManager().getDocumentManager().getTestSuite(tsInfo.getTSKey());
} catch (Throwable e) {
throw new RuntimeException("couldn't get test suite " + tsInfo.getTSID() + "\n" + e.getClass().getName() + " mesg=" + e.getMessage() + "\n");
}
if (testSuite != null && testSuite.getTSInfoNew().isLocked()) {
throw new RuntimeException("Cannot addTestCases to locked table");
}
if (testSuite != null) {
// Saving BioModels
TestCaseNew[] existingTestCases = testSuite.getTestCases();
java.util.HashMap<KeyValue, BioModel> bioModelHashMap = new java.util.HashMap<KeyValue, BioModel>();
// if(existingTestCases != null){
// Find BioModels, Using the same BM reference for sibling Applications
int pcounter = 0;
// use iterator to allow removal of test case from collection if exception
Iterator<TestCaseNew> iter = testCases.iterator();
while (iter.hasNext()) {
TestCaseNew testCase = iter.next();
pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
pp.setMessage("Checking " + testCase.getVersion().getName());
try {
if (testCase instanceof TestCaseNewBioModel) {
TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
//
if (bioModelHashMap.get(bioTestCase.getBioModelInfo().getVersion().getVersionKey()) == null) {
pp.setMessage("Getting BM " + testCase.getVersion().getName());
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bioTestCase.getBioModelInfo().getVersion().getVersionKey());
if (!bioModel.getVersion().getOwner().equals(getRequestManager().getDocumentManager().getUser())) {
throw new Exception("BioModel does not belong to VCELLTESTACCOUNT, cannot proceed with test!");
}
//
// if biomodel already exists in same testsuite, then use this BioModel edition
//
BioModel newBioModel = null;
if (existingTestCases != null) {
for (int j = 0; newBioModel == null && j < existingTestCases.length; j++) {
if (existingTestCases[j] instanceof TestCaseNewBioModel) {
TestCaseNewBioModel existingTestCaseBioModel = (TestCaseNewBioModel) existingTestCases[j];
//
if (existingTestCaseBioModel.getBioModelInfo().getVersion().getBranchID().equals(bioTestCase.getBioModelInfo().getVersion().getBranchID())) {
//
if (existingTestCaseBioModel.getBioModelInfo().getVersion().getVersionKey().equals(bioTestCase.getBioModelInfo().getVersion().getVersionKey())) {
//
// same, store this "unchanged" in bioModelHashMap
//
newBioModel = bioModel;
} else {
//
throw new Exception("can't add new test case using (" + bioTestCase.getBioModelInfo().getVersion().getName() + " " + bioTestCase.getBioModelInfo().getVersion().getDate() + ")\n" + "a test case already exists with different edition of same BioModel dated " + existingTestCaseBioModel.getBioModelInfo().getVersion().getDate());
}
}
}
}
}
if (newBioModel == null) {
pp.setMessage("Saving BM " + testCase.getVersion().getName());
//
// some older models have membrane voltage variable names which are not unique
// (e.g. membranes 'pm' and 'nm' both have membrane voltage variables named 'Voltage_Membrane0')
//
// if this is the case, we will try to repair the conflict (for math testing purposes only) by renaming the voltage variables to their default values.
//
// Ordinarily, the conflict will be identified as an "Error" issue and the user will be prompted to repair before saving or math generation.
//
bioModel.refreshDependencies();
boolean bFoundIdentifierConflictUponLoading = hasDuplicateIdentifiers(bioModel);
if (bFoundIdentifierConflictUponLoading) {
//
// look for two MembraneVoltage instances with same variable name, rename all
//
HashSet<String> membraneVoltageVarNames = new HashSet<String>();
ArrayList<MembraneVoltage> membraneVoltageVars = new ArrayList<MembraneVoltage>();
for (Structure struct : bioModel.getModel().getStructures()) {
if (struct instanceof Membrane) {
MembraneVoltage membraneVoltage = ((Membrane) struct).getMembraneVoltage();
if (membraneVoltage != null) {
membraneVoltageVars.add(membraneVoltage);
membraneVoltageVarNames.add(membraneVoltage.getName());
}
}
}
if (membraneVoltageVars.size() != membraneVoltageVarNames.size()) {
// rename them all to the default names
for (MembraneVoltage memVoltage : membraneVoltageVars) {
memVoltage.setName(Membrane.getDefaultMembraneVoltageName(memVoltage.getMembrane().getName()));
}
}
}
SimulationContext[] simContexts = bioModel.getSimulationContexts();
for (int j = 0; j < simContexts.length; j++) {
simContexts[j].clearVersion();
GeometrySurfaceDescription gsd = simContexts[j].getGeometry().getGeometrySurfaceDescription();
if (gsd != null) {
GeometricRegion[] grArr = gsd.getGeometricRegions();
if (grArr == null) {
gsd.updateAll();
}
}
MathMapping mathMapping = simContexts[j].createNewMathMapping();
// for older models that do not have absolute compartment sizes set, but have relative sizes (SVR/VF); or if there is only one compartment with size not set,
// compute absolute compartment sizes using relative sizes and assuming a default value of '1' for one of the compartments.
// Otherwise, the math generation will fail, since for the relaxed topology (VCell 5.3 and later) absolute compartment sizes are required.
GeometryContext gc = simContexts[j].getGeometryContext();
if (simContexts[j].getGeometry().getDimension() == 0 && ((gc.isAllSizeSpecifiedNull() && !gc.isAllVolFracAndSurfVolSpecifiedNull()) || (gc.getModel().getStructures().length == 1 && gc.isAllSizeSpecifiedNull()))) {
// choose the first structure in model and set its size to '1'.
Structure struct = simContexts[j].getModel().getStructure(0);
double structSize = 1.0;
StructureSizeSolver.updateAbsoluteStructureSizes(simContexts[j], struct, structSize, struct.getStructureSize().getUnitDefinition());
}
simContexts[j].setMathDescription(mathMapping.getMathDescription());
}
Simulation[] sims = bioModel.getSimulations();
String[] simNames = new String[sims.length];
for (int j = 0; j < sims.length; j++) {
// prevents parent simulation (from the original mathmodel) reference connection
// Otherwise it will refer to data from previous (parent) simulation.
sims[j].clearVersion();
simNames[j] = sims[j].getName();
// if(sims[j].getSolverTaskDescription().getSolverDescription().equals(SolverDescription.FiniteVolume)){
// sims[j].getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
// }
}
newBioModel = getRequestManager().getDocumentManager().save(bioModel, simNames);
}
bioModelHashMap.put(bioTestCase.getBioModelInfo().getVersion().getVersionKey(), newBioModel);
}
}
} catch (Throwable e) {
String identifier = testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey();
if (lg.isInfoEnabled()) {
lg.info(identifier, e);
}
errors.append("Error collecting BioModel for TestCase " + identifier + '\n' + e.getClass().getName() + " " + e.getMessage() + '\n');
// remove to avoid further processing attempts
iter.remove();
}
}
// }
// then process each BioModelTestCase individually
// if(bioModelHashMap != null){
pcounter = 0;
for (TestCaseNew testCase : testCases) {
pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
pp.setMessage("Checking " + testCase.getVersion().getName());
try {
AddTestCasesOP testCaseOP = null;
if (testCase instanceof TestCaseNewBioModel) {
pp.setMessage("Processing BM " + testCase.getVersion().getName());
TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
BioModel newBioModel = (BioModel) bioModelHashMap.get(bioTestCase.getBioModelInfo().getVersion().getVersionKey());
if (newBioModel == null) {
throw new Exception("BioModel not found");
}
SimulationContext simContext = null;
for (int j = 0; j < newBioModel.getSimulationContexts().length; j++) {
if (newBioModel.getSimulationContext(j).getName().equals(bioTestCase.getSimContextName())) {
simContext = newBioModel.getSimulationContext(j);
}
}
Simulation[] newSimulations = simContext.getSimulations();
AddTestCriteriaOPBioModel[] testCriteriaOPs = new AddTestCriteriaOPBioModel[newSimulations.length];
for (int j = 0; j < newSimulations.length; j++) {
TestCriteriaNewBioModel tcritOrigForSimName = null;
for (int k = 0; bioTestCase.getTestCriterias() != null && k < bioTestCase.getTestCriterias().length; k += 1) {
if (bioTestCase.getTestCriterias()[k].getSimInfo().getName().equals(newSimulations[j].getName())) {
tcritOrigForSimName = (TestCriteriaNewBioModel) bioTestCase.getTestCriterias()[k];
break;
}
}
KeyValue regressionBioModelKey = null;
KeyValue regressionBioModelSimKey = null;
if (bioTestCase.getType().equals(TestCaseNew.REGRESSION)) {
if (regrRefFlag == TestingFrameworkWindowManager.COPY_REGRREF) {
regressionBioModelKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionBioModelInfo() != null ? tcritOrigForSimName.getRegressionBioModelInfo().getVersion().getVersionKey() : null);
regressionBioModelSimKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionSimInfo() != null ? tcritOrigForSimName.getRegressionSimInfo().getVersion().getVersionKey() : null);
} else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNORIGINAL_REGRREF) {
regressionBioModelKey = (tcritOrigForSimName != null ? bioTestCase.getBioModelInfo().getVersion().getVersionKey() : null);
regressionBioModelSimKey = (tcritOrigForSimName != null ? tcritOrigForSimName.getSimInfo().getVersion().getVersionKey() : null);
} else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNNEW_REGRREF) {
regressionBioModelKey = newBioModel.getVersion().getVersionKey();
regressionBioModelSimKey = newSimulations[j].getVersion().getVersionKey();
} else {
throw new IllegalArgumentException(this.getClass().getName() + ".addTestCases(...) BIOMODEL Unknown Regression Operation Flag");
}
}
testCriteriaOPs[j] = new AddTestCriteriaOPBioModel(testCase.getTCKey(), newSimulations[j].getVersion().getVersionKey(), regressionBioModelKey, regressionBioModelSimKey, (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxAbsError() : new Double(1e-16)), (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxRelError() : new Double(1e-9)), null);
}
testCaseOP = new AddTestCasesOPBioModel(new BigDecimal(tsInfo.getTSKey().toString()), newBioModel.getVersion().getVersionKey(), simContext.getKey(), bioTestCase.getType(), bioTestCase.getAnnotation(), testCriteriaOPs);
getRequestManager().getDocumentManager().doTestSuiteOP(testCaseOP);
}
} catch (Throwable e) {
errors.append("Error processing Biomodel for TestCase " + (testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey()) + "\n" + e.getClass().getName() + " " + e.getMessage() + "\n");
}
}
// }
// Process MathModels
pcounter = 0;
for (TestCaseNew testCase : testCases) {
pp.setProgress(Math.max(1, ((int) ((pcounter++ / (double) (testCases.size() * 3)) * 100))));
pp.setMessage("Checking " + testCase.getVersion().getName());
try {
AddTestCasesOP testCaseOP = null;
if (testCase instanceof TestCaseNewMathModel) {
TestCaseNewMathModel mathTestCase = (TestCaseNewMathModel) testCase;
pp.setMessage("Getting MathModel " + testCase.getVersion().getName());
MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mathTestCase.getMathModelInfo().getVersion().getVersionKey());
if (!mathModel.getVersion().getOwner().equals(getRequestManager().getDocumentManager().getUser())) {
throw new Exception("MathModel does not belong to VCELLTESTACCOUNT, cannot proceed with test!");
}
Simulation[] sims = mathModel.getSimulations();
String[] simNames = new String[sims.length];
for (int j = 0; j < sims.length; j++) {
// prevents parent simulation (from the original mathmodel) reference connection
// Otherwise it will refer to data from previous (parent) simulation.
sims[j].clearVersion();
simNames[j] = sims[j].getName();
// if(sims[j].getSolverTaskDescription().getSolverDescription().equals(SolverDescription.FiniteVolume)){
// sims[j].getSolverTaskDescription().setSolverDescription(SolverDescription.FiniteVolumeStandalone);
// }
}
pp.setMessage("Saving MathModel " + testCase.getVersion().getName());
MathModel newMathModel = getRequestManager().getDocumentManager().save(mathModel, simNames);
Simulation[] newSimulations = newMathModel.getSimulations();
AddTestCriteriaOPMathModel[] testCriteriaOPs = new AddTestCriteriaOPMathModel[newSimulations.length];
for (int j = 0; j < newSimulations.length; j++) {
TestCriteriaNewMathModel tcritOrigForSimName = null;
for (int k = 0; mathTestCase.getTestCriterias() != null && k < mathTestCase.getTestCriterias().length; k += 1) {
if (mathTestCase.getTestCriterias()[k].getSimInfo().getName().equals(newSimulations[j].getName())) {
tcritOrigForSimName = (TestCriteriaNewMathModel) mathTestCase.getTestCriterias()[k];
break;
}
}
KeyValue regressionMathModelKey = null;
KeyValue regressionMathModelSimKey = null;
if (mathTestCase.getType().equals(TestCaseNew.REGRESSION)) {
if (regrRefFlag == TestingFrameworkWindowManager.COPY_REGRREF) {
regressionMathModelKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionMathModelInfo() != null ? tcritOrigForSimName.getRegressionMathModelInfo().getVersion().getVersionKey() : null);
regressionMathModelSimKey = (tcritOrigForSimName != null && tcritOrigForSimName.getRegressionSimInfo() != null ? tcritOrigForSimName.getRegressionSimInfo().getVersion().getVersionKey() : null);
} else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNORIGINAL_REGRREF) {
regressionMathModelKey = (tcritOrigForSimName != null ? mathTestCase.getMathModelInfo().getVersion().getVersionKey() : null);
regressionMathModelSimKey = (tcritOrigForSimName != null ? tcritOrigForSimName.getSimInfo().getVersion().getVersionKey() : null);
} else if (regrRefFlag == TestingFrameworkWindowManager.ASSIGNNEW_REGRREF) {
regressionMathModelKey = newMathModel.getVersion().getVersionKey();
regressionMathModelSimKey = newSimulations[j].getVersion().getVersionKey();
} else {
throw new IllegalArgumentException(this.getClass().getName() + ".addTestCases(...) MATHMODEL Unknown Regression Operation Flag");
}
}
testCriteriaOPs[j] = new AddTestCriteriaOPMathModel(testCase.getTCKey(), newSimulations[j].getVersion().getVersionKey(), regressionMathModelKey, regressionMathModelSimKey, (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxAbsError() : new Double(1e-16)), (tcritOrigForSimName != null ? tcritOrigForSimName.getMaxRelError() : new Double(1e-9)), null);
}
testCaseOP = new AddTestCasesOPMathModel(new BigDecimal(tsInfo.getTSKey().toString()), newMathModel.getVersion().getVersionKey(), mathTestCase.getType(), mathTestCase.getAnnotation(), testCriteriaOPs);
getRequestManager().getDocumentManager().doTestSuiteOP(testCaseOP);
}
} catch (Throwable e) {
errors.append("Error processing MathModel for TestCase " + (testCase.getVersion() != null ? "Name=" + testCase.getVersion().getName() : "TCKey=" + testCase.getTCKey()) + "\n" + e.getClass().getName() + " " + e.getMessage() + "\n");
}
}
}
if (errors.length() > 0) {
return errors.toString();
}
return null;
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class TestingFrameworkWindowManager method queryTCritCrossRef.
@SuppressWarnings("serial")
public void queryTCritCrossRef(final TestSuiteInfoNew tsin, final TestCriteriaNew tcrit, final String varName) {
try {
QueryTestCriteriaCrossRefOP queryTestCriteriaCrossRefOP = new QueryTestCriteriaCrossRefOP(tsin.getTSKey(), tcrit.getTCritKey(), varName);
TestCriteriaCrossRefOPResults testCriteriaCrossRefOPResults = (TestCriteriaCrossRefOPResults) getRequestManager().getDocumentManager().doTestSuiteOP(queryTestCriteriaCrossRefOP);
final Vector<TestCriteriaCrossRefOPResults.CrossRefData> xrefDataV = testCriteriaCrossRefOPResults.getCrossRefData();
final TestSuiteInfoNew[] testSuiteInfos = getRequestManager().getDocumentManager().getTestSuiteInfos();
Vector<TestSuiteInfoNew> missingTestSuites = new Vector<TestSuiteInfoNew>();
for (int i = 0; i < testSuiteInfos.length; i++) {
boolean bFound = false;
for (int j = 0; j < xrefDataV.size(); j++) {
if (xrefDataV.elementAt(j).tsVersion.equals(testSuiteInfos[i].getTSID())) {
bFound = true;
break;
}
}
if (!bFound) {
missingTestSuites.add(testSuiteInfos[i]);
}
}
TestCriteriaCrossRefOPResults.CrossRefData xrefDataSource = null;
for (int i = 0; i < xrefDataV.size(); i++) {
if (xrefDataV.elementAt(i).tcritKey.equals(tcrit.getTCritKey())) {
xrefDataSource = xrefDataV.elementAt(i);
break;
}
}
if (xrefDataSource == null) {
throw new RuntimeException("Couldn't find source Test Criteria in query results.");
}
final int numColumns = 8;
final int XREFDATA_ALLOWANCE = 1;
final int TSKEY_ALLOWANCE = 1;
final int XREFDATA_OFFSET = numColumns;
final int TSDATE_OFFSET = 1;
final int VARNAME_OFFSET = 3;
final int TSKEYMISSING_OFFSET = numColumns + 1;
final String[] colNames = new String[numColumns];
final Object[][] sourceRows = new Object[xrefDataV.size() + missingTestSuites.size()][numColumns + XREFDATA_ALLOWANCE + TSKEY_ALLOWANCE];
String sourceTestSuite = null;
colNames[0] = "tsVersion";
colNames[1] = "tsDate";
colNames[2] = "tsBaseVersion";
colNames[3] = "varName";
colNames[4] = "RelErorr";
colNames[5] = "limitRelErorr";
colNames[6] = "limitAbsErorr";
colNames[7] = "AbsErorr";
for (int i = 0; i < xrefDataV.size(); i++) {
sourceRows[i][colNames.length] = xrefDataV.elementAt(i);
if (xrefDataV.elementAt(i).tcritKey.equals(queryTestCriteriaCrossRefOP.getTestCriterium())) {
sourceTestSuite = xrefDataV.elementAt(i).tsVersion;
}
sourceRows[i][0] = xrefDataV.elementAt(i).tsVersion;
sourceRows[i][2] = (xrefDataV.elementAt(i).tsRefVersion == null ? (xrefDataV.elementAt(i).regressionModelID == null ? /* && xrefDataV.elementAt(i).regressionMMref==null*/
"" : "Ref Model exist BUT outside of TestSuites") : xrefDataV.elementAt(i).tsRefVersion);
sourceRows[i][6] = xrefDataV.elementAt(i).maxAbsErorr;
sourceRows[i][5] = xrefDataV.elementAt(i).maxRelErorr;
if (xrefDataV.elementAt(i).varName != null) {
sourceRows[i][VARNAME_OFFSET] = xrefDataV.elementAt(i).varName;
sourceRows[i][4] = xrefDataV.elementAt(i).varCompSummary.getRelativeError();
sourceRows[i][7] = xrefDataV.elementAt(i).varCompSummary.getAbsoluteError();
} else {
sourceRows[i][VARNAME_OFFSET] = "-No Report-";
// "No Report";
sourceRows[i][4] = null;
// "No Report";
sourceRows[i][7] = null;
}
for (int j = 0; j < testSuiteInfos.length; j++) {
if (xrefDataV.elementAt(i).tsVersion.equals(testSuiteInfos[j].getTSID())) {
sourceRows[i][1] = testSuiteInfos[j].getTSDate();
break;
}
}
}
for (int i = xrefDataV.size(); i < sourceRows.length; i++) {
sourceRows[i][0] = missingTestSuites.elementAt(i - xrefDataV.size()).getTSID();
sourceRows[i][TSDATE_OFFSET] = missingTestSuites.elementAt(i - xrefDataV.size()).getTSDate();
sourceRows[i][TSKEYMISSING_OFFSET] = missingTestSuites.elementAt(i - xrefDataV.size()).getTSKey();
}
// Arrays.sort(rows,
// new Comparator<Object[]>(){
// public int compare(Object[] o1, Object[] o2) {
// return ((String)o1[0]).compareToIgnoreCase((String)o2[0]);
// // if(o1[0].equals(o2[0])){
// // return o1[3].compareToIgnoreCase(o2[3]);
// // }
// // return o1[0].compareToIgnoreCase(o2[0]);
// }
// }
// );
final VCellSortTableModel<Object[]> tableModel = new VCellSortTableModel<Object[]>(colNames) {
public Class<?> getColumnClass(int columnIndex) {
if (columnIndex == TSDATE_OFFSET) {
return Date.class;
} else if (columnIndex >= 4 && columnIndex <= 7) {
return Double.class;
}
return String.class;
}
public boolean isCellEditable(int row, int column) {
return false;
}
public Object getValueAt(int rowIndex, int columnIndex) {
return getValueAt(rowIndex)[columnIndex];
}
public Comparator<Object[]> getComparator(final int col, final boolean ascending) {
return new Comparator<Object[]>() {
public int compare(Object[] o1, Object[] o2) {
if (o1[col] == null && o2[col] == null) {
return 0;
}
// if(ascending){
if (o1[col] == null) {
return 1;
}
if (o2[col] == null) {
return -1;
}
// }
if (getColumnClass(col).equals(String.class)) {
if (ascending) {
return ((String) o1[col]).compareToIgnoreCase(((String) o2[col]));
} else {
return ((String) o2[col]).compareToIgnoreCase(((String) o1[col]));
}
} else if (getColumnClass(col).equals(Date.class)) {
if (ascending) {
return ((Date) o1[col]).compareTo(((Date) o2[col]));
}
return ((Date) o2[col]).compareTo(((Date) o1[col]));
} else if (getColumnClass(col).equals(Double.class)) {
if (ascending) {
return ((Double) o1[col]).compareTo(((Double) o2[col]));
}
return ((Double) o2[col]).compareTo(((Double) o1[col]));
}
throw new RuntimeException("TestSuite XRef Query unexpecte column class " + getColumnClass(col).getName());
}
};
}
};
tableModel.setData(Arrays.asList(sourceRows));
// Create table
final JSortTable table = new JSortTable();
table.setModel(tableModel);
table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
final JScrollPane scrollPaneContentPane = new JScrollPane(table);
table.setPreferredScrollableViewportSize(new Dimension(500, 250));
table.getColumnModel().getColumn(TSDATE_OFFSET).setCellRenderer(new DefaultTableCellRenderer() {
// DateFormat formatter = DateFormat.getDateTimeInstance();
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
return super.getTableCellRendererComponent(table, (value == null ? null : ((Date) value).toString()), /*formatter.format((Date)value)*/
isSelected, hasFocus, row, column);
}
});
DefaultTableCellRenderer dtcr = new DefaultTableCellRenderer() {
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
return super.getTableCellRendererComponent(table, (value == null ? null : ((Double) value).toString()), /*formatter.format((Date)value)*/
isSelected, hasFocus, row, column);
}
};
table.getColumnModel().getColumn(4).setCellRenderer(dtcr);
table.getColumnModel().getColumn(5).setCellRenderer(dtcr);
table.getColumnModel().getColumn(6).setCellRenderer(dtcr);
table.getColumnModel().getColumn(7).setCellRenderer(dtcr);
// table.getColumnModel().getColumn(4).setCellRenderer(
// new DefaultTableCellRenderer(){
// public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
// return super.getTableCellRendererComponent(table,(value == null?null:((Double)value).toString())/*formatter.format((Date)value)*/, isSelected, hasFocus, row, column);
// }
// }
// );
// table.getTableHeader().setReorderingAllowed(false);
// Popup Menu
final TestCriteriaCrossRefOPResults.CrossRefData xrefDataSourceFinal = xrefDataSource;
final JPopupMenu queryPopupMenu = new JPopupMenu();
final JMenuItem changeLimitsMenuItem = new JMenuItem("Change Selected Error Limits...");
final String OPEN_MODEL = "Open Model(s)";
final JMenuItem openModelMenuItem = new JMenuItem(OPEN_MODEL);
final String OPEN_REGRREFMODEL = "Open Regr Ref Model(s)";
final JMenuItem openRegrRefModelMenuItem = new JMenuItem(OPEN_REGRREFMODEL);
final String SELECT_REF_IN_TREE = "Select in Tree View";
final JMenuItem showInTreeMenuItem = new JMenuItem(SELECT_REF_IN_TREE);
final String SELECT_REGR_REF_IN_TREE = "Select RegrRef TCase in Tree View";
final JMenuItem showRegrRefInTreeMenuItem = new JMenuItem(SELECT_REGR_REF_IN_TREE);
queryPopupMenu.add(changeLimitsMenuItem);
queryPopupMenu.add(openModelMenuItem);
queryPopupMenu.add(openRegrRefModelMenuItem);
queryPopupMenu.add(showInTreeMenuItem);
queryPopupMenu.add(showRegrRefInTreeMenuItem);
ActionListener showInTreeActionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
int[] selectedRows = table.getSelectedRows();
if (selectedRows == null || selectedRows.length != 1) {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Action " + actionEvent.getActionCommand() + " accepts only single selection!");
return;
}
TestCriteriaCrossRefOPResults.CrossRefData xrefData = (TestCriteriaCrossRefOPResults.CrossRefData) tableModel.getValueAt(selectedRows[0], XREFDATA_OFFSET);
BigDecimal missingTSKey = (BigDecimal) tableModel.getValueAt(selectedRows[0], TSKEYMISSING_OFFSET);
if (actionEvent.getActionCommand().equals(SELECT_REF_IN_TREE)) {
getTestingFrameworkWindowPanel().selectInTreeView((xrefData != null ? xrefData.tsKey : missingTSKey), (xrefData != null ? xrefData.tcaseKey : null), (xrefData != null ? xrefData.tcritKey : null));
} else if (actionEvent.getActionCommand().equals(SELECT_REGR_REF_IN_TREE)) {
if (xrefData == null) {
PopupGenerator.showErrorDialog(getComponent(), "No Regression Reference info available.");
return;
}
getTestingFrameworkWindowPanel().selectInTreeView((xrefData != null ? xrefData.regressionModelTSuiteID : null), (xrefData != null ? xrefData.regressionModelTCaseID : null), (xrefData != null ? xrefData.regressionModelTCritID : null));
}
ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
if (childWindow != null) {
childWindow.show();
}
}
};
showInTreeMenuItem.addActionListener(showInTreeActionListener);
showRegrRefInTreeMenuItem.addActionListener(showInTreeActionListener);
ActionListener openModelsActionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
int[] selectedRows = table.getSelectedRows();
String failureS = "";
TestCriteriaCrossRefOPResults.CrossRefData xrefData = null;
int openCount = 0;
for (int i = 0; i < selectedRows.length; i++) {
try {
xrefData = (TestCriteriaCrossRefOPResults.CrossRefData) tableModel.getValueAt(selectedRows[i], XREFDATA_OFFSET);
if (xrefData != null && (actionEvent.getActionCommand().equals(OPEN_REGRREFMODEL) ? xrefData.regressionModelID != null : true)) {
openCount += 1;
VCDocumentInfo vcDocInfo = null;
if (xrefData.isBioModel) {
vcDocInfo = getRequestManager().getDocumentManager().getBioModelInfo(new KeyValue((actionEvent.getActionCommand().equals(OPEN_REGRREFMODEL) ? xrefData.regressionModelID : xrefData.modelID)));
} else {
vcDocInfo = getRequestManager().getDocumentManager().getMathModelInfo(new KeyValue((actionEvent.getActionCommand().equals(OPEN_REGRREFMODEL) ? xrefData.regressionModelID : xrefData.modelID)));
}
getRequestManager().openDocument(vcDocInfo, TestingFrameworkWindowManager.this, true);
}
} catch (Exception e) {
failureS += failureS + "key=" + xrefData.modelID + " " + e.getMessage() + "\n";
e.printStackTrace();
}
}
if (failureS.length() > 0 || openCount == 0) {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Failed to open some models\n" + failureS + (openCount == 0 ? "Selection(s) had no model(s)" : ""));
}
ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
if (childWindow != null) {
childWindow.show();
}
}
};
openModelMenuItem.addActionListener(openModelsActionListener);
openRegrRefModelMenuItem.addActionListener(openModelsActionListener);
changeLimitsMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
int[] selectedRows = table.getSelectedRows();
Vector<TestCriteriaCrossRefOPResults.CrossRefData> changeTCritV = new Vector<TestCriteriaCrossRefOPResults.CrossRefData>();
for (int i = 0; i < selectedRows.length; i++) {
TestCriteriaCrossRefOPResults.CrossRefData xrefData = (TestCriteriaCrossRefOPResults.CrossRefData) tableModel.getValueAt(selectedRows[i], XREFDATA_OFFSET);
if (xrefData != null) {
boolean bFound = false;
for (int j = 0; j < changeTCritV.size(); j++) {
if (changeTCritV.elementAt(j).tcritKey.equals(xrefData.tcritKey)) {
bFound = true;
break;
}
}
if (!bFound) {
changeTCritV.add(xrefData);
}
}
}
if (changeTCritV.size() > 0) {
Double relativeErrorLimit = null;
Double absoluteErrorLimit = null;
while (true) {
try {
String ret = PopupGenerator.showInputDialog(getComponent(), "Enter new TestCriteria Error Limits for '" + xrefDataSourceFinal.simName + "'. '-'(dash) to keep original value.", "RelativeErrorLimit,AbsoluteErrorLimit");
int commaPosition = ret.indexOf(',');
if (commaPosition == -1) {
throw new Exception("No comma found separating RelativeErrorLimit AbsoluteErrorLimit");
}
if (commaPosition != ret.lastIndexOf(',')) {
throw new Exception("Only 1 comma allowed separating RelativeErrorLimit and AbsoluteErrorLimit");
}
final String KEEP_ORIGINAL_VALUE = "-";
String relativeErrorS = ret.substring(0, commaPosition);
String absoluteErrorS = ret.substring(commaPosition + 1, ret.length());
if (!relativeErrorS.equals(KEEP_ORIGINAL_VALUE)) {
relativeErrorLimit = Double.parseDouble(relativeErrorS);
}
if (!absoluteErrorS.equals(KEEP_ORIGINAL_VALUE)) {
absoluteErrorLimit = Double.parseDouble(absoluteErrorS);
}
if ((relativeErrorLimit != null && relativeErrorLimit <= 0) || (absoluteErrorLimit != null && absoluteErrorLimit <= 0)) {
throw new Exception("Error limits must be greater than 0");
}
break;
} catch (UserCancelException e) {
ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
if (childWindow != null) {
childWindow.show();
}
return;
} catch (Exception e) {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Error parsing Error Limits\n" + e.getMessage());
}
}
double[] relErrorLimitArr = new double[changeTCritV.size()];
double[] absErrorLimitArr = new double[changeTCritV.size()];
Object[][] rows = new Object[changeTCritV.size()][5];
for (int j = 0; j < changeTCritV.size(); j++) {
relErrorLimitArr[j] = (relativeErrorLimit != null ? relativeErrorLimit.doubleValue() : changeTCritV.elementAt(j).maxRelErorr);
absErrorLimitArr[j] = (absoluteErrorLimit != null ? absoluteErrorLimit.doubleValue() : changeTCritV.elementAt(j).maxAbsErorr);
rows[j][2] = new Double(relErrorLimitArr[j]);
rows[j][4] = new Double(absErrorLimitArr[j]);
rows[j][1] = new Double(changeTCritV.elementAt(j).maxRelErorr);
rows[j][3] = new Double(changeTCritV.elementAt(j).maxAbsErorr);
rows[j][0] = changeTCritV.elementAt(j).tsVersion;
}
try {
PopupGenerator.showComponentOKCancelTableList(getComponent(), "Confirm Error Limit Changes", new String[] { "TSVersion", "Orig RelErrorLimit", "New RelErrorLimit", "Orig AbsErrorLimit", "New AbsErrorLimit" }, rows, null);
} catch (UserCancelException e) {
ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
if (childWindow != null) {
childWindow.show();
}
return;
}
// Get information needed to generate new TestCriteria Reports
final String YES_ANSWER = "Yes";
Hashtable<TestSuiteInfoNew, Vector<TestCriteriaCrossRefOPResults.CrossRefData>> genReportHash = null;
String genRepResult = PopupGenerator.showWarningDialog(getComponent(), "Generate Reports for changed Test Criterias?", new String[] { YES_ANSWER, "No" }, YES_ANSWER);
if (genRepResult != null && genRepResult.equals(YES_ANSWER)) {
genReportHash = new Hashtable<TestSuiteInfoNew, Vector<TestCriteriaCrossRefOPResults.CrossRefData>>();
for (int i = 0; i < changeTCritV.size(); i++) {
boolean bFound = false;
for (int j = 0; j < testSuiteInfos.length; j++) {
if (changeTCritV.elementAt(i).tsVersion.equals(testSuiteInfos[j].getTSID())) {
bFound = true;
Vector<TestCriteriaCrossRefOPResults.CrossRefData> tempV = genReportHash.get(testSuiteInfos[j]);
if (tempV == null) {
tempV = new Vector<TestCriteriaCrossRefOPResults.CrossRefData>();
genReportHash.put(testSuiteInfos[j], tempV);
}
tempV.add(changeTCritV.elementAt(i));
}
}
if (!bFound) {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Couldn't find testsuiteinfo for testcriteria");
return;
}
}
}
BigDecimal[] changeTCritBDArr = new BigDecimal[changeTCritV.size()];
for (int i = 0; i < changeTCritV.size(); i++) {
changeTCritBDArr[i] = changeTCritV.elementAt(i).tcritKey;
}
ChangeTestCriteriaErrorLimitOP changeTestCriteriaErrorLimitOP = new ChangeTestCriteriaErrorLimitOP(changeTCritBDArr, absErrorLimitArr, relErrorLimitArr);
try {
getTestingFrameworkWindowPanel().getDocumentManager().doTestSuiteOP(changeTestCriteriaErrorLimitOP);
} catch (Exception e) {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Failed Changing Error limits for selected " + xrefDataSourceFinal.simName + "\n" + e.getMessage());
return;
}
ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).getChildWindowFromContentPane(scrollPaneContentPane);
if (childWindow != null) {
childWindow.close();
}
getTestingFrameworkWindowPanel().refreshTree((TestSuiteInfoNew) null);
if (genReportHash != null) {
updateReports(genReportHash);
} else {
new Thread(new Runnable() {
public void run() {
TestingFrameworkWindowManager.this.queryTCritCrossRef(tsin, tcrit, varName);
}
}).start();
}
} else {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "No selected rows contain Test Criteria.");
}
}
});
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
checkPopup(e);
}
@Override
public void mousePressed(MouseEvent e) {
super.mousePressed(e);
checkPopup(e);
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
checkPopup(e);
}
private void checkPopup(MouseEvent mouseEvent) {
if (mouseEvent.isPopupTrigger()) {
// Not use because popupmenu will not show at edge
// if(table.getSelectedRowCount() <= 1){
// table.getSelectionModel().setSelectionInterval(table.rowAtPoint(mouseEvent.getPoint()),table.rowAtPoint(mouseEvent.getPoint()));
// }
doPopup(mouseEvent);
} else {
queryPopupMenu.setVisible(false);
}
}
private void doPopup(MouseEvent mouseEvent) {
// queryPopupMenu.add(showInTreeMenuItem);
if (table.getSelectedRowCount() == 0) {
changeLimitsMenuItem.setEnabled(false);
openModelMenuItem.setEnabled(false);
openRegrRefModelMenuItem.setEnabled(false);
showInTreeMenuItem.setEnabled(false);
showRegrRefInTreeMenuItem.setEnabled(false);
} else {
changeLimitsMenuItem.setEnabled(true);
openModelMenuItem.setEnabled(true);
openRegrRefModelMenuItem.setEnabled(true);
showInTreeMenuItem.setEnabled(true);
if (table.getSelectedRowCount() == 1) {
TestCriteriaCrossRefOPResults.CrossRefData xrefData = (TestCriteriaCrossRefOPResults.CrossRefData) tableModel.getValueAt(table.getSelectedRow(), numColumns);
showRegrRefInTreeMenuItem.setEnabled(xrefData != null && xrefData.regressionModelID != null && xrefData.tsRefVersion != null);
}
}
queryPopupMenu.show(mouseEvent.getComponent(), mouseEvent.getPoint().x, mouseEvent.getPoint().y);
}
});
String title = (xrefDataSource.isBioModel ? "BM" : "MM") + " " + xrefDataSource.tcSolutionType + " (" + sourceTestSuite + ") " + " \"" + (xrefDataSource.isBioModel ? xrefDataSource.bmName : xrefDataSource.mmName) + "\" :: " + (xrefDataSource.isBioModel ? "app=\"" + xrefDataSource.bmAppName + "\" :: sim=\"" + xrefDataSource.simName + "\"" : "sim=\"" + xrefDataSource.simName + "\"");
ChildWindow childWindow = TFWFinder.findChildWindowManager(getComponent()).addChildWindow(scrollPaneContentPane, scrollPaneContentPane, title);
// childWindow.setSize(600,400);
childWindow.setIsCenteredOnParent();
childWindow.pack();
childWindow.setResizable(true);
childWindow.show();
} catch (DataAccessException e) {
e.printStackTrace();
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Error Query TestCriteria Cross Ref:\n" + e.getMessage());
}
}
use of org.vcell.util.document.KeyValue in project vcell by virtualcell.
the class DBReactionWizardPanel method bfnActionPerformed.
/**
* Comment
*/
private void bfnActionPerformed(java.awt.event.ActionEvent actionEvent) {
try {
//
javax.swing.DefaultListModel pndlm = (javax.swing.DefaultListModel) getParameterNamesJList().getModel();
//
if (actionEvent.getSource().equals(getBackJButton())) {
if (getResolverJPanel().isVisible() && pndlm.size() == 0 && getSearchDictionaryJRadioButton().isSelected() == false) {
// skip Parameters if there are none
((java.awt.CardLayout) getCardLayoutJPanel().getLayout()).previous(getCardLayoutJPanel());
}
((java.awt.CardLayout) getCardLayoutJPanel().getLayout()).previous(getCardLayoutJPanel());
} else if (actionEvent.getSource().equals(getNextJButton())) {
if (getSearchCriteriaJPanel().isVisible()) {
if (getSearchDictionaryJRadioButton().isSelected()) {
getParameterJPanel().setVisible(false);
} else {
getParameterJPanel().setVisible(true);
}
if (!lastSearchIsSameAsCurrent()) {
search();
lastReactionSelection = null;
return;
}
} else if (getParameterJPanel().isVisible()) {
if (lastReactStepSelection == null || !lastReactStepSelection.equals(getReactionStep0())) {
lastReactStepSelection = getReactionStep0();
ReactionType rxType = null;
if (getReactionStep0() instanceof FluxReaction) {
if (getReactionStep0().isReversible()) {
rxType = ReactionType.REACTTYPE_FLUX_REVERSIBLE;
} else {
rxType = ReactionType.REACTTYPE_FLUX_IRREVERSIBLE;
}
} else {
if (getReactionStep0().isReversible()) {
rxType = ReactionType.REACTTYPE_SIMPLE_REVERSIBLE;
} else {
rxType = ReactionType.REACTTYPE_SIMPLE_IRREVERSIBLE;
}
}
KeyValue bmid = mapRXIDtoBMIDs.get(lastReactStepSelection.getKey());
KeyValue structRef = mapRXIDtoStructRefIDs.get(lastReactStepSelection.getKey());
ReactionDescription dbfr = new ReactionDescription(getReactionStep0().getName(), rxType, getReactionStep0().getKey(), bmid, structRef);
//
ReactionParticipant[] rpArr = getReactionStep0().getReactionParticipants();
for (int i = 0; i < rpArr.length; i += 1) {
DBNonFormalUnboundSpecies dbnfu = new DBNonFormalUnboundSpecies(rpArr[i].getSpecies().getCommonName());
char role;
if (rpArr[i] instanceof Reactant) {
role = ReactionDescription.RX_ELEMENT_REACTANT;
} else if (rpArr[i] instanceof Product) {
role = ReactionDescription.RX_ELEMENT_PRODUCT;
} else if (rpArr[i] instanceof Catalyst) {
role = ReactionDescription.RX_ELEMENT_CATALYST;
} else {
throw new RuntimeException("Unsupported ReationParticiapnt=" + rpArr[i].getClass().getName());
}
dbfr.addReactionElement(dbnfu, rpArr[i].getSpeciesContext().getName(), rpArr[i].getStoichiometry(), role);
}
if (dbfr.isFluxReaction()) {
// make sure flux is in right direction
Structure outsideStruct = getModel().getStructureTopology().getOutsideFeature((Membrane) getReactionStep0().getStructure());
String defaultOutsideSCName = dbfr.getOrigSpeciesContextName(dbfr.getFluxIndexOutside());
for (int i = 0; i < rpArr.length; i += 1) {
if (rpArr[i].getSpeciesContext().getName().equals(defaultOutsideSCName)) {
if (!rpArr[i].getStructure().equals(outsideStruct)) {
dbfr.swapFluxSCNames();
}
break;
}
}
}
setupRX(dbfr);
}
}
//
((java.awt.CardLayout) getCardLayoutJPanel().getLayout()).next(getCardLayoutJPanel());
} else if (actionEvent.getSource().equals(getFinishJButton())) {
applySelectedReactionElements();
}
//
configureBFN();
} catch (Exception e) {
e.printStackTrace();
DialogUtils.showErrorDialog(this, "DBReactionWizard failed\n" + e.getMessage(), e);
}
}
Aggregations