Skip to content

Commit

Permalink
Merge branch 'post-3.7-fixes' into support-3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
KaterynaHonchar committed Jan 25, 2018
2 parents 536ba4e + d0afa4e commit 5c8c73a
Show file tree
Hide file tree
Showing 24 changed files with 1,682 additions and 102 deletions.
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2010-2018 Evolveum
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.evolveum.midpoint.gui.api.model;

import org.apache.wicket.model.AbstractReadOnlyModel;
import org.jetbrains.annotations.NotNull;

/**
* EXPERIMENTAL
* TODO better name
*
* @author mederly
*/
public class ReadOnlyValueModel<T> extends AbstractReadOnlyModel<T> {

@NotNull private final T object;

public ReadOnlyValueModel(@NotNull T object) {
this.object = object;
}

@Override
public T getObject() {
return object;
}
}
Expand Up @@ -46,7 +46,7 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.gui.api.SubscriptionType;
import com.evolveum.midpoint.gui.api.model.ReadOnlyModel;
import com.evolveum.midpoint.gui.api.model.ReadOnlyValueModel;
import com.evolveum.midpoint.model.api.ModelExecuteOptions;
import com.evolveum.midpoint.schema.GetOperationOptions;
import com.evolveum.midpoint.schema.SelectorOptions;
Expand Down Expand Up @@ -701,9 +701,10 @@ public List<T> getObject() {
};
}

// use for small enums only
@NotNull
public static <T extends Enum> IModel<List<T>> createReadonlyModelFromEnum(@NotNull Class<T> type, @NotNull Predicate<T> filter) {
return new ReadOnlyModel<>(() ->
public static <T extends Enum> IModel<List<T>> createReadonlyValueModelFromEnum(@NotNull Class<T> type, @NotNull Predicate<T> filter) {
return new ReadOnlyValueModel<>(
Arrays.stream(type.getEnumConstants())
.filter(filter)
.collect(Collectors.toList()));
Expand Down
Expand Up @@ -23,10 +23,7 @@
import javax.xml.namespace.QName;

import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.query.builder.S_AtomicFilterExit;
import com.evolveum.midpoint.prism.query.builder.S_FilterEntryOrEmpty;
import com.evolveum.midpoint.schema.constants.SchemaConstants;
import com.evolveum.midpoint.util.exception.SchemaException;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.web.page.admin.PageAdminFocus;
import com.evolveum.midpoint.web.page.admin.users.component.AssignmentInfoDto;
Expand Down Expand Up @@ -179,8 +176,8 @@ protected <T extends ObjectType> void addSelectedAssignmentsPerformed(AjaxReques
createNewAssignmentContainerValueWrapper(newAssignment);
}

refreshTable(target);

refreshTable(target);
reloadSavePreviewButtons(target);
}

protected List<IColumn<ContainerValueWrapper<AssignmentType>, String>> initColumns() {
Expand Down
Expand Up @@ -23,14 +23,14 @@
import com.evolveum.midpoint.gui.api.util.WebModelServiceUtils;
import com.evolveum.midpoint.prism.PrismContainerValue;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.web.component.objectdetails.FocusMainPanel;
import com.evolveum.midpoint.web.component.prism.*;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ActivationStatusType;
import org.apache.commons.lang.StringUtils;
import org.apache.wicket.AttributeModifier;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.DataTable;
import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
Expand Down Expand Up @@ -440,6 +440,7 @@ protected void deleteAssignmentPerformed(AjaxRequestTarget target, List<Containe
value.setSelected(false);
});
refreshTable(target);
reloadSavePreviewButtons(target);
}

protected ContainerValueWrapper<AssignmentType> createNewAssignmentContainerValueWrapper(PrismContainerValue<AssignmentType> newAssignment) {
Expand Down Expand Up @@ -511,4 +512,11 @@ private IModel<String> getActivationLabelModel(ContainerValueWrapper<AssignmentT

}


protected void reloadSavePreviewButtons(AjaxRequestTarget target){
FocusMainPanel mainPanel = findParent(FocusMainPanel.class);
if (mainPanel != null) {
mainPanel.reloadSavePreviewButtons(target);
}
}
}
Expand Up @@ -18,28 +18,27 @@
import com.evolveum.midpoint.gui.api.ComponentConstants;
import com.evolveum.midpoint.gui.api.component.tabs.CountablePanelTab;
import com.evolveum.midpoint.gui.api.component.tabs.PanelTab;
import com.evolveum.midpoint.gui.api.model.CountableLoadableModel;
import com.evolveum.midpoint.gui.api.model.LoadableModel;
import com.evolveum.midpoint.gui.api.page.PageBase;
import com.evolveum.midpoint.gui.api.util.FocusTabVisibleBehavior;
import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.prism.query.ObjectQuery;
import com.evolveum.midpoint.prism.query.builder.QueryBuilder;
import com.evolveum.midpoint.util.exception.SystemException;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.web.component.assignment.AssignmentDto;
import com.evolveum.midpoint.web.component.assignment.AssignmentEditorDto;
import com.evolveum.midpoint.web.component.assignment.AssignmentsUtil;
import com.evolveum.midpoint.web.component.form.Form;
import com.evolveum.midpoint.web.component.prism.ContainerValueWrapper;
import com.evolveum.midpoint.web.component.prism.ContainerWrapper;
import com.evolveum.midpoint.web.component.prism.ObjectWrapper;
import com.evolveum.midpoint.web.component.prism.ValueStatus;
import com.evolveum.midpoint.web.page.admin.PageAdminFocus;
import com.evolveum.midpoint.web.page.admin.PageAdminObjectDetails;
import com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoProvider;
import com.evolveum.midpoint.web.page.admin.server.dto.TaskDtoProviderOptions;
import com.evolveum.midpoint.web.page.admin.users.dto.FocusSubwrapperDto;
import com.evolveum.midpoint.web.page.admin.users.dto.UserDtoStatus;
import com.evolveum.midpoint.web.page.self.PageSelfProfile;
import com.evolveum.midpoint.web.util.OnePageParameterEncoder;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import org.apache.commons.lang.StringUtils;
Expand Down Expand Up @@ -310,18 +309,17 @@ protected boolean areSavePreviewButtonsEnabled(){
}

private boolean isAssignmentsModelChanged(){
// if (assignmentsModel == null && assignmentsModel.getObject() == null){
// return false;
// }
// if (assignmentsModel.getObject().isEmpty()){
// return false;
// }
// for (AssignmentType assignment : assignmentsModel.getObject()){
// //TODO check status
//// if (UserDtoStatus.DELETE.equals(dto.getStatus()) || UserDtoStatus.ADD.equals(dto.getStatus())){
// return true;
//// }
// }
ObjectWrapper<F> focusWrapper = getObjectModel().getObject();
ContainerWrapper<AssignmentType> assignmentsWrapper =
focusWrapper.findContainerWrapper(new ItemPath(FocusType.F_ASSIGNMENT));
if (assignmentsWrapper != null) {
for (ContainerValueWrapper assignmentWrapper : assignmentsWrapper.getValues()) {
if (ValueStatus.DELETED.equals(assignmentWrapper.getStatus()) ||
ValueStatus.ADDED.equals(assignmentWrapper.getStatus())) {
return true;
}
}
}
return false;
}

Expand Down
Expand Up @@ -69,7 +69,7 @@ protected void initLayout() {
createStringResource("ObjectType.description"), ID_LABEL_SIZE, ID_INPUT_SIZE, false);
add(description);

IModel choices = WebComponentUtil.createReadonlyModelFromEnum(ExportType.class, e -> e != ExportType.JXL);
IModel choices = WebComponentUtil.createReadonlyValueModelFromEnum(ExportType.class, e -> e != ExportType.JXL);
IChoiceRenderer renderer = new EnumChoiceRenderer();
DropDownFormGroup exportType = new DropDownFormGroup(ID_EXPORT_TYPE, new PropertyModel<ExportType>(getModel(), ReportDto.F_EXPORT_TYPE), choices, renderer,
createStringResource("ReportType.export"), ID_LABEL_SIZE, ID_INPUT_SIZE, true);
Expand Down
Expand Up @@ -114,8 +114,12 @@ protected TaskDto load() {
final Task operationTask = getTaskManager().createTaskInstance(OPERATION_LOAD_TASK);
final TaskType taskType = loadTaskTypeChecked(taskOid, operationTask, result);
currentTaskDto = prepareTaskDto(taskType, operationTask, result);
result.computeStatusIfUnknown();
if (!result.isSuccess()) {
showResult(result);
}
return currentTaskDto;
} catch (SchemaException|ObjectNotFoundException|ExpressionEvaluationException e) {
} catch (SchemaException e) {
throw new SystemException("Couldn't prepare task DTO: " + e.getMessage(), e);
}
}
Expand All @@ -142,7 +146,6 @@ protected List<NodeType> load() {
}
}
};
edit = false;
initLayout();
}

Expand All @@ -162,11 +165,6 @@ protected IModel<String> createPageTitleModel() {

private TaskType loadTaskTypeChecked(String taskOid, Task operationTask, OperationResult result) {
TaskType taskType = loadTaskType(taskOid, operationTask, result);

if (!result.isSuccess()) {
showResult(result);
}

if (taskType == null) {
getSession().error(getString("pageTaskEdit.message.cantTaskDetails"));
showResult(result, false);
Expand All @@ -182,7 +180,6 @@ public IModel<List<NodeType>> getNodeListModel() {

private TaskType loadTaskType(String taskOid, Task operationTask, OperationResult result) {
TaskType taskType = null;

try {
Collection<SelectorOptions<GetOperationOptions>> options = GetOperationOptions.retrieveItemsNamed(
TaskType.F_SUBTASK,
Expand All @@ -194,17 +191,15 @@ private TaskType loadTaskType(String taskOid, Task operationTask, OperationResul
new ItemPath(TaskType.F_WORKFLOW_CONTEXT, WfContextType.F_REQUESTER_REF)
));
taskType = getModelService().getObject(TaskType.class, taskOid, options, operationTask, result).asObjectable();
result.computeStatus();
} catch (Exception ex) {
result.recordFatalError("Couldn't get task.", ex);
}
return taskType;
}

private TaskDto prepareTaskDto(TaskType task, Task operationTask, OperationResult result) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
TaskDto taskDto = new TaskDto(task, null, getModelService(), getTaskService(), getModelInteractionService(),
private TaskDto prepareTaskDto(TaskType task, Task operationTask, OperationResult result) throws SchemaException {
return new TaskDto(task, null, getModelService(), getTaskService(), getModelInteractionService(),
getTaskManager(), getWorkflowManager(), TaskDtoProviderOptions.fullOptions(), operationTask, result, this);
return taskDto;
}


Expand Down Expand Up @@ -301,7 +296,7 @@ public Component getRefreshingBehaviorParent() {
return getRefreshPanel();
}

public void refreshTaskModels() {
private void refreshTaskModels() {
TaskDto oldTaskDto = taskDtoModel.getObject();
if (oldTaskDto == null) {
LOGGER.warn("Null or empty taskModel");
Expand All @@ -320,8 +315,13 @@ public void refreshTaskModels() {
currentTaskDto = newTaskDto;
taskDtoModel.setObject(newTaskDto);
objectWrapperModel.setObject(newWrapper);
} catch (ObjectNotFoundException|SchemaException|ExpressionEvaluationException|RuntimeException|Error e) {
} catch (SchemaException|RuntimeException|Error e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't refresh task {}", e, oldTaskDto);
result.recordFatalError("Couldn't refresh task: " + e.getMessage(), e);
}
result.computeStatusIfUnknown();
if (!result.isSuccess()) {
showResult(result);
}
}

Expand Down
Expand Up @@ -169,7 +169,7 @@ public class TaskDto extends Selectable implements InlineMenuable {
// (e.g. with subtasks, if they are needed) - a conservative approach to this is implemented in fillInChildren
public TaskDto(@NotNull TaskType taskType, TaskType parentTaskBean, ModelService modelService, TaskService taskService, ModelInteractionService modelInteractionService,
TaskManager taskManager, WorkflowManager workflowManager, TaskDtoProviderOptions options,
Task opTask, OperationResult parentResult, PageBase pageBase) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
Task opTask, OperationResult parentResult, PageBase pageBase) throws SchemaException {
Validate.notNull(modelService);
Validate.notNull(taskService);
Validate.notNull(modelInteractionService);
Expand All @@ -191,18 +191,33 @@ public TaskDto(@NotNull TaskType taskType, TaskType parentTaskBean, ModelService
fillInParentTaskAttributes(taskType, parentTaskBean, taskService, options, opTask, thisOpResult);
fillInOperationResultAttributes(taskType);
if (options.isRetrieveModelContext()) {
fillInModelContext(taskType, modelInteractionService, opTask, thisOpResult);
try {
fillInModelContext(taskType, modelInteractionService, opTask, thisOpResult);
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't retrieve model context for task {}", e, taskType);
// TODO make sure that op result contains the error (in common cases it is there)
}
}
if (options.isRetrieveWorkflowContext()) {
// TODO fill-in "cheap" wf attributes not only when this option is set
fillInWorkflowAttributes(taskType, modelInteractionService, workflowManager, pageBase.getPrismContext(), opTask, thisOpResult);
try {
fillInWorkflowAttributes(taskType, modelInteractionService, workflowManager, pageBase.getPrismContext(), opTask, thisOpResult);
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't retrieve workflow-related attributes from task {}", e, taskType);
// TODO make sure that op result contains the error (in common cases it is there)
}
}
thisOpResult.computeStatusIfUnknown();

fillFromExtension();

fillInChildren(taskType, modelService, taskService, modelInteractionService, taskManager, workflowManager, options,
opTask, parentResult, pageBase);
try {
fillInChildren(taskType, modelService, taskService, modelInteractionService, taskManager, workflowManager, options,
opTask, parentResult, pageBase);
} catch (CommonException | RuntimeException e) {
LoggingUtils.logUnexpectedException(LOGGER, "Couldn't retrieve children task information for task {}", e, taskType);
// TODO make sure that op result contains the error (in common cases it is there)
}

if (options.isCreateHandlerDto()) {
handlerDto = HandlerDtoFactory.instance().createDtoForTask(this, pageBase, opTask, thisOpResult);
Expand All @@ -217,7 +232,7 @@ public TaskDto(@NotNull TaskType taskType, TaskType parentTaskBean, ModelService
private void fillInChildren(@NotNull TaskType taskType, ModelService modelService, TaskService taskService,
ModelInteractionService modelInteractionService, TaskManager taskManager, WorkflowManager workflowManager,
TaskDtoProviderOptions options, Task opTask, OperationResult parentResult, PageBase pageBase)
throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException {
throws SchemaException {
TaskType thisTaskWithChildren = null;
for (TaskType child : taskType.getSubtask()) {
TaskDto childTaskDto = new TaskDto(child, thisTaskWithChildren, modelService, taskService, modelInteractionService,
Expand Down Expand Up @@ -325,8 +340,7 @@ private void fillInOperationResultAttributes(TaskType taskType) throws SchemaExc
}

private void fillInModelContext(TaskType taskType, ModelInteractionService modelInteractionService, Task opTask, OperationResult result) throws ObjectNotFoundException {
ModelContext ctx = ModelContextUtil.unwrapModelContext(taskType.getModelOperationContext(), modelInteractionService, opTask, result
);
ModelContext ctx = ModelContextUtil.unwrapModelContext(taskType.getModelOperationContext(), modelInteractionService, opTask, result);
if (ctx != null) {
modelOperationStatusDto = new ModelOperationStatusDto(ctx, modelInteractionService, opTask, result);
}
Expand Down
3 changes: 2 additions & 1 deletion gui/admin-gui/src/main/resources/static/js/midpoint-theme.js
Expand Up @@ -34,7 +34,8 @@ function clickFuncWicket6(eventData) {
|| (clickedElement.tagName.toUpperCase() == 'INPUT'
&& (clickedElement.type.toUpperCase() == 'BUTTON'
|| clickedElement.type.toUpperCase() == 'SUBMIT')))
&& clickedElement.parentNode.id.toUpperCase() != 'NOBUSY' ) {
&& clickedElement.parentNode.id.toUpperCase() != 'NOBUSY'
&& clickedElement.disabled == 'false') {
showAjaxStatusSign();
}
}
Expand Down

0 comments on commit 5c8c73a

Please sign in to comment.