Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
skublik committed Sep 30, 2021
2 parents a89e7ee + 0faa4a2 commit e8a3d81
Show file tree
Hide file tree
Showing 32 changed files with 264 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@
import java.util.*;

import com.evolveum.midpoint.gui.api.util.GuiDisplayTypeUtil;
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.gui.impl.util.ObjectCollectionViewUtil;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.model.common.util.DefaultColumnUtils;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.delta.ChangeType;
import com.evolveum.midpoint.prism.delta.ObjectDelta;
import com.evolveum.midpoint.schema.result.OperationResult;
Expand Down Expand Up @@ -204,7 +202,7 @@ public void onClick(AjaxRequestTarget target) {
}
}

if (getNewObjectInfluencesList().size() <= 1) {
if (!showNewObjectCreationPopup()) {
newObjectPerformed(target, null, getObjectCollectionView());
return;
}
Expand All @@ -228,6 +226,10 @@ protected void buttonClickPerformed(AjaxRequestTarget target, AssignmentObjectRe
return createNewObjectButton;
}

protected boolean showNewObjectCreationPopup() {
return getNewObjectInfluencesList() != null && getNewObjectInfluencesList().size() > 1;
}

protected boolean isViewForObjectCollectionType(CompiledObjectCollectionView collectionView, String oid, QName type) {
if (collectionView == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,6 @@ private void initLayout() {
tabbedPanel.setOutputMarkupId(true);
add(tabbedPanel);



DisplayNamePanel<C> displayNamePanel = createDisplayNamePanel(ID_DISPLAY_NAME);

displayNamePanel.setOutputMarkupId(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,26 +224,27 @@ public Collection<ObjectDeltaOperation<? extends ObjectType>> saveOrPreviewPerfo
LOGGER.trace("returning from saveOrPreviewPerformed");
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = executeChanges(deltas, previewOnly, options, task, result, target);

postProcessResult(result, executedDeltas);
postProcessResult(result, executedDeltas, target);

return executedDeltas;
}

protected void postProcessResult(OperationResult result, Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas) {
protected void postProcessResult(OperationResult result, Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas, AjaxRequestTarget target) {
result.computeStatusIfUnknown();

if (allowRedirectBack() && !result.isError()) { // && allowRedirectBack()) {
redirectBack();
} else {
target.add(getFeedbackPanel());
}
}

protected Collection<ObjectDeltaOperation<? extends ObjectType>> executeChanges(Collection<ObjectDelta<? extends ObjectType>> deltas, boolean previewOnly, ExecuteChangeOptionsDto options, Task task, OperationResult result, AjaxRequestTarget target) {
if (noChangesToExecute(deltas, options)) {
recordNoChangesWarning(result);

if (shouldBeStoppedProcessingOfChanges(deltas, options, previewOnly, target, result)) {
return null;
}

if (deltas.isEmpty()) {
result.recordWarning("PageAdminObjectDetails.noChangesSave");
showResult(result);
target.add(getFeedbackPanel());
redirectBack();
return null;
}
//TODO force
Expand All @@ -259,40 +260,23 @@ protected Collection<ObjectDeltaOperation<? extends ObjectType>> executeChanges(
ObjectChangeExecutor changeExecutor = getChangeExecutor();
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = changeExecutor.executeChanges(deltas, previewOnly, task, result, target);

result.computeStatusIfUnknown();
if (changeExecutor instanceof ObjectChangesExecutorImpl) {
showResult(result);
if (!previewOnly && result.isSuccess() && allowRedirectBack()) {
redirectBack();
} else {
target.add(getFeedbackPanel());
}
}

return executedDeltas;
}

protected boolean allowRedirectBack() {
return true;
protected boolean noChangesToExecute(Collection<ObjectDelta<? extends ObjectType>> deltas, ExecuteChangeOptionsDto options) {
return deltas.isEmpty();
}

protected boolean shouldBeStoppedProcessingOfChanges(Collection<ObjectDelta<? extends ObjectType>> deltas, ExecuteChangeOptionsDto options, boolean previewOnly, AjaxRequestTarget target, OperationResult result){
if (ItemStatus.NOT_CHANGED == getObjectDetailsModels().getObjectStatus()) {
if (deltas.isEmpty() && !options.isReconcile()) {
if (!previewOnly) {
result.recordWarning(getString("PageAdminObjectDetails.noChangesSave"));
showResult(result);
if (allowRedirectBack()) {
redirectBack();
}
} else {
warn(getString("PageAdminObjectDetails.noChangesPreview"));
target.add(getFeedbackPanel());
}
return true;
}
}
return false;
protected void recordNoChangesWarning(OperationResult result) {
result.recordWarning(getString("PageAdminObjectDetails.noChangesSave"));
}

protected boolean allowRedirectBack() {
return true;
}

protected ExecuteChangeOptionsDto getExecuteChangesOptionsDto() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ && getSearchModel().getObject().isTypeChanged()) {
super.refreshTable(target);
}

@Override
protected boolean showNewObjectCreationPopup() {
return CollectionUtils.isNotEmpty(getNewObjectReferencesList(getObjectCollectionView(), null));
}

@Override
protected List<ObjectReferenceType> getNewObjectReferencesList(CompiledObjectCollectionView collectionView, AssignmentObjectRelation relation) {
List<ObjectReferenceType> refList = super.getNewObjectReferencesList(collectionView, relation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,22 +155,19 @@ protected Collection<ObjectDeltaOperation<? extends ObjectType>> executeChanges(
return super.executeChanges(deltas, previewOnly, options, task, result, target);
}

// @Override
// protected final void saveOrPreviewPostProcess(AjaxRequestTarget target, Task task, ExecuteChangeOptionsDto options) {
// Fragment progressPanelFragment = new ProgressFragment(ID_DETAILS_VIEW, ID_PROGRESS_PANEL_FRAGMENT, PageFocusDetails.this, options);
// replace(progressPanelFragment);
// target.add(progressPanelFragment);
// }

// @Override
// protected void postProcessDeltas(AjaxRequestTarget target, Collection<ObjectDelta<? extends ObjectType>> deltas, ItemStatus status, ExecuteChangeOptionsDto executeChangeOptionsDto) throws SchemaException {
// super.postProcessDeltas(target, deltas, status, executeChangeOptionsDto);
//
// if (executeChangeOptionsDto.isReconcile() && deltas.isEmpty()) {
// ObjectDelta emptyDelta = getPrismContext().deltaFor(getType()).asObjectDelta(getModelPrismObject().getOid());
// deltas.add(emptyDelta);
// }
// }
@Override
protected void recordNoChangesWarning(OperationResult result) {
if (previewRequested) {
result.recordWarning(getString("PageAdminObjectDetails.noChangesPreview"));
} else {
super.recordNoChangesWarning(result);
}
}

@Override
protected boolean allowRedirectBack() {
return !previewRequested;
}

protected ProgressPanel getProgressPanel() {
return (ProgressPanel) get(createComponentPath(ID_DETAILS_VIEW, ID_PROGRESS_PANEL));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,43 +148,18 @@ public void saveAndRunPerformed(AjaxRequestTarget target) {
Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas = saveOrPreviewPerformed(target, saveResult, false);

if (!saveResult.isError()) {
OperationResult saveAndRunResult = new OperationResult(OPERATION_SAVE_AND_RUN_REPORT);
PrismObject<ReportType> report;
if (getModelObjectType().getOid() != null) {
report = getModelPrismObject();
} else {
report = (PrismObject<ReportType>) executedDeltas.iterator().next().getObjectDelta().getObjectToAdd();
}
PrismObject<ReportType> report = getReport(executedDeltas);
if (!ReportOperationalButtonsPanel.hasParameters(report.asObjectable())) {
try {
Task task = createSimpleTask(OPERATION_RUN_REPORT);
getReportManager().runReport(report, null, task, saveAndRunResult);
} catch (Exception ex) {
saveAndRunResult.recordFatalError(ex);
} finally {
saveAndRunResult.computeStatusIfUnknown();
showResult(saveAndRunResult);
redirectBack();
}

runReport(report, null);
} else {

RunReportPopupPanel runReportPopupPanel = new RunReportPopupPanel(getMainPopupBodyId(), report.asObjectable()) {

private static final long serialVersionUID = 1L;

protected void runConfirmPerformed(AjaxRequestTarget target, ReportType reportType, PrismContainer<ReportParameterType> reportParam) {
try {
Task task = createSimpleTask(OPERATION_RUN_REPORT);
getReportManager().runReport(reportType.asPrismObject(), reportParam, task, saveAndRunResult);
} catch (Exception ex) {
saveAndRunResult.recordFatalError(ex);
} finally {
saveAndRunResult.computeStatusIfUnknown();
}
protected void runConfirmPerformed(AjaxRequestTarget target, PrismObject<ReportType> report, PrismContainer<ReportParameterType> reportParam) {
runReport(report, reportParam);
hideMainPopup(target);
showResult(saveAndRunResult);
redirectBack();
}
};
showMainPopup(runReportPopupPanel, target);
Expand All @@ -195,6 +170,28 @@ protected void runConfirmPerformed(AjaxRequestTarget target, ReportType reportTy
}
}

private PrismObject<ReportType> getReport(Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas) {
if (getModelObjectType().getOid() != null) {
return getModelPrismObject();
}
return (PrismObject<ReportType>) executedDeltas.iterator().next().getObjectDelta().getObjectToAdd();

}

private void runReport(PrismObject<ReportType> report, PrismContainer<ReportParameterType> reportParam) {
Task task = createSimpleTask(OPERATION_RUN_REPORT);
OperationResult saveAndRunResult = task.getResult();
try {
getReportManager().runReport(report, reportParam, task, saveAndRunResult);
} catch (Exception ex) {
saveAndRunResult.recordFatalError(ex);
} finally {
saveAndRunResult.computeStatusIfUnknown();
saveAndRunResult.setBackgroundTaskOid(task.getOid());
redirectBack();
}
}

@Override
protected boolean allowRedirectBack() {
return !processingOfSaveAndRun;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,16 @@ protected void savePerformed(AjaxRequestTarget target) {
}

@Override
protected void postProcessResult(OperationResult result, Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas) {
protected void postProcessResult(OperationResult result, Collection<ObjectDeltaOperation<? extends ObjectType>> executedDeltas, AjaxRequestTarget target) {
if (executedDeltas == null) {
super.postProcessResult(result, executedDeltas, target);
return;
}
String taskOid = ObjectDeltaOperation.findFocusDeltaOidInCollection(executedDeltas);
if (taskOid != null) {
result.setBackgroundTaskOid(taskOid);
}
super.postProcessResult(result, executedDeltas, target);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,18 @@ protected UserDetailsModel createObjectDetailsModels(PrismObject<UserType> objec
return new UserDetailsModel(createPrismObejctModel(object), this);
}

private boolean delegationChangesExist = false;
@Override
protected boolean shouldBeStoppedProcessingOfChanges(Collection<ObjectDelta<? extends ObjectType>> deltas, ExecuteChangeOptionsDto options, boolean previewOnly, AjaxRequestTarget target, OperationResult result) {
protected Collection<ObjectDeltaOperation<? extends ObjectType>> executeChanges(Collection<ObjectDelta<? extends ObjectType>> deltas, boolean previewOnly, ExecuteChangeOptionsDto options, Task task, OperationResult result, AjaxRequestTarget target) {
if (ItemStatus.NOT_CHANGED == getObjectDetailsModels().getObjectStatus()) {
boolean delegationChangesExist = processDeputyAssignments(previewOnly);

if (deltas.isEmpty() && !options.isReconcile()) {
if (!previewOnly) {
if (!delegationChangesExist) {
result.recordWarning(getString("PageAdminObjectDetails.noChangesSave"));
showResult(result);
}
redirectBack();
} else {
if (!delegationChangesExist) {
warn(getString("PageAdminObjectDetails.noChangesPreview"));
target.add(getFeedbackPanel());
}
}
return true;
}
delegationChangesExist = processDeputyAssignments(previewOnly);
}
return false;
return super.executeChanges(deltas, previewOnly, options, task, result, target);
}

@Override
protected boolean noChangesToExecute(Collection<ObjectDelta<? extends ObjectType>> deltas, ExecuteChangeOptionsDto options) {
return deltas.isEmpty() && !options.isReconcile() && !delegationChangesExist;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ protected <PC extends ItemPanelContext> PC createPanelCtx(IModel<PrismContainerW
protected void onInitialize() {
super.onInitialize();

setOutputMarkupId(true);

add(AttributeModifier.append("class", () -> {
String cssClasses = "";
if (getModelObject() != null && ValueStatus.ADDED == getModelObject().getStatus()) {
Expand Down Expand Up @@ -220,8 +222,6 @@ protected void processSelectedChildren(AjaxRequestTarget target, List<PrismConta
}

private void prepareNewContainers(AjaxRequestTarget target, List<PrismContainerDefinition<?>> containers) {
getPageBase().hideMainPopup(target);

Task task = getPageBase().createSimpleTask("Create child containers");
WrapperContext ctx = new WrapperContext(task, task.getResult());
containers.forEach(container -> {
Expand Down Expand Up @@ -258,7 +258,7 @@ private ToggleIconButton<Void> getSortButton() {
}

private void refreshPanel(AjaxRequestTarget target) {
target.add(PrismContainerValuePanel.this);
target.add(PrismContainerValuePanel.this.findParent(ItemPanel.class));
target.add(getPageBase().getFeedbackPanel());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ protected void onInitialize() {

private void initLayout() {
MidpointForm<VW> form = new MidpointForm<>(ID_VALUE_FORM);
form.setOutputMarkupId(true);
add(form);
form.add(createHeaderPanel());

Expand Down Expand Up @@ -291,7 +292,7 @@ protected boolean isRemoveButtonVisible() {

}

private MidpointForm<VW> getForm() {
protected MidpointForm<VW> getForm() {
return (MidpointForm) get(ID_VALUE_FORM);
}

Expand All @@ -303,6 +304,10 @@ protected Component getValuePanel() {
return (Component) get(createComponentPath(ID_VALUE_FORM, ID_VALUE_CONTAINER, ID_INPUT));
}

protected Component getValueContainer() {
return (Component) get(createComponentPath(ID_VALUE_FORM, ID_VALUE_CONTAINER));
}

private ValueMetadataWrapperImpl getValueMetadata() {
return getModelObject().getValueMetadata();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
</tr>
</tbody>
</table>
<a class="btn btn-primary pull-right" wicket:id="select"/>
</div>
<p align="right">
<a class="btn btn-primary btn-sm" wicket:id="select"/>
<a class="btn btn-default btn-sm" wicket:id="cancelButton"/>
</p>
</wicket:panel>
</html>

0 comments on commit e8a3d81

Please sign in to comment.