Search in sources :

Example 21 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class ScenePanel method initLayout.

private void initLayout() {
    final IModel<SceneDto> model = getModel();
    WebMarkupContainer box = new WebMarkupContainer(ID_BOX);
    box.add(AttributeModifier.append("class", new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            SceneDto dto = model.getObject();
            if (dto.getBoxClassOverride() != null) {
                return dto.getBoxClassOverride();
            }
            if (dto.getChangeType() == null) {
                return null;
            }
            switch(dto.getChangeType()) {
                case ADD:
                    return "box-success";
                case DELETE:
                    return "box-danger";
                case MODIFY:
                    return "box-info";
                default:
                    return null;
            }
        }
    }));
    add(box);
    WebMarkupContainer headerPanel = new WebMarkupContainer(ID_HEADER_PANEL);
    box.add(headerPanel);
    headerPanel.add(new SceneButtonPanel(ID_OPTION_BUTTONS, model) {

        @Override
        public void minimizeOnClick(AjaxRequestTarget target) {
            headerOnClickPerformed(target, model);
        }
    });
    Label headerChangeType = new Label(ID_HEADER_CHANGE_TYPE, new ChangeTypeModel());
    //headerChangeType.setRenderBodyOnly(true);
    Label headerObjectType = new Label(ID_HEADER_OBJECT_TYPE, new ObjectTypeModel());
    //headerObjectType.setRenderBodyOnly(true);
    IModel<String> nameModel = new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return model.getObject().getName(ScenePanel.this);
        }
    };
    Label headerNameLabel = new Label(ID_HEADER_NAME_LABEL, nameModel);
    LinkPanel headerNameLink = new LinkPanel(ID_HEADER_NAME_LINK, nameModel) {

        @Override
        public void onClick(AjaxRequestTarget target) {
            PrismContainerValue<?> value = getModelObject().getScene().getSourceValue();
            if (value != null && value.getParent() instanceof PrismObject) {
                PrismObject<? extends ObjectType> object = (PrismObject<? extends ObjectType>) value.getParent();
                WebComponentUtil.dispatchToObjectDetailsPage(ObjectTypeUtil.createObjectRef(object), getPageBase(), false);
            }
        }
    };
    Label headerDescription = new Label(ID_HEADER_DESCRIPTION, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            return model.getObject().getDescription(ScenePanel.this);
        }
    });
    Label headerWrapperDisplayName = new Label(ID_HEADER_WRAPPER_DISPLAY_NAME, new AbstractReadOnlyModel<String>() {

        @Override
        public String getObject() {
            String key = ((WrapperScene) getModelObject().getScene()).getDisplayNameKey();
            Object[] parameters = ((WrapperScene) getModelObject().getScene()).getDisplayNameParameters();
            return new StringResourceModel(key, this).setModel(null).setDefaultValue(key).setParameters(parameters).getObject();
        }
    });
    headerPanel.add(headerChangeType);
    headerPanel.add(headerObjectType);
    headerPanel.add(headerNameLabel);
    headerPanel.add(headerNameLink);
    headerPanel.add(headerDescription);
    headerPanel.add(headerWrapperDisplayName);
    headerChangeType.add(createHeaderOnClickBehaviour(model));
    headerObjectType.add(createHeaderOnClickBehaviour(model));
    headerNameLabel.add(createHeaderOnClickBehaviour(model));
    headerDescription.add(createHeaderOnClickBehaviour(model));
    headerWrapperDisplayName.add(createHeaderOnClickBehaviour(model));
    VisibleEnableBehaviour visibleIfNotWrapper = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !getModelObject().isWrapper();
        }
    };
    VisibleEnableBehaviour visibleIfWrapper = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return getModelObject().isWrapper();
        }
    };
    VisibleEnableBehaviour visibleIfExistingObject = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject().isWrapper()) {
                return false;
            }
            return isExistingViewableObject();
        }
    };
    VisibleEnableBehaviour visibleIfNotWrapperAndNotExistingObject = new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            if (getModelObject().isWrapper()) {
                return false;
            }
            return !isExistingViewableObject();
        }
    };
    headerChangeType.add(visibleIfNotWrapper);
    headerObjectType.add(visibleIfNotWrapper);
    headerNameLabel.add(visibleIfNotWrapperAndNotExistingObject);
    headerNameLink.add(visibleIfExistingObject);
    headerDescription.add(visibleIfNotWrapper);
    headerWrapperDisplayName.add(visibleIfWrapper);
    WebMarkupContainer body = new WebMarkupContainer(ID_BODY);
    body.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            SceneDto wrapper = model.getObject();
            return !wrapper.isMinimized();
        }
    });
    box.add(body);
    WebMarkupContainer itemsTable = new WebMarkupContainer(ID_ITEMS_TABLE);
    itemsTable.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !model.getObject().getItems().isEmpty();
        }
    });
    WebMarkupContainer oldValueLabel = new WebMarkupContainer(ID_OLD_VALUE_LABEL);
    oldValueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(oldValueLabel);
    WebMarkupContainer newValueLabel = new WebMarkupContainer(ID_NEW_VALUE_LABEL);
    newValueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(newValueLabel);
    WebMarkupContainer valueLabel = new WebMarkupContainer(ID_VALUE_LABEL);
    valueLabel.add(new VisibleEnableBehaviour() {

        @Override
        public boolean isVisible() {
            return !model.getObject().containsDeltaItems();
        }
    });
    itemsTable.add(valueLabel);
    ListView<SceneItemDto> items = new ListView<SceneItemDto>(ID_ITEMS, new PropertyModel<List<SceneItemDto>>(model, SceneDto.F_ITEMS)) {

        @Override
        protected void populateItem(ListItem<SceneItemDto> item) {
            SceneItemPanel panel = new SceneItemPanel(ID_ITEM, item.getModel());
            panel.setRenderBodyOnly(true);
            item.add(panel);
        }
    };
    items.setReuseItems(true);
    itemsTable.add(items);
    body.add(itemsTable);
    ListView<SceneDto> partialScenes = new ListView<SceneDto>(ID_PARTIAL_SCENES, new PropertyModel<List<SceneDto>>(model, SceneDto.F_PARTIAL_SCENES)) {

        @Override
        protected void populateItem(ListItem<SceneDto> item) {
            ScenePanel panel = new ScenePanel(ID_PARTIAL_SCENE, item.getModel());
            panel.setOutputMarkupPlaceholderTag(true);
            item.add(panel);
        }
    };
    partialScenes.setReuseItems(true);
    body.add(partialScenes);
}
Also used : Label(org.apache.wicket.markup.html.basic.Label) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) LinkPanel(com.evolveum.midpoint.web.component.data.column.LinkPanel) PrismObject(com.evolveum.midpoint.prism.PrismObject) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) ListView(org.apache.wicket.markup.html.list.ListView) List(java.util.List) VisibleEnableBehaviour(com.evolveum.midpoint.web.component.util.VisibleEnableBehaviour) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ListItem(org.apache.wicket.markup.html.list.ListItem)

