• How to call a java class in my workflow?

  • OpenKM a de nombreuses fonctionnalités interessantes, mais demande un minimum de configuration pour être pleinement exploité.
OpenKM a de nombreuses fonctionnalités interessantes, mais demande un minimum de configuration pour être pleinement exploité.

Moderator: dedisoft

Forum rules: Avant de poser une question, merci de regarder la documentation du wiki ou d'utiliser la fonction recherche du forum. Et rappelez vous que nous n'avons ni boule de cristal ni possibilité de lire dans les pensées, aussi pensez à spécifier quelle version d'OpenKM vous utilisez ainsi que la version du navigateur web et du système d'exploitation. Pour de plus amples informations lisez Comment reporter un bug efficacement (anglais).
 #49332  by kouadio
 
I created a java class WorkflowLogger according to the following tutorial. In my workflow, being in Eclipse, I do not know how to call the com.openkm.workflow.Workflow.java program so that it can save the workflow information in the database.
I find that it is neither ActionHandler nor TackHandler nor AssignmentHandler.
I remember that I am a novice and I use the virtual machine preinstalled.
Thank you for your help.
 #49352  by jllort
 
You should watch at least all the videos from this point https://docs.openkm.com/kcenter/view/wf ... ourse.html
In the OpenKM development environment you have the almost samples shown in the videos, check them, there sure the OpenKM API classes are used. Basically you will find them in ActionHandlers is the most common place to use them.
 #49379  by kouadio
 
Hi,
Thank you for assistance.
When I call my java class procedure (<action name"save" class="com.openkm.workflow.WorkflowLogger"></action>), here is the error I get in my file catalinat.log:
Code: Select all
GRAVE [http-nio-0.0.0.0-8080-exec-10] org.jbpm.instantiation.Delegation.instantiate couldn't instantiate delegation class 'com.openkm.workflow.WorkflowLogger'
 java.lang.NullPointerException
Thank you for helping me
 #49412  by jllort
 
Did you created the WorkflowLogger.java class ? because in the code of OpenKM does not exist
Did you acced in the project ( into the par file the class exist, did you added in the same panel you add forms ). The par file is a zip file ( renamed )
 #49707  by kouadio
 
After downloading another version of "Community development environment", the workflow ran without incident. However, I do not know where the data is stored. I look in the OKM_DB_METADATA_VALUE and OKM_DB_METADATA_TYPE tables but nothing, no data.
 #49727  by kouadio
 
I want the data from my form that was populated in my workflow journey. Here is an extract from my forms.xml file and in attached file a screenshot of the user page and the summary of the data in the administration screen of the workflow. In fact, this is the information I want, but I can't find it in any table in my database.
Code: Select all
<workflow-form task="avis favorable">
    <input label="Date" name="date" data="date" readonly="true" />
    <input name="direction" label="Direction" data="direction" readonly="true"/>
    <input name="Responsable" label="Responsable hiérarchique" data="Responsable" readonly="true"/>
    <input name="Ordonnateur" label="Ordonnateur" data="Ordonnateur" readonly="true"/>
    
    <checkbox name="budgetise" label="budgetise" data="budgetise" readonly="true"/>
    <checkbox name="non budgetise" label="non budgetise" data="non budgetise" readonly="true"/>
    <input label="Designation" name="Designation" data="Designation" readonly="true" />
	
    <input label="Quantite" name="quantite" data="quantite" readonly="true" />
    <input label="Prix unitaire" name="Prix unitaire" data="Prix unitaire" readonly="true" />
    <input label="Montant total TTC" name="Montant total TTC" data="Montant total TTC" readonly="true" />
    
    <textarea label="Observations" name="observations" data="observations" readonly="true" />
    <input label="Avis responsable supérieur" name="responsable" data="responsable" readonly="true" />
    <input label="Avis controle de gestion" name="cgai" data="cgai" readonly="true" />
    <input label="Avis DAF" name="daf" data="daf" readonly="true" />
    <button name="Terminer" label="Terminer" transition="terminer"/>
</workflow-form>
Attachments
Workflow.PNG
Workflow.PNG (146.97 KiB) Viewed 48551 times
Formulaire.PNG
Formulaire.PNG (42.52 KiB) Viewed 48551 times
 #49746  by jllort
 
