public TreeNodeOngoing(int clusterId, TimeInterval interval) throws Exception { this.clusterId = clusterId; this.interval = interval; if( interval.isOngoing() ) { this.mid = interval.getMin(); } else { throw new Exception("Must be providing an on-going time interval"); } }
public TreeNodeRegular(int clusterId, TimeInterval interval) throws Exception { this.clusterId = clusterId; this.interval = interval; if( interval.isOngoing() ) { throw new Exception("Must be providing a regular time interval"); } else { this.mid = (long)(interval.getMin() + interval.getMax(null)) / (long)2; } }
static private JSONObject saveNode(TreeNode node) throws Exception { JSONObject jsonNode = new JSONObject(); TimeInterval nodeInterval = node.getInterval(); jsonNode.put("id", node.getClusterId()); jsonNode.put("min", nodeInterval.getMin()); if( nodeInterval.isOngoing() ){ jsonNode.put("ongoing", true); } else { jsonNode.put("max", node.getInterval().getMax(null)); } jsonNode.put("mid", node.getMidPoint()); TreeNode lowChildNode = node.getLowChildNode(); if( null != lowChildNode ){ JSONObject jsonChild = saveNode(lowChildNode); jsonNode.put("l",jsonChild); } TreeNode highChildNode = node.getHighChildNode(); if( null != highChildNode ){ JSONObject jsonChild = saveNode(highChildNode); jsonNode.put("h",jsonChild); } return jsonNode; }
String minStr = ""+nodeInterval.getMin(); String maxStr = "now"; if( !nodeInterval.isOngoing() ){
if( elemInt.getMin() <= this.getMidPoint() && null != this.getLowChildNode() ){ this.getLowChildNode().insertElement(element, result, operations, now); } else if( elemInt.getMin() > this.getMidPoint() && null != this.getHighChildNode() ){ this.getHighChildNode().insertElement(element, result, operations, now); && elemInt.getMin() <= this.getMidPoint() ){ List<TreeElement> nodeElements = operations.getElementsForClusterId(this.getClusterId()); int count = nodeElements.size(); && elemInt.getMin() > this.getMidPoint() ){ List<TreeElement> nodeElements = operations.getElementsForClusterId(this.getClusterId()); int count = nodeElements.size();
this.getLowChildNode().insertElement(element, result, operations, now); } else if( elemInt.getMin() >= this.getMidPoint() && null != this.getHighChildNode() ){ this.getHighChildNode().insertElement(element, result, operations, now); && elemInt.getMin() >= this.getMidPoint() ){ int count = 1; List<TreeElement> nodeElements = operations.getElementsForClusterId(this.getClusterId()); for(TreeElement nodeElement : nodeElements){ if( nodeElement.getInterval().getMin() >= this.getMidPoint() ){ ++count;