diff --git a/README.md b/README.md
old mode 100644
new mode 100755
index 2bfe06a..dbe61ee
--- a/README.md
+++ b/README.md
@@ -1,49 +1,158 @@
# Review Microservice
-A microservice for generic units of work (e.g., a challenge)
+Microservice for supporting Topcoder Online Review platform.
-## Getting Started
-This microservice is using [dropwizard](dropwizard.io) as the REST API framework and implements the [v3 API spec](https://docs.google.com/a/appirio.com/presentation/d/15pucEI0MHj9y778EyaAWGh4MBH-I73i1-GS0ir7FhxE/edit#slide=id.g29c3ffcc3_020). If you are unfamiliar with dropwizard, take a look at their [Getting Started](http://dropwizard.io/getting-started.html) page.
+# Prerequisities
-### Building
-We are using Maven 2 to build and building is as simple as `mvn package`. *Make sure you are using Java 8 for build and runtime*
+- Java 8 with Maven 2+
+- Docker
-### Configuration
-Configuration is managed through a yaml file. The `src/main/resources/review-service.yaml` file should contain the necessary configuration for you to run locally.
+# Local Deployment
-### Framework Stack
-- dropwizard-core - core REST API
-- dropwizard-auth - user authentication
-- dropwizard-jdbi - database access
-- dropwizard-testing - unit testing
-- mysql-connector-java - mysql JDBC driver
-- fest-assert-core, mockito-core - unit testing
-- slf4j - logging
+### Start Informix instance via Docker
-### Database
-We are using mysql RDS for the database. For development use, connect to the topcoder-dev instance. Database access should be limited to the DAO layer. We are using the [JDBI](http://jdbi.org/) framework for database access. Where possible we should use the [SQL Objects API](http://jdbi.org/sql_object_overview/) approach listed in the JDBI documentation.
+- Set an IP for Docker by setting the environment variable `DOCKER_IP`. Recommended to set to `0.0.0.0`
-For this service, the DAO is managed by `ReviewDAO`
+- Command to set the environment variable `DOCKER_IP`
-**We need to keep the data model clean and name properties of our representation (model) objects as the column names so we can use the automatic bean mapping facilities instead of needing to manually wire things together. Any deviation requires prior approval.**
+```
+export DOCKER_IP=0.0.0.0
+```
+
+- To run Informix locally, go to the `local` folder and execute the following command:
+
+```
+docker-compose up
+```
-### API Endpoint
-The API endpoint for this service is `com.appirio.service.review.resources.ReviewResource` It contains the specific resource paths supported by this service. The root of the service is /v3/reviews. API methods should be annotated with the appropriate jax-rs annotations and the `@Timed` annotation for metrics. An example method is shown below.
+If you should ever encounter the error:
+
+```
+[java] Caused by: com.topcoder.db.connectionfactory.DBConnectionException: error occurs while creating the connection.
+You already have 20 connections at this
+time. Any further connections
```
-@GET
-@Timed
-public ApiResponse getReviews(@Auth AuthUser auth,
- @APIQueryParam(repClass = Review.class) QueryParameter queryParameter)
- logger.debug("getReviews, filter : " + queryParameter.getFilter().getFields());
- return MetadataApiResponseFactory.createResponse(reviewManager.getReviews(auth, queryParameter,
- new BaseAuthorizationContext(auth)));
-}
+Try to restart the informix database server as below:
+```
+#### log into the container based on the container name got in the previous step
+docker exec -it local_informix bash
+
+#### restart the database server
+onmode -ky
+oninit
+```
+
+### Inserting test records
+
+- Test data is present in SQL file (`test_data.sql`) in `local` folder.
+
+- Transfer the `test_data.sql` to docker environment by executing the following command
+
```
+docker cp test_data.sql local_informix:/home/informix
+```
+
+- Insert the records in `tcs_catalog` database by executing the following command
+
+```
+docker exec -it local_informix dbaccess tcs_catalog test_data.sql
+```
+
+- Docker environment is ready to be used in our service.
+
+### Configuration Variables
+The configuration file `service/src/main/resources/review-service.yaml` contain the necessary configuration to run the microservice locally. Below configuration variables need to be set using environment variables.
+
+|Name | Description |
+|--------------------|:-----------------------------------------:|
+|AUTH_DOMAIN | Authentication domain of JWT, Dont set unless you have valid tokens with given AUTH_DOMAIN, Defaulted to 'topcoder-dev.com' |
+|IP | The IP of your docker container |
+|OLTP_USER | The Informix OLTP user |
+|OLTP_PW | The Informix OLTP user password |
+|OLTP_URL | The JDBC URL of Informix OLTP database |
+|DW_USER | The Informix DW user |
+|DW_PW | The Informix DW user password |
+|DW_URL | The JDBC URL of Informix DW database |
+|TC_JWT_KEY | Secret used in JWT Service, Used for signature verification as well |
+
+In Linux, Set the environment variables as
+
+```
+export AUTH_DOMAIN=...
+export IP=...
+export OLTP_USER=...
+export OLTP_PW=...
+export OLTP_URL=...
+export DW_USER=...
+export DW_PW=...
+export DW_URL=...
+```
+
+### Working credentials for local deployment
+
+```
+export IP=0.0.0.0
+export OLTP_USER=informix
+export OLTP_PW=1nf0rm1x
+export OLTP_URL=jdbc:informix-sqli://$IP:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;IFX_LOCK_MODE_WAIT=5;OPTCOMPIND=0;STMT_CACHE=1
+export DW_USER=informix
+export DW_PW=1nf0rm1x
+export DW_URL=jdbc:informix-sqli://$IP:2021/common_dw:INFORMIXSERVER=informixoltp_tcp;IFX_LOCK_MODE_WAIT=5;OPTCOMPIND=0;STMT_CACHE=1
+export TC_JWT_KEY=secret
+```
+
+### Set up Local Maven repository for Appirio Maven
+
+- Since maven.appirio.net is not accessible, We need to set up a local maven repository with the zip file `temp-maven-repo-master.zip`
+
+- Unzip the contents to any of the directory in your System. **In Linux, the directory should not be a mounted directory like pen drive, hard disk, etc..**
+
+- Open `pom.xml` in `service` directory and replace the `` of Local repository with `absolute path of the unzipped file`. E.g. If you have unzipped the files to `/home/user/temp-maven-repo-master`, then POM entry will look like
+
+```
+
+ 1_temp_appirio_maven_repo
+ Appirio Maven Local Repository
+ file:///home/user/temp-maven-repo-master
+
+```
+
+### Build Microservice
+
+In the `service` folder of this project, run the following command to build the service.
+
+```
+mvn clean package
+```
+
+### Start Microservice
+
+- Before starting please ensure that all environment variables listed above is set properly and docker is up and running.
+
+- Then start the service using the following command in the 'service' folder:
+
+```
+java -jar ./target/review-microservice-*.jar server ./src/main/resources/review-service.yaml
+```
+
+### Verification
+
+Though there are many endpoints, For starters, it's sufficient to verify two end points.
+
+- Endpoint `/v3/scorecards` doesn't require Authentication
+
+- Endpoint `/v3/reviews` require Authentication
+
+Use the postman collection in `Postman` directory to verify the end points.
+
+- **Ensure to import the postman environment before testing the endpoints**
+
+- Request `Get list of all Scorecards` returns all scorecard templates present in the database
+
+**Loaded test data has details for 3 submissions for a single competition reviewed by 2 reviewers**
-Note the `TCAuth` parameter provided by the `ServiceAuthenticator` class will provide user auth information and is a required parameterfor all secured API calls.
-You must set up `TC_JWT_KEY` environment variable, the sample value is `4WvoZLWhFPZ5jauw2+XCU+p772S4oBN25tNPyjHR`.
+- Request `Get list of all reviews Reviewer1` return the reviews done by Reviewer 1.
-### Testing
-All API endpoint methods should have unit tests. For this service we are following the dropwizard testing recommendations as described [here](http://dropwizard.io/manual/testing.html)
+- Request `Get list of all reviews Reviewer2` return the reviews done by Reviewer 2.
-For manual API testing, the [postman chrome app](https://chrome.google.com/webstore/detail/postman-rest-client/fdmmgilgnpjigdojojpjoooidkmcomcm?hl=en) is useful.
+ **Note: Some of the fields in returned output will be NULL, It's expected. That's how the internal controllers and services are written**
diff --git a/local/docker-compose.yml b/local/docker-compose.yml
index f8f55a9..4c69346 100644
--- a/local/docker-compose.yml
+++ b/local/docker-compose.yml
@@ -1,14 +1,15 @@
version: '2'
services:
informix:
+ container_name: local_informix
image: "appiriodevops/informix:1b3d4ef"
ports:
- "2021:2021"
kafka:
image: spotify/kafka
environment:
- ADVERTISED_HOST: $DOCKER_IP
- ADVERTISED_PORT: 9092
+ ADVERTISED_HOST: ${DOCKER_IP}
+ ADVERTISED_PORT: 2181
ports:
- "2181:2181"
- "9092:9092"
diff --git a/local/run.sh b/local/run.sh
new file mode 100755
index 0000000..7d47abb
--- /dev/null
+++ b/local/run.sh
@@ -0,0 +1,11 @@
+export IP=192.168.1.2
+export OLTP_USER=informix
+export OLTP_PW=1nf0rm1x
+export OLTP_URL=jdbc:informix-sqli://$IP:2021/tcs_catalog:INFORMIXSERVER=informixoltp_tcp;IFX_LOCK_MODE_WAIT=5;OPTCOMPIND=0;STMT_CACHE=1
+export DW_USER=informix
+export DW_PW=1nf0rm1x
+export DW_URL=jdbc:informix-sqli://$IP:2021/common_dw:INFORMIXSERVER=informixoltp_tcp;IFX_LOCK_MODE_WAIT=5;OPTCOMPIND=0;STMT_CACHE=1
+export TC_JWT_KEY=secret
+
+
+java -jar ../service/target/review-microservice-*.jar server ../service/src/main/resources/review-service.yaml
\ No newline at end of file
diff --git a/local/test_data.sql b/local/test_data.sql
new file mode 100755
index 0000000..6a63f2b
--- /dev/null
+++ b/local/test_data.sql
@@ -0,0 +1,58 @@
+database tcs_catalog;
+
+/* Data for a project*/
+
+insert into project(project_id, project_status_id, project_category_id, create_user, create_date, modify_user, modify_date)
+values(1, 1, 1, 132456, current, 132456, current);
+
+/* Data for 2 reviewers and 3 submitters based on the token provided */
+insert into resource(resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) values(2, 4, 1, 13, 1234, 132456, current, 132456, current);
+
+insert into resource(resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) values(3, 4, 1, 13, 1235, 132456, current, 132456, current);
+
+insert into resource(resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) values(4, 1, 1, 13, 1200, 132456, current, 132456, current);
+
+insert into resource(resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) values(5, 1, 1, 13, 1201, 132456, current, 132456, current);
+
+insert into resource(resource_id, resource_role_id, project_id, project_phase_id, user_id, create_user, create_date, modify_user, modify_date) values(6, 1, 1, 13, 1202, 132456, current, 132456, current);
+
+/* Data for 3 uploads */
+
+insert into upload(upload_id, project_id, project_phase_id, resource_id, upload_type_id, upload_status_id, parameter, create_user, create_date, modify_user, modify_date) values(1, 1, 12, 4, 1, 1, 'someparam', 132456, current, 132456, current);
+
+insert into upload(upload_id, project_id, project_phase_id, resource_id, upload_type_id, upload_status_id, parameter, create_user, create_date, modify_user, modify_date) values(2, 1, 12, 5, 1, 1, 'someparam', 132456, current, 132456, current);
+
+insert into upload(upload_id, project_id, project_phase_id, resource_id, upload_type_id, upload_status_id, parameter, create_user, create_date, modify_user, modify_date) values(3, 1, 12, 6, 1, 1, 'someparam', 132456, current, 132456, current);
+
+
+/* Data for 3 submission */
+
+insert into submission(submission_id, upload_id, submission_status_id, submission_type_id, create_user, create_date, modify_user, modify_date)
+values(1, 1, 1, 1, 132456, current, 132456, current);
+
+insert into submission(submission_id, upload_id, submission_status_id, submission_type_id, create_user, create_date, modify_user, modify_date)
+values(2, 2, 1, 1, 132456, current, 132456, current);
+
+insert into submission(submission_id, upload_id, submission_status_id, submission_type_id, create_user, create_date, modify_user, modify_date)
+values(3, 3, 1, 1, 132456, current, 132456, current);
+
+
+/* 3 submissions for a single competition reviewed by 2 reviewers*/
+
+insert into review(review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, score, initial_score, create_user, create_date, modify_user, modify_date)
+ values(1, 2, 1, 13, 30000410, 1, 100, 95, 132456, current, 132456, current);
+
+insert into review(review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, score, initial_score, create_user, create_date, modify_user, modify_date)
+ values(2, 3, 1, 13, 30000410, 1, 100, 95, 132456, current, 132456, current);
+
+insert into review(review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, score, initial_score, create_user, create_date, modify_user, modify_date)
+ values(3, 2, 2, 13, 30000410, 1, 65, 55, 132456, current, 132456, current);
+
+insert into review(review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, score, initial_score, create_user, create_date, modify_user, modify_date)
+ values(4, 3, 2, 13, 30000410, 1, 70, 60, 132456, current, 132456, current);
+
+insert into review(review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, score, initial_score, create_user, create_date, modify_user, modify_date)
+ values(5, 2, 3, 13, 30000410, 1, 90, 87, 132456, current, 132456, current);
+
+insert into review(review_id, resource_id, submission_id, project_phase_id, scorecard_id, committed, score, initial_score, create_user, create_date, modify_user, modify_date)
+ values(6, 3, 3, 13, 30000410, 1, 84.36, 78, 132456, current, 132456, current);
diff --git a/postman/review-microservice.postman_collection.json b/postman/review-microservice.postman_collection.json
new file mode 100755
index 0000000..2bba9a1
--- /dev/null
+++ b/postman/review-microservice.postman_collection.json
@@ -0,0 +1,812 @@
+{
+ "variables": [],
+ "info": {
+ "name": "review-microservice",
+ "_postman_id": "550e2ca7-d86d-77a7-a597-98a1945ebc8f",
+ "description": "",
+ "schema": "https://schema.getpostman.com/json/collection/v2.0.0/collection.json"
+ },
+ "item": [
+ {
+ "name": "Delete Review",
+ "item": [
+ {
+ "name": "Anonymous - Delete Review - 401",
+ "request": {
+ "method": "DELETE",
+ "header": [],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/71492"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Delete Review",
+ "request": {
+ "method": "DELETE",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/71492"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Delete Review - Not Found",
+ "request": {
+ "method": "DELETE",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/4582"
+ },
+ "response": []
+ },
+ {
+ "name": "Non-Admin - Delete Review",
+ "request": {
+ "method": "DELETE",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Reviewer1 Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/71492"
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Re-open Review",
+ "item": [
+ {
+ "name": "Admin - Reopen Review",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/71492/reopen"
+ },
+ "response": []
+ },
+ {
+ "name": "Anonymous - Reopen Review - 401",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}",
+ "disabled": true
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/71492/reopen"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Reopen Review - Not Found",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/7452/reopen"
+ },
+ "response": []
+ },
+ {
+ "name": "Non-Admin - Reopen Review",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Reviewer1 Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/71492/reopen"
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Reset Aggregation",
+ "item": [
+ {
+ "name": "Admin - Reset Aggregation",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/resetAggregation"
+ },
+ "response": []
+ },
+ {
+ "name": "Non Admin - Reset Aggregation",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Reviewer1 Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/resetAggregation"
+ },
+ "response": []
+ },
+ {
+ "name": "Anonymous - Reset Aggregation - 401",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}",
+ "disabled": true
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/resetAggregation"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Reset Aggregation - Not Found",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/13/resetAggregation"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Reset Aggregation - Challenge Not Active - 400",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/11/resetAggregation"
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Reset Review",
+ "item": [
+ {
+ "name": "Admin - Reset Review",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/resetReview"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Reset Review - Not Found",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/resetReview"
+ },
+ "response": []
+ },
+ {
+ "name": "Non Admin - Reset Review",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Reviewer1 Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/resetReview"
+ },
+ "response": []
+ },
+ {
+ "name": "Anonymous - Reset Review - Unauthorized - 401",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/resetReview"
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Update Autopilot",
+ "item": [
+ {
+ "name": "Admin - Enable Autopilot",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"param\" : {\n \t\"enable\" : true\n }\n \n}"
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/updateAutopilot"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Enable Autopilot - Bad Request - 400",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"param\" : {\n \t\"enable\" : \n }\n \n}"
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/updateAutopilot"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Disable Autopilot",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"param\" : {\n \t\"enable\" : false\n }\n \n}"
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/updateAutopilot"
+ },
+ "response": []
+ },
+ {
+ "name": "Non Admin - Enable Autopilot",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Reviewer1 Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"param\" : {\n \t\"enable\" : true\n }\n \n}"
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/updateAutopilot"
+ },
+ "response": []
+ },
+ {
+ "name": "Anonymous - Enable Autopilot - Unauthorized - 401",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"param\" : {\n \t\"enable\" : true\n }\n \n}"
+ },
+ "url": "{{apiUrl}}/v3/reviews/30005520/updateAutopilot"
+ },
+ "response": []
+ },
+ {
+ "name": "Admin - Enable Autopilot - Not Found",
+ "request": {
+ "method": "POST",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Administrator Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": "{\n \"param\" : {\n \t\"enable\" : true\n }\n \n}"
+ },
+ "url": "{{apiUrl}}/v3/reviews/13/updateAutopilot"
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Review Opportunities",
+ "item": [
+ {
+ "name": "Get review opportunities for dev F2F (iterative review)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJoZWZmYW4iLCJleHAiOjE3NjYyODkyNDYsInVzZXJJZCI6IjEzMjQ1NiIsImlhdCI6MTQ1MDkyOTI0NiwiZW1haWwiOm51bGwsImp0aSI6IjEzNjljNjAwLWUwYTEtNDUyNS1hN2M3LTU2YmU3ZDgxM2Y1MSJ9.hp5peSoj-fh3KFkskvBpfUFIcJNtsv4zIMFV-D8F3JA",
+ "disabled": true
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{apiUrl}}/v3/reviewOpportunities?challengeTypeId=38",
+ "host": [
+ "{{apiUrl}}"
+ ],
+ "path": [
+ "v3",
+ "reviewOpportunities"
+ ],
+ "query": [
+ {
+ "key": "challengeTypeId",
+ "value": "38",
+ "equals": true
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get review opportunities for UI prototype",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJoZWZmYW4iLCJleHAiOjE3NjYyODkyNDYsInVzZXJJZCI6IjEzMjQ1NiIsImlhdCI6MTQ1MDkyOTI0NiwiZW1haWwiOm51bGwsImp0aSI6IjEzNjljNjAwLWUwYTEtNDUyNS1hN2M3LTU2YmU3ZDgxM2Y1MSJ9.hp5peSoj-fh3KFkskvBpfUFIcJNtsv4zIMFV-D8F3JA",
+ "disabled": true
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{apiUrl}}/v3/reviewOpportunities?challengeTypeId=19",
+ "host": [
+ "{{apiUrl}}"
+ ],
+ "path": [
+ "v3",
+ "reviewOpportunities"
+ ],
+ "query": [
+ {
+ "key": "challengeTypeId",
+ "value": "19",
+ "equals": true
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get review opportunities",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJoZWZmYW4iLCJleHAiOjE3NjYyODkyNDYsInVzZXJJZCI6IjEzMjQ1NiIsImlhdCI6MTQ1MDkyOTI0NiwiZW1haWwiOm51bGwsImp0aSI6IjEzNjljNjAwLWUwYTEtNDUyNS1hN2M3LTU2YmU3ZDgxM2Y1MSJ9.hp5peSoj-fh3KFkskvBpfUFIcJNtsv4zIMFV-D8F3JA",
+ "disabled": true
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviewOpportunities"
+ },
+ "response": []
+ },
+ {
+ "name": "Get review opportunities for assembly (contest review and spec)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJoZWZmYW4iLCJleHAiOjE3NjYyODkyNDYsInVzZXJJZCI6IjEzMjQ1NiIsImlhdCI6MTQ1MDkyOTI0NiwiZW1haWwiOm51bGwsImp0aSI6IjEzNjljNjAwLWUwYTEtNDUyNS1hN2M3LTU2YmU3ZDgxM2Y1MSJ9.hp5peSoj-fh3KFkskvBpfUFIcJNtsv4zIMFV-D8F3JA",
+ "disabled": true
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{apiUrl}}/v3/reviewOpportunities?challengeTypeId=14",
+ "host": [
+ "{{apiUrl}}"
+ ],
+ "path": [
+ "v3",
+ "reviewOpportunities"
+ ],
+ "query": [
+ {
+ "key": "challengeTypeId",
+ "value": "14",
+ "equals": true
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get review opportunities (challenge type id not supported)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJoZWZmYW4iLCJleHAiOjE3NjYyODkyNDYsInVzZXJJZCI6IjEzMjQ1NiIsImlhdCI6MTQ1MDkyOTI0NiwiZW1haWwiOm51bGwsImp0aSI6IjEzNjljNjAwLWUwYTEtNDUyNS1hN2M3LTU2YmU3ZDgxM2Y1MSJ9.hp5peSoj-fh3KFkskvBpfUFIcJNtsv4zIMFV-D8F3JA",
+ "disabled": true
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{apiUrl}}/v3/reviewOpportunities?challengeTypeId=100",
+ "host": [
+ "{{apiUrl}}"
+ ],
+ "path": [
+ "v3",
+ "reviewOpportunities"
+ ],
+ "query": [
+ {
+ "key": "challengeTypeId",
+ "value": "100",
+ "equals": true
+ }
+ ]
+ }
+ },
+ "response": []
+ },
+ {
+ "name": "Get review opportunities (challenge type id is not positive)",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJoZWZmYW4iLCJleHAiOjE3NjYyODkyNDYsInVzZXJJZCI6IjEzMjQ1NiIsImlhdCI6MTQ1MDkyOTI0NiwiZW1haWwiOm51bGwsImp0aSI6IjEzNjljNjAwLWUwYTEtNDUyNS1hN2M3LTU2YmU3ZDgxM2Y1MSJ9.hp5peSoj-fh3KFkskvBpfUFIcJNtsv4zIMFV-D8F3JA",
+ "disabled": true
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": {
+ "raw": "{{apiUrl}}/v3/reviewOpportunities?challengeTypeId=-14",
+ "host": [
+ "{{apiUrl}}"
+ ],
+ "path": [
+ "v3",
+ "reviewOpportunities"
+ ],
+ "query": [
+ {
+ "key": "challengeTypeId",
+ "value": "-14",
+ "equals": true
+ }
+ ]
+ }
+ },
+ "response": []
+ }
+ ]
+ },
+ {
+ "name": "Get list of all Scorecards",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/scorecards"
+ },
+ "response": []
+ },
+ {
+ "name": "Get list of all reviews Reviewer1",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Reviewer1 Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews"
+ },
+ "response": []
+ },
+ {
+ "name": "Get list of all reviews Reviewer2",
+ "request": {
+ "method": "GET",
+ "header": [
+ {
+ "key": "Authorization",
+ "value": "{{Reviewer2 Token}}"
+ },
+ {
+ "key": "Content-Type",
+ "value": "application/json"
+ }
+ ],
+ "body": {
+ "mode": "raw",
+ "raw": ""
+ },
+ "url": "{{apiUrl}}/v3/reviews"
+ },
+ "response": []
+ }
+ ]
+}
\ No newline at end of file
diff --git a/postman/review-microservice.postman_environment.json b/postman/review-microservice.postman_environment.json
new file mode 100755
index 0000000..748b0f3
--- /dev/null
+++ b/postman/review-microservice.postman_environment.json
@@ -0,0 +1,34 @@
+{
+ "id": "de37a461-f5ae-23ea-9c06-fdf7e8e05622",
+ "name": "review-microservice",
+ "values": [
+ {
+ "enabled": true,
+ "key": "apiUrl",
+ "value": "http://localhost:8080",
+ "type": "text"
+ },
+ {
+ "enabled": true,
+ "key": "Reviewer1 Token",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJyZXZpZXdlciJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoicmV2aWV3ZXIxIiwiZXhwIjoxNzY2Mjg5MjQ2LCJ1c2VySWQiOiIxMjM0IiwiaWF0IjoxNDUwOTI5MjQ2LCJlbWFpbCI6bnVsbCwianRpIjoiMTM2OWM2MDAtZTBhMS00NTI1LWE3YzctNTZiZTdkODEzZjUxIn0.4AOKcnvm4Wms_lY_RyYv61OHXCC-I__JnEPRZEN3-vM",
+ "type": "text"
+ },
+ {
+ "enabled": true,
+ "key": "Reviewer2 Token",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJyZXZpZXdlciJdLCJpc3MiOiJodHRwczovL2FwaS50b3Bjb2Rlci1kZXYuY29tIiwiaGFuZGxlIjoicmV2aWV3ZXIyIiwiZXhwIjoxNzY2Mjg5MjQ2LCJ1c2VySWQiOiIxMjM1IiwiaWF0IjoxNDUwOTI5MjQ2LCJlbWFpbCI6bnVsbCwianRpIjoiMTM2OWM2MDAtZTBhMS00NTI1LWE3YzctNTZiZTdkODEzZjUxIn0.RrkQ7srca99ctABa_VM9VYediC2mcg4hPOiQ1Roou14",
+ "type": "text"
+ },
+ {
+ "enabled": true,
+ "key": "Administrator Token",
+ "value": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJyb2xlcyI6WyJhZG1pbmlzdHJhdG9yIl0sImlzcyI6Imh0dHBzOi8vYXBpLnRvcGNvZGVyLWRldi5jb20iLCJoYW5kbGUiOiJhZG1pbiIsImV4cCI6MTc2NjI4OTI0NiwidXNlcklkIjoiNTU1NSIsImlhdCI6MTQ1MDkyOTI0NiwiZW1haWwiOm51bGwsImp0aSI6IjEzNjljNjAwLWUwYTEtNDUyNS1hN2M3LTU2YmU3ZDgxM2Y1MSJ9.Wg4nPCva9opNyrYQTngSoXetXr-W-ZSDtD2jae1gswk",
+ "type": "text"
+ }
+ ],
+ "timestamp": 1507999856202,
+ "_postman_variable_scope": "environment",
+ "_postman_exported_at": "2017-10-14T21:32:17.437Z",
+ "_postman_exported_using": "Postman/5.3.0"
+}
diff --git a/service/build/Dockerfile.template b/service/build/Dockerfile.template
index 323f307..02c9481 100644
--- a/service/build/Dockerfile.template
+++ b/service/build/Dockerfile.template
@@ -1,6 +1,6 @@
FROM appiriodevops/ap-microservice-base:0.0.1
-MAINTAINER mdesiderio@appirio.com
+MAINTAINER devops+jenkins@topcoder.com
WORKDIR /data
diff --git a/service/build/deploy.sh b/service/build/deploy.sh
index 1dc8864..4132c22 100755
--- a/service/build/deploy.sh
+++ b/service/build/deploy.sh
@@ -41,10 +41,11 @@ cp $WORKSPACE/service/target/review-microservice*.jar review-microservice.jar
cp $WORKSPACE/service/src/main/resources/review-service.yaml review-service.yaml
echo "Building docker image $DOCKER_REPO/$IMAGE"
-sudo docker build -t $DOCKER_REPO/$IMAGE $DEPLOY_DIR
+docker build -t $DOCKER_REPO/$IMAGE $DEPLOY_DIR
echo "Pushing image to docker $DOCKER_REPO/$IMAGE"
-sudo docker push $DOCKER_REPO/$IMAGE
+#docker login -u ykohata
+docker push $DOCKER_REPO/$IMAGE
echo "Generating dockerrun file"
cat $DOCKERRUN_TEMPLATE | sed -e "s/@IMAGE@/${IMAGE}/g" > $DOCKERRUN
diff --git a/service/pom.xml b/service/pom.xml
index 51aa367..20c1190 100644
--- a/service/pom.xml
+++ b/service/pom.xml
@@ -10,8 +10,8 @@
1.0.0
1.5.4
2.7.3
- 4.0.0
- 1.0.16-SNAPSHOT
+ 4.0.1-DEV
+ 1.0.20-SNAPSHOT
@@ -105,7 +105,7 @@
-
+
org.javassist
@@ -242,12 +242,12 @@
appirio-repo
Appirio Maven Repository
- file:///mnt/maven/repository
+ http://maven.topcoder-dev.com:8080/
appirio-repo
Appirio Maven Repository
- file:///mnt/maven/repository
+ http://maven.topcoder-dev.com:8080/
@@ -265,7 +265,7 @@
false
-
org.apache.maven.plugins
@@ -294,26 +294,33 @@
+
+ temp-maven-repo
+ https://github.com/appirio-tech/temp-maven-repo/raw/master
+
+ true
+ always
+
+
+
+ Appirio Technology Maven Repository
+ http://maven.topcoder-dev.com:8080/
+
+ always
+
+
+ always
+
+
com.springsource.repository.bundles.release
SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases
http://repository.springsource.com/maven/bundles/release
-
com.springsource.repository.bundles.external
SpringSource Enterprise Bundle Repository - External Bundle Releases
http://repository.springsource.com/maven/bundles/external
-
- Appirio Technology Maven Repository
- http://maven.appirio.net:8080/
-
- always
-
-
- always
-
-
diff --git a/service/sql/populate-db-samples.sql b/service/sql/populate-db-samples.sql
old mode 100644
new mode 100755
index 5da42b3..84f4012
--- a/service/sql/populate-db-samples.sql
+++ b/service/sql/populate-db-samples.sql
@@ -394,4 +394,4 @@ INSERT INTO REVIEW_PROCESS (
'PEER',
'PEER',
1
-);
\ No newline at end of file
+);
diff --git a/service/sql/review-process.sql b/service/sql/review-process.sql
old mode 100644
new mode 100755
index 53afeb2..cf85813
--- a/service/sql/review-process.sql
+++ b/service/sql/review-process.sql
@@ -90,4 +90,4 @@ CREATE TABLE SCORECARD_ITEM (
FOREIGN KEY (scorecardId) references SCORECARD(id),
FOREIGN KEY (questionId) references SCORECARD_QUESTION(id),
FOREIGN KEY (questionOptionId) references SCORECARD_QUESTION_OPTION(id)
-);
\ No newline at end of file
+);
diff --git a/service/src/main/java/com/appirio/service/resourcefactory/ReviewFactory.java b/service/src/main/java/com/appirio/service/resourcefactory/ReviewFactory.java
index 9abab88..3b126d7 100644
--- a/service/src/main/java/com/appirio/service/resourcefactory/ReviewFactory.java
+++ b/service/src/main/java/com/appirio/service/resourcefactory/ReviewFactory.java
@@ -3,6 +3,7 @@
import io.dropwizard.setup.Environment;
import com.appirio.service.review.ReviewServiceConfiguration;
+import com.appirio.service.review.manager.ChallengeManager;
import com.appirio.service.review.manager.ReviewManager;
import com.appirio.service.review.resources.ReviewResource;
import com.appirio.service.supply.resources.ResourceFactory;
@@ -10,8 +11,12 @@
/**
* Factory for ReviewResource
- *
- * @author rrecharla@appirio.com
+ *
+ * v1.1 Updates : https://www.topcoder.com/challenge-details/30059779/?type=develop
+ * Updated getResourceInstance() to set the ChallengeManager field.
+ *
+ * @author rrecharla@appirio.com, TCSCODE
+ * @version 1.1
*/
public class ReviewFactory implements ResourceFactory {
@@ -43,6 +48,7 @@ public ReviewFactory(ReviewServiceConfiguration config, Environment env) {
@Override
public ReviewResource getResourceInstance() throws SupplyException {
final ReviewManager reviewManager = new ReviewManager();
- return new ReviewResource(reviewManager);
+ final ChallengeManager challengeManager = new ChallengeManager();
+ return new ReviewResource(reviewManager, challengeManager);
}
}
diff --git a/service/src/main/java/com/appirio/service/resourcefactory/ReviewOpportunitiesFactory.java b/service/src/main/java/com/appirio/service/resourcefactory/ReviewOpportunitiesFactory.java
new file mode 100644
index 0000000..d9e0baf
--- /dev/null
+++ b/service/src/main/java/com/appirio/service/resourcefactory/ReviewOpportunitiesFactory.java
@@ -0,0 +1,35 @@
+package com.appirio.service.resourcefactory;
+
+import com.appirio.service.review.manager.ReviewOpportunitiesManager;
+import com.appirio.service.review.resources.ReviewOpportunitiesResource;
+import com.appirio.service.supply.resources.ResourceFactory;
+import com.appirio.supply.SupplyException;
+
+/**
+ * ReviewOpportunitiesFactory is used to create the ReviewOpportunitiesResource
+ *
+ * It's added in Topcoder - Create Endpoint to Fetch Review Opportunities v1.0
+ *
+ * @author TCCoder
+ * @version 1.0
+ *
+ */
+public class ReviewOpportunitiesFactory implements ResourceFactory {
+
+ /**
+ * Simple constructor to initialize ReviewOpportunitiesFactory
+ */
+ public ReviewOpportunitiesFactory() {
+ }
+
+ /**
+ * Get ReviewOpportunitiesResource object
+ * @return ReviewOpportunitiesResource the review opportunities resource
+ * @throws SupplyException exception for supply server
+ */
+ @Override
+ public ReviewOpportunitiesResource getResourceInstance() throws SupplyException {
+ final ReviewOpportunitiesManager reviewOpportunitiesManager = new ReviewOpportunitiesManager();
+ return new ReviewOpportunitiesResource(reviewOpportunitiesManager);
+ }
+}
\ No newline at end of file
diff --git a/service/src/main/java/com/appirio/service/review/ReviewServiceApplication.java b/service/src/main/java/com/appirio/service/review/ReviewServiceApplication.java
index e596c7a..5b7d754 100644
--- a/service/src/main/java/com/appirio/service/review/ReviewServiceApplication.java
+++ b/service/src/main/java/com/appirio/service/review/ReviewServiceApplication.java
@@ -6,6 +6,7 @@
import com.appirio.service.resourcefactory.PeerReviewFactory;
import com.appirio.service.resourcefactory.ReviewFactory;
import com.appirio.service.resourcefactory.ReviewItemFactory;
+import com.appirio.service.resourcefactory.ReviewOpportunitiesFactory;
import com.appirio.service.resourcefactory.ScorecardFactory;
import com.appirio.service.resourcefactory.ScorecardQuestionFactory;
import com.appirio.service.supply.resources.SupplyDatasourceFactory;
@@ -15,8 +16,13 @@
/**
* Main application class for the review service application.
+ *
+ * Version 1.1 - Topcoder - Create Endpoint to Fetch Review Opportunities v1.0
+ * - register ReviewOpportunitiesFactory in registerResources
+ *
*
* @author TCDEVELOPER
+ * @version 1.1
*/
public class ReviewServiceApplication extends BaseApplication {
@@ -56,9 +62,10 @@ protected void logServiceSpecificConfigs(ReviewServiceConfiguration config) {
}
/**
+ * Register resources for the application
* @see BaseApplication
- * @param config ReviewServiceConfiguration
- * @param env Environment
+ * @param config the ReviewServiceConfiguration
+ * @param env the Environment
*/
@Override
protected void registerResources(ReviewServiceConfiguration config, Environment env) throws Exception {
@@ -70,6 +77,7 @@ protected void registerResources(ReviewServiceConfiguration config, Environment
env.jersey().register(new ReviewItemFactory(config, env).getResourceInstance());
env.jersey().register(new ScorecardFactory(config, env).getResourceInstance());
env.jersey().register(new ScorecardQuestionFactory(config, env).getResourceInstance());
+ env.jersey().register(new ReviewOpportunitiesFactory().getResourceInstance());
}
/**
diff --git a/service/src/main/java/com/appirio/service/review/api/AutoPilot.java b/service/src/main/java/com/appirio/service/review/api/AutoPilot.java
new file mode 100644
index 0000000..7b22a8a
--- /dev/null
+++ b/service/src/main/java/com/appirio/service/review/api/AutoPilot.java
@@ -0,0 +1,20 @@
+package com.appirio.service.review.api;
+
+import javax.validation.constraints.NotNull;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * This class represents a challenge instance
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+@Getter
+@Setter
+public class AutoPilot {
+ @NotNull
+ private Boolean enable;
+}
\ No newline at end of file
diff --git a/service/src/main/java/com/appirio/service/review/api/Challenge.java b/service/src/main/java/com/appirio/service/review/api/Challenge.java
new file mode 100644
index 0000000..eafa289
--- /dev/null
+++ b/service/src/main/java/com/appirio/service/review/api/Challenge.java
@@ -0,0 +1,35 @@
+package com.appirio.service.review.api;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * This class represents a challenge instance
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+@Getter
+@Setter
+public class Challenge {
+ /**
+ * The challenge id.
+ */
+ private Long id;
+
+ /**
+ * The challenge name.
+ */
+ private String name;
+
+ /**
+ * The challenge status.
+ */
+ private String status;
+
+ /**
+ * The challenge current active phase.
+ */
+ private String activePhase;
+}
\ No newline at end of file
diff --git a/service/src/main/java/com/appirio/service/review/api/Payment.java b/service/src/main/java/com/appirio/service/review/api/Payment.java
new file mode 100644
index 0000000..a1a6d3c
--- /dev/null
+++ b/service/src/main/java/com/appirio/service/review/api/Payment.java
@@ -0,0 +1,41 @@
+package com.appirio.service.review.api;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import lombok.Setter;
+
+/**
+ * Represents the Payment entity.
+ *
+ * It's added in Topcoder - Update Review Opportunities Endpoint
+ *
+ * @author TCCoder
+ * @version 1.0
+ */
+@AllArgsConstructor
+@NoArgsConstructor
+public class Payment {
+
+ /**
+ * Represents the reviewer role
+ */
+ @Setter
+ @Getter
+ private String role;
+
+ /**
+ * Represents the reviewer role id
+ */
+ @Setter
+ @Getter
+ private long roleId;
+
+
+ /**
+ * Represents the reviewer payment
+ */
+ @Setter
+ @Getter
+ private Double payment;
+}
diff --git a/service/src/main/java/com/appirio/service/review/api/ReviewOpportunitiesDTO.java b/service/src/main/java/com/appirio/service/review/api/ReviewOpportunitiesDTO.java
new file mode 100644
index 0000000..50ad585
--- /dev/null
+++ b/service/src/main/java/com/appirio/service/review/api/ReviewOpportunitiesDTO.java
@@ -0,0 +1,150 @@
+package com.appirio.service.review.api;
+
+import java.util.Date;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Represents the ReviewOpportunitiesDTO entity.
+ *
+ * It's added in Topcoder - Create Endpoint to Fetch Review Opportunities v1.0
+ *
+ * @author TCCoder
+ * @version 1.0
+ */
+public class ReviewOpportunitiesDTO {
+ /**
+ * Represents the review auction id attribute.
+ */
+ @Getter
+ @Setter
+ private long reviewAuctionId;
+
+ /**
+ * Represents the review auction type id attribute.
+ */
+ @Getter
+ @Setter
+ private int reviewAuctionTypeId;
+
+ /**
+ * Represents the challenge id attribute.
+ */
+ @Getter
+ @Setter
+ private long challengeId;
+
+ /**
+ * Represents the number of submissions attribute.
+ */
+ @Getter
+ @Setter
+ private int numberOfSubmissions;
+
+ /**
+ * Represents the review start attribute.
+ */
+ @Getter
+ @Setter
+ private Date reviewStart;
+
+ /**
+ * Represents the review end attribute.
+ */
+ @Getter
+ @Setter
+ private Date reviewEnd;
+
+ /**
+ * Represents the number of review positions available attribute.
+ */
+ @Getter
+ @Setter
+ private int numberOfReviewPositionsAvailable;
+
+ /**
+ * Represents the challenge type attribute.
+ */
+ @Getter
+ @Setter
+ private String challengeType;
+
+ /**
+ * Represents the challenge type id attribute.
+ */
+ @Getter
+ @Setter
+ private int challengeTypeId;
+
+ /**
+ * Represents the review type attribute.
+ */
+ @Getter
+ @Setter
+ private String reviewType;
+
+ /**
+ * Represents the challenge name attribute.
+ */
+ @Getter
+ @Setter
+ private String challengeName;
+
+ /**
+ * Represents the challenge version attribute.
+ */
+ @Getter
+ @Setter
+ private String ChallengeVersion;
+
+ /**
+ * Represents the review application role id attribute.
+ */
+ @Getter
+ @Setter
+ private long reviewApplicationRoleId;
+
+ /**
+ * Represents the resource role id attribute.
+ */
+ @Getter
+ @Setter
+ private long resourceRoleId;
+
+ /**
+ * Represents the fixed amount attribute.
+ */
+ @Getter
+ @Setter
+ private double fixedAmount;
+
+ /**
+ * Represents the base coefficient attribute.
+ */
+ @Getter
+ @Setter
+ private double baseCoefficient;
+
+ /**
+ * Represents the incremental coefficient attribute.
+ */
+ @Getter
+ @Setter
+ private double incrementalCoefficient;
+
+ /**
+ * Represents the prize attribute.
+ */
+ @Getter
+ @Setter
+ private double prize;
+
+ /**
+ * Represents the submission count attribute.
+ */
+ @Getter
+ @Setter
+ private int submissionCount;
+
+}
\ No newline at end of file
diff --git a/service/src/main/java/com/appirio/service/review/api/ReviewOpportunityItem.java b/service/src/main/java/com/appirio/service/review/api/ReviewOpportunityItem.java
new file mode 100644
index 0000000..2ce39cc
--- /dev/null
+++ b/service/src/main/java/com/appirio/service/review/api/ReviewOpportunityItem.java
@@ -0,0 +1,93 @@
+package com.appirio.service.review.api;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * Represents the ReviewOpportunityItem entity.
+ *
+ * It's added in Topcoder - Create Endpoint to Fetch Review Opportunities version 1.0
+ *
+ * Updates in Topcoder - Update Review Opportunities Endpoint
+ * - remove payment
+ * - add payments as a list of Payment
+ *
+ * @author TCCoder
+ * @version 1.0
+ */
+public class ReviewOpportunityItem {
+ /**
+ * Represents the id attribute.
+ */
+ @Getter
+ @Setter
+ private long id;
+
+ /**
+ * Represents the start date attribute.
+ */
+ @Getter
+ @Setter
+ @JsonFormat(pattern = "EEE MMM dd yyyy hh:mm:ss z", locale = "us")
+ private Date startDate;
+
+ /**
+ * Represents the submissions attribute.
+ */
+ @Getter
+ @Setter
+ private int submissions;
+
+ /**
+ * Represents the open positions attribute.
+ */
+ @Getter
+ @Setter
+ private int openPositions;
+
+ /**
+ * Represents the type attribute.
+ */
+ @Getter
+ @Setter
+ private String type;
+
+ /**
+ * Represents the challenge id attribute.
+ */
+ @Getter
+ @Setter
+ @JsonIgnore
+ private long challengeId;
+
+ /**
+ * Represents the challenge name attribute.
+ */
+ @Getter
+ @Setter
+ @JsonIgnore
+ private String challengeName;
+
+ /**
+ * Represents the challenge attribute.
+ * The keys will be 'id', 'title' and 'version', and the corresponding values will be the id, name and version of the challenge.
+ */
+ @Getter
+ @Setter
+ private Map challenge;
+
+ /**
+ * Represents the payment attribute.
+ */
+ @Getter
+ @Setter
+ private List payments;
+
+}
\ No newline at end of file
diff --git a/service/src/main/java/com/appirio/service/review/authorization/manager/ReviewAuthorizationManager.java b/service/src/main/java/com/appirio/service/review/authorization/manager/ReviewAuthorizationManager.java
index ec05fd4..8346f8f 100644
--- a/service/src/main/java/com/appirio/service/review/authorization/manager/ReviewAuthorizationManager.java
+++ b/service/src/main/java/com/appirio/service/review/authorization/manager/ReviewAuthorizationManager.java
@@ -11,9 +11,16 @@
* Review authorization manager
*
* @see AuthorizationManager
+ *
+ * v1.1 (ADMIN APP CHALLENGE FEE AND REVIEW MANAGEMENT API)
+ *
+ * - Updated canRead() to allow the administrator to read a review
+ * - Updated canReadWriteDelete() to allow administrator to delete reviews
+ *
+ *
*
- * @author mdesiderio@appirio.com
- *
+ * @author mdesiderio@appirio.com, TCSCODER
+ * @version 1.1
*/
public class ReviewAuthorizationManager extends AuthorizationManager {
@@ -91,7 +98,8 @@ public boolean canRead(Review model, AuthorizationContext context) {
// -- The user is the reviewer resource
// -- The user is the submitter and the review is committed
return principalIsReviewer(model, context)
- || (principalIsSubmitter(model, context) && reviewIsCommitted(model));
+ || (principalIsSubmitter(model, context) && reviewIsCommitted(model))
+ || context.getPrincipal().hasRole("administrator");
}
/**
@@ -119,10 +127,7 @@ public boolean canReadWrite(Review model, AuthorizationContext context) {
*/
@Override
public boolean canReadWriteDelete(Review model, AuthorizationContext context) {
- // Only administrators can delete reviews, and this functionality is not
- // yet implemented in the
- // review microservice
- return false;
+ // Only administrators are allowed to delete reviews.
+ return context.getPrincipal().hasRole("administrator");
}
-
}
diff --git a/service/src/main/java/com/appirio/service/review/dao/ChallengeDAO.java b/service/src/main/java/com/appirio/service/review/dao/ChallengeDAO.java
new file mode 100644
index 0000000..cf50dd3
--- /dev/null
+++ b/service/src/main/java/com/appirio/service/review/dao/ChallengeDAO.java
@@ -0,0 +1,25 @@
+package com.appirio.service.review.dao;
+
+import org.skife.jdbi.v2.sqlobject.Bind;
+import com.appirio.service.review.api.Challenge;
+import com.appirio.supply.dataaccess.DatasourceName;
+import com.appirio.supply.dataaccess.SqlQueryFile;
+
+/**
+ * DAO to access challenge related data
+ *
+ * @author TCSCODER
+ * @version 1.0
+ */
+@DatasourceName("oltp")
+public interface ChallengeDAO {
+
+ /**
+ * Get a challenge by id.
+ *
+ * @param challengeId the id of the challenge to retrieve.
+ * @return The Challenge instance
+ */
+ @SqlQueryFile("sql/challenge/get-by-id.sql")
+ Challenge getChallenge(@Bind("challengeId") Long challengeId);
+}
\ No newline at end of file
diff --git a/service/src/main/java/com/appirio/service/review/dao/ReviewDAO.java b/service/src/main/java/com/appirio/service/review/dao/ReviewDAO.java
index f264ee4..082e3a2 100644
--- a/service/src/main/java/com/appirio/service/review/dao/ReviewDAO.java
+++ b/service/src/main/java/com/appirio/service/review/dao/ReviewDAO.java
@@ -18,13 +18,24 @@
import java.util.Map;
/**
- * DAO to handle review data
+ * DAO to handle review data.
+ *
+ *
+ * Version 1.1 (ADMIN APP CHALLENGE FEE AND REVIEW MANAGEMENT API)
+ *
+ * - Added method resetAggregation()
+ * - Added method resetReview()
+ * - Added method updateAutoPilot()
+ * - Added method reopenReview()
+ * - Added method deleteReview()
+ *
+ *
*
- * @author mdesiderio@appirio.com
+ * @author mdesiderio@appirio.com, TCSCODER
+ * @version 1.1
*/
@DatasourceName("oltp")
public interface ReviewDAO {
-
/**
* Get a single review by id. Authenticated version to be invoked by
* managers / resources
@@ -35,8 +46,7 @@ public interface ReviewDAO {
*/
@AuthManager(ReviewAuthorizationManager.class)
@SqlQueryFile("sql/review/review-by-id-query.sql")
- Review getReview(@Bind("reviewId") Long reviewId,
- @AuthContext AuthorizationContext authContext);
+ Review getReview(@Bind("reviewId") Long reviewId, @AuthContext AuthorizationContext authContext);
/**
* Get a single review by id. Unauthenticated version for internal use
@@ -49,16 +59,15 @@ Review getReview(@Bind("reviewId") Long reviewId,
// TODO: document this
@SqlUpdateFile("sql/review/review-update.sql")
- void updateReview(@Audit @Validate @BindBean Review review,
- @AuditActionPerformer @Bind("userId") Long userId);
+ void updateReview(@Audit @Validate @BindBean Review review, @AuditActionPerformer @Bind("userId") Long userId);
// TODO: document this
// TODO: Test this
@SqlUpdateFile("sql/review/review-update-user-editable-fields.sql")
void updateReviewUserEditableFields(
- @AuthManager(ReviewAuthorizationManager.class) @Audit @Validate @BindBean Review review,
- @AuditActionPerformer @Bind("userId") Long userId,
- @AuthContext AuthorizationContext authContext);
+ @AuthManager(ReviewAuthorizationManager.class) @Audit @Validate @BindBean Review review,
+ @AuditActionPerformer @Bind("userId") Long userId,
+ @AuthContext AuthorizationContext authContext);
/**
* Creates a new review
@@ -67,8 +76,7 @@ void updateReviewUserEditableFields(
* @param userId user id
*/
@SqlUpdateFile("sql/review/review-insert.sql")
- void createReview(@Audit @Validate @BindBean Review review,
- @AuditActionPerformer @Bind("userId") Long userId);
+ void createReview(@Audit @Validate @BindBean Review review, @AuditActionPerformer @Bind("userId") Long userId);
/**
* For a given user and a given challenge, returns the counts of how many
@@ -79,8 +87,7 @@ void createReview(@Audit @Validate @BindBean Review review,
* @return returns counts of pending, submitted and total reviews
*/
@SqlQueryFile("sql/review/user-review-count-query.sql")
- Map getUserReviewsCount(@Bind("userId") Long userId,
- @Bind("challengeId") Long challengeId);
+ Map getUserReviewsCount(@Bind("userId") Long userId, @Bind("challengeId") Long challengeId);
/**
* Submissions associated with a challenge, not reviewed by the user, not
@@ -95,9 +102,8 @@ Map getUserReviewsCount(@Bind("userId") Long userId,
* @return list of submissions
*/
@SqlQueryFile("sql/review/next-submission-to-review-by-required-reviews-query.sql")
- List