Search in sources :

Example 1 with AssignmentItemDto

use of com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto in project midpoint by Evolveum.

the class MyAssignmentsPanel method initLayout.

private void initLayout() {
    List<IColumn<AssignmentItemDto, String>> columns = new ArrayList<IColumn<AssignmentItemDto, String>>();
    columns.add(new IconColumn<AssignmentItemDto>(null) {

        private static final long serialVersionUID = 1L;

        @Override
        protected IModel<String> createIconModel(final IModel<AssignmentItemDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    AssignmentItemDto item = rowModel.getObject();
                    if (item.getType() == null) {
                        return OperationResultStatusPresentationProperties.FATAL_ERROR.getIcon() + " fa-lg";
                    }
                    return item.getType().getIconCssClass();
                }
            };
        }

        @Override
        protected IModel<String> createTitleModel(final IModel<AssignmentItemDto> rowModel) {
            return new AbstractReadOnlyModel<String>() {

                private static final long serialVersionUID = 1L;

                @Override
                public String getObject() {
                    AssignmentItemDto item = rowModel.getObject();
                    if (item.getType() == null) {
                        return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.error");
                    }
                    switch(item.getType()) {
                        case CONSTRUCTION:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.accountConstruction");
                        case ORG_UNIT:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.orgUnit");
                        case ROLE:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.role");
                        default:
                            return MyAssignmentsPanel.this.getString("MyAssignmentsPanel.type.error");
                    }
                }
            };
        }
    });
    columns.add(new AbstractColumn<AssignmentItemDto, String>(createStringResource("MyAssignmentsPanel.assignment.displayName")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<AssignmentItemDto>> cellItem, String componentId, final IModel<AssignmentItemDto> rowModel) {
            AssignmentHeaderPanel panel = new AssignmentHeaderPanel(componentId, rowModel);
            panel.add(new AttributeModifier("class", "dash-assignment-header"));
            cellItem.add(panel);
        }
    });
    ISortableDataProvider provider = new ListDataProvider(this, getModel());
    TablePanel accountsTable = new TablePanel<AssignmentItemDto>(ID_ASSIGNMETNS_TABLE, provider, columns);
    accountsTable.setShowPaging(false);
    add(accountsTable);
}
Also used : ListDataProvider(com.evolveum.midpoint.web.component.util.ListDataProvider) IModel(org.apache.wicket.model.IModel) AssignmentHeaderPanel(com.evolveum.midpoint.web.component.assignment.AssignmentHeaderPanel) ArrayList(java.util.ArrayList) ISortableDataProvider(org.apache.wicket.extensions.markup.html.repeater.data.table.ISortableDataProvider) AttributeModifier(org.apache.wicket.AttributeModifier) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) AssignmentItemDto(com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto) TablePanel(com.evolveum.midpoint.web.component.data.TablePanel)

Example 2 with AssignmentItemDto

use of com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto in project midpoint by Evolveum.

the class PageSelfDashboard method initAssignments.

private void initAssignments() {
    AsyncDashboardPanel<Object, List<AssignmentItemDto>> assignedOrgUnits = new AsyncDashboardPanel<Object, List<AssignmentItemDto>>(ID_ASSIGNMENTS, createStringResource("PageDashboard.assignments"), GuiStyleConstants.CLASS_ICON_ASSIGNMENTS, GuiStyleConstants.CLASS_OBJECT_ROLE_BOX_CSS_CLASSES, true) {

        private static final long serialVersionUID = 1L;

        @Override
        protected SecurityContextAwareCallable<CallableResult<List<AssignmentItemDto>>> createCallable(Authentication auth, IModel callableParameterModel) {
            return new SecurityContextAwareCallable<CallableResult<List<AssignmentItemDto>>>(getSecurityEnforcer(), auth) {

                @Override
                public CallableResult<List<AssignmentItemDto>> callWithContextPrepared() throws Exception {
                    return loadAssignments();
                }
            };
        }

        @Override
        protected Component getMainComponent(String markupId) {
            return new MyAssignmentsPanel(markupId, new PropertyModel<List<AssignmentItemDto>>(getModel(), CallableResult.F_VALUE));
        }
    };
    assignedOrgUnits.add(new VisibleEnableBehaviour() {

        private static final long serialVersionUID = 1L;

        @Override
        public boolean isVisible() {
            UserInterfaceElementVisibilityType visibilityType = getComponentVisibility(PredefinedDashboardWidgetId.MY_ASSIGNMENTS);
            return WebComponentUtil.getElementVisibility(visibilityType);
        }
    });
    add(assignedOrgUnits);
}
Also used : IModel(org.apache.wicket.model.IModel) MyAssignmentsPanel(com.evolveum.midpoint.web.page.admin.home.component.MyAssignmentsPanel) SecurityContextAwareCallable(com.evolveum.midpoint.web.component.SecurityContextAwareCallable) AsyncDashboardPanel(com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel) Authentication(org.springframework.security.core.Authentication) PrismObject(com.evolveum.midpoint.prism.PrismObject) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AssignmentItemDto(com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto) CallableResult(com.evolveum.midpoint.web.component.util.CallableResult) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult)

Example 3 with AssignmentItemDto

use of com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto in project midpoint by Evolveum.

the class PageSelfDashboard method createAssignmentItem.

