use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.
the class PlainAttrs method setAttrs.
@Override
protected void setAttrs(final MembershipTO membershipTO) {
List<AttrTO> attrs = new ArrayList<>();
Map<String, AttrTO> attrMap = EntityTOUtils.buildAttrMap(membershipTO.getPlainAttrs());
membershipSchemas.get(membershipTO.getGroupKey()).values().stream().map(schema -> {
AttrTO attrTO = new AttrTO();
attrTO.setSchema(schema.getKey());
if (attrMap.get(schema.getKey()) == null || attrMap.get(schema.getKey()).getValues().isEmpty()) {
attrTO.getValues().add("");
// is important to set the schema info only after values setting
attrTO.setSchemaInfo(schema);
} else {
attrTO.getValues().addAll(attrMap.get(schema.getKey()).getValues());
}
return attrTO;
}).forEachOrdered(attrTO -> {
attrs.add(attrTO);
});
membershipTO.getPlainAttrs().clear();
membershipTO.getPlainAttrs().addAll(attrs);
}
use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.
the class DerAttrs method setAttrs.
@Override
protected void setAttrs() {
List<AttrTO> attrs = new ArrayList<>();
Map<String, AttrTO> attrMap = EntityTOUtils.buildAttrMap(anyTO.getDerAttrs());
schemas.values().forEach(schema -> {
AttrTO attrTO = new AttrTO();
attrTO.setSchema(schema.getKey());
if (attrMap.containsKey(schema.getKey())) {
attrTO.getValues().addAll(attrMap.get(schema.getKey()).getValues());
}
attrs.add(attrTO);
});
anyTO.getDerAttrs().clear();
anyTO.getDerAttrs().addAll(attrs);
}
use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.
the class DerAttrs method setAttrs.
@Override
protected void setAttrs(final MembershipTO membershipTO) {
List<AttrTO> attrs = new ArrayList<>();
Map<String, AttrTO> attrMap = EntityTOUtils.buildAttrMap(anyTO.getDerAttrs());
for (DerSchemaTO schema : membershipSchemas.get(membershipTO.getGroupKey()).values()) {
AttrTO attrTO = new AttrTO();
attrTO.setSchema(schema.getKey());
if (attrMap.containsKey(schema.getKey())) {
attrTO.getValues().addAll(attrMap.get(schema.getKey()).getValues());
}
attrs.add(attrTO);
}
membershipTO.getDerAttrs().clear();
membershipTO.getDerAttrs().addAll(attrs);
}
use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.
the class Update method doExecute.
@Override
protected void doExecute(final String executionId) {
User user = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER, User.class);
UserPatch userPatch = engine.getRuntimeService().getVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, UserPatch.class);
user = userDAO.save(user);
UserTO original = dataBinder.getUserTO(user, true);
PropagationByResource propByRes = dataBinder.update(user, userPatch);
PasswordPatch password = userPatch.getPassword();
Set<AttrTO> virAttrs = userPatch.getVirAttrs();
UserTO updated = dataBinder.getUserTO(user.getKey());
userPatch = AnyOperations.diff(updated, original, false);
userPatch.setPassword(password);
userPatch.getVirAttrs().clear();
userPatch.getVirAttrs().addAll(virAttrs);
// report updated user and propagation by resource as result
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER, user);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_TO, updated);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.USER_PATCH, userPatch);
engine.getRuntimeService().setVariable(executionId, FlowableUserWorkflowAdapter.PROP_BY_RESOURCE, propByRes);
}
use of org.apache.syncope.common.lib.to.AttrTO in project syncope by apache.
the class DefaultAnyObjectWorkflowAdapter method doUpdate.
@Override
protected WorkflowResult<AnyObjectPatch> doUpdate(final AnyObject anyObject, final AnyObjectPatch anyObjectPatch) {
AnyObjectTO original = dataBinder.getAnyObjectTO(anyObject, true);
PropagationByResource propByRes = dataBinder.update(anyObject, anyObjectPatch);
Set<AttrTO> virAttrs = anyObjectPatch.getVirAttrs();
AnyObjectTO updated = dataBinder.getAnyObjectTO(anyObjectDAO.save(anyObject), true);
AnyObjectPatch effectivePatch = AnyOperations.diff(updated, original, false);
effectivePatch.getVirAttrs().clear();
effectivePatch.getVirAttrs().addAll(virAttrs);
return new WorkflowResult<>(effectivePatch, propByRes, "update");
}
Aggregations