Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logs to analyse hierarchy updation issue #65

Merged
merged 3 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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