Search in sources :

Example 1 with CreateTemplatePanel

use of com.evolveum.midpoint.gui.impl.page.admin.CreateTemplatePanel in project midpoint by Evolveum.

the class PageAssignmentHolderDetails method createTemplatePanel.

private CreateTemplatePanel<AH> createTemplatePanel() {
    return new CreateTemplatePanel<>(ID_TEMPLATE) {

        @Override
        protected Collection<CompiledObjectCollectionView> findAllApplicableArchetypeViews() {
            return PageAssignmentHolderDetails.this.findAllApplicableArchetypeViews();
        }

        @Override
        protected QName getType() {
            return ObjectTypes.getObjectType(PageAssignmentHolderDetails.this.getType()).getTypeQName();
        }

        @Override
        protected void onTemplateChosePerformed(CompiledObjectCollectionView collectionViews, AjaxRequestTarget target) {
            PrismObject<AH> assignmentHolder;
            try {
                assignmentHolder = getPrismContext().createObject(PageAssignmentHolderDetails.this.getType());
            } catch (Throwable e) {
                LOGGER.error("Cannot create prism object for {}. Using object from page model.", PageAssignmentHolderDetails.this.getType());
                assignmentHolder = getObjectDetailsModels().getObjectWrapperModel().getObject().getObjectOld().clone();
            }
            List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionViews);
            if (archetypeRef != null) {
                AssignmentHolderType holder = assignmentHolder.asObjectable();
                archetypeRef.forEach(a -> holder.getAssignment().add(ObjectTypeUtil.createAssignmentTo(a, getPrismContext())));
            }
            reloadObjectDetailsModel(assignmentHolder);
            Fragment fragment = createDetailsFragment();
            fragment.setOutputMarkupId(true);
            PageAssignmentHolderDetails.this.replace(fragment);
            target.add(fragment);
        }
    };
}
Also used : AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) CreateTemplatePanel(com.evolveum.midpoint.gui.impl.page.admin.CreateTemplatePanel) CompiledObjectCollectionView(com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView) Fragment(org.apache.wicket.markup.html.panel.Fragment)

Aggregations

CreateTemplatePanel (com.evolveum.midpoint.gui.impl.page.admin.CreateTemplatePanel)1 CompiledObjectCollectionView (com.evolveum.midpoint.model.api.authentication.CompiledObjectCollectionView)1 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)1 Fragment (org.apache.wicket.markup.html.panel.Fragment)1