Showing posts with label Process Engine API. Show all posts
Showing posts with label Process Engine API. Show all posts

Tuesday 14 April 2015

Create Work item through existing Workflow (Process Engine API)

//Create Work item through existing Workflow (Process Engine API)


public VWCreateLiveWOResult[] createLiveWorkObject( java.lang.String[] fieldNames, 
java.lang.Object[] fieldValues, 
java.lang.String workflowIdentifier, 
int numberToCreate) 
throws VWException

will creates (initializes, saves, and dispatches) work items from a transferred workflow definition, specified by its workflow identifier. Multiple work classes on one roster are supported

fieldNames - A String array containing the names of the fields to update in the new work items, in the same order that the values for those fields are supplied in the fieldValues parameter.

fieldValues - An array of Objects whose values are supplied, in order, to the fields named in the fieldNames parameter. 

workflowIdentifier - The workflow definition name (work class name) as returned by VWWorkflowDefinition.getName method, or the workflow version (version property) as returned by VWTransferResult.getVersion. You can get a VWTransferResult object using the transfer method. If a translation source exists, the authored work class name is translated.

numberToCreate - An integer for the number of work items to create. 


try {
      String[] myWorkObjectNumbers = (String[])null;
      String[] myRosterNames = (String[])null;

      VWCreateLiveWOResult[] createWORes = this.peSession
        .createLiveWorkObject(myFieldNames, myLaunchValues, myWorkflowName, 1);

      if (createWORes[0].success())
      {
        myWorkObjectNumbers = new String[createWORes.length];
        myRosterNames = new String[createWORes.length];
        for (int i = 0; i < createWORes.length; i++) {
          myWorkObjectNumbers[i] =
            createWORes[i].getWorkObjectNumber();
          log.info("New workflow with Wob Number [" +
            myWorkObjectNumbers[i] +
            "] launched successfully");
          myRosterNames[i] = createWORes[i].getRosterName();
          log.debug("Workflow Roster Name is [" + myRosterNames[i] +
            "]");
        }

      }

    }
    catch (Exception ex)
    {
      log.error("Exception occured while launching workflow:" +
        ex.getMessage(), ex);
      throw ex;
    }

  






Thursday 20 November 2014

Dispatch Work Item in FileNet Process Engine (Process Engine API)

   
    //Fetch the Work Item
    VWWorkObject vwWorkObj=null;
      try{
          VWRoster roster=peSession.getRoster(rosterName);
          int queryFlags=VWRoster.QUERY_NO_OPTIONS;
          String Name = "abcd";
          String filter="Doc_Name="+Name;//Change Accrordigly (Based on Process Administaration tool fields)
             
          VWRosterQuery query=roster.createQuery(null, null, null, queryFlags, filter, null, VWFetchType.FETCH_TYPE_WORKOBJECT);
          log.info("Total records for Work ITem: "+query.fetchCount());
         
          while(query.hasNext()){
              vwWorkObj=(VWWorkObject) query.next(); 
          }
         
      }catch(VWException vwe){
          log.error("Exception found at PEManager.getVWWorkObject():"+vwe,vwe);
          vwe.printStackTrace();
      }catch(Exception vwe){
          log.error("Exception found at PEManager.getVWWorkObject():"+vwe,vwe);
          vwe.printStackTrace();
      }
     
//Terminate(Dispatch) work Item
try{

if(vwWorkObj!=null){

String Response = "Cancel";
VWStepElement vwStepObj=vwWorkObj.fetchStepElement();
vwStepObj.doLock(true);
vwStepObj.setSelectedResponse(Response);

vwStepObj.doDispatch();
}else{
                           
log.info("VWWorkObject is NULL");
                       
}
                       
}catch(Exception ex){
                           
ex.printStackTrace();
                       
}   

Thursday 13 November 2014

Search Work Item in Roaster (PE API)

//Search Work Item in Roaster


public static VWWorkObject getVWWorkObject(VWSession peSession,String rosterName){
      VWWorkObject vwwObj=null;
      try{
     
     
          VWRoster roster=peSession.getRoster(rosterName);
          int queryFlags=VWRoster.QUERY_NO_OPTIONS;
          String abc = "abc";
          String filter="Property_Name ="+abc;

          //Change filter based on requirement

       
          VWRosterQuery query=roster.createQuery(null, null, null, queryFlags, filter, null, VWFetchType.FETCH_TYPE_WORKOBJECT);
          log.info("Total records for Work ITem: "+query.fetchCount());
         
          while(query.hasNext()){
              vwwObj=(VWWorkObject) query.next(); 
          }
         
      }catch(VWException vwe){
          log.error("Exception found at PEManager.getVWWorkObject():"+vwe,vwe);
          vwe.printStackTrace();
      }catch(Exception vwe){
          log.error("Exception found at PEManager.getVWWorkObject():"+vwe,vwe);
          vwe.printStackTrace();
      }
     
      return vwwObj;
  }

Get PE Session (Process Engine JAVA API)

Process Engine API

//Get Session

  public static VWSession getPESession()
    {
      String strAppURI1="http://localhost:9080/wsi/FNCEWS40MTOM/";
      System.out.println("[ENTER  PEManager getPESession()]");
      VWSession peSession = null;

      System.setProperty("java.security.auth.login.config","C:\\opt\\jaas.conf.WSI");
    

      try
      {
        peSession = new VWSession();
        peSession.setBootstrapCEURI(strAppURI1);
    
        peSession.logon(username, password, connectionPoint);
        String sn = peSession.getPEServerName();
        System.out.println("++++++++++++++++"+ sn);

        System.out.println("PE session established:"+peSession);
      }
      catch (VWException e) {
          System.out.println("Exception occured while establishing PE session." );
          e.printStackTrace();

      }
      System.out.println("[Exit PEManager getPESession()]");
    return peSession;
  }

//Close VWSession

public static void closePESession(VWSession peSession)
  {
    log.debug("[Enter closePESession]");
    try {
      if (peSession != null)
        peSession.logoff();
    }
    catch (VWException e) {
      log.error(e.getMessage(), e);
    }

    log.debug("[Exit : closePESession]");
  }