Skip to content

Commit

Permalink
Configurable deadline rounding for certification stages.
Browse files Browse the repository at this point in the history
  • Loading branch information
mederly committed Mar 3, 2017
1 parent 9c254aa commit 8048da6
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 18 deletions.
Expand Up @@ -193,7 +193,14 @@
<xsd:element name="duration" type="xsd:duration" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
How long should the stage last? The resulting time is rounded up to 23:59:59 of the resulting day.
How long should the stage last?
</xsd:documentation>
</xsd:annotation>
</xsd:element>
<xsd:element name="deadlineRounding" type="c:DeadlineRoundingType" minOccurs="0">
<xsd:annotation>
<xsd:documentation>
How to round the deadline (if at all)? The default is to 23:59:59 of the computed day.
</xsd:documentation>
</xsd:annotation>
</xsd:element>
Expand Down
Expand Up @@ -923,7 +923,7 @@
<xsd:simpleType name="BeforeAfterType">
<xsd:annotation>
<xsd:documentation>
An enumeration that defines when the activity will be excuted.
An enumeration that defines when the activity will be executed.
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
Expand All @@ -950,6 +950,45 @@
</xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="DeadlineRoundingType">
<xsd:annotation>
<xsd:documentation>
Way of rounding deadline(s) e.g. for certification or approval stages.
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="none">
<xsd:annotation>
<xsd:documentation>
The deadline will not be rounded.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="NONE"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="hour">
<xsd:annotation>
<xsd:documentation>
The deadline will be rounded to 59:59 of the computed hour.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="HOUR"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
<xsd:enumeration value="day">
<xsd:annotation>
<xsd:documentation>
The deadline will be rounded to 23:59:59 of the computed day.
</xsd:documentation>
<xsd:appinfo>
<jaxb:typesafeEnumMember name="DAY"/>
</xsd:appinfo>
</xsd:annotation>
</xsd:enumeration>
</xsd:restriction>
</xsd:simpleType>

<xsd:complexType name="NodeType">
<xsd:annotation>
Expand Down
Expand Up @@ -51,15 +51,7 @@
import com.evolveum.midpoint.util.logging.LoggingUtils;
import com.evolveum.midpoint.util.logging.Trace;
import com.evolveum.midpoint.util.logging.TraceManager;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignStateType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCampaignType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationCaseType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationStageDefinitionType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.AccessCertificationStageType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.TriggerType;
import com.evolveum.midpoint.xml.ns._public.common.common_3.*;
import com.evolveum.prism.xml.ns._public.types_3.PolyStringType;
import org.apache.commons.lang3.Validate;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -282,10 +274,18 @@ protected AccessCertificationStageType createStage(AccessCertificationCampaignTy
if (stageDef.getDuration() != null) {
deadline.add(stageDef.getDuration());
}
deadline.setHour(23);
deadline.setMinute(59);
deadline.setSecond(59);
deadline.setMillisecond(999);
DeadlineRoundingType rounding = stageDef.getDeadlineRounding() != null ?
stageDef.getDeadlineRounding() : DeadlineRoundingType.DAY;
switch (rounding) {
case DAY:
deadline.setHour(23);
case HOUR:
deadline.setMinute(59);
deadline.setSecond(59);
deadline.setMillisecond(999);
case NONE:
// nothing here
}
stage.setDeadline(deadline);

stage.setName(stageDef.getName());
Expand Down
Expand Up @@ -78,6 +78,8 @@ public void initSystem(Task initTask, OperationResult initResult) throws Excepti
roleATest3xOid = addAndRecompute(ROLE_A_TEST_3X, initTask, initResult);
roleATest3yOid = addAndRecompute(ROLE_A_TEST_3Y, initTask, initResult);

assignOrg(USER_JACK_OID, ORG_SECURITY_TEAM_OID, initTask, initResult);

assignRole(USER_JACK_OID, roleATest2aOid);
assignRole(USER_JACK_OID, roleATest2bOid);
assignRole(USER_JACK_OID, roleATest3aOid);
Expand Down
Expand Up @@ -69,6 +69,7 @@ jack->CTO none (A) -> A none (A) -> A | A
<stageDefinition>
<number>1</number>
<duration>P3D</duration>
<deadlineRounding>hour</deadlineRounding>
<reviewerSpecification>
<useObjectManager>
<orgType>functional</orgType>
Expand All @@ -82,6 +83,7 @@ jack->CTO none (A) -> A none (A) -> A | A
<stageDefinition>
<number>2</number>
<duration>P7D</duration>
<deadlineRounding>none</deadlineRounding>
<reviewerSpecification>
<useTargetOwner>true</useTargetOwner>
</reviewerSpecification>
Expand Down
Expand Up @@ -36,9 +36,6 @@
<assignment id="3">
<targetRef oid="00000000-d34d-b33f-f00d-ffffffff0000" type="c:RoleType"/> <!-- reviewer -->
</assignment>
<assignment id="4">
<targetRef oid="e015eb10-1426-4104-86c0-eb0cf9dc423f" type="c:OrgType"/> <!-- Security Team -->
</assignment>

<activation>
<administrativeStatus>enabled</administrativeStatus>
Expand Down
1 change: 1 addition & 0 deletions model/certification-impl/testng-integration.xml
Expand Up @@ -21,6 +21,7 @@
<class name="com.evolveum.midpoint.certification.test.BasicCertificationTest"/>
<class name="com.evolveum.midpoint.certification.test.RoleInducementCertificationTest"/>
<class name="com.evolveum.midpoint.certification.test.CriticalRolesCertificationTest"/>
<class name="com.evolveum.midpoint.certification.test.SoDCertificationTest"/>
</classes>
</test>
</suite>

0 comments on commit 8048da6

Please sign in to comment.