You must collect the data in the form during the workflow transaction and store as metadata. The workflow will not make it automatically do it for you, it is something you must control in your side ( workflow form elements does not have a direct mapping to metadata, because maybe you are interested in mapping single workflow form into several metadata groups )
 #49780  by jllort
 
Is a manual mapping. You got the values in the transaction ( are stored in the context ). Must get the data and store as metadata.

Take a look here https://docs.openkm.com/kcenter/view/wf ... -node.html in your case into the vars are objects of type Input, Select ( FormElements ).

Here the code to import metadata https://docs.openkm.com/kcenter/view/ok ... tiesSimple
 #49805  by kouadio
 
I tell you I'm really null in java. In accordance with your recommendations, here is my configuration which does not work. Really, I don't know how to solve my problem.
Code: Select all
package com.openkm.workflow.ged;

import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ISO8601;
public class metadonneesinsert implements ActionHandler {

	 /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public static void main(String[] args) {
        try {                                           
            Map<String, String> properties = new HashMap<>();
            properties.put("okp:BonCommande.direction", "new direction");
            properties.put("okp:BonCommande.civilite", "new civilite");
            properties.put("okp:BonCommande.Ordonnateur", "new Ordonnateur");
            properties.put("okp:BonCommande.document", "new document");
            properties.put("okp:BonCommande.justificatif", "new justificatif");
            properties.put("okp:BonCommande.description", "new description");
            properties.put("okp:BonCommande.duree", "new duree");
            properties.put("okp:BonCommande.observations", "new observations");
            properties.put("okp:BonCommande.avisarchiviste", "new avisarchiviste");
            
            // Date fields must be saved with basic ISO 8601 format
            properties.put("okp:BonCommande.date", ISO8601.formatBasic(Calendar.getInstance()));
            OKMPropertyGroup.getInstance().setPropertiesSimple(null, "/okm:root/logo.pdf","okg:BonCommande", properties);           
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

	@Override
	public void execute(ExecutionContext arg0) throws Exception {
		// TODO Auto-generated method stub
	}
}
Attachments
Formulaire.PNG
Formulaire.PNG (27.03 KiB) Viewed 46378 times
ActionHandler.PNG
ActionHandler.PNG (19.62 KiB) Viewed 46378 times
 #49818  by jllort
 
Try with the code below:
package com.openkm.workflow.ged;
Code: Select all
import org.jbpm.graph.def.ActionHandler;
import org.jbpm.graph.exe.ExecutionContext;

import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;

import com.openkm.api.OKMPropertyGroup;
import com.openkm.util.ISO8601;
public class metadonneesinsert implements ActionHandler {
 private static final long serialVersionUID = 1 L;


 @Override
 public void execute(ExecutionContext arg0) throws Exception {
  try {
   Map < String, String > properties = new HashMap < > ();
   properties.put("okp:BonCommande.direction", "new direction");
   properties.put("okp:BonCommande.civilite", "new civilite");
   properties.put("okp:BonCommande.Ordonnateur", "new Ordonnateur");
   properties.put("okp:BonCommande.document", "new document");
   properties.put("okp:BonCommande.justificatif", "new justificatif");
   properties.put("okp:BonCommande.description", "new description");
   properties.put("okp:BonCommande.duree", "new duree");
   properties.put("okp:BonCommande.observations", "new observations");
   properties.put("okp:BonCommande.avisarchiviste", "new avisarchiviste");

   // Date fields must be saved with basic ISO 8601 format
   properties.put("okp:BonCommande.date", ISO8601.formatBasic(Calendar.getInstance()));
   OKMPropertyGroup.getInstance().setPropertiesSimple(null, "/okm:root/logo.pdf", "okg:BonCommande", properties);
  } catch (Exception e) {
   e.printStackT
  }
 }
Consider to play with JAVA in OpenKM you should have at least 3 years of expertice.
 #49830  by kouadio
 
When I copy and paste the code in eclipse window, I get three (03) errors as shown in the image below:
Attachments
metadonnesinsert.PNG
metadonnesinsert.PNG (122.34 KiB) Viewed 44943 times
 #49843  by jllort
 
Sorry, but sincerely if you are not able to solve these errors yourself you do not have minimal knowledge to play with the JAVA workflows. I thin you have 2 options:
1- try to find somebody more skilled with JAVA
2- in the forum were freelance people what might help you on it ( viewtopic.php?f=5&t=23156&p=49549&hilit=saul#p49549 )

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.