use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.
the class PageAdminObjectDetails method changeArchetypeButtonClicked.
private void changeArchetypeButtonClicked(AjaxRequestTarget target) {
AssignmentPopup changeArchetypePopup = new AssignmentPopup(getMainPopupBodyId(), null) {
private static final long serialVersionUID = 1L;
@Override
protected void addPerformed(AjaxRequestTarget target, List<AssignmentType> newAssignmentsList) {
OperationResult result = new OperationResult(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
if (newAssignmentsList.size() > 1) {
result.recordWarning(getString("PageAdminObjectDetails.change.archetype.more.than.one.selected"));
showResult(result);
target.add(PageAdminObjectDetails.this.getFeedbackPanel());
return;
}
AssignmentType oldArchetypAssignment = getOldArchetypeAssignment(result);
if (oldArchetypAssignment == null) {
showResult(result);
target.add(PageAdminObjectDetails.this.getFeedbackPanel());
return;
}
try {
ObjectDelta<O> delta = getPrismContext().deltaFor(getCompileTimeClass()).item(AssignmentHolderType.F_ASSIGNMENT).delete(oldArchetypAssignment.clone()).asObjectDelta(getObjectWrapper().getOid());
delta.addModificationAddContainer(AssignmentHolderType.F_ASSIGNMENT, newAssignmentsList.iterator().next());
Task task = createSimpleTask(OPERATION_EXECUTE_ARCHETYPE_CHANGES);
getModelService().executeChanges(MiscUtil.createCollection(delta), null, task, result);
} catch (Exception e) {
LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage(), e);
result.recordFatalError(getString("PageAdminObjectDetails.change.archetype.failed", e.getMessage()), e);
}
result.computeStatusIfUnknown();
showResult(result);
target.add(PageAdminObjectDetails.this.getFeedbackPanel());
refresh(target);
}
@Override
protected List<ITab> createAssignmentTabs(AssignmentObjectRelation assignmentObjectRelation) {
List<ITab> tabs = new ArrayList<>();
tabs.add(new PanelTab(getPageBase().createStringResource("ObjectTypes.ARCHETYPE"), new VisibleBehaviour(() -> true)) {
private static final long serialVersionUID = 1L;
@Override
public WebMarkupContainer createPanel(String panelId) {
return new FocusTypeAssignmentPopupTabPanel<ArchetypeType>(panelId, ObjectTypes.ARCHETYPE, null) {
private static final long serialVersionUID = 1L;
@Override
protected PrismContainerWrapper<AssignmentType> getAssignmentWrapperModel() {
PrismContainerWrapper<AssignmentType> assignmentsWrapper = null;
try {
assignmentsWrapper = getObjectWrapper().findContainer(FocusType.F_ASSIGNMENT);
} catch (SchemaException e) {
LOGGER.error("Cannot find assignment wrapper: {}", e.getMessage());
}
return assignmentsWrapper;
}
@Override
protected List<QName> getSupportedRelations() {
return Collections.singletonList(SchemaConstants.ORG_DEFAULT);
}
@Override
protected void onSelectionPerformed(AjaxRequestTarget target, IModel<SelectableBean<ArchetypeType>> rowModel) {
target.add(getObjectListPanel());
tabLabelPanelUpdate(target);
}
@Override
protected IModel<Boolean> getObjectSelectCheckBoxEnableModel(IModel<SelectableBean<ArchetypeType>> rowModel) {
if (rowModel == null) {
return Model.of(false);
}
List selectedObjects = getSelectedObjectsList();
return Model.of(selectedObjects == null || selectedObjects.size() == 0 || (rowModel.getObject() != null && rowModel.getObject().isSelected()));
}
@Override
protected ObjectTypes getObjectType() {
return ObjectTypes.ARCHETYPE;
}
@Override
protected ObjectQuery addFilterToContentQuery() {
ObjectQuery query = super.addFilterToContentQuery();
if (query == null) {
query = getPrismContext().queryFactory().createQuery();
}
List<String> archetypeOidsList = getArchetypeOidsListToAssign();
ObjectFilter filter = getPrismContext().queryFor(ArchetypeType.class).id(archetypeOidsList.toArray(new String[0])).buildFilter();
query.addFilter(filter);
return query;
}
};
}
});
return tabs;
}
@Override
protected IModel<String> getWarningMessageModel() {
return createStringResource("PageAdminObjectDetails.button.changeArchetype.warningMessage");
}
};
changeArchetypePopup.setOutputMarkupPlaceholderTag(true);
showMainPopup(changeArchetypePopup, target);
}
use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.
the class TaskBasicPanel method initLayout.
protected void initLayout() {
SingleContainerPanel mainPanel = new SingleContainerPanel(ID_MAIN_PANEL, getObjectWrapperModel(), getPanelConfiguration()) {
@Override
protected ItemVisibility getVisibility(ItemWrapper itemWrapper) {
return getBasicTabVisibility(itemWrapper.getPath());
}
@Override
protected ItemEditabilityHandler getEditabilityHandler() {
return wrapper -> getBasicTabEditability(wrapper.getPath());
}
@Override
protected IModel<PrismContainerWrapper> createVirtualContainerModel(VirtualContainersSpecificationType virtualContainer) {
if (isDeprecatedVirtualContainer(virtualContainer)) {
return null;
}
return super.createVirtualContainerModel(virtualContainer);
}
};
add(mainPanel);
}
use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.
the class ProvenanceMetadataPanel method createMetadataDetailsPanel.
private void createMetadataDetailsPanel(ListItem<PrismContainerValueWrapper<ProvenanceMetadataType>> provenanceListItem, ListItem<PrismContainerValueWrapper<ValueMetadataType>> valueMetadataListItem) {
WebMarkupContainer panel = createAcquisitionPanel(PrismContainerWrapperModel.fromContainerValueWrapper(provenanceListItem.getModel(), ProvenanceMetadataType.F_ACQUISITION));
provenanceListItem.add(panel);
ToggleIconButton<Void> showMore = createShowMoreButton(provenanceListItem.getModel());
provenanceListItem.add(showMore);
IModel<PrismContainerWrapper<Containerable>> detailsModel = createDetailsModel(valueMetadataListItem.getModel());
Label label = new Label(ID_YIELD_HEADER, createDetailsDescriptionModel(detailsModel));
provenanceListItem.add(label);
label.add(new VisibleBehaviour(() -> provenanceListItem.getModelObject().isShowEmpty()));
MetadataContainerPanel<Containerable> defaultPanel = createDefaultPanel(detailsModel, provenanceListItem.getModel());
defaultPanel.add(new VisibleBehaviour(() -> !getModelObject().isShowMetadataDetails() && provenanceListItem.getModelObject().isShowEmpty()));
provenanceListItem.add(defaultPanel);
ItemPanelSettings settings = getSettings().copy();
settings.setVisibilityHandler(w -> createItemVisibilityBehavior(w));
ValueMetadataPanel<ValueMetadataType, PrismContainerValueWrapper<ValueMetadataType>> valueMetadataPanel = new ValueMetadataPanel<>(ID_VALUE_METADATA_DETAILS, valueMetadataListItem.getModel(), settings);
valueMetadataPanel.add(new VisibleBehaviour(() -> getModelObject().isShowMetadataDetails() && provenanceListItem.getModelObject().isShowEmpty()));
provenanceListItem.add(valueMetadataPanel);
}
use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.
the class ConstructionAssociationPanel method getAssociationsShadowRefs.
private List<ObjectReferenceType> getAssociationsShadowRefs(boolean compareName, QName name) {
List<ObjectReferenceType> shadowsList = new ArrayList<>();
try {
PrismContainerWrapper associationWrapper = getModelObject().findContainer(ConstructionType.F_ASSOCIATION);
associationWrapper.getValues().forEach(associationValueWrapper -> {
if (ValueStatus.DELETED.equals(((PrismContainerValueWrapper) associationValueWrapper).getStatus())) {
return;
}
PrismContainerValue associationValue = ((PrismContainerValueWrapper) associationValueWrapper).getNewValue();
ResourceObjectAssociationType assoc = (ResourceObjectAssociationType) associationValue.asContainerable();
if (assoc == null || assoc.getOutbound() == null || assoc.getOutbound().getExpression() == null || ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression(), getPageBase().getPrismContext()) == null) {
return;
}
if (compareName) {
QName assocRef = ItemPathTypeUtil.asSingleNameOrFailNullSafe(assoc.getRef());
if (name != null && name.equals(assocRef)) {
shadowsList.addAll(ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression(), getPageBase().getPrismContext()));
}
} else {
shadowsList.addAll(ExpressionUtil.getShadowRefValue(assoc.getOutbound().getExpression(), getPageBase().getPrismContext()));
}
});
} catch (SchemaException ex) {
// nothing?
}
return shadowsList;
}
use of com.evolveum.midpoint.gui.api.prism.wrapper.PrismContainerWrapper in project midpoint by Evolveum.
the class TaskTabsVisibility method computeOperationVisible.
public boolean computeOperationVisible(PageTask parentPage, PrismObjectWrapper<TaskType> taskWrapper) {
PrismContainerWrapper lensContext = null;
try {
lensContext = taskWrapper.findContainer(TaskType.F_MODEL_OPERATION_CONTEXT);
} catch (SchemaException ex) {
LOGGER.warn("Unable to find modelOperationContext in task {}", taskWrapper.getObject().asObjectable());
}
operationVisible = parentPage.isEditingFocus() && isTaskItemReadable(taskWrapper, TaskType.F_MODEL_OPERATION_CONTEXT) && lensContext != null && !lensContext.isEmpty();
return operationVisible;
}
Aggregations