Skip to content

Commit

Permalink
Issue #SB-25430 fix: Fixed childNodes list.
Browse files Browse the repository at this point in the history
  • Loading branch information
AmiableAnil committed Jul 6, 2021
1 parent 0514331 commit 7d5ed00
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ object HierarchyManager {
val req = new Request(request)
if ("add".equalsIgnoreCase(operation)) {
val updatedChildren = restructureUnit(hierarchy.get("children").asInstanceOf[java.util.List[java.util.Map[String, AnyRef]]],
convertNodeToMap(leafNodes), leafNodeIds, 1, rootNode.getIdentifier.replace(".img", ""))
val updatedHierarchy = Map("children" -> updatedChildren, "identifier" -> rootNode.getIdentifier.replace(".img", "")).asJava
convertNodeToMap(leafNodes), leafNodeIds, 1, rootNode.getIdentifier.replace(imgSuffix, ""))
val updatedHierarchy = Map("children" -> updatedChildren, "identifier" -> rootNode.getIdentifier.replace(imgSuffix, "")).asJava
req.put("hierarchy", ScalaJsonUtils.serialize(updatedHierarchy))
}
if ("remove".equalsIgnoreCase(operation)) {
Expand All @@ -145,7 +145,7 @@ object HierarchyManager {
.filter(child => !leafNodeIds.contains(child.get("identifier")))
filteredChildren.sortBy(_.get("index").asInstanceOf[Integer])
.zipWithIndex.foreach(zippedChild => zippedChild._1.put("index", (zippedChild._2.asInstanceOf[Integer] + 1).asInstanceOf[Object]))
val updatedHierarchy = Map("children" -> filteredChildren, "identifier" -> rootNode.getIdentifier.replace(".img", "")).asJava
val updatedHierarchy = Map("children" -> filteredChildren, "identifier" -> rootNode.getIdentifier.replace(imgSuffix, "")).asJava
req.put("hierarchy", ScalaJsonUtils.serialize(updatedHierarchy))
}
req.put("identifier", rootNode.getIdentifier)
Expand Down Expand Up @@ -326,7 +326,7 @@ object HierarchyManager {
def updateRootNode(rootNode: Node, request: Request, operation: String)(implicit oec: OntologyEngineContext, ec: ExecutionContext) = {
val req = new Request(request)
val leafNodes = request.get("children").asInstanceOf[java.util.List[String]]
var childNodes = new java.util.ArrayList[String]()
val childNodes = new java.util.ArrayList[String]()
childNodes.addAll(rootNode.getMetadata.getOrDefault("childNodes", Array[String]()).asInstanceOf[Array[String]].toList)
if(operation.equalsIgnoreCase("add"))
childNodes.addAll(leafNodes)
Expand Down Expand Up @@ -402,7 +402,7 @@ object HierarchyManager {
} else
Future(Map[String, AnyRef]())
} else if (ResponseHandler.checkError(response) && response.getResponseCode.code() == 404 && Platform.config.hasPath("collection.image.migration.enabled") && Platform.config.getBoolean("collection.image.migration.enabled")) {
req.put("identifier", identifier.replaceAll(".img", "") + ".img")
req.put("identifier", identifier.replaceAll(imgSuffix, "") + imgSuffix)
val responseFuture = oec.graphService.readExternalProps(req, List("hierarchy"))
responseFuture.map(response => {
if (!ResponseHandler.checkError(response)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ object UpdateHierarchyManager {
updateHierarchyRelatedData(childrenIdentifiersMap.getOrElse(rootId, Map[String, Int]()), 1,
rootId, nodeList, childrenIdentifiersMap, updatedNodeList).map(finalEnrichedNodeList => {
TelemetryManager.info("Final enriched list size: " + finalEnrichedNodeList.size)
val childNodeIds = finalEnrichedNodeList.map(node => node.getIdentifier).filterNot(id => StringUtils.containsIgnoreCase(rootId, id)).distinct
val childNodeIds = finalEnrichedNodeList.map(node => node.getIdentifier.replaceAll(".img", "")).filterNot(id => StringUtils.containsIgnoreCase(rootId, id)).distinct
TelemetryManager.info("Final enriched ids (childNodes): " + childNodeIds + " :: size: " + childNodeIds.size)
updateNodeList(nodeList, rootId, new java.util.HashMap[String, AnyRef]() {
put(HierarchyConstants.DEPTH, 0.asInstanceOf[AnyRef])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ object UpdateHierarchyManager {
updateHierarchyRelatedData(childrenIdentifiersMap.getOrElse(rootId, Map[String, Int]()), 1,
rootId, nodeList, childrenIdentifiersMap, updatedNodeList).map(finalEnrichedNodeList => {
TelemetryManager.info("Final enriched list size: " + finalEnrichedNodeList.size)
val childNodeIds = finalEnrichedNodeList.map(node => node.getIdentifier).filterNot(id => StringUtils.containsIgnoreCase(rootId, id)).distinct
val childNodeIds = finalEnrichedNodeList.map(node => node.getIdentifier.replaceAll(".img", "")).filterNot(id => StringUtils.containsIgnoreCase(rootId, id)).distinct
TelemetryManager.info("Final enriched ids (childNodes): " + childNodeIds + " :: size: " + childNodeIds.size)
// UNDERSTANDING: below we used nodeList to update DEPTH and CHILD_NODES. It automatically updated to finalEnrichedNodeList.
// Because, the Node object is a Java POJO with metadata using java.util.Map.
Expand Down

0 comments on commit 7d5ed00

Please sign in to comment.