cancel
Showing results for 
Search instead for 
Did you mean: 

Add content to bpm_package

vbr
Champ in-the-making
Champ in-the-making
Hello,

I start a workflow on a folder with java code like this


NodeRef wfPackage = ServiceHelper.workflowService.createPackage(folderRef); // folderRef is a nodeRef to a folder

workflowProps.put(WorkflowModel.ASSOC_PACKAGE, wfPackage);

workflowService.startWorkflow(workflowId, parameters);


The workflow is well started and I can see each documents contained in the folderRef but when I want to add some document in the bpm package, I have this error:

07170034 Found 1 integrity violations:
   The association source type is incorrect:
    Source Node: workspace://SpacesStore/52fe26f3-7221-4a5f-9cf3-a87d2f6082b0
    Association: Association[ class=ClassDef[name={http://www.alfresco.org/model/bpm/1.0}package], name={http://www.alfresco.org/model/bpm/1.0}packageContains, target class={http://www.alfresco.org/model/system/1.0}base, source role=null, target role=null]
    Required Source Type: {http://www.alfresco.org/model/bpm/1.0}package
    Actual Source Type: {http://www.alfresco.org/model/content/1.0}folder


Somedbody has an issue?

Thank you for help!
9 REPLIES 9

kaynezhang
World-Class Innovator
World-Class Innovator
You have provide a container parameter for
workflowService.createPackage(folderRef)
,the type of folderRef should be "bpmSmiley Tongueackage"
Or you can just use
 NodeRef wfPackage = ServiceHelper.workflowService.createPackage(null);

vbr
Champ in-the-making
Champ in-the-making
Hello,

Thank you for you answer. I know that I provided a container for the methode createPackage. It's because I want to start my workflow on a folder. Is there an other solution to do that?

I want that the folder is linked with the bpm_package of the workflow.

Thank you for your help and have a good day!

kaynezhang
World-Class Innovator
World-Class Innovator
You can do it like this

NodeRef wfPackage = ServiceHelper.workflowService.createPackage(null);
//make your folder as a child of workflow package,and the association type is WorkflowModel.ASSOC_PACKAGE_CONTAINS
QName qName = QName.createQName(***_url, ****localName);
nodeService.addChild(wfPackage, folderRef,  WorkflowModel.ASSOC_PACKAGE_CONTAINS,qName );

vbr
Champ in-the-making
Champ in-the-making
Ok thank you, I will try that.

What is
QName.createQName(***_url, ****localName)
? What is his purpose?

Thank you!

kaynezhang
World-Class Innovator
World-Class Innovator
qname is the qualified name of the association ,you can name it what ever you like for example

   QName name = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI,"childFolder");

vbr
Champ in-the-making
Champ in-the-making
Now It works but I see the folder in the bpm_package.

I would like to see the files contained in the folder.

Is it possible to browse the children of the folder and add each files in the bpm_package?

Thank you!

kaynezhang
World-Class Innovator
World-Class Innovator
Of course you can ,just get folder children of bpm_package using getChildAssocs() method of NodeService,and then use getChildAssocs() method again to get children of the folder.

vbr
Champ in-the-making
Champ in-the-making
Ok, thank you! Now it works! But is this possible that when I add a file, this file is added to bpm_package and also in the folder on which I started the workflow? Or does I have to write some code to do this?

Thank you!

kaynezhang
World-Class Innovator
World-Class Innovator
Yes ,you can add a file to bpm_package and  to the folder on which you started the workflow at the same time ,but you don't need do.
Just adding it to  the folder on which you started the workflow will be ok ,since you already have added the folder to bpm_package ,you can navigate the file through bpm_package .