diff --git a/taxonomy-api/taxonomy-actors/src/main/scala/org/sunbird/actors/TermActor.scala b/taxonomy-api/taxonomy-actors/src/main/scala/org/sunbird/actors/TermActor.scala index 04a8b0c1b..17025a5a0 100644 --- a/taxonomy-api/taxonomy-actors/src/main/scala/org/sunbird/actors/TermActor.scala +++ b/taxonomy-api/taxonomy-actors/src/main/scala/org/sunbird/actors/TermActor.scala @@ -38,6 +38,7 @@ class TermActor @Inject()(implicit oec: OntologyEngineContext) extends BaseActor @throws[Exception] private def create(request: Request): Future[Response] = { val requestList: util.List[util.Map[String, AnyRef]] = getRequestData(request) + request.getRequest.remove("term") if (TERM_CREATION_LIMIT < requestList.size) throw new ClientException("ERR_INVALID_TERM_REQUEST", "No. of request exceeded max limit of " + TERM_CREATION_LIMIT) RequestUtil.restrictProperties(request) val frameworkId = request.getRequest.getOrDefault(Constants.FRAMEWORK, "").asInstanceOf[String] @@ -45,16 +46,19 @@ class TermActor @Inject()(implicit oec: OntologyEngineContext) extends BaseActor val categoryId = generateIdentifier(frameworkId, request.getRequest.getOrDefault(Constants.CATEGORY, "").asInstanceOf[String]) CategoryData.flatMap(node => { if (null != node && StringUtils.equalsAnyIgnoreCase(node.getIdentifier, categoryId)) { - val categoryList = new util.ArrayList[Map[String, AnyRef]] - val relationMap = new util.HashMap[String, AnyRef] - relationMap.put("identifier", categoryId) - relationMap.put("index", getIndex(node)) - categoryList.add(relationMap) - request.put("categories", categoryList) val identifier = new util.ArrayList[String] var codeError = 0 var serverError = 0 + val index: Integer = getIndex(node) + var i: Integer = 0 val future = requestList.asScala.map(req => { + val categoryList = new util.ArrayList[util.Map[String, AnyRef]] + val relationMap = new util.HashMap[String, AnyRef] + relationMap.put("identifier", categoryId) + relationMap.put("index", (index + i).asInstanceOf[Integer]) + i = (i + 1) + categoryList.add(relationMap) + request.put("categories", categoryList) request.getRequest.put(Constants.IDENTIFIER, generateIdentifier(categoryId, req.getOrDefault(Constants.CODE, "").asInstanceOf[String])) request.getRequest.putAll(req) DataNode.create(request).map(termNode => @@ -67,7 +71,7 @@ class TermActor @Inject()(implicit oec: OntologyEngineContext) extends BaseActor } }) Future.sequence(future).flatMap { _ => - createResponse(codeError, serverError, identifier, requestList.size) + createResponse(codeError, serverError, identifier, requestList.size) } } else throw new ClientException("ERR_INVALID_CATEGORY_ID", "Please provide valid category") })