Search in sources :

Example 1 with PrismObjectWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper in project midpoint by Evolveum.

the class TestWrapperDelta method test301ModifyProfilingClassLoggerOfSystemConfig.

@Test
public void test301ModifyProfilingClassLoggerOfSystemConfig() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    SystemConfigurationType systemConfigBefore = getSystemConfiguration();
    WrapperContext ctx = new WrapperContext(task, result);
    PrismObjectWrapper objectWrapper = createObjectWrapper(systemConfigBefore.asPrismContainer(), ItemStatus.NOT_CHANGED, ctx);
    PrismContainerWrapper<LoggingConfigurationType> loggingConfig = objectWrapper.findContainer(SystemConfigurationType.F_LOGGING);
    PrismContainerWrapper<Containerable> profilingClassLogger = loggingConfig.findContainer(ItemName.fromQName(ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH));
    PrismPropertyWrapper<LoggingLevelType> loggerLevel = profilingClassLogger.getValue().findProperty(ClassLoggerConfigurationType.F_LEVEL);
    PrismPropertyWrapper<String> appenderLevel = profilingClassLogger.getValue().findProperty(ClassLoggerConfigurationType.F_APPENDER);
    loggerLevel.getValue().setRealValue(LoggingLevelType.DEBUG);
    appenderLevel.getValues().get(0).setRealValue("MIDPOINT_PROFILE_LOG");
    // GIVEN
    ObjectDelta<UserType> systemConfigDelta = objectWrapper.getObjectDelta();
    assertModificationsSize(systemConfigDelta, 1);
    assertModification(systemConfigDelta, ItemPath.create(SystemConfigurationType.F_LOGGING, LoggingConfigurationType.F_CLASS_LOGGER, ClassLoggerConfigurationType.F_LEVEL), ModificationTypeType.ADD, LoggingLevelType.DEBUG);
    assertModification(systemConfigDelta, ItemPath.create(SystemConfigurationType.F_LOGGING, LoggingConfigurationType.F_CLASS_LOGGER, ClassLoggerConfigurationType.F_APPENDER), ModificationTypeType.ADD, "MIDPOINT_PROFILE_LOG");
    // WHEN
    executeChanges(systemConfigDelta, null, task, result);
    // THEN
    SystemConfigurationType systemConfigAfter = getSystemConfiguration();
    loggingConfig = objectWrapper.findContainer(SystemConfigurationType.F_LOGGING);
    profilingClassLogger = loggingConfig.findContainer(ItemName.fromQName(ProfilingClassLoggerWrapperFactoryImpl.PROFILING_LOGGER_PATH));
    loggerLevel = profilingClassLogger.getValue().findProperty(ClassLoggerConfigurationType.F_LEVEL);
    appenderLevel = profilingClassLogger.getValue().findProperty(ClassLoggerConfigurationType.F_APPENDER);
    if (!loggerLevel.getValue().getRealValue().equals(LoggingLevelType.DEBUG)) {
        AssertJUnit.fail("Expected value: " + LoggingLevelType.DEBUG + " after executing of changes. Values present: " + loggerLevel.getValue().getRealValue());
    }
    if (!appenderLevel.getValues().get(0).getRealValue().equals("MIDPOINT_PROFILE_LOG")) {
        AssertJUnit.fail("Expected value: " + "MIDPOINT_PROFILE_LOG" + " after executing of changes. Values present: " + appenderLevel.getValues().get(0).getRealValue());
    }
}
Also used : Task(com.evolveum.midpoint.task.api.Task) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) AbstractInitializedGuiIntegrationTest(com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with PrismObjectWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper in project midpoint by Evolveum.

the class TestWrapperDelta method test310modifySystemConfigurationAddCollectionView.

@Test
public void test310modifySystemConfigurationAddCollectionView() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ModelServiceLocator locator = getServiceLocator(task);
    SystemConfigurationType systemConfigBefore = getSystemConfiguration();
    WrapperContext ctx = new WrapperContext(task, result);
    PrismObjectWrapper objectWrapper = createObjectWrapper(systemConfigBefore.asPrismContainer(), ItemStatus.NOT_CHANGED, ctx);
    ItemPath guiObjectViewPath = ItemPath.create(SystemConfigurationType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_OBJECT_COLLECTION_VIEWS, GuiObjectListViewsType.F_OBJECT_COLLECTION_VIEW);
    PrismContainerWrapper<GuiObjectListViewType> collections = objectWrapper.findContainer(guiObjectViewPath);
    // GIVEN
    PrismContainerValue<GuiObjectListViewType> newCollection = collections.getItem().createNewValue();
    ctx.setShowEmpty(true);
    PrismContainerValueWrapper<GuiObjectListViewType> newCollectionValueWrapper = locator.createValueWrapper(collections, newCollection, ValueStatus.ADDED, ctx);
    collections.getValues().add(newCollectionValueWrapper);
    PrismPropertyWrapper<QName> type = newCollectionValueWrapper.findProperty(GuiObjectListViewType.F_TYPE);
    type.getValue().setRealValue(new QName("RoleType"));
    PrismPropertyWrapper<String> identifier = newCollectionValueWrapper.findProperty(GuiObjectListViewType.F_IDENTIFIER);
    identifier.getValue().setRealValue("my-roles-collection");
    // WHEN
    ObjectDelta<SystemConfigurationType> delta = objectWrapper.getObjectDelta();
    GuiObjectListViewType expectedValue = new GuiObjectListViewType(prismContext);
    expectedValue.setIdentifier("my-roles-collection");
    expectedValue.setType(new QName("RoleType"));
    assertModification(delta, guiObjectViewPath, ModificationTypeType.ADD, expectedValue);
    executeChanges(delta, null, task, result);
    // THEN
    SystemConfigurationType systemConfigAfter = getSystemConfiguration();
    AdminGuiConfigurationType adminGuiConfig = systemConfigAfter.getAdminGuiConfiguration();
    assertNotNull("Unexpected empty admin gui configuration.", adminGuiConfig);
    GuiObjectListViewsType collectionViews = adminGuiConfig.getObjectCollectionViews();
    assertNotNull("Unexpected empty gui object collection views", collectionViews);
    GuiObjectListViewType myRolesCollection = null;
    for (GuiObjectListViewType collectionView : collectionViews.getObjectCollectionView()) {
        if ("my-roles-collection".equals(collectionView.getIdentifier())) {
            myRolesCollection = collectionView;
        }
    }
    assertNotNull("Newly added collection view not present in system configuration, something strange", myRolesCollection);
    assertFalse("c:RoleType should not be equals to RoleType", RoleType.COMPLEX_TYPE.equals(myRolesCollection.getType()));
    assertTrue("c:RoleType should match RoleType", QNameUtil.match(RoleType.COMPLEX_TYPE, myRolesCollection.getType()));
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelServiceLocator(com.evolveum.midpoint.gui.api.util.ModelServiceLocator) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PolyString(com.evolveum.midpoint.prism.polystring.PolyString) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) AbstractInitializedGuiIntegrationTest(com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with PrismObjectWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper in project midpoint by Evolveum.

the class PageResource method createTabsPanel.

private AjaxTabbedPanel<ITab> createTabsPanel() {
    List<ITab> tabs = new ArrayList<>();
    tabs.add(new PanelTab(createStringResource("PageResource.tab.details")) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new ResourceDetailsTabPanel(panelId, resourceModel);
        }
    });
    tabs.add(new PanelTab(createStringResource("PageResource.tab.content.tasks")) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new ResourceTasksPanel(panelId, resourceModel);
        }
    });
    tabs.add(new PanelTab(createStringResource("PageResource.tab.content.account")) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new ResourceContentTabPanel(panelId, ShadowKindType.ACCOUNT, resourceModel);
        }
    });
    tabs.add(new PanelTab(createStringResource("PageResource.tab.content.entitlement")) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new ResourceContentTabPanel(panelId, ShadowKindType.ENTITLEMENT, resourceModel);
        }
    });
    tabs.add(new PanelTab(createStringResource("PageResource.tab.content.generic")) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new ResourceContentTabPanel(panelId, ShadowKindType.GENERIC, resourceModel);
        }
    });
    tabs.add(new PanelTab(createStringResource("PageResource.tab.content.others")) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new ResourceContentTabPanel(panelId, null, resourceModel);
        }
    });
    tabs.add(new PanelTab(createStringResource("PageResource.tab.connector")) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            return new ResourceConnectorPanel(panelId, loadWrapperModel(resourceModel));
        }
    });
    tabs.add(new PanelTab(createStringResource("PageResource.tab.schemaHandling")) {

        private static final long serialVersionUID = 1L;

        @Override
        public WebMarkupContainer createPanel(String panelId) {
            PrismObjectWrapperFactory<ResourceType> resourceFactory = PageResource.this.findObjectWrapperFactory(resourceModel.getObject().getDefinition());
            Task task = createSimpleTask("Create resource wrapper");
            OperationResult result = task.getResult();
            WrapperContext ctx = new WrapperContext(task, result);
            PrismObjectWrapper<ResourceType> resourceWrapper;
            try {
                resourceWrapper = resourceFactory.createObjectWrapper(resourceModel.getObject(), ItemStatus.NOT_CHANGED, ctx);
            } catch (SchemaException e) {
                resourceWrapper = null;
            }
            if (resourceWrapper == null) {
                return new WebMarkupContainer(panelId);
            }
            return new ResourceSchemaHandlingTabPanel(panelId, PrismContainerWrapperModel.fromContainerWrapper(Model.of(resourceWrapper), ResourceType.F_SCHEMA_HANDLING));
        }
    });
    AjaxTabbedPanel<ITab> resourceTabs = new AjaxTabbedPanel<ITab>(ID_TAB_PANEL, tabs) {

        private static final long serialVersionUID = 1L;

        @Override
        protected void onTabChange(int index) {
            updateBreadcrumbParameters(PARAMETER_SELECTED_TAB, index);
        }
    };
    resourceTabs.setOutputMarkupId(true);
    return resourceTabs;
}
Also used : PanelTab(com.evolveum.midpoint.gui.api.component.tabs.PanelTab) SchemaException(com.evolveum.midpoint.util.exception.SchemaException) Task(com.evolveum.midpoint.task.api.Task) ArrayList(java.util.ArrayList) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) AjaxTabbedPanel(com.evolveum.midpoint.web.component.AjaxTabbedPanel) PrismObjectWrapperFactory(com.evolveum.midpoint.gui.api.factory.wrapper.PrismObjectWrapperFactory)

