Search in sources :

Example 6 with AttrTO

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);
}
Also used : Form(org.apache.wicket.markup.html.form.Form) AttrTO(org.apache.syncope.common.lib.to.AttrTO) StringResourceModel(org.apache.wicket.model.StringResourceModel) EntityTOUtils(org.apache.syncope.common.lib.EntityTOUtils) AnyTO(org.apache.syncope.common.lib.to.AnyTO) FieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel) StringUtils(org.apache.commons.lang3.StringUtils) AjaxDropDownChoicePanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDropDownChoicePanel) ArrayList(java.util.ArrayList) AjaxCheckBoxPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxCheckBoxPanel) AjaxSpinnerFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel) PlainSchemaTO(org.apache.syncope.common.lib.to.PlainSchemaTO) AttrSchemaType(org.apache.syncope.common.lib.types.AttrSchemaType) EncryptedFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.EncryptedFieldPanel) SchemaUtils(org.apache.syncope.client.console.commons.SchemaUtils) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) Map(java.util.Map) ListUtils(org.apache.commons.collections4.ListUtils) AjaxTextFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxTextFieldPanel) IModel(org.apache.wicket.model.IModel) AjaxDateTimeFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateTimeFieldPanel) MembershipTO(org.apache.syncope.common.lib.to.MembershipTO) ListView(org.apache.wicket.markup.html.list.ListView) IChoiceRenderer(org.apache.wicket.markup.html.form.IChoiceRenderer) ListModel(org.apache.wicket.model.util.ListModel) SyncopeConstants(org.apache.syncope.common.lib.SyncopeConstants) Accordion(org.apache.syncope.client.console.wicket.markup.html.bootstrap.tabs.Accordion) ListItem(org.apache.wicket.markup.html.list.ListItem) AbstractTab(org.apache.wicket.extensions.markup.html.tabs.AbstractTab) Model(org.apache.wicket.model.Model) SchemaType(org.apache.syncope.common.lib.types.SchemaType) PageReference(org.apache.wicket.PageReference) GroupTO(org.apache.syncope.common.lib.to.GroupTO) Collectors(java.util.stream.Collectors) AjaxDateFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AjaxDateFieldPanel) LabelInfo(org.apache.syncope.client.console.wicket.ajax.markup.html.LabelInfo) List(java.util.List) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PropertyModel(org.apache.wicket.model.PropertyModel) AjaxWizard(org.apache.syncope.client.console.wizards.AjaxWizard) MultiFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.MultiFieldPanel) BinaryFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.BinaryFieldPanel) AbstractFieldPanel(org.apache.syncope.client.console.wicket.markup.html.form.AbstractFieldPanel) UserTO(org.apache.syncope.common.lib.to.UserTO) ResourceModel(org.apache.wicket.model.ResourceModel) Collections(java.util.Collections) AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) ArrayList(java.util.ArrayList)

Example 7 with AttrTO

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);
}
Also used : AttrTO(org.apache.syncope.common.lib.to.AttrTO) ArrayList(java.util.ArrayList)

Example 8 with AttrTO

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);
}
Also used : AttrTO(org.apache.syncope.common.lib.to.AttrTO) ArrayList(java.util.ArrayList) DerSchemaTO(org.apache.syncope.common.lib.to.DerSchemaTO)

Example 9 with AttrTO

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);
}
Also used : User(org.apache.syncope.core.persistence.api.entity.user.User) PasswordPatch(org.apache.syncope.common.lib.patch.PasswordPatch) UserTO(org.apache.syncope.common.lib.to.UserTO) AttrTO(org.apache.syncope.common.lib.to.AttrTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) UserPatch(org.apache.syncope.common.lib.patch.UserPatch)

Example 10 with AttrTO

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");
}
Also used : AnyObjectTO(org.apache.syncope.common.lib.to.AnyObjectTO) WorkflowResult(org.apache.syncope.core.provisioning.api.WorkflowResult) AttrTO(org.apache.syncope.common.lib.to.AttrTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) AnyObjectPatch(org.apache.syncope.common.lib.patch.AnyObjectPatch)

Aggregations

AttrTO (org.apache.syncope.common.lib.to.AttrTO)70 Test (org.junit.jupiter.api.Test)31 UserTO (org.apache.syncope.common.lib.to.UserTO)30 MembershipTO (org.apache.syncope.common.lib.to.MembershipTO)19 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)17 Map (java.util.Map)15 GroupTO (org.apache.syncope.common.lib.to.GroupTO)15 ArrayList (java.util.ArrayList)14 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)14 List (java.util.List)13 Collections (java.util.Collections)11 StringUtils (org.apache.commons.lang3.StringUtils)11 AnyTO (org.apache.syncope.common.lib.to.AnyTO)10 Optional (java.util.Optional)9 Set (java.util.Set)9 Autowired (org.springframework.beans.factory.annotation.Autowired)9 HashMap (java.util.HashMap)8 Collectors (java.util.stream.Collectors)8 EntityTOUtils (org.apache.syncope.common.lib.EntityTOUtils)8 AnyObjectTO (org.apache.syncope.common.lib.to.AnyObjectTO)8