Page 1 of 1

Wizard Workflow Upload Problem

PostPosted:Wed Dec 26, 2012 1:00 pm
by mammacori
Hi, all
i've modified the workflow guide example "medium" adding an upload element in forms.xml
i've deploied it to openkm and all makes sense.
the workflow works well but i'm not able to fire wizard after uploading file
if i add the file manually wizard fires and all is ok.
if i add file using a form in a workflow the file has been inserted in repository but the wizard doesn't start.
Is there a way to fire the wizard using a workflow ?

Please help me
Alessandro

Re: Wizard Workflow Upload Problem

PostPosted:Thu Dec 27, 2012 10:43 am
by jllort
Should be made some changes in logic to take in consideration that uploaded file from workflow can have some wizard ( actual logic does not allows it ). We have think it in other way that not means better than your propose, but now after finishing workflow is executed next task, there user should be required for it.

In someway you're on truth that for general logic if some file is added should be required to put metadata etc... ( básically wizard ). If you want to take a look of actual implementation see: http://doxygen.openkm.com/6.2.x/dc/d69/ ... pload.html take a look at
Code: Select all
private FileUploadForm addSubmitCompleteHandler(final FileUploadForm uploadForm) {
and specially in the logic where's evaluated
Code: Select all
actualFileToUpload.getWorkflow() == null
I think with minor change here could be solved ( but I'm not totally sure ) the most important think is when is executed executeWorkflow(actualFileToUpload.getWorkflowTaskId()); into uploadNewPendingFile() method

Re: Wizard Workflow Upload Problem

PostPosted:Sun Dec 30, 2012 12:43 pm
by mammacori
Hi jllort,
thanks a lot.
For one thing, please excuse me and my bad english.

Back to our problem, when all is said and done, i can't fire wizard from workflow, isn't it ?
The only way you suggest is to code something in the java source but, as a famous minstrell said, i'm too old to code but too young to retired from work ( i'm 42 and my graduate work was on java 1.0 with awt :mrgreen: ; i have not coded in java for donkey's years except for some little works with j2ee)

For these reason i think that i will try to implement a simple handler that asks the user for the metadata in the same form in which i inserted the upload button and then set the metadata... i only need to find the method to set the properties to add to the file

So, briefly,
user fills a form with the name of the file to checkin and with the metadata i need
the handler get the filename, upload it and then set the property variables.

Do you have any code to take as an example ?
my goal is to code as less as possible to reduce to the minimum bugs and bad code

thanks a lot
alessandro

Re: Wizard Workflow Upload Problem

PostPosted:Mon Dec 31, 2012 11:04 am
by jllort
Simply example how to set metadata ( first add property group and then add values )
Code: Select all
// Create new metadata
OKMPropertyGroup.getInstance().addGroup(token, doc.getPath(), grpName);
Map properties = new HashMap();
properties.put("okp:contract.cups",status.cups);
properties.put("okp:contract.year",gson.toJson(new String[] {status.year}));
properties.put("okp:contract.month",gson.toJson(new String[] {status.month.toLowerCase()}));
OKMPropertyGroup.getInstance().setPropertiesSimple(token, doc.getPath(), grpName, properties);
Take a look here for complete code example http://wiki.openkm.com/index.php/Cronta ... h_metadata

Re: Wizard Workflow Upload Problem

PostPosted:Mon Dec 31, 2012 12:03 pm
by mammacori
hi jllort, thanks a lot !!!
yesterday in the afternoon i worked hard on this problem and i arrived to code till
Code: Select all
OKMPropertyGroup.getInstance().setPropertiesSimple(token, doc.getPath(), grpName, properties);
this line of code give me an error that today i will not able to solve because i can't work on it... :evil:

this afternoon i have to help my elder son in his xmas holiday homeworks ( today we have to study english, in particular engish possessive ) and this morning i helped the younger in his first step into calligraphy and writing :D

i get a strange error it cannot find the method setPropertiesSimple in the import list i gave and it states cannot find in a library i did not import ... i have to investigate

this is the code in the simple.xml file
Code: Select all
import com.openkm.api.OKMDocument;
import com.openkm.module.DocumentModule;
import com.openkm.module.ModuleManager;
import com.openkm.bean.Document;
import com.openkm.bean.PropertyGroup;
import com.openkm.module.PropertyGroupModule;
import java.util.Map;

String docUID = executionContext.getVariable("Bom").documentUuid;
String path2 = OKMDocument.getInstance().getPath(null, docUID);
DocumentModule dm = ModuleManager.getDocumentModule();
Document doc = dm.getProperties(null, path2);

PropertyGroupModule cm = ModuleManager.getPropertyGroupModule();
cm.addGroup(null, path2, "okg:technology");

Map properties = new HashMap();
properties.put("Type", "Culo");
properties.put("Language", "Java"); 
properties.put("Comment","Trattasi di prova");
properties.put("Description", "la corazzata cotiomkin e una cagata pazzesca"); 

cm.setProperties(null, path2, "okg:technology", properties);
here i get the following error
Code: Select all
Method setProperties( null, java.lang.String, java.lang.String, java.util.HashMap ) not found in class'com.openkm.module.db.DbPropertyGroupModule' 
but i did not import the module d.DbProperty bla bla... so for one thing the system does not find the method in the libraries i imported and for second thing it tries to look for in some strange path i don't know

if you have some times to dedicate to my problem i will thank you... in any case i will keep you inform on my further step ...

thanks again
Alessandro

Re: Wizard Workflow Upload Problem

PostPosted:Tue Jan 01, 2013 5:53 pm
by jllort
The difference between your code and which I proposed to you is that I'm using
Code: Select all
OKMPropertyGroup.getInstance()
not
Code: Select all
PropertyGroupModule cm = ModuleManager.getPropertyGroupModule();
The method sePropertiesSimple is implemented at OKMPropertyGroup but is not defined into PropertyGroupModule that's the reason of the error.

Re: Wizard Workflow Upload Problem

PostPosted:Wed Jan 02, 2013 4:23 pm
by mammacori
GOTCHA !!!!

the problem was i did not import OKMPropertyGroup therefore when i was calling the method you suggested i got the error BUT
this workflow will make me crazy.

at this time i finally don't get error but the properties aren't set :cry:

this is the pseudo code
Code: Select all
get the uid
set properties value
add group (technology one)
add to the group the properties 
finish
when i check the file in opekm dashboard i can see the group but i can't see any value ...all the fields are empty

following the code:
Code: Select all
import com.openkm.api.OKMDocument;
import com.openkm.module.DocumentModule;
import com.openkm.module.ModuleManager;
import com.openkm.bean.Document;
import java.util.*;
import com.openkm.module.PropertyGroupModule;
import com.openkm.bean.PropertyGroup;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.api.OKMRepository;

print("Going through: route 1");-->

<!-- becca la uid del doc inserito -->
String docUID = executionContext.getVariable("Bom").documentUuid;
				
<!--  definisci le info per il wizard-->
Map properties = new HashMap(); 
properties.put("Type", "Culo"); 
properties.put("Language", "Java"); 
properties.put("Comment", "Trattasi di prova");
properties.put("Description", "la corazzata cotiomkin e una cagata pazzesca"); 

<!--  beccati il path del doc -->
String path2 = OKMDocument.getInstance().getPath(null, docUID);

OKMPropertyGroup.getInstance().addGroup(null, path2, "okg:technology");
OKMPropertyGroup.getInstance().setPropertiesSimple(null, path2, "okg:technology", properties); 
print(" su questo file: "+path2);
print(" dovrei avere aggiunto: "+properties);
what's wrong ?
do have i to provide the types of each variable for the group ?

Alessandro

Re: Wizard Workflow Upload Problem

PostPosted:Wed Jan 02, 2013 5:17 pm
by mammacori
Dear jillard using your suggestion i've solved !!!!
It works !!!!
Thanks a lot, really !

following the code
i think it's not a good code, it seems more a cat in the pigeons than a good java code but it works and that's is all i need ...

this snippet goes into the script tag of the node of the xml file in jpdl project.
maybe some import are redundant or unuseful but ....
Code: Select all
import com.openkm.api.OKMDocument;
import com.openkm.module.DocumentModule;
import com.openkm.module.ModuleManager;
import com.openkm.bean.Document;
import java.util.*;
import com.openkm.module.PropertyGroupModule;
import com.openkm.bean.PropertyGroup;
import com.openkm.api.OKMPropertyGroup;
import com.openkm.api.OKMProperty;
import com.openkm.api.OKMRepository;
	
<!-- get the document uid  -->
String docUID = executionContext.getVariable("Bom").documentUuid;

<!--  set the properties' value -->
Map properties = new HashMap(); 
properties.put("okp:technology.type", "t1"); 
properties.put("okp:technology.language", "java"); 
properties.put("okp:technology.comment", "Trattasi di prova");
properties.put("okp:technology.description", "la corazzata cotiomkin e una cagata pazzesca"); 

<!--  get the document  path -->
String path2 = OKMDocument.getInstance().getPath(null, docUID);

<!-- add property group -->
OKMPropertyGroup.getInstance().addGroup(null, path2, "okg:technology");

<!-- add propertis' value -->
OKMPropertyGroup.getInstance().setPropertiesSimple(null, path2, "okg:technology", properties); 

<!-- add keyword --> 		
OKMProperty.getInstance().addKeyword(null,path2,"parolachiave");
Alessandro
PS
do you believe that the code can be useful to someone else ? In case how can i post it to the group ? i Think that at least the post should have a different subject.

Re: Wizard Workflow Upload Problem

PostPosted:Thu Jan 03, 2013 10:38 pm
by jllort
If you want to share your workflow, probably can help someone. When you got it finished we can put at http://wiki.openkm.com/index.php/Utilities under a new section workflows.

Final suggestion: Into workflow it's a good practice use system token ( use with care ).
Code: Select all
String systemToken = DbSessionManager.getInstance().getSystemToken();
String path2 = OKMDocument.getInstance().getPath(systemToken, docUID); // replaced null to systemToken