Create Metadata in Workflow - Exercise 8

OpenKM has many interesting features, but requires some configuration process to show its full potential.
Forum rules
Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
jllort
Moderator
Moderator
Posts: 11570
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Create Metadata in Workflow - Exercise 8

Post by jllort »

Last documentation is here:
https://docs.openkm.com/kcenter/

You are looking for API, you have two options:
https://docs.openkm.com/kcenter/view/ok ... ption.html
https://docs.openkm.com/apidoc/ ( in this case you are looking for a class into the package com.openkm.api named OKMPropertyGroup )
dferguson
Expert Boarder
Expert Boarder
Posts: 120
Joined: Thu May 18, 2017 12:48 pm

Re: Create Metadata in Workflow - Exercise 8

Post by dferguson »

So, I have the Linux Mint Portable Dev up and running and I can successfully deploy this workflow to OpenKM. However I have a few questions. Excuse me if these are found in documentation elsewhere but I can't seem to find it.

First, why does starting this workflow require the admin to set the assigned "reviewer"? It seems unuseful to allow a user to start a workflow then have it sit and require an admin to pick the actor ID. Wouldn't it make more sense to have the workflow initiator select the from the pooled actors?

Second, I know I need to register the metadata group, but where do I find the information for this group i.e. what is the group label, Group name, and Group info. I am familiar with adding metadata groups, but I can't decipher what the metadata group is for this exercise.
jllort
Moderator
Moderator
Posts: 11570
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Create Metadata in Workflow - Exercise 8

Post by jllort »

In our information I think you will find enought information about metadata fields https://docs.openkm.com/kcenter/view/ok ... ields.html

About workflow, what is your scenario :
1- you want to show form as part of the starting of the workflow ?
2- you want to assing task to some group of users, not to a single user ?

Because by default you can assign a task to an specific users, seems is not your case or you have missed this step ?
dferguson
Expert Boarder
Expert Boarder
Posts: 120
Joined: Thu May 18, 2017 12:48 pm

Re: Create Metadata in Workflow - Exercise 8

Post by dferguson »

I am very familiar how to edit and register metadata. What is not clear with regards to Exercise 8 is where is the metadata for that exercise defined. As mentioned by several other users in this thread, the portion for the metadata definition is unclear. In Alex's comments I can see mention of okg:test and okg:Doc_State. Where is the rest of the definition? My portable dev seems to be missing some stuff.

Is it possible that Exercise 8 in the Portable Dev for Linux Mint is missing some files? I only have exercise8.jpdl.xml, exercise8.jpg, and forms.xml. I have no *.java files.
jllort
Moderator
Moderator
Posts: 11570
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Create Metadata in Workflow - Exercise 8

Post by jllort »

I think we have shared everything in the portable dev environment, also you can check directly in the repository:
https://github.com/openkm/workflow-course

We have also released a more conformatble development environment based on Virtual Machine https://s3-eu-west-1.amazonaws.com/open ... PorDev.ova next week we will publish in the website with some video

Tell me what is the correspondence of the exercice 8 with documentation shown at https://docs.openkm.com/kcenter/view/wfg/
dferguson
Expert Boarder
Expert Boarder
Posts: 120
Joined: Thu May 18, 2017 12:48 pm

Re: Create Metadata in Workflow - Exercise 8

Post by dferguson »

I have the virtual machine portable development environment as I mentioned.

To finish Exercise 8, I need two things.

1. I need the full definition of the property groups used in this exercise.
2. I need the java files which execute the nodes

Exercise 8 simply says...

https://www.openkm.com/wiki/index.php/W ... Exercise_8
For changing metadata property group use the code:

Code: Select all

String sysToken = DbSessionManager.getInstance().getSystemToken();
OKMPropertyGroup.getInstance().setProperties(sysToken, path, grpName, properties);
In this case we have created nodes to make the actions. We made it with the idea to be more clear, but in real case we suggest using transactions for doing this kind of logic ( updating metadata ), because workflow will have less boxes.
use it where?
jllort
Moderator
Moderator
Posts: 11570
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Create Metadata in Workflow - Exercise 8

Post by jllort »

This is an old wiki section, https://www.openkm.com/wiki/index.php/Workflow_Course I suggest going with new documentation
https://docs.openkm.com/kcenter/view/wf ... ample.html at least here you have a video of it.

Seems the files are
https://github.com/openkm/workflow-cour ... ision.java
https://github.com/openkm/workflow-cour ... ction.java

I think into the sample we had not created metadata, but might be easily done in the transaction node.
You can create any group https://github.com/openkm/workflow-cour ... ction.java and set metadata using https://docs.openkm.com/kcenter/view/ok ... ertySimple
dferguson
Expert Boarder
Expert Boarder
Posts: 120
Joined: Thu May 18, 2017 12:48 pm

Re: Create Metadata in Workflow - Exercise 8

