Search in sources :

Example 1 with PrismValueWrapper

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

the class AbstractGuiIntegrationTest method getServiceLocator.

protected ModelServiceLocator getServiceLocator(final Task pageTask) {
    return new ModelServiceLocator() {

        @Override
        public ModelService getModelService() {
            return modelService;
        }

        @Override
        public ModelInteractionService getModelInteractionService() {
            return modelInteractionService;
        }

        @Override
        public DashboardService getDashboardService() {
            return dashboardService;
        }

        @Override
        public Task createSimpleTask(String operationName) {
            MidPointPrincipal user = AuthUtil.getPrincipalUser();
            if (user == null) {
                throw new IllegalStateException("No authenticated user");
            }
            return WebModelServiceUtils.createSimpleTask(operationName, SchemaConstants.CHANNEL_USER_URI, user.getFocus().asPrismObject(), taskManager);
        }

        @Override
        public PrismContext getPrismContext() {
            return prismContext;
        }

        @Override
        public SecurityEnforcer getSecurityEnforcer() {
            return securityEnforcer;
        }

        @Override
        public SecurityContextManager getSecurityContextManager() {
            return securityContextManager;
        }

        @NotNull
        @Override
        public CompiledGuiProfile getCompiledGuiProfile() {
            Task task = createSimpleTask("getCompiledGuiProfile");
            try {
                return getModelInteractionService().getCompiledGuiProfile(task, task.getResult());
            } catch (ObjectNotFoundException | SchemaException | CommunicationException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException e) {
                throw new SystemException(e.getMessage(), e);
            }
        }

        @Override
        public Task getPageTask() {
            return pageTask;
        }

        @Override
        public ExpressionFactory getExpressionFactory() {
            return expressionFactory;
        }

        @Override
        public LocalizationService getLocalizationService() {
            return localizationService;
        }

        @Override
        public Locale getLocale() {
            return Locale.US;
        }

        @Override
        public GuiComponentRegistry getRegistry() {
            return registry;
        }

        @Override
        public <O extends ObjectType> PrismObjectWrapperFactory<O> findObjectWrapperFactory(PrismObjectDefinition<O> objectDef) {
            return registry.getObjectWrapperFactory(objectDef);
        }

        @Override
        public <I extends Item, IW extends ItemWrapper> IW createItemWrapper(I item, ItemStatus status, WrapperContext ctx) throws SchemaException {
            ItemWrapperFactory<IW, ?, ?> factory = registry.findWrapperFactory(item.getDefinition(), null);
            ctx.setCreateIfEmpty(true);
            return factory.createWrapper(null, item, status, ctx);
        }

        @Override
        public <IW extends ItemWrapper, VW extends PrismValueWrapper, PV extends PrismValue> VW createValueWrapper(IW parentWrapper, PV newValue, ValueStatus status, WrapperContext context) throws SchemaException {
            ItemWrapperFactory<IW, VW, PV> factory = registry.findWrapperFactory(parentWrapper, null);
            return factory.createValueWrapper(parentWrapper, newValue, status, context);
        }

        @Override
        public MidpointFormValidatorRegistry getFormValidatorRegistry() {
            return null;
        }

        @Override
        public AdminGuiConfigurationMergeManager getAdminGuiConfigurationMergeManager() {
            return null;
        }

        @Override
        public CorrelationService getCorrelationService() {
            return null;
        }
    };
}
Also used : ItemStatus(com.evolveum.midpoint.gui.api.prism.ItemStatus) Task(com.evolveum.midpoint.task.api.Task) ItemWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper) ObjectType(com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType) WrapperContext(com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext) PrismValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismValueWrapper) ValueStatus(com.evolveum.midpoint.web.component.prism.ValueStatus) MidPointPrincipal(com.evolveum.midpoint.security.api.MidPointPrincipal) ModelServiceLocator(com.evolveum.midpoint.gui.api.util.ModelServiceLocator)

Example 2 with PrismValueWrapper

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

the class WrapperTestUtil method fillInPropertyWrapper.

private static <T> void fillInPropertyWrapper(ModelServiceLocator modelServiceLocator, PrismPropertyWrapper itemWrapper, ItemName itemName, T... newValues) throws SchemaException {
    for (T newValue : newValues) {
        List<PrismValueWrapper> valueWrappers = itemWrapper.getValues();
        PrismValueWrapper lastValueWrapper = valueWrappers.get(valueWrappers.size() - 1);
        PrismPropertyValue<T> pval = (PrismPropertyValue<T>) lastValueWrapper.getNewValue();
        pval.setValue(newValue);
    }
}
Also used : PrismValueWrapper(com.evolveum.midpoint.gui.api.prism.wrapper.PrismValueWrapper)

Aggregations

PrismValueWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.PrismValueWrapper)2 WrapperContext (com.evolveum.midpoint.gui.api.factory.wrapper.WrapperContext)1 ItemStatus (com.evolveum.midpoint.gui.api.prism.ItemStatus)1 ItemWrapper (com.evolveum.midpoint.gui.api.prism.wrapper.ItemWrapper)1 ModelServiceLocator (com.evolveum.midpoint.gui.api.util.ModelServiceLocator)1 MidPointPrincipal (com.evolveum.midpoint.security.api.MidPointPrincipal)1 Task (com.evolveum.midpoint.task.api.Task)1 ValueStatus (com.evolveum.midpoint.web.component.prism.ValueStatus)1 ObjectType (com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType)1