Well, I've played a bit with ODWEK, and did the following code:
WARNING/ LEGAL Stuff: this is just a sample, it is not supposed to be pretty or to be fullproof !!! use it with your own risk. I don't want to be accused of anything if something goes wrong!
You can use this code without any restriction, I don't care what you'll do with it, and please again use it at your own risk :-D
import java.util.Enumeration;
import java.util.Vector;
import com.ibm.edms.od.*;
public class GetDocFromLoadID {
public static void main(String[] args) throws Exception {
String loadID = "5001-1-0-1FAA-1328202949-1328203141";
ODConfig ocfg = new ODConfig();
ODServer osrv = new ODServer(ocfg);
osrv.initialize("Testing");
osrv.setServerName("localhost");
osrv.setPort(1445);
osrv.setUserId("USER");
osrv.setPassword("PASSWORD");
osrv.logon();
String agidString = loadID.substring(0, loadID.indexOf("-"));
String restLoadID = loadID.substring(loadID.indexOf("-") + 1,
loadID.length());
String priNIDString = restLoadID.substring(0, restLoadID.indexOf("-"));
restLoadID = restLoadID.substring(restLoadID.indexOf("-") + 1,
restLoadID.length());
String secNIDString = restLoadID.substring(0, restLoadID.indexOf("-"));
restLoadID = restLoadID.substring(restLoadID.indexOf("-") + 1,
restLoadID.length());
String docNameString = restLoadID.substring(0, restLoadID.indexOf("-"));
restLoadID = restLoadID.substring(restLoadID.indexOf("-") + 1,
restLoadID.length());
String startDateNameString = restLoadID.substring(0,
restLoadID.indexOf("-"));
String endDateNameString = restLoadID.substring(
restLoadID.indexOf("-") + 1, restLoadID.length());
System.out.println("LoadID is " + loadID);
System.out.println("-> agid=" + agidString);
System.out.println("-> Pri_NID=" + priNIDString);
System.out.println("-> Sec_NID=" + secNIDString);
System.out.println("-> Doc_Name=" + docNameString);
System.out.println("-> Start_Date=" + startDateNameString);
System.out.println("-> End_Date=" + endDateNameString);
System.out.println();
ODApplicationGroup odag = osrv.getApplicationGroup(Long.parseLong(agidString));
Enumeration<ODApplicationGroupField> agfld = odag.getFields();
System.out.println("Name of the Application Group=" + odag.getName());
Enumeration<ODApplicationGroupField> odAGFlds = odag.getFields();
String agFieldSegment = "";
while (odAGFlds.hasMoreElements()) {
ODApplicationGroupField odAGFld = odAGFlds.nextElement();
if ((odAGFld.getFieldMask() & ODConstant.OD_FLD_SEGMENT) != 0) {
agFieldSegment = odAGFld.getName();
break;
}
}
if (agFieldSegment == "") {
System.out
.println("Could not find a Segment Field in Application Group");
System.exit(1);
}
System.out.println("Segment Field=" + agFieldSegment);
Enumeration<ODFolder> listODFolder = osrv.getFolders();
String folderToSearch = "";
OUT: while (listODFolder.hasMoreElements()) {
ODFolder folder = listODFolder.nextElement();
folder.open();
for (String agName : folder.getApplGroupNames()) {
if (agName.equals(odag.getName())) {
folderToSearch = folder.getName();
folder.close();
break OUT;
}
}
folder.close();
}
if (folderToSearch == "") {
System.out
.println("Could not find a folder to search the documents");
System.exit(1);
}
System.out.println("Folder to search=" + folderToSearch);
ODFolder odfolder = osrv.openFolder(folderToSearch);
odfolder.setApplGroupForSearchWithSQL(odag.getName());
Vector<ODHit> odhit = odfolder.search("where doc_name like '"
+ docNameString + "%' and PRI_NID=" + priNIDString
+ " and SEC_NID=" + secNIDString+ " and "+agFieldSegment+">="+startDateNameString+ " and "+agFieldSegment+"<="+endDateNameString);
int counter=0;
for (ODHit singleHit : odhit) {
System.out.println("Retrieving document #"+counter);
singleHit.getDocument("/tmp/"+loadID+"_"+counter+".out",true);
counter++;
}
osrv.logoff();
}
}
Well for me it works and here is the output:
LoadID is 5001-1-0-1FAA-1328202949-1328203141
-> agid=5001
-> Pri_NID=1
-> Sec_NID=0
-> Doc_Name=1FAA
-> Start_Date=1328202949
-> End_Date=1328203141
Name of the Application Group=System Log
Segment Field=time_stamp
Folder to search=System Log
Retrieving document #0
Retrieving document #1
Retrieving document #2
Retrieving document #3
Retrieving document #4
Retrieving document #5
Retrieving document #6
Retrieving document #7
and in my /tmp/ directory I have the following files:
$ ls -l /tmp/5001\-1\-0\-1FAA\-1328202949\-1328203141_*
-rw-rw-r--. 1 alex staff 1804 Feb 9 11:18 /tmp/5001-1-0-1FAA-1328202949-1328203141_0.out
-rw-rw-r--. 1 alex staff 5266 Feb 9 11:18 /tmp/5001-1-0-1FAA-1328202949-1328203141_1.out
-rw-rw-r--. 1 alex staff 1708 Feb 9 11:18 /tmp/5001-1-0-1FAA-1328202949-1328203141_2.out
-rw-rw-r--. 1 alex staff 1717 Feb 9 11:18 /tmp/5001-1-0-1FAA-1328202949-1328203141_3.out
-rw-rw-r--. 1 alex staff 1705 Feb 9 11:18 /tmp/5001-1-0-1FAA-1328202949-1328203141_4.out
-rw-rw-r--. 1 alex staff 851 Feb 9 11:18 /tmp/5001-1-0-1FAA-1328202949-1328203141_5.out
-rw-rw-r--. 1 alex staff 851 Feb 9 11:18 /tmp/5001-1-0-1FAA-1328202949-1328203141_6.out
-rw-rw-r--. 1 alex staff 851 Feb 9 11:18 /tmp/5001-1-0-1FAA-1328202949-1328203141_7.out
I know the code is not documented, the code is not pretty, it needs a lot of refactorisation, but I did it in 30 minutes... with lots of API methods search, and tests....
I hope it helps in solving your question.
Sincerely yours,
Alessandro