use of com.evolveum.midpoint.model.api.AssignmentObjectRelation in project midpoint by Evolveum.
the class ChooseMemberPopup method getAssignButtonDescription.
private List<CompositedIconButtonDto> getAssignButtonDescription() {
List<CompositedIconButtonDto> additionalAssignmentButtons = new ArrayList<>();
List<AssignmentObjectRelation> assignmentObjectRelations = WebComponentUtil.divideAssignmentRelationsByAllValues(loadMemberRelationsList());
if (assignmentObjectRelations != null) {
assignmentObjectRelations.forEach(relation -> {
DisplayType additionalDispayType = GuiDisplayTypeUtil.getAssignmentObjectRelationDisplayType(ChooseMemberPopup.this.getPageBase(), relation, "abstractRoleMemberPanel.menu.assignMember");
CompositedIconBuilder builder = WebComponentUtil.getAssignmentRelationIconBuilder(ChooseMemberPopup.this.getPageBase(), relation, additionalDispayType.getIcon(), WebComponentUtil.createIconType(GuiStyleConstants.EVO_ASSIGNMENT_ICON, "green"));
CompositedIcon icon = builder.build();
CompositedIconButtonDto buttonDto = createCompositedIconButtonDto(additionalDispayType, relation, icon);
additionalAssignmentButtons.add(buttonDto);
});
}
additionalAssignmentButtons.add(createCompositedIconButtonDto(getAssignMemberButtonDisplayType(), null, null));
return additionalAssignmentButtons;
}
use of com.evolveum.midpoint.model.api.AssignmentObjectRelation in project midpoint by Evolveum.
the class ChooseMemberPopup method onInitialize.
@Override
protected void onInitialize() {
super.onInitialize();
Form form = new Form(ID_FORM);
form.setOutputMarkupId(true);
add(form);
IModel<List<CompositedIconButtonDto>> assignButtonDescriptionModel = createAssignButtonDescriptionModel();
MultiCompositedButtonPanel assignDescriptionButtonsPanel = new MultiCompositedButtonPanel(ID_COMPOSITED_BUTTONS, assignButtonDescriptionModel) {
private static final long serialVersionUID = 1L;
@Override
protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
Form form = (Form) ChooseMemberPopup.this.get(ID_FORM);
isCompositedButtonsPanelVisible = false;
addOrReplaceTabPanels(form, relationSpec);
target.add(form);
}
};
form.add(assignDescriptionButtonsPanel);
assignDescriptionButtonsPanel.add(new VisibleBehaviour(() -> isCompositedButtonsPanelVisible));
addOrReplaceTabPanels(form, null);
AjaxButton cancelButton = new AjaxButton(ID_CANCEL_BUTTON, createStringResource("userBrowserDialog.button.cancelButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
}
};
cancelButton.setOutputMarkupId(true);
form.add(cancelButton);
AjaxButton addButton = new AjaxButton(ID_ADD_BUTTON, createStringResource("userBrowserDialog.button.addButton")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
boolean orgPanelProcessed = false;
for (ITab panelTab : tabs) {
WebMarkupContainer tabPanel = ((CountablePanelTab) panelTab).getPanel();
if (tabPanel == null) {
continue;
}
MemberPopupTabPanel memberPanel = (MemberPopupTabPanel) tabPanel;
if (memberPanel.getObjectType().equals(ObjectTypes.ORG) && orgPanelProcessed) {
continue;
}
List<ObjectType> selectedObjects = memberPanel.getObjectType().equals(ObjectTypes.ORG) ? memberPanel.getPreselectedObjects() : memberPanel.getSelectedObjectsList();
if (selectedObjects == null || selectedObjects.size() == 0) {
continue;
}
executeMemberOperation(memberPanel.getAbstractRoleTypeObject(), createInOidQuery(selectedObjects), memberPanel.getRelationValue(), memberPanel.getObjectType().getTypeQName(), target, getPageBase());
if (memberPanel.getObjectType().equals(ObjectTypes.ORG)) {
orgPanelProcessed = true;
}
}
ChooseMemberPopup.this.getPageBase().hideMainPopup(target);
}
};
addButton.add(AttributeAppender.append("title", getAddButtonTitleModel()));
addButton.add(new EnableBehaviour(() -> isAddButtonEnabled()));
addButton.setOutputMarkupId(true);
form.add(addButton);
}
use of com.evolveum.midpoint.model.api.AssignmentObjectRelation in project midpoint by Evolveum.
the class ResourceTasksPanel method initLayout.
protected void initLayout() {
final MainObjectListPanel<TaskType> tasksPanel = new MainObjectListPanel<>(ID_TASKS_TABLE, TaskType.class, null) {
private static final long serialVersionUID = 1L;
@Override
protected UserProfileStorage.TableId getTableId() {
return UserProfileStorage.TableId.PAGE_RESOURCE_TASKS_PANEL;
}
@Override
protected ISelectableDataProvider<TaskType, SelectableBean<TaskType>> createProvider() {
return createSelectableBeanObjectDataProvider(() -> createResourceTasksQuery(), null);
}
@Override
protected List<InlineMenuItem> createInlineMenu() {
return null;
}
@Override
protected void newObjectPerformed(AjaxRequestTarget target, AssignmentObjectRelation relation, CompiledObjectCollectionView collectionView) {
if (collectionView == null) {
collectionView = getObjectCollectionView();
}
List<ObjectReferenceType> archetypeRef = ObjectCollectionViewUtil.getArchetypeReferencesList(collectionView);
try {
PrismContext prismContext = getPrismContext();
PrismObjectDefinition<TaskType> def = prismContext.getSchemaRegistry().findObjectDefinitionByType(TaskType.COMPLEX_TYPE);
PrismObject<TaskType> obj = def.instantiate();
TaskType newTask = obj.asObjectable();
ObjectReferenceType resourceRef = new ObjectReferenceType();
resourceRef.setOid(ResourceTasksPanel.this.getObjectWrapper().getOid());
resourceRef.setType(ResourceType.COMPLEX_TYPE);
newTask.setObjectRef(resourceRef);
WebComponentUtil.initNewObjectWithReference(getPageBase(), newTask, archetypeRef);
} catch (SchemaException ex) {
getPageBase().getFeedbackMessages().error(ResourceTasksPanel.this, ex.getUserFriendlyMessage());
target.add(getPageBase().getFeedbackPanel());
}
}
@Override
protected List<IColumn<SelectableBean<TaskType>, String>> createDefaultColumns() {
return ColumnUtils.getDefaultTaskColumns();
}
@Override
protected List<CompiledObjectCollectionView> getNewObjectInfluencesList() {
List<CompiledObjectCollectionView> newObjectInfluencesList = super.getNewObjectInfluencesList();
List<CompiledObjectCollectionView> filteredInfluencesList = new ArrayList<>();
if (newObjectInfluencesList != null) {
newObjectInfluencesList.forEach(influence -> {
if (influence.getCollection() != null && influence.getCollection().getCollectionRef() != null && ArrayUtils.contains(resourceTaskArchetypeOids, influence.getCollection().getCollectionRef().getOid())) {
filteredInfluencesList.add(influence);
}
});
}
return filteredInfluencesList;
}
};
tasksPanel.setAdditionalBoxCssClasses(GuiStyleConstants.CLASS_OBJECT_TASK_BOX_CSS_CLASSES);
add(tasksPanel);
AjaxButton runNow = new AjaxButton(ID_RUN_NOW, getPageBase().createStringResource("pageTaskEdit.button.runNow")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<String> oids = createOidList(getTaskListPanel().getSelectedRealObjects());
if (!oids.isEmpty()) {
OperationResult result = TaskOperationUtils.runNowPerformed(oids, getPageBase());
getPageBase().showResult(result);
} else {
noTasksSelected();
}
target.add(getPageBase().getFeedbackPanel());
}
};
add(runNow);
AjaxButton resume = new AjaxButton(ID_RESUME, getPageBase().createStringResource("pageTaskEdit.button.resume")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
if (!tasks.isEmpty()) {
OperationResult result = TaskOperationUtils.resumeTasks(tasks, getPageBase());
getPageBase().showResult(result);
} else {
noTasksSelected();
}
target.add(getPageBase().getFeedbackPanel());
}
};
add(resume);
AjaxButton suspend = new AjaxButton(ID_SUSPEND, getPageBase().createStringResource("pageTaskEdit.button.suspend")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick(AjaxRequestTarget target) {
List<TaskType> tasks = getTaskListPanel().getSelectedRealObjects();
if (!tasks.isEmpty()) {
OperationResult result = TaskOperationUtils.suspendTasks(tasks, getPageBase());
getPageBase().showResult(result);
} else {
noTasksSelected();
}
target.add(getPageBase().getFeedbackPanel());
}
};
add(suspend);
}
use of com.evolveum.midpoint.model.api.AssignmentObjectRelation in project midpoint by Evolveum.
the class PageSystemConfiguration method initLayout.
private void initLayout() {
IModel<List<CompositedIconButtonDto>> model = Model.ofList(Arrays.asList(createCompositedButton("fa fa-wrench", PageSystemBasic.class), createCompositedButton("fa fa-camera", PageSystemPolicies.class), createCompositedButton("fa fa-envelope", PageSystemNotification.class), createCompositedButton("fa fa-file-text", PageSystemLogging.class), createCompositedButton("fa fa-camera", PageProfiling.class), createCompositedButton("fa fa-camera", PageSystemAdminGui.class), createCompositedButton("fa fa-camera", PageSystemWorkflow.class), createCompositedButton("fa fa-camera", PageRoleManagement.class), createCompositedButton("fa fa-camera", PageSystemInternals.class), createCompositedButton("fa fa-camera", PageAccessCertification.class)));
MultiCompositedButtonPanel panel = new MultiCompositedButtonPanel(ID_CONTAINER, model) {
@Override
protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRelation relationSpec, CompiledObjectCollectionView collectionViews, Class<? extends WebPage> page) {
navigateToNext(page);
}
};
panel.add(AttributeModifier.append("class", " row"));
add(panel);
}
use of com.evolveum.midpoint.model.api.AssignmentObjectRelation 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);
}
Aggregations