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

Issue #KN-730 fix: QR Code and QRRequired inconsistency debug #916

Merged
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 @@ -29,10 +29,15 @@ import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import scala.concurrent.{ExecutionContext, Future}

import scala.collection.JavaConverters._

object CollectionCSVManager extends CollectionInputFileReader {

private val CONTENT_FOLDER = "cloud_storage.content.folder"
val logger = Logger.getLogger("CollectionCSVManager")
val categoryMap: java.util.Map[String, AnyRef] = Platform.getAnyRef("contentTypeToPrimaryCategory",
new util.HashMap[String, AnyRef]()).asInstanceOf[java.util.Map[String, AnyRef]]

def getCode(code: String): String = {DigestUtils.md5Hex(code)}

def validateInputData(inputFileExtension: String, csvRecords: util.List[CSVRecord], mode: String, collectionHierarchy: Map[String, AnyRef])(implicit oec: OntologyEngineContext, ec: ExecutionContext): List[Map[String, AnyRef]] = {
Expand Down Expand Up @@ -323,9 +328,9 @@ object CollectionCSVManager extends CollectionInputFileReader {
else
try {
s""""${nodeInfo(CollectionTOCConstants.IDENTIFIER).toString}": {"isNew": false,"root": false, "metadata": {"mimeType": "application/vnd.ekstep.content-collection",
|"contentType": "$collectionUnitType","name": ${JsonUtils.serialize(nodeInfo("name").toString.trim)},
|"contentType": "$collectionUnitType","name": ${JsonUtils.serialize(nodeInfo("name").toString.trim)}, "primaryCategory": "${getPrimaryCategory(collectionUnitType)}",
|"description": ${if(nodeInfo.contains(CollectionTOCConstants.DESCRIPTION)) JsonUtils.serialize(nodeInfo(CollectionTOCConstants.DESCRIPTION).toString) else JsonUtils.serialize("")},
|"dialcodeRequired": "${nodeInfo(CollectionTOCConstants.DIAL_CODE_REQUIRED).toString}","dialcodes": "${nodeInfo(CollectionTOCConstants.DIAL_CODES).toString}",
|"dialcodeRequired": "${nodeInfo(CollectionTOCConstants.DIAL_CODE_REQUIRED).toString}","dialcodes": ["${nodeInfo(CollectionTOCConstants.DIAL_CODES).toString}"],
|"code": "${nodeInfo(CollectionTOCConstants.IDENTIFIER).toString}","framework": "$frameworkID",
|"keywords": ${if(nodeInfo.contains(CollectionTOCConstants.KEYWORDS) && nodeInfo(CollectionTOCConstants.KEYWORDS).asInstanceOf[List[String]].nonEmpty)
nodeInfo(CollectionTOCConstants.KEYWORDS).asInstanceOf[List[String]].map(keyword=>JsonUtils.serialize(keyword)).mkString("[",",","]") else "[]"},
Expand Down Expand Up @@ -500,5 +505,13 @@ object CollectionCSVManager extends CollectionInputFileReader {
})
}

private def getPrimaryCategory(contentType: String): String ={
val primaryCategory = categoryMap.get(contentType)
if(primaryCategory.isInstanceOf[String])
primaryCategory.asInstanceOf[String]
else
primaryCategory.asInstanceOf[util.List[String]].asScala.headOption.getOrElse("Learning Resource")

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ object UpdateHierarchyManager {
def updateHierarchy(request: Request)(implicit oec: OntologyEngineContext, ec: ExecutionContext): Future[Response] = {
validateRequest(request)
val nodesModified: java.util.HashMap[String, AnyRef] = request.getRequest.get(HierarchyConstants.NODES_MODIFIED).asInstanceOf[java.util.HashMap[String, AnyRef]]
TelemetryManager.info("UpdateHierarchyManager:: updateHierarchy:: nodesModified: " + nodesModified)
val hierarchy: java.util.HashMap[String, AnyRef] = request.getRequest.get(HierarchyConstants.HIERARCHY).asInstanceOf[java.util.HashMap[String, AnyRef]]
TelemetryManager.info("UpdateHierarchyManager:: updateHierarchy:: hierarchy: " + hierarchy)
val rootId: String = getRootId(nodesModified, hierarchy)
TelemetryManager.info("UpdateHierarchyManager:: updateHierarchy:: rootId: " + rootId)
request.getContext.put(HierarchyConstants.ROOT_ID, rootId)
getValidatedRootNode(rootId, request).map(node => {
getExistingHierarchy(request, node).map(existingHierarchy => {
Expand Down