cancel
Showing results for 
Search instead for 
Did you mean: 

Mandatory Value in a Workflow

emgiraldo
Champ in-the-making
Champ in-the-making
Hi there.

My name is Erik.

Right now I have a simple workflow (taken from Alfresco Developer Guide, pag 296, Step-by-Step: Grabbing the Hello World Argument from the User), I have the following files:

Workflow definition (processdefinition.xml):
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="scwf:helloWorldUI">
   <start-state name="start">
      <task name="scwf:submitHelloWorldTask" />      
      <transition name="" to="hello"></transition>
   </start-state>
   <node name="hello">
      <transition name="" to="end1">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <variable name="scwf_helloName" access="read"/>
               <expression>
                  logger.log("Hello, " + scwf_helloName + "!");
               </expression>
            </script>
         </action>
      </transition>
   </node>
   <end-state name="end1"></end-state>
</process-definition>


Custom Model for the WorkFlow(scWorkflowModel.xml):
<?xml version="1.0" encoding="UTF-8"?>
   <!– Definition of new Model –>
<model name="scwf:workflowmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <!– Optional meta-data about the model –>
   <description>Someco Workflow Model</description>
   <author>Optaros</author>
   <version>1.0</version>
   <!– Imports are required to allow references to definitions in other models –>
   
   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
      <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm" />
   </imports>
      <!– Introduction of new namespaces defined by this model –>
      <namespaces>
         <namespace uri=" http://www.someco.com/model/workflow/1.0" prefix="scwf" />
      </namespaces>
      <types>
         <type name="scwf:submitHelloWorldTask">
            <parent>bpm:startTask</parent>
            <properties>
               <property name="scwf:helloName">
                  <type>d:text</type>
                  <mandatory>false</mandatory>
                  <multiple>true</multiple>
               </property>
            </properties>
         </type>         
      </types>
</model>

Workflow properties file (config/extension/scWorkflow.properties):
#
# Hello World UI Workflow
#
# scWorkflowModel related strings
scwf_workflowmodel.type.scwf_submitHelloWorldTask.title=Start Hello World UI Workflow Erik
scwf_workflowmodel.type.scwf_submitHelloWorldTask.description=Submit a workflow that says hello in the log
scwf_workflowmodel.property.scwf_helloName.title=Name
scwf_workflowmodel.property.scwf_helloName.description=Say hello to this person
# processdefinition related strings
scwf_helloWorldUI.workflow.title=Hello World UI
scwf_helloWorldUI.workflow.description=A simple hello wo

Registering spring beans to alfresco context (someco-model-context.xml):
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <!– Registration of new models –>
    <bean id="someco.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/model/scModel.xml</value>
                <value>alfresco/extension/model/scWorkflowModel.xml</value>
            </list>
        </property>
    </bean>
    <bean id="extension.workflowBootstrap" parent="workflowDeployer">
      <property name="labels">
         <list>
            <value>alfresco.extension.scWorkflow</value>
         </list>
      </property>
   </bean>   
</beans>

The workflow appear, but What I need, well according to the example is to pass the value in the start step of the Workflow, but I can not get this working, it just does not appear in the UI, I'v trying to google it but I can not find an answer.

It would be great if anyone could tell me What I'm missing or if I'm doing something wrong.

Thanks a lot!
3 REPLIES 3

smicyk
Champ in-the-making
Champ in-the-making
Hi,

you probably miss configuration in web-client-config-custom.xml file. You should create such file and add to spring configuration in similar way as model. In this file you should define what should be visible on each process step.

Thanks,
smicyk

emgiraldo
Champ in-the-making
Champ in-the-making
Hi,

you probably miss configuration in web-client-config-custom.xml file. You should create such file and add to spring configuration in similar way as model. In this file you should define what should be visible on each process step.

Thanks,
smicyk

Thanks for your answer smicky. I haven't been able to show a property in the worflow process, what I did was to use package properties from the bpm for saving general aspects about the workflow process, like this (According to the book):

