Skip to content

Commit 2dea279

Browse files
committed
Generate list of pub models with sim results 4
1 parent a523889 commit 2dea279

File tree

2 files changed

+124
-2
lines changed

2 files changed

+124
-2
lines changed

README_orphan.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,17 @@ NOTE: enter following after 'java' for debug (-agentlib:jdwp=transport=dt_socket
122122
4b. Run to save vcml of published modesl with sims that have no data or exceptions removed from vcml
123123

124124
java -cp ./dbbackupclean/ojdbc6-11.2.0.4.jar:./dbbackupclean/ucp-11.2.0.4.jar:./dbbackupclean/vcell-oracle-0.0.1-SNAPSHOT.jar:./cbit_vcell_tools_IonItems.jar:./maven- jars/jhdf5_2.10-2.9.jar
125-
-Djava.library.path="./natlibs" cbit.vcell.tools.IonItems "jdbc:oracle:thin:@vcell-db.cam.uchc.edu:1521:vcelldborcl" "/share/apps/vcell3/users" publishedmodelvcml /tmp/ionvcml 0 0
125+
-Djava.library.path="./natlibs" cbit.vcell.tools.IonItems "jdbc:oracle:thin:@vcell-db.cam.uchc.edu:1521:vcelldborcl" "/share/apps/vcell3/users" publishedmodelvcml /share/apps/vcell3/users/ionvcml 0 0
126126

127127
4c. Run to read vcml saved from 4b and compare to vcml from db and print the sims that had to be removed
128128

129129
java -cp ./dbbackupclean/ojdbc6-11.2.0.4.jar:./dbbackupclean/ucp-11.2.0.4.jar:./dbbackupclean/vcell-oracle-0.0.1-SNAPSHOT.jar:./cbit_vcell_tools_IonItems.jar:./maven-jars/jhdf5_2.10-2.9.jar
130-
-Djava.library.path="./natlibs" cbit.vcell.tools.IonItems "jdbc:oracle:thin:@vcell-db.cam.uchc.edu:1521:vcelldborcl" /tmp/ionvcml publishedmodelvcmldiff
130+
-Djava.library.path="./natlibs" cbit.vcell.tools.IonItems "jdbc:oracle:thin:@vcell-db.cam.uchc.edu:1521:vcelldborcl" /share/apps/vcell3/users/ionvcml publishedmodelvcmldiff
131+
132+
4d. Run to save vcml from TestSuit
133+
134+
java -cp ./dbbackupclean/ojdbc6-11.2.0.4.jar:./dbbackupclean/ucp-11.2.0.4.jar:./dbbackupclean/vcell-oracle-0.0.1-SNAPSHOT.jar:./cbit_vcell_tools_IonItems.jar:./maven-jars/jhdf5_2.10-2.9.jar
135+
-Djava.library.path="./natlibs" cbit.vcell.tools.IonItems "jdbc:oracle:thin:@vcell-db.cam.uchc.edu:1521:vcelldborcl" /share/apps/vcell3/users/ionts testsuitemodelvcml
131136

132137
***----------------------------------------------------------------------------------------------------------***
133138

vcell-server/src/main/java/cbit/vcell/tools/IonItems.java

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import cbit.vcell.geometry.GeometryThumbnailImageFactoryAWT;
3636
import cbit.vcell.mathmodel.MathModel;
3737
import cbit.vcell.messaging.db.SimulationJobTable;
38+
import cbit.vcell.modeldb.BioModelSimContextLinkTable;
3839
import cbit.vcell.modeldb.BioModelSimulationLinkTable;
3940
import cbit.vcell.modeldb.BioModelTable;
4041
import cbit.vcell.modeldb.DBTopLevel;
@@ -44,6 +45,8 @@
4445
import cbit.vcell.modeldb.MathModelTable;
4546
import cbit.vcell.modeldb.PublicationModelLinkTable;
4647
import cbit.vcell.modeldb.ServerDocumentManager;
48+
import cbit.vcell.modeldb.TFTestCaseTable;
49+
import cbit.vcell.modeldb.TFTestSuiteTable;
4750
import cbit.vcell.modeldb.UserTable;
4851
import cbit.vcell.modeldb.VersionTable;
4952
import cbit.vcell.simdata.Cachetable;
@@ -64,6 +67,7 @@
6467
public class IonItems {
6568
//See vcell-node1:/opt/build/frm/cbit_vcell_tools_IonItems.info
6669
private static final String PUBLISHEDMODELVCML = "publishedmodelvcml";
70+
private static final String TESTSUITEMODELVCML = "testsuitemodelvcml";
6771
private static final String PUBLICMODELWITHSIMS = "publicmodelwithsims";
6872
private static final String PUBLISHEDMODELVCMLDIFF = "publishedmodelvcmldiff";
6973

@@ -119,6 +123,9 @@ public static void main(String[] args) {
119123
}else if(command.toLowerCase().equals(PUBLISHEDMODELVCMLDIFF)) {
120124
File dirWithSavedVCML = new File(args[1]);
121125
readVCMLWithSimsRemoved(con, dirWithSavedVCML);
126+
}else if (command.toLowerCase().equals(TESTSUITEMODELVCML)) {
127+
File dirToSaveVCML = new File(args[1]);
128+
saveVCMLTestSuite(dirToSaveVCML,0,0);
122129
}
123130

124131
} catch (Exception e) {
@@ -140,10 +147,120 @@ public static void main(String[] args) {
140147

141148
}
142149

150+
private static void saveVCMLTestSuite(File dirToSaveVCML,long startSimKey,long endSimKey) throws Exception{
151+
// select distinct vc_biomodelsimcontext.biomodelref modelkey
152+
// from vc_tftestsuite,vc_tftestcase,vc_biomodelsimcontext
153+
// where vc_tftestsuite.tsversion='88_alpha_from_87_alpha'
154+
// and vc_tftestcase.testsuiteref=vc_tftestsuite.id
155+
// and vc_tftestcase.bmappref is not null
156+
// and vc_tftestcase.bmappref=vc_biomodelsimcontext.id
157+
// union
158+
// select distinct vc_mathmodel.id modelkey
159+
// from vc_tftestsuite,vc_tftestcase,vc_mathmodel
160+
// where vc_tftestsuite.tsversion='88_alpha_from_87_alpha'
161+
// and vc_tftestcase.testsuiteref=vc_tftestsuite.id
162+
// and vc_tftestcase.mathmodelref is not null
163+
// and vc_tftestcase.mathmodelref=vc_mathmodel.id;
164+
String modelKeyStr = "modelkey";
165+
String userKeyStr = "userkey";
166+
String useridStr = "userid";
167+
String modelUserKeyStr = modelKeyStr+","+UserTable.table.id.getQualifiedColName()+" "+userKeyStr+","+UserTable.table.userid.getQualifiedColName()+" "+useridStr;
168+
String testSuitTestCaseLink =
169+
TFTestSuiteTable.table.tsVersion.getQualifiedColName()+"="+"'88_alpha_from_87_alpha'"+
170+
" AND "+TFTestCaseTable.table.testSuiteRef.getQualifiedColName()+"="+TFTestSuiteTable.table.id.getQualifiedColName();
171+
String testSuitAndUserStr = TFTestSuiteTable.table.getTableName()+","+TFTestCaseTable.table.getTableName()+","+UserTable.table.getTableName();
172+
String bioModelTypeStr = "biomodel";
173+
String mathModelTypeStr = "mathmodel";
174+
String modelTypeKeyStr = "modeltype";
175+
String sql =
176+
"SELECT distinct "+"'"+bioModelTypeStr+"' "+modelTypeKeyStr+","+BioModelTable.table.id.getQualifiedColName()+" "+modelUserKeyStr+
177+
" FROM "+testSuitAndUserStr+","+BioModelSimContextLinkTable.table.getTableName()+","+BioModelTable.table.getTableName()+
178+
" WHERE "+testSuitTestCaseLink+" AND "+TFTestCaseTable.table.bmAppRef.getQualifiedColName()+" IS NOT NULL"+
179+
" AND "+TFTestCaseTable.table.bmAppRef.getQualifiedColName()+"="+BioModelSimContextLinkTable.table.id.getQualifiedColName()+
180+
" AND "+BioModelSimContextLinkTable.table.bioModelRef.getQualifiedColName()+"="+BioModelTable.table.id.getQualifiedColName()+
181+
" AND "+BioModelTable.table.ownerRef.getQualifiedColName()+"="+UserTable.table.id.getQualifiedColName()+
182+
" UNION "+
183+
"SELECT distinct "+"'"+mathModelTypeStr+"' "+modelTypeKeyStr+","+MathModelTable.table.id.getQualifiedColName()+" "+modelUserKeyStr+
184+
" FROM "+testSuitAndUserStr+","+MathModelTable.table.getTableName()+
185+
" WHERE "+testSuitTestCaseLink+" AND "+TFTestCaseTable.table.mathModelRef.getQualifiedColName()+" IS NOT NULL"+
186+
" AND "+TFTestCaseTable.table.mathModelRef.getQualifiedColName()+"="+MathModelTable.table.id.getQualifiedColName()+
187+
" AND "+MathModelTable.table.ownerRef.getQualifiedColName()+"="+UserTable.table.id.getQualifiedColName();
188+
189+
Statement stmt = null;
190+
try {
191+
stmt = con.createStatement();
192+
//ArrayList<VCDocument> successDocs = new ArrayList<VCDocument>();
193+
DatabaseServerImpl databaseServerImpl = new DatabaseServerImpl(connFac,null);
194+
ArrayList<Object[]> modeKeyAndUser = new ArrayList<Object[]>();
195+
196+
ResultSet rset = stmt.executeQuery(sql);
197+
while(rset.next()) {
198+
BigDecimal modelKeyBigDecimal = rset.getBigDecimal(modelKeyStr);
199+
KeyValue modelKey = new KeyValue(modelKeyBigDecimal);
200+
String modelType = rset.getString(modelTypeKeyStr);
201+
if(startSimKey == 0 || (modelKeyBigDecimal.longValue() >= startSimKey && modelKeyBigDecimal.longValue() <= endSimKey)) {
202+
User user = new User(rset.getString(useridStr), new KeyValue(rset.getBigDecimal(userKeyStr)));
203+
modeKeyAndUser.add(new Object[] {(modelType.equals(bioModelTypeStr)?VCDocumentType.BIOMODEL_DOC:VCDocumentType.MATHMODEL_DOC),modelKey,user});
204+
}
205+
}
206+
rset.close();
207+
stmt.close();
208+
209+
VCDocument vcDoc = null;
210+
for(int ii=0;ii<modeKeyAndUser.size();ii++) {
211+
try {
212+
VCDocumentType vcDocType = (VCDocumentType)modeKeyAndUser.get(ii)[0];
213+
KeyValue modelKey = (KeyValue)modeKeyAndUser.get(ii)[1];
214+
User user = (User)modeKeyAndUser.get(ii)[2];
215+
//-----NOTE: (privacy, versionflag) may not match between xml and database (because privacy and versionflag can be set without saving model)
216+
//some models regenerated from xml will not have same privacy and versionflag matched in query from database (the database values are correct, ignore the xml values)
217+
BigString modelXML = (vcDocType == VCDocumentType.BIOMODEL_DOC?databaseServerImpl.getBioModelXML(user, modelKey):databaseServerImpl.getMathModelXML(user, modelKey));
218+
vcDoc = null;
219+
if(vcDocType == VCDocumentType.BIOMODEL_DOC) {
220+
BioModel bm = cbit.vcell.xml.XmlHelper.XMLToBioModel(new XMLSource(modelXML.toString()));
221+
bm.refreshDependencies();
222+
vcDoc = bm;
223+
}else {
224+
MathModel mm = cbit.vcell.xml.XmlHelper.XMLToMathModel(new XMLSource(modelXML.toString()));
225+
mm.refreshDependencies();
226+
vcDoc = mm;
227+
}
228+
//if(true) {
229+
// System.out.println(modelKey+" "+user+" "+vcDoc);
230+
// continue;
231+
//}
232+
233+
String docXml = null;
234+
if(vcDoc.getDocumentType() == VCDocument.VCDocumentType.BIOMODEL_DOC) {
235+
docXml = XmlHelper.bioModelToXML(((BioModel)vcDoc));
236+
}else {
237+
docXml = XmlHelper.mathModelToXML(((MathModel)vcDoc));
238+
}
239+
PrintWriter pw = new PrintWriter(new File(dirToSaveVCML,vcDoc.getVersion().getVersionKey().toString()+".xml"));
240+
pw.write(docXml);
241+
pw.close();
242+
// }
243+
} catch (Exception e) {
244+
System.out.println("----------GENERALERROR "+vcDoc.getVersion().getVersionKey());
245+
e.printStackTrace();
246+
if(vcDoc != null) {
247+
PrintWriter pw = new PrintWriter(new File(dirToSaveVCML,vcDoc.getVersion().getVersionKey().toString()+"_exception.xml"));
248+
pw.write("");
249+
pw.close();
250+
}
251+
}
252+
}
253+
} finally{
254+
if(stmt != null){try{stmt.close();}catch(Exception e){e.printStackTrace();}}
255+
}
256+
257+
}
258+
143259
public static void usage() {
144260
System.out.println("cbit.vcell.tools.IonItems jdbc:oracle:thin:@VCELL_DB_HOST:1521:VCEL_DB_NAME vcellUsersRootDir "+PUBLICMODELWITHSIMS+" {true,false print more info}}");
145261
System.out.println("cbit.vcell.tools.IonItems jdbc:oracle:thin:@VCELL_DB_HOST:1521:VCEL_DB_NAME vcellUsersRootDir "+PUBLISHEDMODELVCML+" dirToSaveVCML, startSimKey endSimKey");
146262
System.out.println("cbit.vcell.tools.IonItems jdbc:oracle:thin:@VCELL_DB_HOST:1521:VCEL_DB_NAME dirWithSavedVCML "+PUBLISHEDMODELVCMLDIFF);
263+
System.out.println("cbit.vcell.tools.IonItems jdbc:oracle:thin:@VCELL_DB_HOST:1521:VCEL_DB_NAME dirToSaveVCML "+TESTSUITEMODELVCML);
147264
System.exit(1);
148265
}
149266

0 commit comments

Comments
 (0)