private AssignmentItemDto createAssignmentItem(PrismObject<UserType> user, PrismContainerValue<AssignmentType> assignment, Task task, OperationResult result) {
    ActivationType activation = assignment.asContainerable().getActivation();
    if (activation != null && activation.getAdministrativeStatus() != null && !activation.getAdministrativeStatus().equals(ActivationStatusType.ENABLED)) {
        return null;
    }
    PrismReference targetRef = assignment.findReference(AssignmentType.F_TARGET_REF);
    if (targetRef == null || targetRef.isEmpty()) {
        // account construction
        PrismContainer construction = assignment.findContainer(AssignmentType.F_CONSTRUCTION);
        String name = null;
        String description = "";
        if (construction.getValue().asContainerable() != null && !construction.isEmpty()) {
            ConstructionType constr = (ConstructionType) construction.getValue().asContainerable();
            if (constr.getResourceRef() != null) {
                ObjectReferenceType resourceRef = constr.getResourceRef();
                PrismObject resource = WebModelServiceUtils.loadObject(ResourceType.class, resourceRef.getOid(), this, task, result);
                name = WebComponentUtil.getName(resource);
                description = constr.getDescription();
            }
        }
        return new AssignmentItemDto(AssignmentEditorDtoType.CONSTRUCTION, name, description, null);
    }
    PrismReferenceValue refValue = targetRef.getValue();
    PrismObject value = refValue.getObject();
    if (value == null) {
        // resolve reference
        value = WebModelServiceUtils.loadObject(ObjectType.class, refValue.getOid(), this, task, result);
    }
    if (value == null) {
        // we couldn't resolve assignment details
        return new AssignmentItemDto(null, null, null, null);
    }
    String name = WebComponentUtil.getDisplayNameOrName(value);
    AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass());
    String relation = refValue.getRelation() != null ? refValue.getRelation().getLocalPart() : null;
    return new AssignmentItemDto(type, name, getAssignmentDescription(value), relation);
}
Also used : AssignmentEditorDtoType(com.evolveum.midpoint.web.component.assignment.AssignmentEditorDtoType) PrismObject(com.evolveum.midpoint.prism.PrismObject) PrismReferenceValue(com.evolveum.midpoint.prism.PrismReferenceValue) PrismReference(com.evolveum.midpoint.prism.PrismReference) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) AssignmentItemDto(com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto)

Example 4 with AssignmentItemDto

use of com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto in project midpoint by Evolveum.

the class PageSelfDashboard method loadAssignments.

private CallableResult<List<AssignmentItemDto>> loadAssignments() throws Exception {
    LOGGER.debug("Loading assignments.");
    CallableResult callableResult = new CallableResult();
    List<AssignmentItemDto> list = new ArrayList<AssignmentItemDto>();
    callableResult.setValue(list);
    PrismObject<UserType> user = principalModel.getObject();
    if (user == null || user.findContainer(UserType.F_ASSIGNMENT) == null) {
        return callableResult;
    }
    Task task = createSimpleTask(OPERATION_LOAD_ASSIGNMENTS);
    OperationResult result = task.getResult();
    callableResult.setResult(result);
    PrismContainer assignments = user.findContainer(UserType.F_ASSIGNMENT);
    List<PrismContainerValue> values = assignments.getValues();
    for (PrismContainerValue assignment : values) {
        AssignmentItemDto item = createAssignmentItem(user, assignment, task, result);
        if (item != null) {
            list.add(item);
        }
    }
    result.recordSuccessIfUnknown();
    result.recomputeStatus();
    Collections.sort(list);
    LOGGER.debug("Finished assignments loading.");
    return callableResult;
}
Also used : Task(com.evolveum.midpoint.task.api.Task) PrismContainerValue(com.evolveum.midpoint.prism.PrismContainerValue) PrismContainer(com.evolveum.midpoint.prism.PrismContainer) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) CallableResult(com.evolveum.midpoint.web.component.util.CallableResult) AccountCallableResult(com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult) AssignmentItemDto(com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto)

Aggregations

AssignmentItemDto (com.evolveum.midpoint.web.page.admin.home.dto.AssignmentItemDto)4 PrismContainer (com.evolveum.midpoint.prism.PrismContainer)2 PrismObject (com.evolveum.midpoint.prism.PrismObject)2 CallableResult (com.evolveum.midpoint.web.component.util.CallableResult)2 AccountCallableResult (com.evolveum.midpoint.web.page.admin.home.dto.AccountCallableResult)2 IModel (org.apache.wicket.model.IModel)2 PrismContainerValue (com.evolveum.midpoint.prism.PrismContainerValue)1 PrismReference (com.evolveum.midpoint.prism.PrismReference)1 PrismReferenceValue (com.evolveum.midpoint.prism.PrismReferenceValue)1 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)1 Task (com.evolveum.midpoint.task.api.Task)1 SecurityContextAwareCallable (com.evolveum.midpoint.web.component.SecurityContextAwareCallable)1 AssignmentEditorDtoType (com.evolveum.midpoint.web.component.assignment.AssignmentEditorDtoType)1 AssignmentHeaderPanel (com.evolveum.midpoint.web.component.assignment.AssignmentHeaderPanel)1 TablePanel (com.evolveum.midpoint.web.component.data.TablePanel)1 ListDataProvider (com.evolveum.midpoint.web.component.util.ListDataProvider)1 VisibleEnableBehaviour (com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour)1 AsyncDashboardPanel (com.evolveum.midpoint.web.page.admin.home.component.AsyncDashboardPanel)1 MyAssignmentsPanel (com.evolveum.midpoint.web.page.admin.home.component.MyAssignmentsPanel)1 ArrayList (java.util.ArrayList)1