<types>
         <type name="scwf:submitReviewTask">
            <parent>bpm:startTask</parent>
            <mandatory-aspects>
               <aspect>scwf:thirdPartyReviewable</aspect>
            </mandatory-aspects>
         </type>   
         <type name="scwf:adminReview">
            <parent>bpm:workflowTask</parent>
            <overrides>
               <property name="bpm:packageItemActionGroup">
                  <default>read_package_item_actions</default>
               </property>
            </overrides>
         </type>
         <type name="scwf:revise">
            <parent>bpm:workflowTask</parent>
            <overrides>
               <property name="bpm:packageItemActionGroup">
                  <default>edit_package_item_actions</default>
               </property>
            </overrides>
         </type>            
      </types>
      
      <aspects>
            <aspect name="scwf:thirdPartyReviewable">
               <title>Someco Third Party Reviewable</title>
               <properties>
                  <property name="scwf:reviewerEmail">
                        <type>d:text</type>
                        <mandatory>false</mandatory>
                        <multiple>false</multiple>
                  </property>
               </properties>
            </aspect>
         </aspects>

It works and I got the wokflow working according of the needs of my company, which actually was very simple. Right now I have I deepder question I think, I created a custom wizard according to the Wiki http://wiki.alfresco.com/wiki/Customising_The_Create_Content_Wizard, in the example it addes a new aspect to the document, what I need right now is to add a textfield to the document which is going to save a x string, what I am doind is I added a new String variable to the mbean, I capture it from the
protected String finishImpl(FacesContext context, String outcome){}
method, and what I want is to asve it to the propertie that I defined.

model:

<type name="sc:doc">
         <title>Someco Document</title>
         <parent>cm:content</parent>         
         <mandatory-aspects>         
                 <aspect>sc:weable</aspect>
                 <aspect>cm:lockable</aspect>
                 <aspect>sc:ref</aspect>
                 <aspect>sc:place</aspect>                 
           </mandatory-aspects>         
      </type>
<aspects>   
       <aspect name="sc:weable">
            <title>Content Weable</title>
            <properties>
            <property name="sc:published">              
               <type>d:boolean</type>      
               <default>false</default>     
            </property>           
         </properties>
      </aspect>
       <aspect name="sc:ref">
            <title>Node reference</title>
            <properties>
            <property name="sc:referencia">              
               <type>d:noderef</type>                         
            </property>           
         </properties>
      </aspect>
      <aspect name="sc:place">
            <title>Place</title>
            <properties>
            <property name="sc:placename">              
               <type>d:text</type>
               <mandatory>false</mandatory>                         
            </property>           
         </properties>
      </aspect>
   </aspects>

Wizard step:


    protected String place;

   @Override
   protected String finishImpl(FacesContext context, String outcome) throws Exception
   {
      super.finishImpl(context, outcome);
     
      // add the selected aspect (the properties page after the wizard
      // will allow us to set the properties)
      QName aspectToAdd = Repository.resolveToQName(this.aspect);
     
      this.getNodeService().addAspect(this.createdNode, aspectToAdd, null);
      Map<QName,Serializable> test = getNodeService().getProperties(this.createdNode);           
      Set<QName> it = test.keySet();                                  
     
      for(QName s:it){//There is no property in this list with the name placename, but I already defined it in the model
         if(s.getLocalName().equals("placename")){ //Does not work, it does not find it          
            test.put(s, this.getPlace());
         }
      }
      getNodeService().setProperties(this.createdNode, test); //Update the properties of the model  
      return outcome;
   }

Jsp:

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>

<h:panelGrid columns="2">
   <h:outputText value="#{msg.aspect}: " />
   <h:selectOneMenu value="#{WizardManager.bean.aspect}">
      <f:selectItems value="#{WizardManager.bean.aspects}" />
   </h:selectOneMenu>
   <h:outputText value="Place:" />
   <h:inputText value="#{WizardManager.bean.place}" />
</h:panelGrid>


The concrete question is: how can I set the place value to the property of the model, so I can see it and edit it later?

Thanks a lot again your your time, and the time of the people who read the post!!!

emgiraldo
Champ in-the-making
Champ in-the-making
Hey guys!

Well, I've figured it out,

PD: This is based on the book "Alfresco Developer Guide".

Context:

You have a custom Wizard and you added a new text field to it, you want to persist it. You have already added a new var to the managed bean for the custom field, you also have a data model associated to it with a custom aspect that has the a property that represents the var of the managed bean.

