Re: AppParameter Question

Gabriel Gruber <[email protected]> Mon, 26 Sep 2005 16:08:29 +0200
Newsgroups gmane.comp.java.enhydra.shark
Message-ID <OF235E3CAE.05636CCD-ONC1257086.003513C0-C1257088.004DAEE0@workflow.at>
Well two things you could try out:
 
* define the AllCompanies Activity Variable as output parameter in terms 
of the toolagent
* if the string array does not work, try out at a java object instead uns 
use f.i. java.util.ArrayList
 
regards,gabriel
______________________
Mag. Gabriel Gruber
Senior Consultant
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Workflow EDV GmbH, Dannebergplatz 6/23, A-1030 Wien
phone: ++43 - 1 - 7188842 22
fax: ++43 - 1 - 7188842 30
mobile: ++43 - 676 - 3939435
mailto:[email protected]
http://www.workflow.at

-----Sean McDonald <[email protected]> wrote: -----

To: [email protected]
From: Sean McDonald <[email protected]>
Date: 23.09.2005 16:50
Subject: [shark] AppParameter Question

I have a datafield that is defined thusly:


                   
                       
                   


I'm using it in a tool agent, to return a list of companies from the 
database.

Here's the method in question:

public static void execute(AppParameter tableName, AppParameter 
descriptionExpression,
                              AppParameter idField, AppParameter 
filterField,
                              AppParameter filterValue, AppParameter 
results) {
       //make a connection to the database
      
//        Database variables

       Connection db = null; // A connection to the database

       Statement sql = null; // Our statement to run queries with

       DatabaseMetaData dbmd = null; // This is basically info the 
driver delivers
      
       ResultSet rs = null;
      
       //Initialize variables
       String database = "//localhost/jpadmin";
       String username = "jpadmin";
       String password = "jpadmin";
      
       try {
           Class.forName("org.postgresql.Driver"); //load the driver
           db = DriverManager.getConnection("jdbc:postgresql:" + database,
                   username, password); //connect to the db
           dbmd = db.getMetaData(); //get MetaData to confirm connection
           System.out.println("Connection to " + 
dbmd.getDatabaseProductName()
                   + " " + dbmd.getDatabaseProductVersion() + " 
successful.\n");
       } catch (ClassNotFoundException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       } catch (SQLException e) {
           // TODO Auto-generated catch block
           e.printStackTrace();
       }

       //parse the query
       String queryText = "SELECT " + (String) idField.the_value + ", " 
+ (String) descriptionExpression.the_value + " " +
                          "FROM " + (String) tableName.the_value + " ";
      
       //if filter clauses were specified, add them to the query
       if(filterField.the_length > 0){
           String filterText = "WHERE " + (String) 
filterField.the_value + "=" + (String) filterValue.the_value;
           queryText = queryText + filterText;
       }
      
      
      
       //create & execute the query
       try {
           sql = db.createStatement();
           rs = sql.executeQuery(queryText);
       } catch (SQLException e1) {
           // TODO Auto-generated catch block
           e1.printStackTrace();
       }
      
       ArrayList myList = new ArrayList();
      
       //build the array list
       int i = 1;
       try {
           while(rs.next()){
               listElement myElement = new listElement();
               int id = rs.getInt(1);
               String description = rs.getString(2);
               myList.add(id + "  " + description);
           }
       } catch (SQLException e2) {
           // TODO Auto-generated catch block
           e2.printStackTrace();
       }
      
       //create the results
       String[] strResults = (String[]) myList.toArray(new String[0]);
      
-----  This is the part i'm uncertain about - i'm not sure how to 
transfer the String array I've created back to the results AppParameter
      
   results.the_value = strResults;
             
}

Here's the error stack:

2005-09-23 14:55:48,612: Rollback of Shark transaction happened.
org.enhydra.shark.api.client.wfmodel.InvalidData: Invalid data type for 
activity variable AllCompanies
   at 
org.enhydra.shark.WfActivityImpl.setProcessContext(WfActivityImpl.java:470)

   at org.enhydra.shark.WfActivityImpl.set_result(WfActivityImpl.java:279)
   at 
org.enhydra.shark.ToolAgentManagerImpl$ToolRunner.invokeApplication(ToolAgentManagerImpl.java:247)

   at 
org.enhydra.shark.ToolAgentManagerImpl$ToolRunner.run(ToolAgentManagerImpl.java:96)

   at 
org.enhydra.shark.ToolAgentManagerImpl.executeActivity(ToolAgentManagerImpl.java:67)

   at org.enhydra.shark.WfActivityImpl.runTool(WfActivityImpl.java:1269)
   at 
org.enhydra.shark.WfActivityImpl.startActivity(WfActivityImpl.java:1212)
   at org.enhydra.shark.WfActivityImpl.activate(WfActivityImpl.java:1157)
   at 
org.enhydra.shark.WfProcessImpl.startActivity(WfProcessImpl.java:816)
   at org.enhydra.shark.WfProcessImpl.run(WfProcessImpl.java:695)
   at org.enhydra.shark.WfProcessImpl.start(WfProcessImpl.java:365)
   at org.enhydra.shark.WfProcessWrapper.start(WfProcessWrapper.java:571)
   at org.enhydra.shark.WfProcessWrapper.start(WfProcessWrapper.java:531)
   at 
org.enhydra.shark.corba.WfProcessCORBA.start(WfProcessCORBA.java:166)
   at 
org.omg.WorkflowModel._WfProcessImplBase._invoke(_WfProcessImplBase.java:193)

   at 
com.ibm.CORBA.iiop.ServerDelegate.dispatchInvokeHandler(ServerDelegate.java:608)

   at com.ibm.CORBA.iiop.ServerDelegate.dispatch(ServerDelegate.java:461)
   at com.ibm.rmi.iiop.ORB.process(ORB.java:436)
   at com.ibm.CORBA.iiop.ORB.process(ORB.java:1728)
   at com.ibm.rmi.iiop.Connection.doWork(Connection.java:2230)
   at com.ibm.rmi.iiop.WorkUnitImpl.doWork(WorkUnitImpl.java:65)
   at com.ibm.rmi.iiop.WorkerThread.run(ThreadPoolImpl.java:203)
   at java.lang.Thread.run(Thread.java:568)


What I'm asking is how i can pass this array of Strings back to Shark 
correctly?

I'm painfully new to all of this, so please be gentle :)

Many thanks
Sean



--
You receive this message as a subscriber of the [email protected] 
mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws
message-footer.txt (text/plain, 271 B)
--
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws