Skip to content

Commit

Permalink
Merge branch 'post-3.7-fixes' of https://github.com/Evolveum/midpoint
Browse files Browse the repository at this point in the history
…into post-3.7-fixes
  • Loading branch information
KaterynaHonchar committed Jan 25, 2018
2 parents 9fe7f2f + e77c314 commit 467079c
Show file tree
Hide file tree
Showing 20 changed files with 1,654 additions and 78 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 @@ -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
Expand Up @@ -13212,6 +13212,17 @@
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="lifecycleStateModel" type="tns:LifecycleStateModelType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Specification of lifecycle states and state transitions.
</xsd:documentation>
<xsd:appinfo>
<a:since>3.7.1</a:since>
<a:experimental>true</a:experimental>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
</xsd:complexType>

Expand Down Expand Up @@ -17463,6 +17474,13 @@
<a:objectReferenceTargetType>tns:FormType</a:objectReferenceTargetType>
</xsd:appinfo>
</xsd:annotation>
<!-- Later on the referenced form may also contain title, panelClass and panelUri.
Equivalent elements from this data type may be used to override those specified
in FormType object referenced from this formRef.
However, not all combination have to be supported. E.g. if the FormType object
specifies a declarative form and this FormSpecificationType specifies panelClass
then an error should be raised.
-->
</xsd:element>
<xsd:element name="panelClass" type="xsd:string" minOccurs="0" maxOccurs="1">
<xsd:annotation>
Expand Down Expand Up @@ -17502,9 +17520,22 @@
</p>
</xsd:documentation>
</xsd:annotation>
<!-- Originally (approx. midPoint 3.4) this datat type was meant ony for specificaiton of "declarative"
forms that specify fields for items. But later (3.7.1) it was discovered that this should be
reused to specify wider range of forms. E.g. parameteric built-in forms (such as "data protection" tab).
Or even parametric declarative or custom forms. No schema changes were made in 3.7.1.
Use case: specify "data protection" tab filter, layout and columns in just one place in the system
(FormType object). And the reuse the specification at several places (e.g. adminGuiConfig in several roles).
The schema change was just analysed, planned and clarified in those comments.
-->
<xsd:complexContent>
<xsd:extension base="c:ObjectType">
<xsd:sequence>
<!-- includeRef and formDefinition are used to specify "declarative" custom form.
Ideally, this should be insided its own container. But as this was not done
originally (approx. midPoint 3.4) we cannot change it now. So we leave it as
it is.
-->
<xsd:element name="includeRef" type="tns:ObjectReferenceType"
minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
Expand All @@ -17521,6 +17552,7 @@
It has to be a prism property. -->
</xsd:element>
</xsd:sequence>
<!-- title, panelClass and panelUri from FormSpecificationType should be also present here. -->
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
Expand Down

0 comments on commit 467079c

Please sign in to comment.