Example 22 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class AbstractRoleMemberPanel method createMembersColumns.

protected List<IColumn<SelectableBean<ObjectType>, String>> createMembersColumns() {
    List<IColumn<SelectableBean<ObjectType>, String>> columns = new ArrayList<>();
    IColumn<SelectableBean<ObjectType>, String> column = new AbstractExportableColumn<SelectableBean<ObjectType>, String>(createStringResource("TreeTablePanel.fullName.displayName")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ObjectType>>> cellItem, String componentId, IModel<SelectableBean<ObjectType>> rowModel) {
            SelectableBean<ObjectType> bean = rowModel.getObject();
            ObjectType object = bean.getValue();
            cellItem.add(new Label(componentId, getMemberObjectDisplayName(object)));
        }

        @Override
        public IModel<String> getDataModel(IModel<SelectableBean<ObjectType>> rowModel) {
            return Model.of(getMemberObjectDisplayName(rowModel.getObject().getValue()));
        }
    };
    columns.add(column);
    column = new AbstractExportableColumn<SelectableBean<ObjectType>, String>(createStringResource("TreeTablePanel.identifier.description")) {

        private static final long serialVersionUID = 1L;

        @Override
        public void populateItem(Item<ICellPopulator<SelectableBean<ObjectType>>> cellItem, String componentId, IModel<SelectableBean<ObjectType>> rowModel) {
            SelectableBean<ObjectType> bean = rowModel.getObject();
            ObjectType object = bean.getValue();
            cellItem.add(new Label(componentId, getMemberObjectIdentifier(object)));
        }

        @Override
        public IModel<String> getDataModel(IModel<SelectableBean<ObjectType>> rowModel) {
            return Model.of(getMemberObjectIdentifier(rowModel.getObject().getValue()));
        }
    };
    columns.add(column);
    return columns;
}
Also used : IModel(org.apache.wicket.model.IModel) AbstractExportableColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.export.AbstractExportableColumn) ArrayList(java.util.ArrayList) Label(org.apache.wicket.markup.html.basic.Label) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) Item(org.apache.wicket.markup.repeater.Item) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean)

