Skip to content

Commit

Permalink
Optimization PR Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
ndegwamartin committed Sep 27, 2023
1 parent 402512d commit 889d4b6
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ public void addLocation(Location location) {
* @param locations
*/
public void buildTreeFromList(List<Location> locations) {
long start = System.currentTimeMillis();
for (Location location : locations) {
addLocation(location);
}
logger.info(String.format("LocationHierarchyTree.buildTreeFromList took : %d ms", System.currentTimeMillis() - start));

}

public Tree getLocationsHierarchy() {
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/org/smartregister/model/location/Tree.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import java.util.Optional;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;

@DatatypeDef(name = "Tree")
public class Tree extends Type implements ICompositeType {
Expand All @@ -52,8 +51,6 @@ public class Tree extends Type implements ICompositeType {
summary = false)
private List<ParentChildrenMap> parentChildren;

private static final Logger logger = Logger.getLogger(Tree.class.getSimpleName());

public SingleTreeNode getTree() {
return listOfNodes;
}
Expand Down Expand Up @@ -143,7 +140,7 @@ public void addNode(String id, String label, Location node, String parentId) {
}

} else {
logger.severe("Node with ID " + id + " already exists in tree");
throw new IllegalArgumentException("Node with ID " + id + " already exists in tree");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import org.hl7.fhir.r4.model.Location;
import org.hl7.fhir.r4.model.Reference;
import org.junit.Test;
import org.smartregister.model.location.utils.TestUtils;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -52,10 +51,9 @@ public void testAddLocationWithoutChildLocations() {

@Test
public void testBuildTreeFromList() {
List<Location> locationList = TestUtils.getTestLocations();
List<Location> locationList = getLocationList();
LocationHierarchyTree locationHierarchyTree = new LocationHierarchyTree();
locationHierarchyTree.buildTreeFromList(locationList);

Tree tree = locationHierarchyTree.getLocationsHierarchy();
assertNotNull(tree);
assertNotNull(tree.getTree());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public static List<Location> getTestLocations() {

List<Location> locationList = new ArrayList<>();


int parentId = 1;

for (Integer i = 1; i < TOTAL_LOCATIONS + 1; i++) {
Expand Down

0 comments on commit 889d4b6

Please sign in to comment.