use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.
the class DatabaseWindowManager method compareAnotherEdition.
/**
* Comment
*/
public void compareAnotherEdition() {
//
if (getPanelSelection() == null) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : No first document selected");
return;
}
VCDocumentInfo thisDocumentInfo = getPanelSelection();
//
// Get the previous version of the documentInfo
//
VCDocumentInfo[] documentVersionsList = null;
try {
documentVersionsList = getDocumentVersionDates(thisDocumentInfo);
} catch (DataAccessException e) {
PopupGenerator.showErrorDialog(this, "Error accessing second document!");
}
if (documentVersionsList == null || documentVersionsList.length == 0) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : Not Enough Versions to Compare!");
return;
}
//
// Obtaining the Dates of the versions as a String, to be displayed as a list
//
String[] versionDatesList = new String[documentVersionsList.length];
for (int i = 0; i < documentVersionsList.length; i++) {
versionDatesList[i] = documentVersionsList[i].getVersion().getDate().toString();
}
//
// Get the user's choice of document version from the list box, use it to get the documentInfo for the
// corresponding version
//
String newVersionChoice = (String) PopupGenerator.showListDialog(this, versionDatesList, "Please select edition");
if (newVersionChoice == null) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : Second document not selected!");
return;
}
int versionIndex = -1;
for (int i = 0; i < versionDatesList.length; i++) {
if (versionDatesList[i].equals(newVersionChoice)) {
versionIndex = i;
}
}
if (versionIndex == -1) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : No such Version Exists " + newVersionChoice);
return;
}
VCDocumentInfo anotherDocumentInfo = documentVersionsList[versionIndex];
// Check if both document types are of the same kind. If not, throw an error.
if (((thisDocumentInfo instanceof BioModelInfo) && !(anotherDocumentInfo instanceof BioModelInfo)) || ((thisDocumentInfo instanceof MathModelInfo) && !(anotherDocumentInfo instanceof MathModelInfo)) || ((thisDocumentInfo instanceof GeometryInfo) && !(anotherDocumentInfo instanceof GeometryInfo))) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : The two documents are not of the same type!");
return;
}
// Now that we have both the document versions to be compared, do the comparison and display the result
compareWithOther(anotherDocumentInfo, thisDocumentInfo);
}
use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.
the class DatabaseWindowManager method compareLatestEdition.
/**
* Comment
*/
public void compareLatestEdition() {
//
if (getPanelSelection() == null) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : No first document selected");
return;
}
VCDocumentInfo thisDocumentInfo = getPanelSelection();
//
// Get the latest version of the documentInfo
//
VCDocumentInfo[] documentVersionsList = null;
try {
documentVersionsList = getDocumentVersionDates(thisDocumentInfo);
} catch (DataAccessException e) {
PopupGenerator.showErrorDialog(this, "Error accessing second document!");
}
if (documentVersionsList == null || documentVersionsList.length == 0) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : Not Enough Versions to Compare!");
return;
}
//
// Obtaining the latest version of the current documentInfo
//
VCDocumentInfo latestDocumentInfo = documentVersionsList[documentVersionsList.length - 1];
for (int i = 0; i < documentVersionsList.length; i++) {
if (documentVersionsList[i].getVersion().getDate().after(latestDocumentInfo.getVersion().getDate())) {
latestDocumentInfo = documentVersionsList[i];
}
}
if (thisDocumentInfo.getVersion().getDate().after(latestDocumentInfo.getVersion().getDate())) {
PopupGenerator.showErrorDialog(this, "Current Version is the latest! Choose another Version or Model to compare!");
return;
}
// Check if both document types are of the same kind. If not, throw an error.
if (((thisDocumentInfo instanceof BioModelInfo) && !(latestDocumentInfo instanceof BioModelInfo)) || ((thisDocumentInfo instanceof MathModelInfo) && !(latestDocumentInfo instanceof MathModelInfo)) || ((thisDocumentInfo instanceof GeometryInfo) && !(latestDocumentInfo instanceof GeometryInfo))) {
PopupGenerator.showErrorDialog(this, "Error Comparing documents : The two documents are not of the same type!");
return;
}
//
// Now that we have both the document versions to be compared, do the comparison and display the result
//
compareWithOther(latestDocumentInfo, thisDocumentInfo);
}
use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.
the class FieldDataWindowManager method findReferencingModels.
public boolean findReferencingModels(final ExternalDataIdentifier targetExtDataID, boolean bShowReferencingModelsList) throws DataAccessException, UserCancelException {
ReferenceQuerySpec rqs = new ReferenceQuerySpec(targetExtDataID);
ReferenceQueryResult rqr = getRequestManager().getDocumentManager().findReferences(rqs);
VersionableTypeVersion[] dependants = null;
Hashtable<VersionableTypeVersion, String[]> choices = new Hashtable<VersionableTypeVersion, String[]>();
boolean bDanglingReferences = false;
VersionableType bioModelType = VersionableType.BioModelMetaData;
VersionableType mathModelType = VersionableType.MathModelMetaData;
if (rqr != null) {
dependants = (rqr.getVersionableFamily().bDependants() ? rqr.getVersionableFamily().getUniqueDependants() : null);
if (dependants != null) {
for (int i = 0; i < dependants.length; i += 1) {
boolean isBioModel = dependants[i].getVType().equals(bioModelType);
boolean isTop = isBioModel || dependants[i].getVType().equals(mathModelType);
if (isTop) {
VersionableRelationship[] vrArr2 = rqr.getVersionableFamily().getDependantRelationships();
for (int j = 0; j < vrArr2.length; j += 1) {
if ((vrArr2[j].from() == dependants[i]) && vrArr2[j].to().getVType().equals((isBioModel ? VersionableType.SimulationContext : VersionableType.MathDescription))) {
for (int k = 0; k < vrArr2.length; k += 1) {
boolean bAdd = false;
if (k == j && vrArr2[k].from().getVType().equals(mathModelType)) {
bAdd = true;
}
if ((vrArr2[k].from() == vrArr2[j].to()) && vrArr2[k].to().getVType().equals(VersionableType.MathDescription)) {
bAdd = true;
}
if (bAdd) {
choices.put(dependants[i], new String[] { dependants[i].getVersion().getName(), (isBioModel ? bioModelType.getTypeName() : mathModelType.getTypeName()), (isBioModel ? vrArr2[k].from().getVersion().getName() : ""), dependants[i].getVersion().getVersionKey().toString() });
}
}
}
}
}
}
bDanglingReferences = (choices.size() == 0);
} else {
bDanglingReferences = true;
}
}
// FieldDataFileOperationResults fdfor = getRequestManager().getDocumentManager().fieldDataFileOperation(
// FieldDataFileOperationSpec.createDependantFuncsFieldDataFileOperationSpec(targetExtDataID));
FieldDataFileOperationResults fdfor = null;
boolean bHasReferences = false;
if (choices.size() > 0 || fdfor != null) {
bHasReferences = true;
if (bShowReferencingModelsList) {
String[] columnNames = new String[] { "Model", "Type", "Description" };
Vector<VersionableType> varTypeV = new Vector<VersionableType>();
Vector<KeyValue> keyValV = new Vector<KeyValue>();
Vector<String[]> choicesV = new Vector<String[]>();
String[][] modelListData = choices.values().toArray(new String[0][0]);
for (int i = 0; i < modelListData.length; i++) {
choicesV.add(new String[] { modelListData[i][0], modelListData[i][1], "Model Variable - " + (modelListData[i][2].length() == 0 ? "" : "App='" + modelListData[i][2] + "'") + " version[" + modelListData[i][3] + "]" });
varTypeV.add((modelListData[i][1].equals(bioModelType.getTypeName()) ? bioModelType : mathModelType));
keyValV.add(new KeyValue(modelListData[i][3]));
}
for (int i = 0; fdfor != null && i < fdfor.dependantFunctionInfo.length; i++) {
String functionNames = "";
for (int j = 0; j < fdfor.dependantFunctionInfo[i].funcNames.length; j++) {
functionNames += (j > 0 ? "," : "") + fdfor.dependantFunctionInfo[i].funcNames[j];
}
choicesV.add(new String[] { fdfor.dependantFunctionInfo[i].referenceSourceName, fdfor.dependantFunctionInfo[i].referenceSourceType, "Data Viewer Function(s) '" + functionNames + "' - " + (fdfor.dependantFunctionInfo[i].applicationName == null ? "" : "App='" + fdfor.dependantFunctionInfo[i].applicationName + "' ") + (fdfor.dependantFunctionInfo[i].simulationName == null ? "" : "Sim='" + fdfor.dependantFunctionInfo[i].simulationName + "' ") + "version[" + fdfor.dependantFunctionInfo[i].refSourceVersionDate + "]" });
if (fdfor.dependantFunctionInfo[i].referenceSourceType.equals(FieldDataFileOperationResults.FieldDataReferenceInfo.FIELDDATATYPENAME)) {
varTypeV.add(null);
} else if (fdfor.dependantFunctionInfo[i].referenceSourceType.equals(bioModelType.getTypeName())) {
varTypeV.add(bioModelType);
} else if (fdfor.dependantFunctionInfo[i].referenceSourceType.equals(mathModelType.getTypeName())) {
varTypeV.add(mathModelType);
} else {
throw new IllegalArgumentException("Unknown reference source type " + fdfor.dependantFunctionInfo[i].referenceSourceType);
}
keyValV.add(fdfor.dependantFunctionInfo[i].refSourceVersionKey);
}
int[] selectionArr = PopupGenerator.showComponentOKCancelTableList(getComponent(), "References to Field Data (Select To Open) " + targetExtDataID.getName(), columnNames, choicesV.toArray(new String[0][0]), ListSelectionModel.SINGLE_SELECTION);
if (selectionArr != null && selectionArr.length > 0) {
if (varTypeV.elementAt(selectionArr[0]) != null) {
if (varTypeV.elementAt(selectionArr[0]).equals(bioModelType)) {
BioModelInfo bmi = getRequestManager().getDocumentManager().getBioModelInfo(keyValV.elementAt(selectionArr[0]));
getRequestManager().openDocument(bmi, FieldDataWindowManager.this, true);
} else if (varTypeV.elementAt(selectionArr[0]).equals(mathModelType)) {
MathModelInfo mmi = getRequestManager().getDocumentManager().getMathModelInfo(keyValV.elementAt(selectionArr[0]));
getRequestManager().openDocument(mmi, FieldDataWindowManager.this, true);
} else {
throw new IllegalArgumentException("Not expecting varType " + varTypeV.elementAt(selectionArr[0]));
}
} else {
PopupGenerator.showInfoDialog(this, "use FiledDataManager to view FieldData '" + choicesV.elementAt(selectionArr[0])[0] + "'");
}
}
}
} else {
if (!bDanglingReferences) {
bHasReferences = false;
if (bShowReferencingModelsList) {
PopupGenerator.showInfoDialog(this, "No Model references found for Field Data " + targetExtDataID.getName());
}
} else {
bHasReferences = true;
if (bShowReferencingModelsList) {
PopupGenerator.showInfoDialog(this, "No current Model references found.\n" + "Field Data has internal database references from\n" + "previously linked Model(s) that have been deleted.\n" + "Note: Field Data '" + targetExtDataID.getName() + "' is not deletable\n" + "until database is culled (daily).");
}
}
}
return bHasReferences;
}
use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.
the class TestingFrameworkWindowManager method generateTestCaseReport.
/**
* Insert the method's description here.
* Creation date: (8/18/2003 5:36:47 PM)
*/
public String generateTestCaseReport(TestCaseNew testCase, TestCriteriaNew onlyThisTCrit, ClientTaskStatusSupport pp, TFGenerateReport.VCDocumentAndSimInfo userDefinedRefSimInfo) {
StringBuffer reportTCBuffer = new StringBuffer();
if (testCase == null) {
reportTCBuffer.append("\n\tTEST CASE :\tERROR: Test Case is NULL\n");
} else {
pp.setMessage(testCase.getVersion().getName() + " " + testCase.getType() + " Getting Simulations");
// Get the Simulations
Simulation[] sims = null;
reportTCBuffer.append("\n\tTEST CASE : " + (testCase.getVersion() != null ? testCase.getVersion().getName() : "Null") + "\n\tAnnotation : " + testCase.getAnnotation() + "\n");
try {
if (testCase instanceof TestCaseNewMathModel) {
MathModelInfo mmInfo = ((TestCaseNewMathModel) testCase).getMathModelInfo();
MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
sims = mathModel.getSimulations();
reportTCBuffer.append("\tMathModel : " + mmInfo.getVersion().getName() + ", " + mmInfo.getVersion().getDate().toString() + "\n");
} else if (testCase instanceof TestCaseNewBioModel) {
TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
// bioTestCase.
BioModelInfo bmInfo = bioTestCase.getBioModelInfo();
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
SimulationContext[] simContextArr = bioModel.getSimulationContexts();
if (simContextArr != null && simContextArr.length > 0) {
SimulationContext simContext = null;
for (int i = 0; i < simContextArr.length; i += 1) {
if (simContextArr[i].getVersion().getVersionKey().compareEqual(bioTestCase.getSimContextKey())) {
simContext = simContextArr[i];
break;
}
}
if (simContext != null) {
sims = bioModel.getSimulations(simContext);
reportTCBuffer.append("\tBioModel : " + bmInfo.getVersion().getName() + ", " + bmInfo.getVersion().getDate().toString() + "\n");
}
}
}
if (sims == null || sims.length == 0) {
reportTCBuffer.append("\tERROR " + "No sims found for TestCase " + (testCase.getVersion() != null ? "name=" + testCase.getVersion().getName() : "key=" + testCase.getTCKey()) + "\n");
}
if (testCase.getTestCriterias() == null || sims.length != testCase.getTestCriterias().length) {
reportTCBuffer.append("\tNote " + "Num sims=" + sims.length + " does not match testCriteria length=" + (testCase.getTestCriterias() != null ? testCase.getTestCriterias().length + "" : "null") + " for TestCase " + (testCase.getVersion() != null ? "name=" + testCase.getVersion().getName() : "key=" + testCase.getTCKey()) + "\n");
}
// Sort
if (sims.length > 0) {
java.util.Arrays.sort(sims, new java.util.Comparator<Simulation>() {
public int compare(Simulation si1, Simulation si2) {
return si1.getName().compareTo(si2.getName());
}
public boolean equals(Object obj) {
return false;
}
});
}
TestCriteriaNew[] testCriterias = (onlyThisTCrit != null ? new TestCriteriaNew[] { onlyThisTCrit } : testCase.getTestCriterias());
for (int k = 0; k < sims.length; k++) {
TestCriteriaNew testCriteria = getMatchingTestCriteria(sims[k], testCriterias);
if (testCriteria != null) {
pp.setMessage((testCase instanceof TestCaseNewMathModel ? "(MM)" : "(BM)") + " " + (onlyThisTCrit == null ? "sim " + (k + 1) + " of " + sims.length : "sim=" + onlyThisTCrit.getSimInfo().getName()) + " " + testCase.getVersion().getName() + " " + testCase.getType());
reportTCBuffer.append(generateTestCriteriaReport(testCase, testCriteria, sims[k], userDefinedRefSimInfo));
}
}
} catch (UserCancelException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
reportTCBuffer.append("\tERROR " + e.getClass().getName() + " mesg=" + e.getMessage() + "\n");
try {
if (onlyThisTCrit != null) {
updateTCritStatus(onlyThisTCrit, TestCriteriaNew.TCRIT_STATUS_RPERROR, "TestCase Error " + e.getClass().getName() + " " + e.getMessage());
} else if (testCase.getTestCriterias() != null) {
for (int i = 0; i < testCase.getTestCriterias().length; i += 1) {
updateTCritStatus(testCase.getTestCriterias()[i], TestCriteriaNew.TCRIT_STATUS_RPERROR, "TestCase Error " + e.getClass().getName() + " " + e.getMessage());
}
}
} catch (Throwable e2) {
//
}
}
}
return reportTCBuffer.toString();
}
use of org.vcell.util.document.MathModelInfo in project vcell by virtualcell.
the class TestingFrameworkWindowManager method getUserSelectedRefSimInfo.
public SimulationInfo getUserSelectedRefSimInfo(RequestManager currentRequstManager, VCDocumentInfo vcDocInfo) throws Exception {
final int MODELTYPE_INDEX = 0;
final int MODELKEY_INDEX = 2;
final int SIMNAME_INDEX = 5;
final String[] ROWDATACOLNAMES = new String[] { "Type", "Model", "Model Key", "Owner", "App", "Sim", "Date" };
Vector<Object[]> simInfoV = new Vector<Object[]>();
// BioModelMetaData[] bmMetaDataArr = getRequestManager().getDocumentManager().getSessionManager().getUserMetaDbServer().getBioModelMetaDatas(true);
// bmMetaDataArr[0].
BioModelInfo[] bioModelInfoArr = null;
if (vcDocInfo == null) {
bioModelInfoArr = currentRequstManager.getDocumentManager().getBioModelInfos();
} else if (vcDocInfo instanceof BioModelInfo) {
bioModelInfoArr = new BioModelInfo[] { (BioModelInfo) vcDocInfo };
}
for (int i = 0; bioModelInfoArr != null && i < bioModelInfoArr.length; i++) {
if (bioModelInfoArr[i].getBioModelChildSummary() != null) {
String[] bmSimContextNamesArr = bioModelInfoArr[i].getBioModelChildSummary().getSimulationContextNames();
for (int j = 0; bmSimContextNamesArr != null && j < bmSimContextNamesArr.length; j++) {
String[] bmSimNamesArr = bioModelInfoArr[i].getBioModelChildSummary().getSimulationNames(bmSimContextNamesArr[j]);
for (int k = 0; bmSimNamesArr != null && k < bmSimNamesArr.length; k++) {
// System.out.println("BM "+
// bioModelInfoArr[i].getVersion().getOwner().getName()+" "+
// bioModelInfoArr[i].getVersion().getName()+
// " app="+bmSimContextNamesArr[j]+
// " sim="+bmSimNamesArr[k]);
simInfoV.add(new Object[] { "BM", bioModelInfoArr[i].getVersion().getName(), bioModelInfoArr[i].getVersion().getVersionKey(), bioModelInfoArr[i].getVersion().getOwner().getName(), bmSimContextNamesArr[j], bmSimNamesArr[k], bioModelInfoArr[i].getVersion().getDate() });
}
}
}
}
MathModelInfo[] mathModelInfoArr = null;
if (vcDocInfo == null) {
mathModelInfoArr = currentRequstManager.getDocumentManager().getMathModelInfos();
} else if (vcDocInfo instanceof MathModelInfo) {
mathModelInfoArr = new MathModelInfo[] { (MathModelInfo) vcDocInfo };
}
for (int i = 0; mathModelInfoArr != null && i < mathModelInfoArr.length; i++) {
if (mathModelInfoArr[i].getMathModelChildSummary() != null) {
String[] mathSimNamesArr = mathModelInfoArr[i].getMathModelChildSummary().getSimulationNames();
for (int j = 0; mathSimNamesArr != null && j < mathSimNamesArr.length; j++) {
// System.out.println("MM "+
// mathModelInfoArr[i].getVersion().getOwner().getName()+" "+
// mathModelInfoArr[i].getVersion().getName()+
// " sim="+mathSimNamesArr[j]);
simInfoV.add(new Object[] { "MM", mathModelInfoArr[i].getVersion().getName(), mathModelInfoArr[i].getVersion().getVersionKey(), mathModelInfoArr[i].getVersion().getOwner().getName(), null, mathSimNamesArr[j], mathModelInfoArr[i].getVersion().getDate() });
}
}
}
Object[][] rowData = new Object[simInfoV.size()][ROWDATACOLNAMES.length];
simInfoV.copyInto(rowData);
int[] simSelection = DialogUtils.showComponentOKCancelTableList(getComponent(), "Choose Ref Simulation", ROWDATACOLNAMES, rowData, ListSelectionModel.SINGLE_SELECTION);
if (simSelection == null || simSelection.length == 0) {
throw UserCancelException.CANCEL_GENERIC;
}
Simulation[] simArr = null;
if (rowData[simSelection[0]][MODELTYPE_INDEX].equals("BM")) {
BioModel bm = currentRequstManager.getDocumentManager().getBioModel((KeyValue) rowData[simSelection[0]][MODELKEY_INDEX]);
simArr = bm.getSimulations();
} else {
MathModel mm = currentRequstManager.getDocumentManager().getMathModel((KeyValue) rowData[simSelection[0]][MODELKEY_INDEX]);
simArr = mm.getSimulations();
}
for (int i = 0; simArr != null && i < simArr.length; i++) {
if (simArr[i].getName().equals(rowData[simSelection[0]][SIMNAME_INDEX])) {
return simArr[i].getSimulationInfo();
}
}
throw new Exception("Couldn't find selected simulation");
}
Aggregations