Example 23 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class AbstractRoleMemberPanel method initMemberTable.

private void initMemberTable(TableId tableId, Form form) {
    WebMarkupContainer memberContainer = new WebMarkupContainer(ID_CONTAINER_MEMBER);
    memberContainer.setOutputMarkupId(true);
    memberContainer.setOutputMarkupPlaceholderTag(true);
    form.add(memberContainer);
    MainObjectListPanel<ObjectType> childrenListPanel = new MainObjectListPanel<ObjectType>(ID_MEMBER_TABLE, ObjectType.class, tableId, getSearchOptions(), getPageBase()) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void objectDetailsPerformed(AjaxRequestTarget target, ObjectType object) {
            detailsPerformed(target, object);
        }

        @Override
        protected boolean isClickable(IModel<SelectableBean<ObjectType>> rowModel) {
            if (rowModel == null || rowModel.getObject() == null || rowModel.getObject().getValue() == null) {
                return false;
            }
            Class<?> objectClass = rowModel.getObject().getValue().getClass();
            return WebComponentUtil.hasDetailsPage(objectClass);
        }

        @Override
        protected void newObjectPerformed(AjaxRequestTarget target) {
            AbstractRoleMemberPanel.this.createFocusMemberPerformed(null, target);
        }

        @Override
        protected List<IColumn<SelectableBean<ObjectType>, String>> createColumns() {
            return createMembersColumns();
        }

        @Override
        protected IColumn<SelectableBean<ObjectType>, String> createActionsColumn() {
            return new InlineMenuHeaderColumn(createMembersHeaderInlineMenu());
        }

        @Override
        protected List<InlineMenuItem> createInlineMenu() {
            return new ArrayList<>();
        }

        @Override
        protected ObjectQuery createContentQuery() {
            ObjectQuery q = super.createContentQuery();
            ObjectQuery members = AbstractRoleMemberPanel.this.createContentQuery();
            List<ObjectFilter> filters = new ArrayList<>();
            if (q != null && q.getFilter() != null) {
                filters.add(q.getFilter());
            }
            if (members != null && members.getFilter() != null) {
                filters.add(members.getFilter());
            }
            if (filters.size() == 1) {
                return ObjectQuery.createObjectQuery(filters.iterator().next());
            }
            return ObjectQuery.createObjectQuery(AndFilter.createAnd(filters));
        }
    };
    childrenListPanel.setOutputMarkupId(true);
    memberContainer.add(childrenListPanel);
}
Also used : MainObjectListPanel(com.evolveum.midpoint.gui.api.component.MainObjectListPanel) IModel(org.apache.wicket.model.IModel) InlineMenuHeaderColumn(com.evolveum.midpoint.web.component.data.column.InlineMenuHeaderColumn) ArrayList(java.util.ArrayList) ObjectFilter(com.evolveum.midpoint.prism.query.ObjectFilter) ObjectQuery(com.evolveum.midpoint.prism.query.ObjectQuery) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) SelectableBean(com.evolveum.midpoint.web.component.util.SelectableBean) InlineMenuItem(com.evolveum.midpoint.web.component.menu.cog.InlineMenuItem)

Example 24 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class AccessCertificationCloseStageTriggerHandler method handle.

