2015-05-01 7 views
5

Nel mio progetto esiste una definizione old.jpdl.xml esistente. Funziona bene. Ora voglio eseguire un'altra definizione new.jpdl.xml. Dopo la distribuzione del file ear ho provato a leggere new.jpdl.xml utilizzando il nuovo ProcessDefinitionId con l'aiuto del seguente codice.Come ottenere ProcessDefinition usando jpdl per JBPM 4.4?

Credo che manchi le fasi di implementazione. Qualcuno può guidarmi, come distribuire o leggere new.jpdl.xml?

public String getProcessInstanceID(ProcessEngine processEngine, 
      FlowControl flowcontrol, String processDefinitionID) 
    { 
     String processInstanceID = null; 
     log.debug("Entering method - getProcessInstanceID"); 
     ProcessDefinitionQuery pdq = processEngine.getRepositoryService() 
       .createProcessDefinitionQuery(); 
     pdq.deploymentId(processDefinitionID); 
     ProcessDefinition procDef = pdq.uniqueResult(); 

     if (null == procDef) 
     { 
      log.error("Process Definition could not be found for the deployment ID: " 
        + processDefinitionID); 
     } 

     Map<String, Object> variables = new HashMap<String, Object>(); 
     variables.put("flowcontrol", flowcontrol); 

     ProcessInstance processInstance = processEngine.getExecutionService() 
       .startProcessInstanceByKey(procDef.getKey(), variables); 

     log.debug("Process Instance ID:" + processInstance.getId()); 
     processInstanceID = processInstance.getId(); 
     log.debug("Exiting method - getProcessInstanceID"); 
     return processInstanceID; 
    } 
+0

Sembra che la tua domanda non stia ottenendo molti punti di vista qui. Potresti provare a chiedere nel [forum ufficiale di JBPM] (https://developer.jboss.org/en/jbpm/content). – Mike

+0

Ciao Mike, ho avuto la soluzione a questo problema. Grazie per aiutarmi. Userò questo forum per altre domande. –

risposta

3

Ho creato un lavoro batch per distribuire il file jpdl. L'API JBPM inserisce internamente i valori nelle tabelle JBPM4_XXX dopo l'implementazione corretta. Sotto la classe che ho usato per distribuire il nuovo file jpdl. Per il passaggio di valori di nome e chiave jpdl, ho usato la dipendenza di primavera. Finalmente questi passaggi hanno funzionato con successo.

public class JBPMDeploymentService extends BatchService { 

      /** 
      * Logger for Batch service 
      */ 
      protected static final Logger log = Logger.getLogger(NAPSJBPMDeploymentService.class); 

      private Map<String, String> jpdlMap = new HashMap<String, String>(); 

      private Map<String, String> procInstMap = new HashMap<String, String>(); 

      public void doService() throws NAPSBatchException 
      { 
       log.info("Entering into doService Method of JBPMDeploymentService ..."); 
       String approvalFlow = getJpdlFileType(); 

       String jpdlXML = getJPDLxml(approvalFlow); 

       String procInst = getProcessInstanceKey(approvalFlow); 

       // constructs the ProcessEngine 
       ProcessEngine processEngine = new Configuration().setResource("naps.jbpm.cfg.xml").buildProcessEngine(); 

       // retrieve the needed services 
       RepositoryService repositoryService = processEngine.getRepositoryService(); 
       ExecutionService executionService = processEngine.getExecutionService(); 



       repositoryService.createDeployment() 
       .addResourceFromClasspath(jpdlXML) 
       .deploy(); 
       //executionService.startProcessInstanceByKey(procInst); 

      } 

    /** 
     * @return the jpdlMap 
     */ 
     public Map<String, String> getJpdlMap() { 
      return jpdlMap; 
     } 

     /** 
     * @param jpdlMap the jpdlMap to set 
     */ 
     public void setJpdlMap(Map<String, String> jpdlMap) { 
      this.jpdlMap = jpdlMap; 
     } 

     /** 
     * @param jpdlKey 
     * @return jpdl xml name 
     */ 
     private String getJPDLxml(String jpdlKey) 
     { 
      return jpdlMap.get(jpdlKey); 
     } 

     /** 
     * @return the procInstMap 
     */ 
     public Map<String, String> getProcInstMap() { 
      return procInstMap; 
     } 

     /** 
     * @param procInstMap the procInstMap to set 
     */ 
     public void setProcInstMap(Map<String, String> procInstMap) { 
      this.procInstMap = procInstMap; 
     } 

     /** 
     * @param procInstKey 
     * @return process Instance key 
     */ 
     private String getProcessInstanceKey(String procInstKey){ 
      return this.procInstMap.get(procInstKey); 
     } 
} 
Problemi correlati