Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix case approval state visualization
The semantics of ApprovalSchemaExecutionInformationType was more clearly defined and the code for its handling radically simplified. The stage/executionRecord part was deprecated and eliminated. See also https://wiki.evolveum.com/display/midPoint/How+to+display+approval+case+%28planned+or+real%29+execution.
- Loading branch information
Showing
21 changed files
with
2,129 additions
and
1,690 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...c/main/java/com/evolveum/midpoint/schema/util/ApprovalSchemaExecutionInformationUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.schema.util; | ||
|
||
import com.evolveum.midpoint.prism.PrismObject; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalSchemaExecutionInformationType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.ApprovalStageExecutionInformationType; | ||
import com.evolveum.midpoint.xml.ns._public.common.common_3.CaseType; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Objects; | ||
|
||
public class ApprovalSchemaExecutionInformationUtil { | ||
public static ApprovalStageExecutionInformationType getStage(ApprovalSchemaExecutionInformationType executionInfo, int number) { | ||
return executionInfo.getStage().stream() | ||
.filter(i -> Objects.equals(number, i.getNumber())) | ||
.findAny() | ||
.orElse(null); | ||
} | ||
|
||
@NotNull | ||
public static PrismObject<CaseType> getEmbeddedCase(ApprovalSchemaExecutionInformationType executionInfo) { | ||
if (executionInfo.getCaseRef() == null) { | ||
throw new IllegalStateException("No caseRef in " + executionInfo); | ||
} else if (executionInfo.getCaseRef().getObject() == null) { | ||
throw new IllegalStateException("No caseRef.object in " + executionInfo); | ||
} else { | ||
//noinspection unchecked | ||
return executionInfo.getCaseRef().getObject(); | ||
} | ||
} | ||
|
||
@NotNull | ||
public static CaseType getEmbeddedCaseBean(ApprovalSchemaExecutionInformationType executionInfo) { | ||
return getEmbeddedCase(executionInfo).asObjectable(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
infra/schema/src/main/java/com/evolveum/midpoint/schema/util/CaseEventUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2020 Evolveum and contributors | ||
* | ||
* This work is dual-licensed under the Apache License 2.0 | ||
* and European Union Public License. See LICENSE file for details. | ||
*/ | ||
|
||
package com.evolveum.midpoint.schema.util; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import com.evolveum.midpoint.xml.ns._public.common.common_3.*; | ||
|
||
public class CaseEventUtil { | ||
|
||
public static boolean completedByUserAction(WorkItemEventType event) { | ||
WorkItemEventCauseInformationType cause = event.getCause(); | ||
return event.getInitiatorRef() != null && | ||
(cause == null || | ||
cause.getType() == null || | ||
cause.getType() == WorkItemEventCauseTypeType.USER_ACTION); | ||
} | ||
|
||
public static List<CaseEventType> getEventsForStage(CaseType aCase, int stageNumber) { | ||
return aCase.getEvent().stream() | ||
.filter(e -> java.util.Objects.equals(e.getStageNumber(), stageNumber)) | ||
.collect(Collectors.toList()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.