Skip to content

Commit

Permalink
Merge branch 'release-4.0.0' into dependabot/maven/platform-core/plat…
Browse files Browse the repository at this point in the history
…form-common/commons-io-commons-io-2.7
  • Loading branch information
maheshkumargangula committed May 10, 2021
2 parents 67ad820 + f1f95ad commit a0c7c7e
Show file tree
Hide file tree
Showing 557 changed files with 50,816 additions and 3,563 deletions.
41 changes: 34 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,44 @@
version: 2.1
executorType: machine
jobs:
kp-build:
machine: true
build:
docker:
- image: circleci/openjdk:14-jdk-buster-node-browsers-legacy
steps:
- checkout
- restore_cache:
key: kp-dependency-cache-{{ checksum "pom.xml" }}
key: kp-dependency-build-cache-{{ checksum "pom.xml" }}
- run:
name: Setup VM and Build
name: Run build
command: |
mvn clean install -DskipTests
- save_cache:
paths:
- ~/.m2
key: kp-dependency-build-cache-{{ checksum "pom.xml" }}

unit-tests:
docker:
- image: circleci/openjdk:14-jdk-buster-node-browsers-legacy
- image: circleci/redis:latest
parallelism: 1
steps:
- checkout
- restore_cache:
key: kp-dependency-test-cache-{{ checksum "pom.xml" }}
- run:
name: Setup environment and run tests
command: bash vmsetup.sh
- save_cache:
paths:
- ~/.m2
key: kp-dependency-test-cache-{{ checksum "pom.xml" }}

workflows:
version: 2.1
workflow:
jobs:
- kp-build
build-then-test:
jobs:
- build
- unit-tests:
requires:
- build
3 changes: 2 additions & 1 deletion .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Please describe the tests that you ran to verify your changes in the below check

**Test Configuration**:
* Software versions: Java 11, scala-2.11, play-2.7.2
* Hardware versions:
* Hardware versions: 2 CPU/ 4GB RAM

### Checklist:

Expand All @@ -30,3 +30,4 @@ Please describe the tests that you ran to verify your changes in the below check
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

32 changes: 32 additions & 0 deletions .github/pull_request_template.md.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

### Type of change

Please choose appropriate options.

- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update

### How Has This Been Tested?

Please describe the tests that you ran to verify your changes in the below checkboxes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

- [ ] Ran Test A
- [ ] Ran Test B

**Test Configuration**:
* Software versions: Java 11, scala-2.11, play-2.7.2
* Hardware versions:

### Checklist:

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
14 changes: 0 additions & 14 deletions Dockerfile

This file was deleted.

123 changes: 123 additions & 0 deletions assessment-api/assessment-actors/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>assessment-api</artifactId>
<groupId>org.sunbird</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>assessment-actors</artifactId>