Example 4 with PrismObjectWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper in project midpoint by Evolveum.

the class GenericSingleContainerPanel method initLayout.

@Override
protected void initLayout() {
    IModel model = () -> {
        PrismObjectWrapper wrapper = getObjectWrapperModel().getObject();
        wrapper.setShowEmpty(true, true);
        return wrapper;
    };
    add(new SingleContainerPanel<C>(ID_DETAILS, model, getPanelConfiguration()));
}
Also used : IModel(org.apache.wicket.model.IModel) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper)

Example 5 with PrismObjectWrapper

use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper in project midpoint by Evolveum.

the class TestWrapperDelta method test311modifySystemConfigurationModifyCollectionType.

@Test
public void test311modifySystemConfigurationModifyCollectionType() throws Exception {
    Task task = getTestTask();
    OperationResult result = task.getResult();
    ModelServiceLocator locator = getServiceLocator(task);
    SystemConfigurationType systemConfigBefore = getSystemConfiguration();
    WrapperContext ctx = new WrapperContext(task, result);
    PrismObjectWrapper objectWrapper = createObjectWrapper(systemConfigBefore.asPrismContainer(), ItemStatus.NOT_CHANGED, ctx);
    ItemPath guiObjectViewPath = ItemPath.create(SystemConfigurationType.F_ADMIN_GUI_CONFIGURATION, AdminGuiConfigurationType.F_OBJECT_COLLECTION_VIEWS, GuiObjectListViewsType.F_OBJECT_COLLECTION_VIEW);
    PrismContainerWrapper<GuiObjectListViewType> collections = objectWrapper.findContainer(guiObjectViewPath);
    PrismContainerValueWrapper<GuiObjectListViewType> foundCollection = null;
    for (PrismContainerValueWrapper<GuiObjectListViewType> collection : collections.getValues()) {
        GuiObjectListViewType collectionRealValue = collection.getRealValue();
        if ("my-roles-collection".equals(collectionRealValue.getIdentifier())) {
            foundCollection = collection;
            break;
        }
    }
    // GIVEN
    PrismPropertyWrapper<QName> collectionType = foundCollection.findProperty(GuiObjectListViewType.F_TYPE);
    collectionType.getValue().setRealValue(RoleType.COMPLEX_TYPE);
    // WHEN
    ObjectDelta<SystemConfigurationType> systemConfigDelta = objectWrapper.getObjectDelta();
    assertTrue("Delta should be empty!", systemConfigDelta.isEmpty());
}
Also used : Task(com.evolveum.midpoint.task.api.Task) ModelServiceLocator(com.evolveum.midpoint.gui.api.util.ModelServiceLocator) QName(javax.xml.namespace.QName) OperationResult(com.evolveum.midpoint.schema.result.OperationResult) PrismObjectWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) ItemPath(com.evolveum.midpoint.prism.path.ItemPath) AbstractInitializedGuiIntegrationTest(com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest) Test(org.testng.annotations.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

PrismObjectWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismObjectWrapper)5 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)4 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)4 Task (com.evolveum.midpoint.task.api.Task)4 AbstractInitializedGuiIntegrationTest (com.evolveum.midpoint.web.AbstractInitializedGuiIntegrationTest)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)3 Test (org.testng.annotations.Test)3 ModelServiceLocator (com.evolveum.midpoint.gui.api.util.ModelServiceLocator)2 ItemPath (com.evolveum.midpoint.prism.path.ItemPath)2 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)2 QName (javax.xml.namespace.QName)2 PanelTab (com.evolveum.midpoint.gui.api.component.tabs.PanelTab)1 PrismObjectWrapperFactory (com.evolveum.midpoint.gui.api.factory.wrapper.PrismObjectWrapperFactory)1 SchemaException (com.evolveum.midpoint.util.exception.SchemaException)1 AjaxTabbedPanel (com.evolveum.midpoint.web.component.AjaxTabbedPanel)1 ArrayList (java.util.ArrayList)1 ITab (org.apache.wicket.extensions.markup.html.tabs.ITab)1 WebMarkupContainer (org.apache.wicket.markup.html.WebMarkupContainer)1 IModel (org.apache.wicket.model.IModel)1