use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.
the class DbDriver method getVCInfoContainer.
/**
* Insert the method's description here.
* Creation date: (9/24/2003 12:54:32 PM)
* @return cbit.vcell.modeldb.VCInfoContainer
*/
public static VCInfoContainer getVCInfoContainer(User user, Connection con, DatabaseSyntax dbSyntax, int whichExtraInfo) throws SQLException, DataAccessException {
VCInfoContainer results = null;
//
VCImageInfo[] vcImageInfos = null;
GeometryInfo[] geometryInfos = null;
MathModelInfo[] mathModelInfos = null;
BioModelInfo[] bioModelInfos = null;
PublicationInfo[] publicationInfos = null;
//
StringBuffer sql = null;
String special = null;
ResultSet rset = null;
boolean enableSpecial = true;
boolean enableDistinct = true;
Statement stmt = con.createStatement();
stmt.setFetchSize(500);
try {
String aliasSimName = "aliasSimName";
String aliasSimID = "aliasSimID";
String aliasSCName = "aliasSCName";
String aliasSVName = "aliasSVName";
//
// BioModelInfos
//
{
double beginTime = System.currentTimeMillis();
special = " ORDER BY " + BioModelTable.table.name.getQualifiedColName() + "," + BioModelTable.table.versionBranchID.getQualifiedColName() + "," + BioModelTable.table.versionDate.getQualifiedColName();
sql = new StringBuffer(BioModelTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), dbSyntax));
sql.insert(7, Table.SQL_GLOBAL_HINT);
rset = stmt.executeQuery(sql.toString());
TreeMap<BigDecimal, BioModelInfo> mapBmToBioModelInfo = new TreeMap<BigDecimal, BioModelInfo>();
while (rset.next()) {
BigDecimal bmID = rset.getBigDecimal(VersionTable.id_ColumnName);
if (!mapBmToBioModelInfo.containsKey(bmID)) {
BioModelInfo versionInfo = (BioModelInfo) BioModelTable.table.getInfo(rset, con, dbSyntax);
mapBmToBioModelInfo.put(bmID, versionInfo);
}
}
rset.close();
if (whichExtraInfo != 0) {
// Add mapping simName->SimID
try {
// String aliasUserKey = "aliasUserKey";
sql = new StringBuffer("SELECT " + SimContextTable.table.id.getQualifiedColName() + "," + SimContextTable.table.name.getQualifiedColName() + " " + aliasSCName + "," + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + "," + SimulationTable.table.name.getQualifiedColName() + " " + aliasSimName + "," + SimulationTable.table.id.getQualifiedColName() + " " + aliasSimID + (whichExtraInfo == 0xFF ? "," + ApplicationMathTable.table.outputFuncLarge.getQualifiedColName() + "," + ApplicationMathTable.table.outputFuncSmall.getQualifiedColName() + "," + SimulationTable.table.mathOverridesSmall + "," + SimulationTable.table.mathOverridesLarge + "," + SubVolumeTable.table.handle.getQualifiedColName() + "," + SubVolumeTable.table.name.getQualifiedColName() + " " + aliasSVName : // SubVolumeTable.table.ordinal.getQualifiedColName()+
"") + " FROM " + SimContextTable.table.getTableName() + "," + BioModelSimContextLinkTable.table.getTableName() + "," + BioModelSimulationLinkTable.table.getTableName() + "," + SimulationTable.table.getTableName() + (whichExtraInfo == 0xFF ? "," + ApplicationMathTable.table.getTableName() + "," + // GeometricRegionTable.table.getTableName()+","+
SubVolumeTable.table.getTableName() : "") + " WHERE " + BioModelSimContextLinkTable.table.simContextRef.getQualifiedColName() + " = " + SimContextTable.table.id.getQualifiedColName() + " AND " + SimulationTable.table.id.getQualifiedColName() + " = " + BioModelSimulationLinkTable.table.simRef.getQualifiedColName() + " AND " + BioModelSimulationLinkTable.table.bioModelRef.getQualifiedColName() + " = " + BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName() + " AND " + SimContextTable.table.mathRef.getQualifiedColName() + " = " + SimulationTable.table.mathRef.getQualifiedColName() + (whichExtraInfo == 0xFF ? " AND " + SimContextTable.table.id.getQualifiedColName() + " = " + ApplicationMathTable.table.simContextRef.getQualifiedColName() + " (+)" + // " AND "+SubVolumeTable.table.geometryRef.getQualifiedColName()+" = "+GeometricRegionTable.table.geometryRef.getQualifiedColName()
" AND " + SimContextTable.table.geometryRef.getQualifiedColName() + " = " + SubVolumeTable.table.geometryRef.getQualifiedColName() + " (+)" : ""));
final BigDecimal[] array = mapBmToBioModelInfo.keySet().toArray(new BigDecimal[0]);
final int MAX_LIST = 500;
for (int i = 0; i < array.length; i += MAX_LIST) {
StringBuffer bmListStr = new StringBuffer();
for (int j = 0; (i + j) < array.length && j < MAX_LIST; j++) {
bmListStr.append((j != 0 ? "," : "") + array[i + j].toString());
}
final String sql2 = sql.toString() + " AND " + BioModelSimulationLinkTable.table.bioModelRef.getQualifiedColName() + " IN (" + bmListStr.toString() + ")" + " ORDER BY " + BioModelSimulationLinkTable.table.bioModelRef.getQualifiedColName() + "," + SimContextTable.table.id.getQualifiedColName() + "," + SimulationTable.table.id.getQualifiedColName();
rset = stmt.executeQuery(sql2);
BioModelInfo bmInfo = null;
while (rset.next()) {
final BigDecimal bmID = rset.getBigDecimal(BioModelSimContextLinkTable.table.bioModelRef.toString());
bmInfo = mapBmToBioModelInfo.get(bmID);
if (bmInfo != null) {
final BigDecimal scID = rset.getBigDecimal(SimContextTable.table.id.toString());
final String scName = rset.getString(aliasSCName);
bmInfo.addSCID(scName, scID);
if ((whichExtraInfo & EXTRAINFO_ANNOTFUNC) != 0) {
if (!bmInfo.hasSCIDForAnnotFunc(scID)) {
String outputFunctionsXML = DbDriver.varchar2_CLOB_get(rset, ApplicationMathTable.table.outputFuncSmall, ApplicationMathTable.table.outputFuncLarge, dbSyntax);
if (outputFunctionsXML != null) {
bmInfo.addAnnotatedFunctionsStr(scName, scID, outputFunctionsXML);
}
}
}
final String simName = rset.getString(aliasSimName);
if (bmInfo.getSimID(simName) == null) {
final BigDecimal simID = rset.getBigDecimal(aliasSimID);
bmInfo.addSimID(simName, simID);
if ((whichExtraInfo & EXTRAINFO_MATHOVERRIDES) != 0) {
CommentStringTokenizer mathOverridesTokenizer = SimulationTable.getMathOverridesTokenizer(rset, dbSyntax);
List<Element> mathOverrideElements = MathOverrides.parseOverrideElementsFromVCML(mathOverridesTokenizer);
// int scanCount=1;
// for(Element ele:mathOverrideElements) {
// if(ele.getSpec() != null) {
// scanCount*=ele.getSpec().getNumValues();
// // if(scanCount==0) {
// // scanCount=ele.getSpec().getNumValues();
// // }else {
// // scanCount*=ele.getSpec().getNumValues();
// // }
// }
// }
// // if(scanCount > 1) {
// // System.out.println("bmid="+bmID+" simid="+simID+" scans="+scanCount+" "+simName);
// // }
bmInfo.addMathOverrides(simName, mathOverrideElements);
}
}
if ((whichExtraInfo & EXTRAINFO_SUBVOLUMES) != 0) {
final int subVolumeID = rset.getInt(SubVolumeTable.table.handle.toString());
if (bmInfo.getSubVolumeName(subVolumeID) == null) {
bmInfo.addSubVolume(subVolumeID, rset.getString(aliasSVName));
}
}
}
}
rset.close();
}
} catch (Exception e) {
e.printStackTrace();
// ignore
}
}
if (mapBmToBioModelInfo.size() > 0) {
bioModelInfos = new BioModelInfo[mapBmToBioModelInfo.size()];
mapBmToBioModelInfo.values().toArray(bioModelInfos);
}
// }
if (lg.isInfoEnabled()) {
lg.info("BioModelInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
}
}
//
// MathModelInfos
//
{
double beginTime = System.currentTimeMillis();
special = " ORDER BY " + MathModelTable.table.name.getQualifiedColName() + "," + MathModelTable.table.versionBranchID.getQualifiedColName() + "," + MathModelTable.table.versionDate.getQualifiedColName();
sql = new StringBuffer(MathModelTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), dbSyntax));
sql.insert(7, Table.SQL_GLOBAL_HINT);
TreeMap<BigDecimal, MathModelInfo> mapMmToMathModelInfo = new TreeMap<BigDecimal, MathModelInfo>();
rset = stmt.executeQuery(sql.toString());
ArrayList<MathModelInfo> tempInfos = new ArrayList<MathModelInfo>();
Set<String> distinctV = new HashSet<String>();
while (rset.next()) {
MathModelInfo versionInfo = (MathModelInfo) MathModelTable.table.getInfo(rset, con, dbSyntax);
if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
tempInfos.add(versionInfo);
distinctV.add(versionInfo.getVersion().getVersionKey().toString());
mapMmToMathModelInfo.put(BigDecimal.valueOf(Long.parseLong(versionInfo.getVersion().getVersionKey().toString())), versionInfo);
}
}
rset.close();
if (whichExtraInfo != 0) {
// Add mapping simName->SimID
try {
// String aliasUserKey = "aliasUserKey";
sql = new StringBuffer("SELECT " + MathModelSimulationLinkTable.table.mathModelRef.getQualifiedColName() + "," + ApplicationMathTable.table.outputFuncLarge.getQualifiedColName() + "," + ApplicationMathTable.table.outputFuncSmall.getQualifiedColName() + "," + SimulationTable.table.name.getQualifiedColName() + " " + aliasSimName + "," + SimulationTable.table.id.getQualifiedColName() + " " + aliasSimID + "," + SimulationTable.table.mathOverridesSmall + "," + SimulationTable.table.mathOverridesLarge + "," + SubVolumeTable.table.handle.getQualifiedColName() + "," + SubVolumeTable.table.name.getQualifiedColName() + " " + aliasSVName + " FROM " + MathModelTable.table.getTableName() + "," + MathDescTable.table.getTableName() + "," + MathModelSimulationLinkTable.table.getTableName() + "," + ApplicationMathTable.table.getTableName() + "," + SimulationTable.table.getTableName() + "," + SubVolumeTable.table.getTableName() + " WHERE " + MathModelSimulationLinkTable.table.mathModelRef.getQualifiedColName() + " = " + ApplicationMathTable.table.mathModelRef.getQualifiedColName() + " (+)" + " AND " + MathModelTable.table.id.getQualifiedColName() + " = " + MathModelSimulationLinkTable.table.mathModelRef.getQualifiedColName() + " AND " + SimulationTable.table.id.getQualifiedColName() + " = " + MathModelSimulationLinkTable.table.simRef.getQualifiedColName() + " AND " + MathDescTable.table.id.getQualifiedColName() + " = " + MathModelTable.table.mathRef.getQualifiedColName() + " AND " + MathDescTable.table.geometryRef.getQualifiedColName() + " = " + SubVolumeTable.table.geometryRef.getQualifiedColName() + " (+)");
final BigDecimal[] array = mapMmToMathModelInfo.keySet().toArray(new BigDecimal[0]);
final int MAX_LIST = 500;
for (int i = 0; i < array.length; i += MAX_LIST) {
StringBuffer mmListStr = new StringBuffer();
for (int j = 0; (i + j) < array.length && j < MAX_LIST; j++) {
mmListStr.append((j != 0 ? "," : "") + array[i + j].toString());
}
final String sql2 = sql.toString() + " AND " + MathModelSimulationLinkTable.table.mathModelRef.getQualifiedColName() + " IN (" + mmListStr.toString() + ")" + " ORDER BY " + MathModelSimulationLinkTable.table.mathModelRef.getQualifiedColName() + "," + SimulationTable.table.id.getQualifiedColName();
rset = stmt.executeQuery(sql2);
MathModelInfo mmInfo = null;
while (rset.next()) {
final BigDecimal mmID = rset.getBigDecimal(MathModelSimulationLinkTable.table.mathModelRef.toString());
mmInfo = mapMmToMathModelInfo.get(mmID);
if (mmInfo != null) {
if (mmInfo.getAnnotatedFunctionsStr() == null) {
String outputFunctionsXML = DbDriver.varchar2_CLOB_get(rset, ApplicationMathTable.table.outputFuncSmall, ApplicationMathTable.table.outputFuncLarge, dbSyntax);
if (outputFunctionsXML != null) {
mmInfo.setAnnotatedFunctionsStr(outputFunctionsXML);
}
}
final String simName = rset.getString(aliasSimName);
if (mmInfo.getSimID(simName) == null) {
final BigDecimal simID = rset.getBigDecimal(aliasSimID);
CommentStringTokenizer mathOverridesTokenizer = SimulationTable.getMathOverridesTokenizer(rset, dbSyntax);
List<Element> mathOverrideElements = MathOverrides.parseOverrideElementsFromVCML(mathOverridesTokenizer);
// int scanCount=1;
// for(Element ele:mathOverrideElements) {
// if(ele.getSpec() != null) {
// scanCount*=ele.getSpec().getNumValues();
// }
// }
mmInfo.addSimID(simName, simID, mathOverrideElements);
}
final int subVolumeID = rset.getInt(SubVolumeTable.table.handle.toString());
if (mmInfo.getSubVolumeName(subVolumeID) == null) {
mmInfo.addSubVolume(subVolumeID, rset.getString(aliasSVName));
}
}
}
rset.close();
}
} catch (Exception e) {
e.printStackTrace();
// ignore
}
}
if (tempInfos.size() > 0) {
mathModelInfos = new MathModelInfo[tempInfos.size()];
tempInfos.toArray(mathModelInfos);
}
if (lg.isInfoEnabled()) {
lg.info("MathModelInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
}
}
//
// VCImageInfos
//
{
double beginTime = System.currentTimeMillis();
special = " ORDER BY " + ImageTable.table.name.getQualifiedColName() + "," + ImageTable.table.versionBranchID.getQualifiedColName() + "," + ImageTable.table.versionDate.getQualifiedColName();
sql = new StringBuffer(ImageTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), true, dbSyntax));
sql.insert(7, Table.SQL_GLOBAL_HINT);
rset = stmt.executeQuery(sql.toString());
ArrayList<VCImageInfo> tempInfos = new ArrayList<VCImageInfo>();
Set<String> distinctV = new HashSet<String>();
while (rset.next()) {
VCImageInfo versionInfo = (VCImageInfo) ImageTable.table.getInfo(rset, con, dbSyntax);
if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
tempInfos.add(versionInfo);
distinctV.add(versionInfo.getVersion().getVersionKey().toString());
}
}
rset.close();
if (tempInfos.size() > 0) {
vcImageInfos = new VCImageInfo[tempInfos.size()];
tempInfos.toArray(vcImageInfos);
}
if (lg.isInfoEnabled()) {
lg.info("ImageInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
}
}
//
// GeometeryInfos
//
{
double beginTime = System.currentTimeMillis();
special = " ORDER BY " + GeometryTable.table.name.getQualifiedColName() + "," + GeometryTable.table.versionBranchID.getQualifiedColName() + "," + GeometryTable.table.versionDate.getQualifiedColName();
sql = new StringBuffer(GeometryTable.table.getInfoSQL(user, null, (enableSpecial ? special : null), true, dbSyntax));
sql.insert(7, Table.SQL_GLOBAL_HINT + (enableDistinct ? "DISTINCT " : ""));
rset = stmt.executeQuery(sql.toString());
ArrayList<GeometryInfo> tempInfos = new ArrayList<GeometryInfo>();
Set<String> distinctV = new HashSet<String>();
while (rset.next()) {
GeometryInfo versionInfo = (GeometryInfo) GeometryTable.table.getInfo(rset, con);
if (!distinctV.contains(versionInfo.getVersion().getVersionKey().toString())) {
tempInfos.add(versionInfo);
distinctV.add(versionInfo.getVersion().getVersionKey().toString());
}
}
rset.close();
if (tempInfos.size() > 0) {
geometryInfos = new GeometryInfo[tempInfos.size()];
tempInfos.toArray(geometryInfos);
}
if (lg.isInfoEnabled()) {
lg.info("GeometryInfo Time=" + (((double) System.currentTimeMillis() - beginTime) / (double) 1000));
}
}
try {
Vector<VersionInfo> bm_mm_VCDocumentInfos = new Vector<>();
bm_mm_VCDocumentInfos.addAll(Arrays.asList((bioModelInfos != null ? bioModelInfos : new BioModelInfo[0])));
bm_mm_VCDocumentInfos.addAll(Arrays.asList((mathModelInfos != null ? mathModelInfos : new MathModelInfo[0])));
DbDriver.addPublicationInfos(con, stmt, bm_mm_VCDocumentInfos);
} catch (Exception e) {
e.printStackTrace();
// Don't fail if something goes wrong with setting publication info
}
} finally {
if (stmt != null) {
stmt.close();
}
}
results = new VCInfoContainer(user, vcImageInfos, geometryInfos, mathModelInfos, bioModelInfos);
return results;
}
use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.
the class ClientDocumentManager method reloadGeometryInfos.
/**
* Insert the method's description here.
* Creation date: (11/14/00 5:33:21 PM)
* @return cbit.vcell.biomodel.BioModelInfo[]
*/
private void reloadGeometryInfos() throws DataAccessException {
try {
System.out.println("ClientDocumentManager.reloadGeometryInfos()");
GeometryInfo[] geometryInfos = sessionManager.getUserMetaDbServer().getGeometryInfos(true);
if (geometryInfos != null) {
geoInfoHash.clear();
for (int i = 0; i < geometryInfos.length; i++) {
geoInfoHash.put(geometryInfos[i].getVersion().getVersionKey(), geometryInfos[i]);
}
}
} catch (RemoteProxyException e) {
handleRemoteProxyException(e);
throw new DataAccessException("RemoteProxyException: " + e.getMessage());
}
}
use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.
the class ClientDocumentManager method addUserToGroup.
/**
* Insert the method's description here.
* Creation date: (11/28/00 5:43:44 PM)
* @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
*/
public GeometryInfo addUserToGroup(GeometryInfo geometryInfo, String userToAdd) throws DataAccessException {
try {
//
// publish from database
//
GeometryInfo newGeometryInfo = (GeometryInfo) addUserToGroup0(geometryInfo, VersionableType.Geometry, geoInfoHash, userToAdd);
// //
// // delete Geometry from cache
// //
// xmlHash.remove(geometryInfo.getVersion().getVersionKey());
// //
// // delete any MathModelMetaData's that use this GeometryInfo from cache
// //
// MathModelInfo referencedMathModelInfos[] = getMathModelReferences(geometryInfo);
// for (int i = 0; i < referencedMathModelInfos.length; i++){
// xmlHash.remove(referencedMathModelInfos[i].getVersion().getVersionKey());
// }
// //
// // delete any BioModelMetaData's that use this GeometryInfo from cache
// //
// BioModelInfo referencedBioModelInfos[] = getBioModelReferences(geometryInfo);
// for (int i = 0; i < referencedBioModelInfos.length; i++){
// xmlHash.remove(referencedBioModelInfos[i].getVersion().getVersionKey());
// }
fireDatabaseUpdate(new DatabaseEvent(this, DatabaseEvent.UPDATE, geometryInfo, newGeometryInfo));
return newGeometryInfo;
} catch (RemoteProxyException e) {
handleRemoteProxyException(e);
throw new DataAccessException(e.getMessage());
}
}
use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.
the class ClientDocumentManager method updateGeometryRelatedHashes.
private void updateGeometryRelatedHashes(Geometry savedGeometry) {
if (savedGeometry == null || (savedGeometry.getVersion() != null && geoInfoHash.get(savedGeometry.getVersion().getVersionKey()) != null)) {
return;
}
KeyValue imageRef = (savedGeometry.getGeometrySpec().getImage() != null) ? (savedGeometry.getGeometrySpec().getImage().getKey()) : (null);
if (imageRef != null && imgInfoHash.get(imageRef) == null) {
VCImage savedVCImage = savedGeometry.getGeometrySpec().getImage();
ISize size = new ISize(savedVCImage.getNumX(), savedVCImage.getNumY(), savedVCImage.getNumZ());
VCImageInfo savedVCImageInfo = new VCImageInfo(savedVCImage.getVersion(), size, savedVCImage.getExtent(), null, VCellSoftwareVersion.fromSystemProperty());
imgInfoHash.put(savedVCImage.getVersion().getVersionKey(), savedVCImageInfo);
}
Version localTimeVersion = convertVersionToLocalTime(savedGeometry.getVersion());
GeometryInfo savedGeometryInfo = new GeometryInfo(localTimeVersion, savedGeometry.getDimension(), savedGeometry.getExtent(), savedGeometry.getOrigin(), imageRef, VCellSoftwareVersion.fromSystemProperty());
geoInfoHash.put(savedGeometry.getVersion().getVersionKey(), savedGeometryInfo);
fireDatabaseInsert(new DatabaseEvent(this, DatabaseEvent.INSERT, null, geoInfoHash.get(savedGeometry.getVersion().getVersionKey())));
}
use of cbit.vcell.geometry.GeometryInfo in project vcell by virtualcell.
the class ClientDocumentManager method setGroupPrivate.
/**
* Insert the method's description here.
* Creation date: (11/28/00 5:43:44 PM)
* @param bioModelInfo cbit.vcell.biomodel.BioModelInfo
*/
public GeometryInfo setGroupPrivate(GeometryInfo geometryInfo) throws DataAccessException {
try {
//
// unpublish from database
//
GeometryInfo newGeometryInfo = (GeometryInfo) setGroupPrivate0(geometryInfo, VersionableType.Geometry, geoInfoHash);
// //
// // delete Geometry from cache
// //
// xmlHash.remove(geometryInfo.getVersion().getVersionKey());
// //
// // delete any MathModelMetaData's that use this GeometryInfo from cache
// //
// MathModelInfo referencedMathModelInfos[] = getMathModelReferences(geometryInfo);
// for (int i = 0; i < referencedMathModelInfos.length; i++){
// xmlHash.remove(referencedMathModelInfos[i].getVersion().getVersionKey());
// }
// //
// // delete any BioModelMetaData's that use this GeometryInfo from cache
// //
// BioModelInfo referencedBioModelInfos[] = getBioModelReferences(geometryInfo);
// for (int i = 0; i < referencedBioModelInfos.length; i++){
// xmlHash.remove(referencedBioModelInfos[i].getVersion().getVersionKey());
// }
fireDatabaseUpdate(new DatabaseEvent(this, DatabaseEvent.UPDATE, geometryInfo, newGeometryInfo));
return newGeometryInfo;
} catch (RemoteProxyException e) {
handleRemoteProxyException(e);
throw new DataAccessException(e.getMessage());
}
}
Aggregations