Hi Fabio,
I have configured the ServiceTask(s) as we discussed and those are getting
triggered appropriately. But what ever changes I'm making while
create/update are not getting propagated to Syncope. Let me explain what I
have done:
- Configured service task before the Create/Update tasks
- The tasks that I created are extending AbstractActivitiDelegate
(Thought it will help in case I need to make use of UserDataBinder, ConfDAO
etc)
- Let me give an example of the processing that I need to do in In the
doExecute method in my service task. I'm trying to extract the domain name
from the email and assign it to another filed that I created in the schema
by name 'domain'
- In case of createBefore, I'm retrieving the email value from UserTO
protected void doExecute(final DelegateExecution execution)
throws Exception {
UserTO userTO = (UserTO)
execution.getVariable(ActivitiUserWorkflowAdapter.USER_TO);
attrValue =
userTO.getAttributeMap().get("email").getValues().get(0);
//extract domain .......
.......
AttributeTO attributeTO = new AttributeTO();
attributeTO.setValues(new
ArrayList<String>(Arrays.asList(domain)));
userTO.getAttributeMap().put("domain", attributeTO);
execution.setVariable(
ActivitiUserWorkflowAdapter.USER_TO, userTO);
}
- Then the org.syncope.core.workflow.activiti.Create gets invoked and I
can' find the above changes in there
- In case of update, I tried the approach that we were using with the
old version and that also doesn't seem to work. Please see the code snippet
below:
public void setStringAttributeValues(final SyncopeUser user, final
String attributeName,
final String[] attributeValues) {
logger.info("Setting attribute {} for user {} with value {}.", new
Object[]{attributeName, user,
attributeValues});
UAttr uAttr = user.getAttribute(attributeName);
if (uAttr == null) {
USchema attributeSchema = this.schemaDAO.find(attributeName,
USchema.class);
uAttr = new UAttr();
uAttr.setSchema(attributeSchema);
uAttr.setOwner(user);
user.addAttribute(uAttr);
}
if (attributeValues == null) {
uAttr.setValues(new ArrayList<AbstractAttrValue>());
} else {
List<UAttrValue> valueList = new ArrayList<UAttrValue>();
for (String s : attributeValues) {
UAttrValue uAttrValue = new UAttrValue();
uAttrValue.setStringValue(s);
valueList.add(uAttrValue);
}
uAttr.setValues(valueList);
}
}
Please let me know the correct approach for Create (CreateBefore) and
Update (UpdateBefore).
Regards,
Antony.
On Fri, Mar 23, 2012 at 2:28 PM, Antony Pulicken
<[email protected]>wrote:
> Thanks Fabio. Even I was thinking in the same direction. I will try that.
>
> Regards,
> Antony.
>
>
> On Fri, Mar 23, 2012 at 1:36 PM, Fabio Martelli
> <[email protected]>wrote:
>
>>
>> Il giorno 23/mar/2012, alle ore 08.04, Antony Pulicken ha scritto:
>>
>> > Hi,
>> >
>> > In the earlier version of Syncope, we could add pre and post functions
>> for each 'action' in the Syncope OS Workflow XML for doing some additional
>> processing/transformation of the data before/after the actions are executed.
>> >
>> > Does any one know how that can be done in Activiti ? I'm able to add
>> listeners for the 'userTask' that listens to the events like
>> create,complete, etc. But this doesn't seem to be working for
>> 'serviceTask'. I will be posting this question in Activiti forums as well.
>> But please let me know in case any one has any suggestion.
>>
>> Hi Antony,
>> I can suggest you to use one or more ServiceTask.
>>
>> For example:
>>
>> <sequenceFlow id="flow1" sourceRef="theStart" targetRef="beforeCreate"/>
>> <serviceTask id="beforeCreate" name="BeforeCreate"
>> activiti:class="org.syncope.core.workflow.activiti.MyBeforeActions"/>
>> <sequenceFlow id="flow2" sourceRef="beforeCreate" targetRef="create"/>
>> <serviceTask id="create" name="Create"
>> activiti:class="org.syncope.core.workflow.activiti.Create"/>
>> ......
>> <sequenceFlow id="flow7" sourceRef="... source ref..."
>> targetRef="afterCreate"/>
>> <serviceTask id="afterCreate" name="AfterCreate"
>> activiti:class="org.syncope.core.workflow.activiti.MyAfterActions"/>
>> <sequenceFlow id="flow8" sourceRef="afterCreate" targetRef="theEnd"/>
>> <endEvent id="theEnd"/>
>>
>> Regards,
>> F.
>
>
>