Commit 47bdd63a authored by Jonathan Shahen's avatar Jonathan Shahen

Bulk work for Always On Reduction is done, support for empty Role Schedules,...

Bulk work for Always On Reduction is done, support for empty Role Schedules, FIXED a bug in the build script where the regression tests pointed to the wrong file
parent b4f583a8
......@@ -96,7 +96,7 @@
<target name="regression" depends="dist" description="Performs a regression test">
<!-- @author Jonathan Shahen -->
<junit haltonfailure="true" printsummary="true">
<test name="mohawk.converter.testing.RegressionTests" />
<test name="mohawk.converter.testing.ConverterRegressionTests" />
<formatter type="plain" usefile="false" />
<classpath refid="test.classpath" />
</junit>
......
......@@ -249,7 +249,9 @@ roleArray returns [ArrayList<Role> r] @init {
{$r.add($b.role);}
)* RightBracket
| a = myrole {$r.add($a.role);}
| a = myrole
{$r.add($a.role);}
;
timeslotArray returns [ArrayList<TimeSlot> t] @init {
......@@ -276,6 +278,7 @@ timeslotArray returns [ArrayList<TimeSlot> t] @init {
mohawkT.timeIntervalHelper.add(new TimeSlot($c.val));
}
| True
;
timeInterval returns [Integer t0, Integer t1]
......
......@@ -140,8 +140,13 @@ public class ConvertToASAPTimeNSA extends ConvertTo {
ArrayList<Integer> precondition = new ArrayList<Integer>();
// Convert RoleSchedule to the New Timeslots
for (TimeSlot ts : rule._roleSchedule) {
roleSchedule.addAll(timeIntervalHelper.indexOfReduced(ts));
if (rule._roleSchedule.size() != 0) {
for (TimeSlot ts : rule._roleSchedule) {
roleSchedule.addAll(timeIntervalHelper.indexOfReduced(ts));
}
} else {
// Grab all of the reduced timeslots
roleSchedule = timeIntervalHelper.indexOfReduced(timeIntervalHelper.getAllTimeInterval());
}
// Convert Preconditions to the Role Indexes
......
......@@ -37,17 +37,20 @@ public class ConvertToASAPTimeSA extends ConvertTo {
workableRules = m.roleHelper.removeEnableDisableRules(m.getAllRules());
// Reduce Roles to Integers
m.roleHelper.allowZeroRole = false; // roles start from 1 NOT 0!
m.roleHelper.setupSortedRoles();
// Reduce TimeIntervals to Timeslots
m.timeIntervalHelper.allowZeroTimeslot = false; // time-slots start from t1 NOT t0!
m.timeIntervalHelper.reduceToTimeslots();
// Convert Query to Reduced ASAPTime SA Query and add any extra rules as needed
ASAPTimeSA_Query query = toASAPTimeSA_Query(m.query, workableRules, m.roleHelper, m.timeIntervalHelper);
Query workableQuery = new Query(m.query);
workableRules = m.roleHelper.alwaysOnRules(workableRules, workableQuery, m.timeIntervalHelper);
// Reduce Roles to Integers
m.roleHelper.allowZeroRole = false; // roles start from 1 NOT 0!
m.roleHelper.setupSortedRoles();
workableRules = m.roleHelper.alwaysOnRules(workableRules, m.timeIntervalHelper);
// Convert Query to Reduced ASAPTime SA Query and add any extra rules as needed
ASAPTimeSA_Query query = toASAPTimeSA_Query(workableQuery, workableRules, m.roleHelper,
m.timeIntervalHelper);
// Convert Rules into Reduced ASAPTime SA Rules
for (Rule r : workableRules) {
......@@ -77,7 +80,7 @@ public class ConvertToASAPTimeSA extends ConvertTo {
} catch (Exception e) {
StringWriter errors = new StringWriter();
e.printStackTrace(new PrintWriter(errors));
logger.fine(errors.toString());
logger.warning(errors.toString());
logger.warning("[ERROR] Unable to convert to Ranise: " + e.getMessage());
lastError = "Error ConvertToRanise.convert.Exception #1";
......@@ -136,6 +139,7 @@ public class ConvertToASAPTimeSA extends ConvertTo {
*/
public ArrayList<ASAPTimeSA_Rule> toASAPTimeSA_Rules(Rule rule, RoleHelper roleHelper,
TimeIntervalHelper timeIntervalHelper) {
ArrayList<ASAPTimeSA_Rule> rules = new ArrayList<ASAPTimeSA_Rule>();
SortedSet<Integer> adminInterval = timeIntervalHelper.indexOfReduced(rule._adminTimeInterval);
......@@ -143,11 +147,17 @@ public class ConvertToASAPTimeSA extends ConvertTo {
ArrayList<Integer> precondition = new ArrayList<Integer>();
// Convert RoleSchedule to the New Timeslots
for (TimeSlot ts : rule._roleSchedule) {
roleSchedule.addAll(timeIntervalHelper.indexOfReduced(ts));
if (rule._roleSchedule.size() != 0) {
for (TimeSlot ts : rule._roleSchedule) {
roleSchedule.addAll(timeIntervalHelper.indexOfReduced(ts));
}
} else {
// Grab all of the reduced timeslots
roleSchedule = timeIntervalHelper.indexOfReduced(timeIntervalHelper.getAllTimeInterval());
}
// Convert Preconditions to the Role Indexes
// System.out.println("Rule: " + rule);
for (Role r : rule._preconditions) {
precondition.add(roleHelper.indexOf(r));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment