-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 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
41 changes: 41 additions & 0 deletions
41
service.impl/src/test/resources/rules/PoliticianBusySchedule.drl
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,41 @@ | ||
package com.hack23.cia.service.impl.rules | ||
|
||
import com.hack23.cia.model.internal.application.data.politician.impl.ViewRiksdagenPolitician | ||
import com.hack23.cia.service.api.action.kpi.Status | ||
import com.hack23.cia.service.impl.rules.PoliticianComplianceCheckImpl | ||
import java.util.Date | ||
import java.util.concurrent.TimeUnit | ||
|
||
function long busyFactor(Date firstAssignmentDate, long totalDaysServed){ | ||
return ( totalDaysServed / TimeUnit.MILLISECONDS.toDays(new Date().getTime() - firstAssignmentDate.getTime()) ); | ||
} | ||
|
||
rule "We have an politician with busy schedule, at least on average more than 4 concurrent roles per day" | ||
dialect "java" | ||
when | ||
$p : PoliticianComplianceCheckImpl( politician.active == true && ( busyFactor(politician.firstAssignmentDate, politician.totalDaysServed ) > 4 )) | ||
then | ||
modify( $p ) { | ||
setStatus( Status.MINOR ) | ||
} | ||
end | ||
|
||
rule "We have an politician with busy schedule, at least on average more than 5 concurrent roles per day" | ||
dialect "java" | ||
when | ||
$p : PoliticianComplianceCheckImpl( politician.active == true && ( busyFactor(politician.firstAssignmentDate, politician.totalDaysServed ) > 5 )) | ||
then | ||
modify( $p ) { | ||
setStatus( Status.MAJOR ) | ||
} | ||
end | ||
|
||
rule "We have an politician with busy schedule, at least on average more than 7 concurrent roles per day" | ||
dialect "java" | ||
when | ||
$p : PoliticianComplianceCheckImpl( politician.active == true && ( busyFactor(politician.firstAssignmentDate, politician.totalDaysServed ) > 6 )) | ||
then | ||
modify( $p ) { | ||
setStatus( Status.CRITICAL ) | ||
} | ||
end |