Post by dferguson »

Thanks for adding this. I think it fills in some of the holes.
aruname
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: Sat Oct 24, 2020 5:20 am
Location: Dubai-UAE

Re: Create Metadata in Workflow - Exercise 8

Post by aruname »

Dear Team

Me too follow this thread and did some work.. but where I got stuck is..

Step 1: followed all above mentioned points (having (ova in VM) installed as development environment)
Step 2: created a workflow with simple reviewer -> send back to "creator"--> resubmit workflow using "swimlane" and ïnitiator" (works great)
Step 3: thought of updating metadata --> but got stuck

The node define with a java class which implements ActionHandler got stuck not moving to next node

Pls help me

Thanks
Arunachalam
Arunachalam
aruname
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: Sat Oct 24, 2020 5:20 am
Location: Dubai-UAE

Re: Create Metadata in Workflow - Exercise 8

Post by aruname »

Code: Select all

package com.openkm.workflow.DocReview;
import com.openkm.api.OKMRepository;

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

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

import com.openkm.module.db.stuff.DbSessionManager;
import com.openkm.api.OKMPropertyGroup;
//import com.openkm.bean.PropertyGroup;

public class UpdateMetaData implements ActionHandler {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Override
	public void execute(ExecutionContext executionContext) throws Exception {

		boolean hasGroup = true;
		String Docstatus = "Verified";
		String uuid = (String) executionContext.getContextInstance().getVariable("uuid");
		//System.out.println(uuid);
		
		
		String path = OKMRepository.getInstance().getNodePath(null, uuid);
		String grpName = "okg:technology";
		
		/*for (PropertyGroup pg : OKMPropertyGroup.getInstance().getGroups(null, path)) {
			if (pg.getName().equals(grpName)) {
				hasGroup = true;
			}
		}*/
		
		if (hasGroup) {
		
		String sysToken = DbSessionManager.getInstance().getSystemToken();
		OKMRepository.getInstance().getNodeUuid(null, path);
		Map properties = new HashMap<>();
		properties.put(grpName,Docstatus);
		OKMPropertyGroup.getInstance().setPropertiesSimple (sysToken, uuid,grpName,properties);
		
		//System.out.println(Docstatus);
		}
	}
}
Arunachalam
aruname
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: Sat Oct 24, 2020 5:20 am
Location: Dubai-UAE

Re: Create Metadata in Workflow - Exercise 8

Post by aruname »

Dear Team

My environment

Application: OpenKM Community version 6.3.9 (build e57b626)
OS Server: Redhat Linux 7 - Red Hat Enterprise Linux Server release 7.9 (Maipo)
Development: OpenKM-ComPorDev - Other Linux (64 bit) (on Oracle Virtual Box 6.1)

Configuration details:

Metadata config
defined : Group Name: okg:technology -> okp:technology.type
User profile:
1) General [tab] , Misc [section] -> Workflows field added with this "reviewDocument"
2) General [tab] , Wizard [section] -> Metadata groups field added with this "Technology"


Thanks
Arunachalam
Arunachalam
jllort
Moderator
Moderator
Posts: 11570
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Create Metadata in Workflow - Exercise 8

Post by jllort »

To update metadata, in a task you should show a form. Then in the transaction collect all the values of the form and then ( add the group or update the group ).
https://docs.openkm.com/kcenter/view/wf ... -node.html ( here is shown how to get variables from the context -> in these vars you will find all the values of the form elements what you might get to use as the new metadata data )

I suggest:
1- check from scripting add and update group features ( remember the users should have assigned the property group in the profiles, otherwise is not visible for them):
2- https://docs.openkm.com/kcenter/view/ok ... l#addGroup ( remember the group is added empty and then you set the metadata )
https://docs.openkm.com/kcenter/view/ok ... tiesSimple ( I suggest this one )
3- Play in scripting https://docs.openkm.com/kcenter/view/ok ... pting.html
aruname
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: Sat Oct 24, 2020 5:20 am
Location: Dubai-UAE

Re: Create Metadata in Workflow - Exercise 8

Post by aruname »

Hi jllort

Great i will explore each point of yours.

Ok will do all these and update you
thanks once again
Arunachalam
Arunachalam
jllort
Moderator
Moderator
Posts: 11570
Joined: Fri Dec 21, 2007 11:23 am
Location: Sineu - ( Illes Balears ) - Spain
Contact:

Re: Create Metadata in Workflow - Exercise 8

Post by jllort »

I suggest if you need to continue talking with it, create a new post and do not continue with current ( it is too large and I think other community readers will be lost with the initial topic )
aruname
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: Sat Oct 24, 2020 5:20 am
Location: Dubai-UAE

Re: Create Metadata in Workflow - Exercise 8

Post by aruname »

Hi jllort

Yes I created new thread

viewtopic.php?f=4&t=23720

Thanks
Arunachalam
Post Reply