@Override
public <O extends ObjectType> void handle(PrismObject<O> prismObject, TriggerType trigger, Task task, OperationResult result) {
    try {
        ObjectType object = prismObject.asObjectable();
        if (!(object instanceof AccessCertificationCampaignType)) {
            LOGGER.error("Trigger of this type is supported only on {} objects, not on {}", AccessCertificationCampaignType.class.getSimpleName(), object.getClass().getName());
            return;
        }
        AccessCertificationCampaignType campaign = (AccessCertificationCampaignType) object;
        LOGGER.info("Automatically closing current stage of {}", ObjectTypeUtil.toShortString(campaign));
        if (campaign.getState() != IN_REVIEW_STAGE) {
            LOGGER.warn("Campaign {} is not in a review stage; this 'close stage' trigger will be ignored.", ObjectTypeUtil.toShortString(campaign));
            return;
        }
        int currentStageNumber = campaign.getStageNumber();
        certificationManager.closeCurrentStage(campaign.getOid(), currentStageNumber, task, result);
        if (currentStageNumber < CertCampaignTypeUtil.getNumberOfStages(campaign)) {
            LOGGER.info("Automatically opening next stage of {}", ObjectTypeUtil.toShortString(campaign));
            certificationManager.openNextStage(campaign.getOid(), currentStageNumber + 1, task, result);
        } else {
            LOGGER.info("Automatically starting remediation for {}", ObjectTypeUtil.toShortString(campaign));
            certificationManager.startRemediation(campaign.getOid(), task, result);
        }
    } catch (SchemaException | ObjectNotFoundException | ObjectAlreadyExistsException | SecurityViolationException | RuntimeException e) {
        LoggingUtils.logException(LOGGER, "Couldn't close current campaign and possibly advance to the next one", e);
    }
}
Also used : ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) SecurityViolationException(com.evolveum.midpoint.util.exception.SecurityViolationException) ObjectNotFoundException(com.evolveum.midpoint.util.exception.ObjectNotFoundException) ObjectAlreadyExistsException(com.evolveum.midpoint.util.exception.ObjectAlreadyExistsException) AccessCertificationCampaignType(com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType)

Example 25 with ObjectType

use of org.mitre.cybox.cybox_2.ObjectType in project midpoint by Evolveum.

the class AbstractTestForExchangeConnector method getOidFromDeltaOperationList.

/**
     * Retrieves OID and OperationResult created by model Web Service from the returned list of ObjectDeltaOperations.
     *
     * @param operationListType result of the model web service executeChanges call
     * @param originalDelta original request used to find corresponding ObjectDeltaOperationType instance. Must be of ADD type.
     * @param operationResultHolder where the result will be put
     * @return OID if found
     *
     * PRELIMINARY IMPLEMENTATION. Currently the first returned ADD delta with the same object type as original delta is returned.
     *
     * TODO move to ModelClientUtil
     */
public static String getOidFromDeltaOperationList(ObjectDeltaOperationListType operationListType, ObjectDeltaType originalDelta, Holder<OperationResultType> operationResultTypeHolder) {
    Validate.notNull(operationListType);
    Validate.notNull(originalDelta);
    if (originalDelta.getChangeType() != ChangeTypeType.ADD) {
        throw new IllegalArgumentException("Original delta is not of ADD type");
    }
    if (originalDelta.getObjectToAdd() == null) {
        throw new IllegalArgumentException("Original delta contains no object-to-be-added");
    }
    for (ObjectDeltaOperationType operationType : operationListType.getDeltaOperation()) {
        ObjectDeltaType objectDeltaType = operationType.getObjectDelta();
        if (objectDeltaType.getChangeType() == ChangeTypeType.ADD && objectDeltaType.getObjectToAdd() != null) {
            ObjectType objectAdded = (ObjectType) objectDeltaType.getObjectToAdd();
            if (objectAdded.getClass().equals(originalDelta.getObjectToAdd().getClass())) {
                operationResultTypeHolder.value = operationType.getExecutionResult();
                return objectAdded.getOid();
            }
        }
    }
    return null;
}
Also used : ObjectDeltaOperationType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectDeltaOperationType) ObjectDeltaType(com.evolveum.prism.xml.ns._public.types_3.ObjectDeltaType) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)

Aggregations

ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)371 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)280 Test (org.testng.annotations.Test)261 ObjectDelta (com.evolveum.midpoint.prism.delta.ObjectDelta)244 Task (com.evolveum.midpoint.task.api.Task)242 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)223 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)153 ArrayList (java.util.ArrayList)119 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)93 OperationResultType (com.evolveum.midpoint.xml.ns._public.common.common_3.OperationResultType)56 Holder (javax.xml.ws.Holder)48 AbstractInitializedModelIntegrationTest (com.evolveum.midpoint.model.intest.AbstractInitializedModelIntegrationTest)34 ReferenceDelta (com.evolveum.midpoint.prism.delta.ReferenceDelta)33 ShadowDiscriminatorObjectDelta (com.evolveum.midpoint.common.refinery.ShadowDiscriminatorObjectDelta)32 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)32 ObjectReferenceType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType)31 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)30 SystemConfigurationType (com.evolveum.midpoint.xml.ns._public.common.common_3.SystemConfigurationType)30 PrismObject (com.evolveum.midpoint.prism.PrismObject)29 ObjectNotFoundException (com.evolveum.midpoint.util.exception.ObjectNotFoundException)29