* @return
*/
// TODO: remove this temporary method
@SuppressWarnings("unchecked")
public ObjectNode getIntervals() {
ObjectNode intervals = JOM.createObjectNode();
List<Interval> infeasible = (List<Interval>) getState().get("infeasible");
List<Weight> preferred = (List<Weight>) getState().get("preferred");
List<Weight> solutions = calculateSolutions();
// merge the intervals
List<Interval> mergedInfeasible = null;
List<Weight> mergedPreferred = null;
if (infeasible != null) {
mergedInfeasible = IntervalsUtil.merge(infeasible);
}
if (preferred != null) {
mergedPreferred = WeightsUtil.merge(preferred);
}
if (infeasible != null) {
ArrayNode arr = JOM.createArrayNode();
for (Interval interval : infeasible) {
ObjectNode o = JOM.createObjectNode();
o.put("start", interval.getStart().toString());
o.put("end", interval.getEnd().toString());
arr.add(o);
}
intervals.put("infeasible", arr);
}
if (preferred != null) {
ArrayNode arr = JOM.createArrayNode();
for (Weight weight : preferred) {
ObjectNode o = JOM.createObjectNode();
o.put("start", weight.getStart().toString());
o.put("end", weight.getEnd().toString());
o.put("weight", weight.getWeight());
arr.add(o);
}
intervals.put("preferred", arr);
}
if (solutions != null) {
ArrayNode arr = JOM.createArrayNode();
for (Weight weight : solutions) {
ObjectNode o = JOM.createObjectNode();
o.put("start", weight.getStart().toString());
o.put("end", weight.getEnd().toString());
o.put("weight", weight.getWeight());
arr.add(o);
}
intervals.put("solutions", arr);
}
if (mergedInfeasible != null) {
ArrayNode arr = JOM.createArrayNode();
for (Interval i : mergedInfeasible) {
ObjectNode o = JOM.createObjectNode();
o.put("start", i.getStart().toString());
o.put("end", i.getEnd().toString());
arr.add(o);
}
intervals.put("mergedInfeasible", arr);
}
if (mergedPreferred != null) {
ArrayNode arr = JOM.createArrayNode();
for (Weight wi : mergedPreferred) {
ObjectNode o = JOM.createObjectNode();
o.put("start", wi.getStart().toString());
o.put("end", wi.getEnd().toString());
o.put("weight", wi.getWeight());
arr.add(o);
}
intervals.put("mergedPreferred", arr);
}