Skip to content

Commit

Permalink
Logs to analyse hierarchy updation issue (#65)
Browse files Browse the repository at this point in the history
* logs to analyse hierarchy updation issue
  • Loading branch information
sreeragksgh authored Nov 16, 2023
1 parent 0546b1f commit 370cd40
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package org.sunbird.managers

import java.util
import java.util.concurrent.CompletionException

import org.apache.commons.collections4.{CollectionUtils, MapUtils}
import org.apache.commons.lang3.StringUtils
import org.slf4j.LoggerFactory
import org.sunbird.common.dto.{Request, Response, ResponseHandler}
import org.sunbird.common.exception.{ClientException, ErrorCodes, ResourceNotFoundException, ServerException}
import org.sunbird.common.{DateUtils, JsonUtils, Platform}
Expand All @@ -25,9 +25,11 @@ import scala.concurrent.{ExecutionContext, Future}

object UpdateHierarchyManager {
val neo4jCreateTypes: java.util.List[String] = Platform.getStringList("neo4j_objecttypes_enabled", List("Question").asJava)
val logger = LoggerFactory.getLogger("org.sunbird.managers.UpdateHierarchyManager")

@throws[Exception]
def updateHierarchy(request: Request)(implicit oec: OntologyEngineContext, ec: ExecutionContext): Future[Response] = {
logger.info("Question set update hierarchy request body : {}", request)
val (nodesModified, hierarchy) = validateRequest(request)
val rootId: String = getRootId(nodesModified, hierarchy)
request.getContext.put(HierarchyConstants.ROOT_ID, rootId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package org.sunbird.managers
import java.util.concurrent.CompletionException
import org.apache.commons.collections4.{CollectionUtils, MapUtils}
import org.apache.commons.lang3.StringUtils
import org.slf4j.LoggerFactory
import org.sunbird.common.dto.{Request, Response, ResponseHandler}
import org.sunbird.common.exception.{ClientException, ErrorCodes, ResourceNotFoundException, ResponseCode, ServerException}
import org.sunbird.common.{DateUtils, JsonUtils, Platform}
Expand All @@ -23,8 +24,10 @@ import scala.concurrent.{ExecutionContext, Future}

object UpdateHierarchyManager {

val logger = LoggerFactory.getLogger("org.sunbird.managers.UpdateHierarchyManager")
@throws[Exception]
def updateHierarchy(request: Request)(implicit oec: OntologyEngineContext, ec: ExecutionContext): Future[Response] = {
logger.info("UpdateHierarchyManager.updateHierarchy = request Body is : {}", request)
validateRequest(request)
val nodesModified: java.util.HashMap[String, AnyRef] = request.getRequest.get(HierarchyConstants.NODES_MODIFIED).asInstanceOf[java.util.HashMap[String, AnyRef]]
val hierarchy: java.util.HashMap[String, AnyRef] = request.getRequest.get(HierarchyConstants.HIERARCHY).asInstanceOf[java.util.HashMap[String, AnyRef]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package org.sunbird.graph.external.store
import java.sql.Timestamp
import java.util
import java.util.Date

import com.datastax.driver.core.Session
import com.datastax.driver.core.querybuilder.{Clause, Insert, QueryBuilder}
import com.google.common.util.concurrent.{FutureCallback, Futures, ListenableFuture, MoreExecutors}
import org.slf4j.LoggerFactory
import org.sunbird.cassandra.{CassandraConnector, CassandraStore}
import org.sunbird.common.JsonUtils
import org.sunbird.common.dto.{Response, ResponseHandler}
Expand All @@ -16,6 +16,7 @@ import org.sunbird.telemetry.logger.TelemetryManager
import scala.concurrent.{ExecutionContext, Future, Promise}

class ExternalStore(keySpace: String , table: String , primaryKey: java.util.List[String]) extends CassandraStore(keySpace, table, primaryKey) {
val logger = LoggerFactory.getLogger("org.sunbird.graph.external.store.ExternalStore")

def insert(request: util.Map[String, AnyRef], propsMapping: Map[String, String])(implicit ec: ExecutionContext): Future[Response] = {
val insertQuery: Insert = QueryBuilder.insertInto(keySpace, table)
Expand Down Expand Up @@ -169,6 +170,8 @@ class ExternalStore(keySpace: String , table: String , primaryKey: java.util.Lis
case _ => update.`with`(QueryBuilder.set(column, values(index)))
}
}
val updateQuery = update.toString
logger.info("Query for update hierarchy is: {}", updateQuery)
try {
val session: Session = CassandraConnector.getSession
session.executeAsync(update).asScala.map( resultset => {
Expand Down

0 comments on commit 370cd40

Please sign in to comment.