Skip to content

Commit

Permalink
Work on repo support for certification work items. In progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 29, 2017
1 parent 05f5fa3 commit 9fda113
Show file tree
Hide file tree
Showing 18 changed files with 1,070 additions and 343 deletions.
Expand Up @@ -71,7 +71,8 @@ public CertCaseDto(AccessCertificationCaseType _case, PageBase page, Task task,
}
}
List<String> names = new ArrayList<>();
for (ObjectReferenceType reviewerRef : _case.getCurrentReviewerRef()) {
// TODO show by work items
for (ObjectReferenceType reviewerRef : CertCampaignTypeUtil.getReviewers(_case)) {
// TODO optimize - don't resolve reviewers twice
PrismObject<UserType> reviewerObject = WebModelServiceUtils.resolveReferenceRaw(reviewerRef, page, task, result);
if (reviewerObject != null) {
Expand Down
Expand Up @@ -337,4 +337,9 @@ public static List<AccessCertificationResponseType> getOutcomesToStopOn(List<Acc
rv.removeAll(advanceToNextStageOn);
return rv;
}

// TODO temporary implementation: replace by work items based approach where possible
public static List<ObjectReferenceType> getReviewers(AccessCertificationCaseType _case) {
throw new UnsupportedOperationException("TODO");
}
}
Expand Up @@ -800,13 +800,13 @@
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="currentReviewerRef" type="tns:ObjectReferenceType" minOccurs="0" maxOccurs="unbounded">
<xsd:element name="workItem" type="tns:AccessCertificationWorkItemType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Who are the reviewers? They are related to the stage mentioned in "currentStageNumber".
Work items for this stage. Some might be completed; however, they remains here until the stage is closed.
</xsd:documentation>
<xsd:appinfo>
<a:objectReferenceTargetType>tns:UserType</a:objectReferenceTargetType>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
Expand Down Expand Up @@ -874,7 +874,7 @@
A bit of hack. Sometimes it is necessary for a case (viewed out of context of any
campaign) point back to its owning certification campaign.

This is only a temporary information - not to be stored in the repository.
This is only a temporary information - not to be stored in the XML object in the repository.
It is used only for objects that are returned from certification API.

EXPERIMENTAL
Expand Down Expand Up @@ -902,6 +902,43 @@
<xsd:attribute name="id" type="xsd:long" use="optional"/>
</xsd:complexType>

<xsd:complexType name="AccessCertificationWorkItemType">
<xsd:annotation>
<xsd:documentation>
A work item for a certification case.
</xsd:documentation>
<xsd:appinfo>
<a:container/>
<a:since>3.6</a:since>
</xsd:appinfo>
</xsd:annotation>
<xsd:sequence>
<xsd:element name="originalReviewerRef" type="tns:ObjectReferenceType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
Original reviewer for this work item.
TODO allow also roles/orgs here.
</xsd:documentation>
<xsd:appinfo>
<a:objectReferenceTargetType>tns:UserType</a:objectReferenceTargetType>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
<xsd:element name="reviewerRef" type="tns:ObjectReferenceType" minOccurs="0" maxOccurs="unbounded">
<xsd:annotation>
<xsd:documentation>
Current reviewer(s) for this work item.
TODO allow also roles/orgs here.
</xsd:documentation>
<xsd:appinfo>
<a:objectReferenceTargetType>tns:UserType</a:objectReferenceTargetType>
</xsd:appinfo>
</xsd:annotation>
</xsd:element>
</xsd:sequence>
<xsd:attribute name="id" type="xsd:long" use="optional"/>
</xsd:complexType>

<xsd:complexType name="AccessCertificationAssignmentCaseType">
<xsd:annotation>
<xsd:appinfo>
Expand Down
Expand Up @@ -275,7 +275,8 @@ List<ItemDelta<?,?>> getDeltasToCreateCases(
_case.setCurrentReviewRequestedTimestamp(stage.getStart());
_case.setCurrentReviewDeadline(stage.getDeadline());

List<AccessCertificationDecisionType> decisions = createEmptyDecisionsForCase(_case.getCurrentReviewerRef(), 1);
// TODO create work items instead
List<AccessCertificationDecisionType> decisions = createEmptyDecisionsForCase(CertCampaignTypeUtil.getReviewers(_case), 1);
_case.getDecision().addAll(decisions);

final AccessCertificationResponseType currentStageOutcome = computationHelper
Expand All @@ -298,6 +299,7 @@ List<ItemDelta<?,?>> getDeltasToCreateCases(

// workaround for a query interpreter deficiency: we fill-in decisions when in stage 1
// (in order to be able to find cases that were not responded to by a given reviewer)
// TODO create work items instead!
private List<AccessCertificationDecisionType> createEmptyDecisionsForCase(List<ObjectReferenceType> forReviewers, int forStage) {
List<AccessCertificationDecisionType> decisions = new ArrayList<>();
for (ObjectReferenceType reviewer : forReviewers) {
Expand Down Expand Up @@ -393,8 +395,9 @@ List<ItemDelta<?,?>> getDeltasToAdvanceCases(AccessCertificationCampaignType cam
stageToBe);
rv.add(currentStageNumberDelta);

// TODO create work items instead
final List<AccessCertificationDecisionType> emptyDecisions = createEmptyDecisionsForCase(
_case.getCurrentReviewerRef(), stageToBe);
CertCampaignTypeUtil.getReviewers(_case), stageToBe);
final ItemDelta emptyDecisionsDelta = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext)
.item(F_CASE, caseId, F_DECISION).add(emptyDecisions.toArray())
.asItemDelta();
Expand Down
Expand Up @@ -64,7 +64,6 @@
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_CURRENT_STAGE_OUTCOME;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_CURRENT_STAGE_NUMBER;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_DECISION;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType.F_CURRENT_REVIEWER_REF;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDecisionType.F_COMMENT;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDecisionType.F_RESPONSE;
import static com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDecisionType.F_STAGE_NUMBER;
Expand Down Expand Up @@ -193,7 +192,7 @@ public void test240AddCases() throws Exception {
case100.setId(100L);
case100.setObjectRef(createObjectRef("100123", ObjectTypes.USER));
case100.setTargetRef(createObjectRef("100456", ObjectTypes.ROLE));
case100.getCurrentReviewerRef().add(createObjectRef("100789", ObjectTypes.USER));
//case100.getCurrentReviewerRef().add(createObjectRef("100789", ObjectTypes.USER));
case100.setCurrentStageNumber(1);

List<ItemDelta<?,?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext)
Expand All @@ -217,6 +216,7 @@ public void test242DeleteCase() throws Exception {
executeAndCheckModification(modifications, result, 0);
}

// FIXME!!!
@Test
public void test244ModifyCase() throws Exception {
OperationResult result = new OperationResult("test244ModifyCase");
Expand All @@ -226,11 +226,11 @@ public void test244ModifyCase() throws Exception {

PrismReferenceValue reviewerToDelete = createObjectRef("100789", ObjectTypes.USER).asReferenceValue();

List<ItemDelta<?,?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext)
.item(F_CASE, 100, F_CURRENT_REVIEWER_REF).delete(reviewerToDelete)
.asItemDeltas();

executeAndCheckModification(modifications, result, 0);
// List<ItemDelta<?,?>> modifications = DeltaBuilder.deltaFor(AccessCertificationCampaignType.class, prismContext)
// .item(F_CASE, 100, F_CURRENT_REVIEWER_REF).delete(reviewerToDelete)
// .asItemDeltas();
//
// executeAndCheckModification(modifications, result, 0);
}


Expand All @@ -248,7 +248,8 @@ public void test248AddDeleteModifyCase() throws Exception {
case110.setId(110L);
case110.setObjectRef(createObjectRef("x100123", ObjectTypes.USER));
case110.setTargetRef(createObjectRef("x100456", ObjectTypes.ROLE));
case110.getCurrentReviewerRef().add(createObjectRef("x100789", ObjectTypes.USER));
// FIXME!!!!
// case110.getCurrentReviewerRef().add(createObjectRef("x100789", ObjectTypes.USER));
case110.setCurrentStageNumber(1);

AccessCertificationCaseType case100 = new AccessCertificationCaseType();
Expand Down Expand Up @@ -340,7 +341,8 @@ public void test270ReplaceCase() throws Exception {
AccessCertificationCaseType caseNoId = new AccessCertificationCaseType(prismContext);
caseNoId.setObjectRef(createObjectRef("aaa", ObjectTypes.USER));
caseNoId.setTargetRef(createObjectRef("bbb", ObjectTypes.ROLE));
caseNoId.getCurrentReviewerRef().add(createObjectRef("ccc", ObjectTypes.USER));
// FIXME!!!!
// caseNoId.getCurrentReviewerRef().add(createObjectRef("ccc", ObjectTypes.USER));
caseNoId.setCurrentStageNumber(1);
caseNoId.getDecision().add(dec777);
caseNoId.getDecision().add(decNoId);
Expand Down

0 comments on commit 9fda113

Please sign in to comment.