web-client-config-custom.xml
<wizard name="createContent" managed-bean="CustomCreateContentWizard"
                 title-id="custom_create_content_wizard_title"
                 description-id="create_content_desc"
                 icon="/images/icons/new_content_large.gif">
               <step name="details" title-id="details" description-id="create_content_step1_desc">
                  <page path="/jsp/content/create-content-wizard/details.jsp"
                        title-id="create_content_step1_title"
                        description-id="create_content_step1_desc"
                        instruction-id="default_instruction" />
               </step>
               <step name="content" title-id="enter_content" description-id="create_content_step2_desc">
                  <condition if="#{CreateContentWizard.mimeType == 'text/html'}">
                     <page path="/jsp/content/create-content-wizard/create-html.jsp"
                           title-id="create_content_step2_title"
                           description-id="create_content_step2_desc"
                           instruction-id="default_instruction" />
                  </condition>
                  <condition if="#{CreateContentWizard.mimeType == 'text/xml'}">
                       <page path="/jsp/content/create-content-wizard/create-xml.jsp"
                           title-id="create_content_step2_title"
                           description-id="create_content_step2_desc"
                           instruction-id="default_instruction" />
                  </condition>
                  <!– Default to the inline text editor –>
                  <page path="/jsp/content/create-content-wizard/create-text.jsp"
                        title-id="create_content_step2_title"
                        description-id="create_content_step2_desc"
                        instruction-id="default_instruction" />
               </step>
              <step name="aspect" title-id="select_aspect" description-id="create_content_step3_desc">
                  <page path="/jsp/extension/wizards/custom-content-wizard/add-aspect.jsp"
                     title-id="create_content_step3_title"
                     description-id="create_content_step3_desc"
                     instruction-id="default_instruction" />
               </step>
   
               <step name="summary" title-id="summary" description-id="summary_step_description">
                  <page path="/jsp/wizard/summary.jsp"
                        title-id="summary"
                        description-id="summary_desc"
                        instruction-id="content_finish_instruction" />
               </step>
           </wizard>

customModel.xml
<type name="sc:doc">
         <title>Someco Document</title>
         <parent>cm:content</parent>         
         <mandatory-aspects>         
                 <aspect>sc:weable</aspect>                                   
           </mandatory-aspects>         
      </type>

<aspect name="sc:weable">
            <title>Content Weable</title>
            <properties>
             <property name="sc:place">              
               <type>d:text</type>     
               <default></default>                           
            </property>
            <property name="sc:published">              
               <type>d:boolean</type>      
               <default>false</default>     
            </property>                             
         </properties>
      </aspect>

CustomWizard.java
@Override
   protected String finishImpl(FacesContext context, String outcome) throws Exception
   {
      super.finishImpl(context, outcome);
     
      ServiceRegistry serviceRegistry = Repository.getServiceRegistry(context);
      PermissionService perService = serviceRegistry.getPermissionService();
      
     
      if(validateUserGroup()){
         perService.deletePermissions(createdNode);
         perService.setInheritParentPermissions(createdNode, false);
         perService.setPermission(createdNode, Constants.GRUPO_COMERCIAL, PermissionService.COORDINATOR, true);
         perService.setPermission(createdNode, Constants.GRUPO_ADMINISTRADOR, PermissionService.EDITOR, true);        
      }
     
      // add the selected aspect (the properties page after the wizard
      // will allow us to set the properties)
      QName aspectToAdd = Repository.resolveToQName(this.aspect);
      //QName aspectToAdd2 = Repository.resolveToQName("sc:place");
     
      this.getNodeService().addAspect(this.createdNode, aspectToAdd, null);                 
      //this.getNodeService().addAspect(this.createdNode, aspectToAdd2, null);
      Map<QName,Serializable> test = getNodeService().getProperties(this.createdNode);
       
      Set<QName> it = test.keySet();                                     
     
      for(QName s:it){          
         if(s.getLocalName().equals("published")){           
            test.put(s, this.isPublicar());           
         }
         if(s.getLocalName().equals("place")){
            test.put(s, this.getPlace());
         }
      }                 
      getNodeService().setProperties(this.createdNode, test);   
      return outcome;
   }


Hope this helps!!!!