Hi,
before moving into Sherlock Holmes mode, are you able to assign a value for the "accountReviewDate" attribute from Admin Console? There might be chance that such attribute is simply not assignable to the given user, thus Syncope silently discards it from update request.

In any case: can you derive something relevant by watching the logs during the execution of the class below?

Regards.

On 22/01/19 22:21, pcrowder wrote:
Hello.

I was wondering if anyone could help with an issue of setting plain
attribute values for a user from a flowable service task. It is behaving in
a strange manner.  The relevant code is below.  The service is called from
the workflow without error. The accountExpiryDate is saved to the database
but the accountReviewDate is not (both dates are in a valid format). Also,
the accountExpiryDate does not display in the admin console and again the
data is in the database. I hope someone can help me with this mystery.

I have tried both with and without an update service task following this
service call in the workflow and it does not appear to have an effect.

Thank you.


@Component
public class UpdateAccountReviewDate extends FlowableServiceTask {
     @Autowired
     private UserDAO userDAO;

     @Autowired
     private PlainSchemaDAO plainSchemaDAO;

     @Autowired
     protected EntityFactory entityFactory;

     @Autowired
     protected AnyUtilsFactory anyUtilsFactory;

     @Autowired
     private UserDataBinder dataBinder;

     @Autowired
     private ConfDAO confDAO;

     //Format defined in schema for fields in question
     private static final DateFormat dateFormat = new
SimpleDateFormat("MM/dd/yyyy");

     @Override
     protected void doExecute(DelegateExecution execution) {
         int expiryDays = getExpiryDays().intValue();
         Date now = new Date();
         Date expiryDate = getFutureDate(now, expiryDays);
         String accountReviewDate = dateFormat.format(now);
         String accountExpiryDate = dateFormat.format(expiryDate);

         User user = execution.getVariable(FlowableRuntimeUtils.USER,
User.class);

         userDAO.save(user);

         UserPatch userPatch = new UserPatch();
         userPatch.setKey(user.getKey());
         userPatch.getPlainAttrs().add(createUpdatePatch("accountReviewDate",
accountReviewDate));
         userPatch.getPlainAttrs().add(createUpdatePatch("accountExpiryDate",
accountExpiryDate));

         PropagationByResource propByRes = dataBinder.update(user,
userPatch);


         execution.setVariable(FlowableRuntimeUtils.USER, user);
         execution.setVariable(FlowableRuntimeUtils.USER_PATCH, userPatch);
         execution.setVariable(FlowableRuntimeUtils.PROP_BY_RESOURCE,
propByRes);
     }

     private AttrPatch createUpdatePatch(String key, String value) {
         return new
AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(createAttribute(key,
value)).build();
     }

     private AttrTO createAttribute(String key, String value) {
         return new AttrTO.Builder().schema(key).value(value).build();
     }
}

--
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Member at The Apache Software Foundation
Syncope, Cocoon, Olingo, CXF, OpenJPA, PonyMail
http://home.apache.org/~ilgrosso/

Reply via email to