<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>actor-core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>graph-engine_2.11</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>qs-hierarchy-manager</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>import-manager</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_${scala.maj.version}</artifactId>
<version>${scalatest.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.scalamock</groupId>
<artifactId>scalamock_${scala.maj.version}</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-testkit_${scala.maj.version}</artifactId>
<version>2.5.22</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<testSourceDirectory>src/test/scala</testSourceDirectory>
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>4.4.0</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<checkMultipleScalaVersions>false</checkMultipleScalaVersions>
</configuration>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>${scoverage.plugin.version}</version>
<configuration>
<scalaVersion>${scala.version}</scalaVersion>
<aggregate>true</aggregate>
<highlighting>true</highlighting>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.sunbird.actors

import javax.inject.Inject
import org.sunbird.actor.core.BaseActor
import org.sunbird.common.dto.{Request, Response}
import org.sunbird.graph.OntologyEngineContext
import org.sunbird.graph.health.HealthCheckManager

import scala.concurrent.{ExecutionContext, Future}


class HealthActor @Inject() (implicit oec: OntologyEngineContext) extends BaseActor {

implicit val ec: ExecutionContext = getContext().dispatcher

@throws[Throwable]
override def onReceive(request: Request): Future[Response] = {
HealthCheckManager.checkAllSystemHealth()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
package org.sunbird.actors

import java.util

import javax.inject.Inject
import org.apache.commons.collections4.CollectionUtils
import org.apache.commons.lang3.StringUtils
import org.sunbird.actor.core.BaseActor
import org.sunbird.common.dto.{Request, Response, ResponseHandler}
import org.sunbird.graph.OntologyEngineContext
import org.sunbird.graph.dac.model.Relation
import org.sunbird.graph.nodes.DataNode
import org.sunbird.graph.utils.NodeUtil
import org.sunbird.parseq.Task

import scala.collection.JavaConversions._
import scala.collection.JavaConverters.seqAsJavaListConverter
import scala.concurrent.{ExecutionContext, Future}

class ItemSetActor @Inject() (implicit oec: OntologyEngineContext) extends BaseActor {

implicit val ec: ExecutionContext = getContext().dispatcher

override def onReceive(request: Request): Future[Response] = request.getOperation match {
case "createItemSet" => create(request)
case "readItemSet" => read(request)
case "updateItemSet" => update(request)
case "reviewItemSet" => review(request)
case "retireItemSet" => retire(request)
case _ => ERROR(request.getOperation)
}


def create(request: Request): Future[Response] = DataNode.create(request).map(node => {
ResponseHandler.OK.put("identifier", node.getIdentifier)
})

def read(request: Request): Future[Response] = {
val fields = request.getRequest.getOrDefault("fields", "").asInstanceOf[String]
.split(",").filter((field: String) => StringUtils.isNotBlank(field) && !StringUtils.equalsIgnoreCase(field, "null")).toList.asJava
request.getRequest.put("fields", fields)
DataNode.read(request).map(node => {
val metadata = NodeUtil.serialize(node, fields, request.getContext.get("schemaName").asInstanceOf[String], request.getContext.get("version").asInstanceOf[String])
metadata.remove("versionKey")
ResponseHandler.OK.put("itemset", metadata)
})
}

def update(request: Request): Future[Response] = DataNode.update(request).map(node => {
ResponseHandler.OK.put("identifier", node.getIdentifier)
})

def review(request: Request): Future[Response] = {
val identifier = request.getContext.get("identifier").asInstanceOf[String]
var flag = false
val readReq = new Request();
val reqContext = request.getContext
readReq.setContext(reqContext)
readReq.put("identifier", identifier)
readReq.put("fields", new util.ArrayList[String])
val updateReq = new Request()
updateReq.setContext(reqContext)
DataNode.read(readReq).map(node => {
if (CollectionUtils.isNotEmpty(node.getOutRelations)) {
//process relations with AssessmentItem
val itemRels: util.List[Relation] = node.getOutRelations.filter((rel: Relation) => StringUtils.equalsAnyIgnoreCase("AssessmentItem", rel.getEndNodeObjectType)).filterNot((reln: Relation) => StringUtils.equalsAnyIgnoreCase("Retired", reln.getEndNodeMetadata.get("status").toString))
val draftRelIds: List[String] = itemRels.filter((rel: Relation) => StringUtils.equalsAnyIgnoreCase("Draft", rel.getEndNodeMetadata.get("status").toString)).map(rel => rel.getEndNodeId).toList
if (CollectionUtils.isNotEmpty(draftRelIds)) {
updateReq.put("identifiers", draftRelIds.asJava)
updateReq.put("metadata", new util.HashMap[String, AnyRef]() {{put("status", "Review")}})
flag = true
}
val newRels: util.List[util.HashMap[String, AnyRef]] = itemRels.sortBy((rel: Relation) => rel.getMetadata.get("IL_SEQUENCE_INDEX").asInstanceOf[Long])(Ordering.Long).map(rel => {
new util.HashMap[String, AnyRef]() {{put("identifier", rel.getEndNodeId);}}}).toList
request.put("items", newRels);
}
request.put("status", "Review")
val func = flag match {
case true => DataNode.bulkUpdate(updateReq).map(f => ResponseHandler.OK())
case false => Future(ResponseHandler.OK())
}
val futureList = Task.parallel[Response](func,
DataNode.update(request).map(node => {
ResponseHandler.OK.put("identifier", node.getIdentifier)
}))
futureList
}).flatMap(f => f).map(f => f.get(1))
}

def retire(request: Request): Future[Response] = {
request.put("status", "Retired")
DataNode.update(request).map(node => {
ResponseHandler.OK.put("identifier", node.getIdentifier)
})
}


}
Loading

0 comments on commit a0c7c7e

Please sign in to comment.