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);
}
};
}
Aggregations