Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

BlobUpload Class Reference

List of all members.

Detailed Description

Utility to alter compatible_process column of process_type table from the command line.

Useage: java cedar.jetweb.db.BlobUpload -ProcessId 1 -Array [ 1 2 3 ]

Author:
J. Monk

Definition at line 27 of file BlobUpload.java.


Static Public Member Functions

void main (String[] args)

Member Function Documentation

void main String[]  args  )  [static]
 

Definition at line 29 of file BlobUpload.java.

References DBConnectionManager.getConnection(), MCProcessType.getProcessName(), DBConnectionManager.init(), DBObjectManager.passDBConnection(), MCProcessType.setCompatibleProcesses(), and DBObjectManager.writeObject().

00029                                           {
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     }


The documentation for this class was generated from the following file:

Generated Wed Jan 17 09:14:27 GMT 2007