00001 00002 // reads MCProcessType from DB, adds compatibility info to it 00003 // and writes it back to the DB 00004 00005 package cedar.jetweb.db; 00006 00007 import cedar.jetweb.model.MCProcessType; 00008 import cedar.jetweb.JetWebConfig; 00009 import cedar.jetweb.JetWebException; 00010 00011 import java.util.Arrays; 00012 import java.util.Vector; 00013 00014 import java.sql.Statement; 00015 00016 00027 public class BlobUpload{ 00028 00029 public static void main(String[] args){ 00030 00031 if(!Arrays.asList(args).contains("-ProcessId")|| 00032 !Arrays.asList(args).contains("-Array")){ 00033 00034 System.out.println("entry not specified on the command line"); 00035 00036 return; 00037 00038 } 00039 00040 System.out.println(" Connecting to database..."); 00041 00042 JetWebConfig.init(); 00043 00044 DBConnectionManager connManager = new DBConnectionManager(); 00045 String[] dbs = {DBConfig.JETWEB}; 00046 connManager.init(dbs); 00047 00048 DBObjectManager objManager = new DBObjectManager(); 00049 objManager.passDBConnection(connManager); 00050 00051 System.out.println(" ...got database"); 00052 00053 //Get the array from the command line: 00054 // first string in array is "[" 00055 00056 System.out.println(" Parsing array..."); 00057 00058 int arrayIndex = Arrays.asList(args).indexOf("-Array") + 2; 00059 00060 Vector<Integer> data = new Vector<Integer>(); 00061 00062 00063 String element = args[arrayIndex]; 00064 while(!element.equals("]")){ 00065 00066 data.add(new Integer(Integer.parseInt(element))); 00067 ++arrayIndex; 00068 element = args[arrayIndex]; 00069 } 00070 00071 System.out.println(" ...got array"); 00072 00073 arrayIndex = Arrays.asList(args).indexOf("-ProcessId")+1; 00074 00075 int procId = Integer.parseInt(args[arrayIndex]); 00076 00077 System.out.println(" Getting exisiting process settings..."); 00078 00079 MCProcessType proc = new MCProcessType(procId); 00080 00081 System.out.println(" ...got existing process"); 00082 00083 proc.setCompatibleProcesses(data); 00084 00085 System.out.println(" Writing new process..."); 00086 00087 System.out.println("process type = "+proc.getProcessName()); 00088 00089 try{ 00090 00091 String cmd = "delete from process_type where process_id="+procId; 00092 00093 Statement stmt = 00094 connManager.getConnection(DBConfig.JETWEB).createStatement(); 00095 00096 stmt.execute(cmd); 00097 00098 objManager.writeObject(proc, "process_type", DBConfig.JETWEB); 00099 }catch(Throwable err){ 00100 System.out.println(err.getMessage()); 00101 } 00102 System.out.println(""); 00103 00104 System.out.println(" ...finished"); 00105 00106 } 00107 00108 00109 }
Generated Wed Jan 17 09:14:27 GMT 2007