realmCount
}
}
- @GetMapping("/realmCountry")
+ /**
+ * API used to get the complete RealmCountry list. Will only return those
+ * RealmCountries that are marked Active.
+ *
+ * @param auth
+ * @return returns the complete list of active RealmCountries
+ */
+ @Operation(description = "API used to get the complete RealmCountry list. Will only return those RealmCountries that are marked Active.", summary = "Get active RealmCountry list", tags = ("realmCountry"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the RealmCountry list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if no RealmCountry found")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of RealmCountry list")
+ @GetMapping("/")
public ResponseEntity getRealmCountry(Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -101,7 +144,21 @@ public ResponseEntity getRealmCountry(Authentication auth) {
}
}
- @GetMapping("/realmCountry/{realmCountryId}")
+ /**
+ * API used to get the RealmCountry for a specific RealmCountryId
+ *
+ * @param realmCountryId realmCountryId that you want RealmCountry for
+ * @param auth
+ * @return returns the RealmCountry object based on RealmCountryId specified
+ */
+ @Operation(description = "API used to get the RealmCountry for a specific RealmCountryId", summary = "Get RealmCountry for a specific RealmCountryId", tags = ("realmCountry"))
+ @Parameters(
+ @Parameter(name = "realmCountryId", description = "RealmCountryId that you want RealmCountry for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the RealmCountry object")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if no RealmCountryId found")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of RealmCountry object")
+ @GetMapping("/{realmCountryId}")
public ResponseEntity getRealmCountry(@PathVariable("realmCountryId") int realmCountryId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -118,7 +175,21 @@ public ResponseEntity getRealmCountry(@PathVariable("realmCountryId") int realmC
}
}
- @GetMapping("/realmCountry/realmId/{realmId}")
+ /**
+ * API used to get the RealmCountry list for a specific realmId
+ *
+ * @param realmId realmId that you want RealmCountry list for
+ * @param auth
+ * @return returns the RealmCountry list based on realmId specified
+ */
+ @Operation(description = "API used to get the RealmCountry list for a specific realmId", summary = "Get RealmCountry list for a specific realmId", tags = ("realmCountry"))
+ @Parameters(
+ @Parameter(name = "realmId", description = "RealmId that you want RealmCountry list for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the RealmCountry list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if no realmId found")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of RealmCountry list")
+ @GetMapping("/realmId/{realmId}")
public ResponseEntity getRealmCountryByRealmId(@PathVariable("realmId") int realmId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -135,11 +206,26 @@ public ResponseEntity getRealmCountryByRealmId(@PathVariable("realmId") int real
}
}
- @GetMapping("/realmCountry/{realmCountryId}/planningUnit")
+ /**
+ * API used to get the active PlanningUnit list for a specific
+ * realmCountryId
+ *
+ * @param realmCountryId realmCountryId that you want PlanningUnit list for
+ * @param auth
+ * @return returns the PlanningUnit list based on realmCountryId specified
+ */
+ @Operation(description = "API used to get the active PlanningUnit list for a specific realmCountryId", summary = "Get PlanningUnit list for a specific realmCountryId", tags = ("realmCountry"))
+ @Parameters(
+ @Parameter(name = "realmCountryId", description = "RealmCountryId that you want PlanningUnit list for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the PlanningUnit list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if no realmCountryId found")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of PlanningUnit list")
+ @GetMapping("/{realmCountryId}/planningUnit")
public ResponseEntity getPlanningUnitForCountry(@PathVariable("realmCountryId") int realmCountryId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
- return new ResponseEntity(this.realmCountryService.getPlanningUnitListForRealmCountryId(realmCountryId, false, curUser), HttpStatus.OK);
+ return new ResponseEntity(this.realmCountryService.getPlanningUnitListForRealmCountryId(realmCountryId, true, curUser), HttpStatus.OK);
} catch (EmptyResultDataAccessException e) {
logger.error("Error while trying to list PlanningUnit for Country", e);
return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.NOT_FOUND);
@@ -152,7 +238,24 @@ public ResponseEntity getPlanningUnitForCountry(@PathVariable("realmCountryId")
}
}
- @PutMapping("/realmCountry/programIds/planningUnit")
+ /**
+ * API used to get the RealmCountryPlanningUnit list for a specific
+ * programIds
+ *
+ * @param programIds Array of programIds that you want
+ * RealmCountryPlanningUnit list for
+ * @param auth
+ * @return returns the RealmCountryPlanningUnit list based on programIds
+ * specified
+ */
+ @Operation(description = "API used to get RealmCountryPlanningUnit list for a specific programIds", summary = "Get RealmCountryPlanningUnit list for a specific programIds", tags = ("realmCountry"))
+ @Parameters(
+ @Parameter(name = "programIds", description = "Array of programIds that you want RealmCountryPlanningUnit list for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the RealmCountryPlanningUnit list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if no programIds found")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of RealmCountryPlanningUnit list")
+ @PutMapping("/programIds/planningUnit")
public ResponseEntity getPlanningUnitForProgramList(@RequestBody String[] programIds, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -169,7 +272,23 @@ public ResponseEntity getPlanningUnitForProgramList(@RequestBody String[] progra
}
}
- @GetMapping("/realmCountry/{realmCountryId}/planningUnit/all")
+ /**
+ * API used to get the complete PlanningUnit list for a specific
+ * realmCountryId
+ *
+ * @param realmCountryId realmCountryId that you want PlanningUnit list for
+ * @param auth
+ * @return returns the complete PlanningUnit list based on realmCountryId
+ * specified
+ */
+ @Operation(description = "API used to get the complete PlanningUnit list for a specific realmCountryId", summary = "Get Complete PlanningUnit list for a specific realmCountryId", tags = ("realmCountry"))
+ @Parameters(
+ @Parameter(name = "realmCountryId", description = "RealmCountryId that you want PlanningUnit list for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the PlanningUnit list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if no realmCountryId found")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of PlanningUnit list")
+ @GetMapping("/{realmCountryId}/planningUnit/all")
public ResponseEntity getPlanningUnitForCountryAll(@PathVariable("realmCountryId") int realmCountryId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -186,7 +305,21 @@ public ResponseEntity getPlanningUnitForCountryAll(@PathVariable("realmCountryId
}
}
- @PutMapping("/realmCountry/planningUnit")
+ /**
+ * API used to save PlanningUnit for RealmCountry
+ *
+ * @param realmCountryPlanningUnits Array of realmCountryPlanningUnits that
+ * you want to save
+ * @param auth
+ * @return returns a Success code if the operation was successful
+ */
+ @Operation(description = "API used to save PlanningUnit for RealmCountry", summary = "Save PlanningUnit for RealmCountry", tags = ("realmCountry"))
+ @Parameters(
+ @Parameter(name = "realmCountryPlanningUnits", description = "Array of realmCountryPlanningUnits that you want to save"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns a Success code if the operation was successful")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Returns a HttpStatus.INTERNAL_SERVER_ERROR if there was some other error that did not allow the operation to complete")
+ @PutMapping("/planningUnit")
public ResponseEntity savePlanningUnitForCountry(@RequestBody RealmCountryPlanningUnit[] realmCountryPlanningUnits, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -201,7 +334,22 @@ public ResponseEntity savePlanningUnitForCountry(@RequestBody RealmCountryPlanni
}
}
- @GetMapping("/realmCountry/program/realmId/{realmId}")
+ /**
+ * API used to get the RealmCountry list by specified reamId for active
+ * programs
+ *
+ * @param realmId realmId that you want RealmCountry list for
+ * @param auth
+ * @return returns the RealmCountry list by reamId for active programs
+ */
+ @Operation(description = "API used to get the RealmCountry list by specified reamId for active programs", summary = "Get RealmCountry list by specified reamId for active programs", tags = ("realmCountry"))
+ @Parameters(
+ @Parameter(name = "realmId", description = "RealmId that you want RealmCountry list for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the RealmCountry list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if no realmId found")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of RealmCountry list")
+ @GetMapping("/program/realmId/{realmId}")
public ResponseEntity getRealmCountryByRealmIdForActivePrograms(@PathVariable("realmId") int realmId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -218,7 +366,19 @@ public ResponseEntity getRealmCountryByRealmIdForActivePrograms(@PathVariable("r
}
}
- @GetMapping("/realmCountry/program")
+ /**
+ * API used to get the RealmCountry list active programs
+ *
+ * @param auth
+ * @return returns the RealmCountry list active programs
+ */
+ @Operation(description = "API used to get the RealmCountry list active programs", summary = "Get the RealmCountry list active programs", tags = ("realmCountry"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the RealmCountry list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "412", description = "Returns a HttpStatus.PRECONDITION_FAILED if a User with access to multiple Realms tried to access a RealmCountry Program list without specifying a Realm")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if no RealmCountry found")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of RealmCountry list")
+ @GetMapping("/program")
public ResponseEntity getRealmCountryForActivePrograms(Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
diff --git a/src/main/java/cc/altius/FASP/rest/controller/RealmRestController.java b/src/main/java/cc/altius/FASP/rest/controller/RealmRestController.java
index 9e94f5d69..e6e6f8a88 100755
--- a/src/main/java/cc/altius/FASP/rest/controller/RealmRestController.java
+++ b/src/main/java/cc/altius/FASP/rest/controller/RealmRestController.java
@@ -10,6 +10,11 @@
import cc.altius.FASP.model.ResponseCode;
import cc.altius.FASP.service.RealmService;
import cc.altius.FASP.service.UserService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +37,7 @@
* @author altius
*/
@RestController
-@RequestMapping("/api")
+@RequestMapping("/api/realm")
public class RealmRestController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -42,8 +47,73 @@ public class RealmRestController {
@Autowired
private UserService userService;
- @PostMapping(path = "/realm")
- public ResponseEntity postRealm(@RequestBody Realm realm, Authentication auth) {
+ /**
+ * API used to get the complete Realm list.
+ *
+ * @param auth
+ * @return returns the complete list of Realms
+ */
+ @GetMapping("/")
+ @Operation(description = "API used to get the complete Realm list.", summary = "Get Realm list", tags = ("realm"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Realm list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Realm list")
+ public ResponseEntity getRealm(Authentication auth) {
+ try {
+ CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
+ return new ResponseEntity(this.realmService.getRealmList(true, curUser), HttpStatus.OK);
+ } catch (Exception e) {
+ logger.error("Error while trying to list Realm", e);
+ return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * API used to get the Realm for a specific RealmId
+ *
+ * @param realmId RealmId that you want the Realm Object for
+ * @param auth
+ * @return returns the Realm object based on RealmId specified
+ */
+ @GetMapping(value = "/{realmId}")
+ @Operation(description = "API used to get the Realm for a specific RealmId", summary = "Get Realm for a RealmId", tags = ("realm"))
+ @Parameters(
+ @Parameter(name = "realmId", description = "RealmId that you want to the Realm for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Realm")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if the RealmId specified does not exist")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Realm")
+
+ public ResponseEntity getRealmById(@PathVariable("realmId") int realmId, Authentication auth) {
+ try {
+ CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
+ return new ResponseEntity(this.realmService.getRealmById(realmId, curUser), HttpStatus.OK);
+ } catch (AccessDeniedException ae) {
+ logger.error("Error while trying to list Realm", ae);
+ return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.FORBIDDEN);
+ } catch (EmptyResultDataAccessException ae) {
+ logger.error("Error while trying to list Realm", ae);
+ return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.NOT_FOUND);
+ } catch (Exception e) {
+ logger.error("Error while trying to list Realm", e);
+ return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * API used to add a Realm
+ *
+ * @param realm Realm object that you want to add
+ * @param auth
+ * @return returns a Success code if the operation was successful
+ */
+ @PostMapping(value = "/")
+ @Operation(description = "API used to add a Realm", summary = "Add Realm", tags = ("realm"))
+ @Parameters(
+ @Parameter(name = "realm", description = "The Realm object that you want to add"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns a Success code if the operation was successful")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "406", description = "Returns a HttpStatus.NOT_ACCEPTABLE if the data supplied is not unique")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Returns a HttpStatus.INTERNAL_SERVER_ERROR if there was some other error that did not allow the operation to complete")
+ public ResponseEntity addRealm(@RequestBody Realm realm, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
this.realmService.addRealm(realm, curUser);
@@ -57,8 +127,22 @@ public ResponseEntity postRealm(@RequestBody Realm realm, Authentication auth) {
}
}
- @PutMapping(path = "/realm")
- public ResponseEntity putRealm(@RequestBody Realm realm, Authentication auth) {
+ /**
+ * API used to update a Realm
+ *
+ * @param realm Realm object that you want to update
+ * @param auth
+ * @return returns a Success code if the operation was successful
+ */
+ @PutMapping(path = "/")
+ @Operation(description = "API used to update a Realm", summary = "Update Realm", tags = ("realm"))
+ @Parameters(
+ @Parameter(name = "realm", description = "The Realm object that you want to update"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns a Success code if the operation was successful")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "406", description = "Returns a HttpStatus.NOT_ACCEPTABLE if the data supplied is not unique")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Returns a HttpStatus.INTERNAL_SERVER_ERROR if there was some other error that did not allow the operation to complete")
+ public ResponseEntity updateRealm(@RequestBody Realm realm, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
this.realmService.updateRealm(realm, curUser);
@@ -75,34 +159,6 @@ public ResponseEntity putRealm(@RequestBody Realm realm, Authentication auth) {
}
}
- @GetMapping("/realm")
- public ResponseEntity getRealm(Authentication auth) {
- try {
- CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
- return new ResponseEntity(this.realmService.getRealmList(true, curUser), HttpStatus.OK);
- } catch (Exception e) {
- logger.error("Error while trying to list Realm", e);
- return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- }
-
- @GetMapping("/realm/{realmId}")
- public ResponseEntity getRealm(@PathVariable("realmId") int realmId, Authentication auth) {
- try {
- CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
- return new ResponseEntity(this.realmService.getRealmById(realmId, curUser), HttpStatus.OK);
- } catch (AccessDeniedException ae) {
- logger.error("Error while trying to list Realm", ae);
- return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.FORBIDDEN);
- } catch (EmptyResultDataAccessException ae) {
- logger.error("Error while trying to list Realm", ae);
- return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.NOT_FOUND);
- } catch (Exception e) {
- logger.error("Error while trying to list Realm", e);
- return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- }
-
// @GetMapping(value = "/sync/realm/{lastSyncDate}")
// public ResponseEntity getRealmListForSync(@PathVariable("lastSyncDate") String lastSyncDate, Authentication auth) {
// try {
diff --git a/src/main/java/cc/altius/FASP/rest/controller/RegionRestController.java b/src/main/java/cc/altius/FASP/rest/controller/RegionRestController.java
index a983a951e..78b914831 100755
--- a/src/main/java/cc/altius/FASP/rest/controller/RegionRestController.java
+++ b/src/main/java/cc/altius/FASP/rest/controller/RegionRestController.java
@@ -10,6 +10,11 @@
import cc.altius.FASP.model.ResponseCode;
import cc.altius.FASP.service.RegionService;
import cc.altius.FASP.service.UserService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -32,7 +37,7 @@
* @author altius
*/
@RestController
-@RequestMapping("/api")
+@RequestMapping("/api/region")
public class RegionRestController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -42,42 +47,17 @@ public class RegionRestController {
@Autowired
private UserService userService;
-// @PostMapping(value = "/region")
-// public ResponseEntity addRegion(@RequestBody Region region, Authentication auth) {
-// try {
-// CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
-// this.regionService.addRegion(region, curUser);
-// return new ResponseEntity(new ResponseCode("static.message.addSuccess"), HttpStatus.OK);
-// } catch (AccessDeniedException e) {
-// logger.error("Error while trying to add Region", e);
-// return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.FORBIDDEN);
-// } catch (DuplicateKeyException e) {
-// logger.error("Error while trying to add Region", e);
-// return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.NOT_ACCEPTABLE);
-// } catch (Exception e) {
-// logger.error("Error while trying to add Region", e);
-// return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
-// }
-// }
- @PutMapping(path = "/region")
- public ResponseEntity putRegion(@RequestBody Region[] regions, Authentication auth) {
- try {
- CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
- this.regionService.saveRegions(regions, curUser);
- return new ResponseEntity(new ResponseCode("static.message.updateSuccess"), HttpStatus.OK);
- } catch (AccessDeniedException e) {
- logger.error("Error while trying to update Region", e);
- return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.FORBIDDEN);
- } catch (DuplicateKeyException e) {
- logger.error("Error while trying to update Region", e);
- return new ResponseEntity(new ResponseCode("static.message.alreadExists"), HttpStatus.NOT_ACCEPTABLE);
- } catch (Exception e) {
- logger.error("Error while trying to update Region", e);
- return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- }
-
- @GetMapping("/region")
+ /**
+ * API used to get the complete Region list.
+ *
+ * @param auth
+ * @return returns the complete list of Regions
+ */
+ @GetMapping("/")
+ @Operation(description = "API used to get the complete Region list.", summary = "Get Region list", tags = ("region"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Region list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Region list")
public ResponseEntity getRegion(Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -91,8 +71,22 @@ public ResponseEntity getRegion(Authentication auth) {
}
}
- @GetMapping("/region/{regionId}")
- public ResponseEntity getRegion(@PathVariable("regionId") int regionId, Authentication auth) {
+ /**
+ * API used to get the Region for a specific RegionId
+ *
+ * @param regionId RegionId that you want the Region Object for
+ * @param auth
+ * @return returns the Region object based on RegionId specified
+ */
+ @GetMapping(value = "/{regionId}")
+ @Operation(description = "API used to get the Region for a specific RegionId", summary = "Get Region for a RegionId", tags = ("region"))
+ @Parameters(
+ @Parameter(name = "regionId", description = "RegionId that you want to the Region for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Region")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if the RegionId specified does not exist")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Region")
+ public ResponseEntity getRegionById(@PathVariable("regionId") int regionId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
return new ResponseEntity(this.regionService.getRegionById(regionId, curUser), HttpStatus.OK);
@@ -108,7 +102,22 @@ public ResponseEntity getRegion(@PathVariable("regionId") int regionId, Authenti
}
}
- @GetMapping("/region/realmCountryId/{realmCountryId}")
+ /**
+ * API used to get the Region list for a RealmCountry Id.
+ *
+ * @param realmCountryId RealmCountryId that you want the Region List from
+ * @param auth
+ * @return returns the complete list of Regions, based on the RealmCountryId
+ * that was passed
+ */
+ @GetMapping("/realmCountryId/{realmCountryId}")
+ @Operation(description = "API used to get the Region list for a list of RealmCountry Ids. Empty list means you want the complete list of Regions", summary = "Get Region list based on RealmCountry list", tags = ("region"))
+ @Parameters(
+ @Parameter(name = "realmCountryId", description = "RealmCountryId that you want the Region list for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Region list based on the RealmCountry that was passed")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if the RealmId specified does not exist")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Region list")
public ResponseEntity getRegionByRealmCountry(@PathVariable("realmCountryId") int realmCountryId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -124,7 +133,38 @@ public ResponseEntity getRegionByRealmCountry(@PathVariable("realmCountryId") in
return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
-
+
+ /**
+ * API used to update Regions
+ *
+ * @param regions Array of Regions that you want to update
+ * @param auth
+ * @return returns a Success code if the operation was successful
+ */
+ @PutMapping(path = "/")
+ @Operation(description = "API used to update a Region", summary = "Update Region", tags = ("region"))
+ @Parameters(
+ @Parameter(name = "regions", description = "The array of Regions that you want to update"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns a Success code if the operation was successful")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "406", description = "Returns a HttpStatus.NOT_ACCEPTABLE if the data supplied is not unique")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Returns a HttpStatus.INTERNAL_SERVER_ERROR if there was some other error that did not allow the operation to complete")
+ public ResponseEntity putRegion(@RequestBody Region[] regions, Authentication auth) {
+ try {
+ CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
+ this.regionService.saveRegions(regions, curUser);
+ return new ResponseEntity(new ResponseCode("static.message.updateSuccess"), HttpStatus.OK);
+ } catch (AccessDeniedException e) {
+ logger.error("Error while trying to update Region", e);
+ return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.FORBIDDEN);
+ } catch (DuplicateKeyException e) {
+ logger.error("Error while trying to update Region", e);
+ return new ResponseEntity(new ResponseCode("static.message.alreadExists"), HttpStatus.NOT_ACCEPTABLE);
+ } catch (Exception e) {
+ logger.error("Error while trying to update Region", e);
+ return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
// @GetMapping(value = "/sync/region/{lastSyncDate}")
// public ResponseEntity getRegionListForSync(@PathVariable("lastSyncDate") String lastSyncDate, Authentication auth) {
@@ -141,5 +181,4 @@ public ResponseEntity getRegionByRealmCountry(@PathVariable("realmCountryId") in
// return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
// }
// }
-
}
diff --git a/src/main/java/cc/altius/FASP/web/controller/ReportController.java b/src/main/java/cc/altius/FASP/rest/controller/ReportRestController.java
similarity index 72%
rename from src/main/java/cc/altius/FASP/web/controller/ReportController.java
rename to src/main/java/cc/altius/FASP/rest/controller/ReportRestController.java
index 2c2cd4128..8f09b6b5f 100644
--- a/src/main/java/cc/altius/FASP/web/controller/ReportController.java
+++ b/src/main/java/cc/altius/FASP/rest/controller/ReportRestController.java
@@ -3,7 +3,7 @@
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
-package cc.altius.FASP.web.controller;
+package cc.altius.FASP.rest.controller;
import cc.altius.FASP.model.CustomUserDetails;
import cc.altius.FASP.model.ProgramPlanningUnit;
@@ -38,6 +38,9 @@
import cc.altius.FASP.service.ReportService;
import cc.altius.FASP.service.UserService;
import com.fasterxml.jackson.annotation.JsonView;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
import java.util.LinkedList;
import java.util.List;
import org.slf4j.Logger;
@@ -58,8 +61,8 @@
* @author ekta
*/
@RestController
-@RequestMapping("/api/report/")
-public class ReportController {
+@RequestMapping("/api/report")
+public class ReportRestController {
@Autowired
private ReportService reportService;
@@ -68,11 +71,12 @@ public class ReportController {
@Autowired
private ProgramService programService;
- private final Logger logger = LoggerFactory.getLogger(ReportController.class);
+ private final Logger logger = LoggerFactory.getLogger(ReportRestController.class);
// Report no 1
// Reports -> Program Catalog
/**
+ * API used to get list of ProgramProductCatalogOutput
*
* Sample JSON {"productCategoryId": -1, "tracerCategoryId": -1, "programId": 2028 }
* -- Program Id must be a valid Program Id, cannot be -1 (Any) *
@@ -80,10 +84,13 @@ public class ReportController {
* -- Return the list of Program-Planning Units and their corresponding fields
*
*
- * @param ProgramProductCatalogInput
+ * @param ppc ProgramProductCatalogInput object
* @param auth Authentication object from JWT
- * @return ProgramProductCatalogOutput
+ * @return list of ProgramProductCatalogOutput
*/
+ @Operation(description = "API used to get the ProgramProductCatalogOutput list.", summary = "get the ProgramProductCatalogOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ProgramProductCatalogOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ProgramProductCatalogOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/programProductCatalog")
public ResponseEntity getProgramProductCatalog(@RequestBody ProgramProductCatalogInput ppc, Authentication auth) {
@@ -99,6 +106,7 @@ public ResponseEntity getProgramProductCatalog(@RequestBody ProgramProductCatalo
// Report no 2
// Reports -> Consumption Reports -> Consumption (Forecast vs Actual)
/**
+ * API used to get list of ConsumptionForecastVsActualOutput
*
* Sample JSON
* {"programId":2535, "versionId":1, "startDate":"2019-01-01", "stopDate":"2019-12-01", "planningUnitId":778, "reportView":1}
@@ -110,10 +118,13 @@ public ResponseEntity getProgramProductCatalog(@RequestBody ProgramProductCatalo
* -- reportView = 2 - Data is reported in terms of Forecasting Unit
*
*
- * @param ConsumptionForecastVsActualInput
+ * @param ppc ConsumptionForecastVsActualInput object
* @param auth Authentication object from JWT
- * @return ConsumptionForecastVsActualOutput
+ * @return list of ConsumptionForecastVsActualOutput
*/
+ @Operation(description = "API used to get the ConsumptionForecastVsActualOutput list.", summary = "get the ConsumptionForecastVsActualOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ConsumptionForecastVsActualOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ConsumptionForecastVsActualOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/consumptionForecastVsActual")
public ResponseEntity getConsumptionForecastVsActual(@RequestBody ConsumptionForecastVsActualInput ppc, Authentication auth) {
@@ -130,6 +141,7 @@ public ResponseEntity getConsumptionForecastVsActual(@RequestBody ConsumptionFor
// Reports -> Consumption Reports -> Consumption (Global)
// Global Report
/**
+ * API used to get list of GlobalConsumptionOutput
*
* Sample JSON
* { "realmId": 1, "realmCountryIds": [5,51], "programIds": [2028,2029,2535], "planningUnitIds": [778,2692], "startDate": "2019-01-01", "stopDate": "2019-12-01", "reportView": 1, "useApprovedSupplyPlanOnly":0}
@@ -142,10 +154,13 @@ public ResponseEntity getConsumptionForecastVsActual(@RequestBody ConsumptionFor
* -- reportView = 2 shows the Consumption in ForecastingUnits
*
*
- * @param gci
+ * @param gci GlobalConsumptionInput object
* @param auth
- * @return
+ * @return list of GlobalConsumptionOutput
*/
+ @Operation(description = "API used to get the GlobalConsumptionOutput list.", summary = "get the GlobalConsumptionOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the GlobalConsumptionOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of GlobalConsumptionOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/globalConsumption")
public ResponseEntity getGlobalConsumption(@RequestBody GlobalConsumptionInput gci, Authentication auth) {
@@ -161,6 +176,7 @@ public ResponseEntity getGlobalConsumption(@RequestBody GlobalConsumptionInput g
// Report no 4
// Reports -> Consumption Reports -> Forecast Error (Monthly)
/**
+ * API used to get list of ForecastMetricsMonthlyOutput
*
* Sample JSON
* { "programId": 2003, "versionId":2, "planningUnitId": 772, "startDate": "2020-01-01", "stopDate": "2020-05-01", "previousMonths": 6}
@@ -175,10 +191,13 @@ public ResponseEntity getGlobalConsumption(@RequestBody GlobalConsumptionInput g
* *
*
*
- * @param fmi
+ * @param fmi ForecastMetricsMonthlyInput object
* @param auth
- * @return
+ * @return list of ForecastMetricsMonthlyOutput
*/
+ @Operation(description = "API used to get the ForecastMetricsMonthlyOutput list.", summary = "get the ForecastMetricsMonthlyOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ForecastMetricsMonthlyOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ForecastMetricsMonthlyOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/forecastMetricsMonthly")
public ResponseEntity getForecastMetricsMonthly(@RequestBody ForecastMetricsMonthlyInput fmi, Authentication auth) {
@@ -195,6 +214,7 @@ public ResponseEntity getForecastMetricsMonthly(@RequestBody ForecastMetricsMont
// Global Report
// Reports -> Consumption Reports -> Forecast Error (by Planning Unit)
/**
+ * API used to get list of ForecastMetricsComparisionOutput
*
* Sample JSON
* { "realmId":1, "realmCountryIds":[2,5], "programIds":[2029,2521,2140], "tracerCategoryIds":[6,7],"planningUnitIds":[], "startDate":"2020-10-01", "previousMonths":3}
@@ -210,10 +230,13 @@ public ResponseEntity getForecastMetricsMonthly(@RequestBody ForecastMetricsMont
* -- ((Abs(actual consumption month 1-forecasted consumption month 1)+ Abs(actual consumption month 2-forecasted consumption month 2)+ Abs(actual consumption month 3-forecasted consumption month 3)+ Abs(actual consumption month 4-forecasted consumption month 4)+ Abs(actual consumption month 5-forecasted consumption month 5)+ Abs(actual consumption month 6-forecasted consumption month 6)) / (Sum of all actual consumption in the last 6 months))
*
*
- * @param fmi
+ * @param fmi ForecastMetricsComparisionInput object
* @param auth
- * @return
+ * @return list of ForecastMetricsComparisionOutput
*/
+ @Operation(description = "API used to get the ForecastMetricsComparisionOutput list.", summary = "get the ForecastMetricsComparisionOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ForecastMetricsComparisionOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ForecastMetricsComparisionOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/forecastMetricsComparision")
public ResponseEntity getForecastMetricsComparision(@RequestBody ForecastMetricsComparisionInput fmi, Authentication auth) {
@@ -230,6 +253,8 @@ public ResponseEntity getForecastMetricsComparision(@RequestBody ForecastMetrics
// Report no 7
// Reports -> Inventory Reports -> Warehouse Capacity (by Program)
/**
+ * API used to get list of WarehouseCapacityOutput
+ *
*
* Sample JSON
* { "realmCountryId":2, "programIds":[3]}
@@ -239,10 +264,13 @@ public ResponseEntity getForecastMetricsComparision(@RequestBody ForecastMetrics
* -- List of all the Regions for the Programs selected and their capacity
*
*
- * @param wci
+ * @param wci WarehouseCapacityInput object
* @param auth
- * @return
+ * @return list of WarehouseCapacityOutput
*/
+ @Operation(description = "API used to get the WarehouseCapacityOutput list.", summary = "get the WarehouseCapacityOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the WarehouseCapacityOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of WarehouseCapacityOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/warehouseCapacityReport")
public ResponseEntity getwarehouseCapacityReport(@RequestBody WarehouseCapacityInput wci, Authentication auth) {
@@ -254,12 +282,27 @@ public ResponseEntity getwarehouseCapacityReport(@RequestBody WarehouseCapacityI
return new ResponseEntity(new ResponseCode("static.label.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
-
+
//Report no
// Reports -> Inventory Reports -> Warehouse Capcity (By Country)
/**
- *
+ * API used to get list of WarehouseByCountryOutput
+ *
+ *
+ * Sample JSON
+ * { "realmCountryIds":[51,16,6]}
+ * -- RealmCountryIds is the list of RealmCountryIds that you want to run the report for
+ * -- RealmCountryIds blank means you want to run it for all RealmCountryIds
+ * -- List of all the Regions for the RealmCountryIds selected and their capacity
+ *
+ *
+ * @param wbc WarehouseByCountryInput object
+ * @param auth
+ * @return list of WarehouseByCountryOutput
*/
+ @Operation(description = "API used to get the WarehouseByCountryOutput list.", summary = "get the WarehouseByCountryOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the WarehouseByCountryOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of WarehouseByCountryOutput list")
@JsonView(Views.ReportView.class)
@PostMapping("/warehouseByCountry")
public ResponseEntity getWarehouseByCountry(@RequestBody WarehouseByCountryInput wbc, Authentication auth) {
@@ -281,6 +324,8 @@ public ResponseEntity getWarehouseByCountry(@RequestBody WarehouseByCountryInput
// Report no 8
// Reports -> Inventory Reports -> Cost of Inventory
/**
+ * API used to get list of CostOfInventoryOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "dt":"2020-04-01", "includePlannedShipments":1}
@@ -293,10 +338,13 @@ public ResponseEntity getWarehouseByCountry(@RequestBody WarehouseByCountryInput
* -- Cost = Closing inventory for that Planning Unit x Catalog Price
*
*
- * @param cii
+ * @param cii CostOfInventoryInput
* @param auth
- * @return
+ * @return list of CostOfInventoryOutput
*/
+ @Operation(description = "API used to get the CostOfInventoryOutput list.", summary = "get the CostOfInventoryOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the CostOfInventoryOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of CostOfInventoryOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/costOfInventory")
public ResponseEntity getCostOfInventory(@RequestBody CostOfInventoryInput cii, Authentication auth) {
@@ -312,6 +360,8 @@ public ResponseEntity getCostOfInventory(@RequestBody CostOfInventoryInput cii,
// Report no 9
// Reports -> Inventory Reports -> Inventory Turns
/**
+ * API used to get list of InventoryTurnsOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "dt":"2020-04-01", "includePlannedShipments":1}
@@ -323,10 +373,13 @@ public ResponseEntity getCostOfInventory(@RequestBody CostOfInventoryInput cii,
* -- Inventory Turns = Total Consumption for the last 12 months (including current month) / Avg Stock during that period
*
*
- * @param it
+ * @param it CostOfInventoryInput object
* @param auth
- * @return
+ * @return list of InventoryTurnsOutput
*/
+ @Operation(description = "API used to get the InventoryTurnsOutput list.", summary = "get the InventoryTurnsOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the InventoryTurnsOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of InventoryTurnsOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/inventoryTurns")
public ResponseEntity getInventoryTurns(@RequestBody CostOfInventoryInput it, Authentication auth) {
@@ -338,10 +391,12 @@ public ResponseEntity getInventoryTurns(@RequestBody CostOfInventoryInput it, Au
return new ResponseEntity(new ResponseCode("static.label.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
}
}
-
+
// Report no 11
// Reports -> Inventory Reports -> Expiries
/**
+ * API used to get list of ExpiredStockOutput
+ *
*
* Sample JSON
* {"programId":2535, "versionId":1, "startDt":"2017-01-01", "stopDt":"2021-12-01", "includePlannedShipments":1}
@@ -353,10 +408,13 @@ public ResponseEntity getInventoryTurns(@RequestBody CostOfInventoryInput it, Au
* -- Include Planned Shipments = 0 means that Shipments that are in the Planned stages will not be considered in the report
*
*
- * @param it
+ * @param esi ExpiredStockInput
* @param auth
- * @return
+ * @return list of ExpiredStockOutput
*/
+ @Operation(description = "API used to get the ExpiredStockOutput list.", summary = "get the ExpiredStockOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ExpiredStockOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ExpiredStockOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/expiredStock")
public ResponseEntity getExpiredStock(@RequestBody ExpiredStockInput esi, Authentication auth) {
@@ -372,6 +430,8 @@ public ResponseEntity getExpiredStock(@RequestBody ExpiredStockInput esi, Authen
// Report no 12
// Reports -> Inventory Reports -> Stock Adjustment
/**
+ * API used to get list of StockAdjustmentReportOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "startDate":"2019-10-01", "stopDate":"2020-10-01", "planningUnitIds":[152,157]}
@@ -381,10 +441,13 @@ public ResponseEntity getExpiredStock(@RequestBody ExpiredStockInput esi, Authen
* -- VAR_PLANNING_UNIT_IDS are the Quoted, Comma separated list of the Planning Unit Ids that you want to run the report for. If you want to run it for all Planning Units in the Program leave it empty
*
*
- * @param si
+ * @param si StockAdjustmentReportInput
* @param auth
- * @return
+ * @return list of StockAdjustmentReportOutput
*/
+ @Operation(description = "API used to get the StockAdjustmentReportOutput list.", summary = "get the StockAdjustmentReportOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the StockAdjustmentReportOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of StockAdjustmentReportOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/stockAdjustmentReport")
public ResponseEntity getStockAdjustmentReport(@RequestBody StockAdjustmentReportInput si, Authentication auth) {
@@ -399,6 +462,8 @@ public ResponseEntity getStockAdjustmentReport(@RequestBody StockAdjustmentRepor
// Report no 13
/**
+ * API used to get list of ProcurementAgentShipmentReportOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "startDate":"2019-10-01", "stopDate":"2020-10-01", "planningUnitIds":[152,157], "includePlannedShipments":1, "procurementAgentId":1}
@@ -414,11 +479,14 @@ public ResponseEntity getStockAdjustmentReport(@RequestBody StockAdjustmentRepor
*
*
*
- * @param pari
+ * @param pari ProcurementAgentShipmentReportInput
* @param auth
- * @return
+ * @return list of ProcurementAgentShipmentReportOutput
*/
// Report -> Shipment Reports -> Shipment Cost Details (Procurement Agent view)
+ @Operation(description = "API used to get the ProcurementAgentShipmentReportOutput list.", summary = "get the ProcurementAgentShipmentReportOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ProcurementAgentShipmentReportOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ProcurementAgentShipmentReportOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/procurementAgentShipmentReport")
public ResponseEntity getProcurementAgentShipmentReport(@RequestBody ProcurementAgentShipmentReportInput pari, Authentication auth) {
@@ -434,6 +502,8 @@ public ResponseEntity getProcurementAgentShipmentReport(@RequestBody Procurement
// Report no 14
// Report -> Shipment Reports -> Procurement Agent Lead Times
/**
+ * API used to get list of ProgramLeadTimesOutput
+ *
*
* Sample JSON
* {"programId":3, "procurementAgentIds":[1,3], "planningUnitIds":[157,152]}
@@ -444,8 +514,11 @@ public ResponseEntity getProcurementAgentShipmentReport(@RequestBody Procurement
*
* @param plt
* @param auth
- * @return
+ * @return list of ProgramLeadTimesOutput
*/
+ @Operation(description = "API used to get the ProgramLeadTimesOutput list.", summary = "get the ProgramLeadTimesOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ProgramLeadTimesOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ProgramLeadTimesOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/programLeadTimes")
public ResponseEntity getProgramLeadTimes(@RequestBody ProgramLeadTimesInput plt, Authentication auth) {
@@ -463,6 +536,8 @@ public ResponseEntity getProgramLeadTimes(@RequestBody ProgramLeadTimesInput plt
// Report no 15
// Report -> Shipment Reports -> Shipment Cost Details (Funding Source view)
/**
+ * API used to get list of FundingSourceShipmentReportOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "startDate":"2019-10-01", "stopDate":"2020-10-01", "planningUnitIds":[152,157], "includePlannedShipments":1, "fundingSourceId":3}
@@ -477,10 +552,13 @@ public ResponseEntity getProgramLeadTimes(@RequestBody ProgramLeadTimesInput plt
* -- FreightPerc is in SUM(FREIGHT_COST)/SUM(PRODUCT_COST) for that ProcurementAgent and that PlanningUnit
*
*
- * @param fsri
+ * @param fsri FundingSourceShipmentReportInput
* @param auth
- * @return
+ * @return list of FundingSourceShipmentReportOutput
*/
+ @Operation(description = "API used to get the FundingSourceShipmentReportOutput list.", summary = "get the FundingSourceShipmentReportOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the FundingSourceShipmentReportOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of FundingSourceShipmentReportOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/fundingSourceShipmentReport")
public ResponseEntity getFundingSourceShipmentReport(@RequestBody FundingSourceShipmentReportInput fsri, Authentication auth) {
@@ -496,18 +574,23 @@ public ResponseEntity getFundingSourceShipmentReport(@RequestBody FundingSourceS
// Report no 16
// Supply Planning -> Supply Plan Report
/**
+ * API used to get list of StockStatusVerticalOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "startDate":"2019-10-01", "stopDate":"2020-07-01", "planningUnitId":152, "allPlanningUnits":true}
*
*
- * @param ssv
+ * @param ssv list of StockStatusVerticalOutput
* @param auth
- * @return
+ * @return list of StockStatusVerticalOutput
*/
// ActualConsumption = 0 -- Forecasted Consumption
// ActualConsumption = 1 -- Actual Consumption
// ActualConsumption = null -- No consumption data
+ @Operation(description = "API used to get the StockStatusVerticalOutput list.", summary = "get the StockStatusVerticalOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the StockStatusVerticalOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of StockStatusVerticalOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/stockStatusVertical")
public ResponseEntity getStockStatusVertical(@RequestBody StockStatusVerticalInput ssv, Authentication auth) {
@@ -526,7 +609,7 @@ public ResponseEntity getStockStatusVertical(@RequestBody StockStatusVerticalInp
}
return new ResponseEntity(ssvoFullList, HttpStatus.OK);
} else {
- return new ResponseEntity(ssvoList, HttpStatus.OK);
+ return new ResponseEntity(ssvoList, HttpStatus.OK);
}
} catch (Exception e) {
logger.error("/api/report/stockStatusVertical", e);
@@ -537,6 +620,8 @@ public ResponseEntity getStockStatusVertical(@RequestBody StockStatusVerticalInp
// Report no 17
// Reports -> Stock Status -> Stock Status Over Time
/**
+ * API used to get list of StockStatusOverTimeOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "startDate":"2019-10-01", "stopDate":"2020-07-01", "planningUnitIds":[152,157], "mosPast":3, "mosFuture":6}
@@ -546,13 +631,16 @@ public ResponseEntity getStockStatusVertical(@RequestBody StockStatusVerticalInp
* you give mosFuture = 6 it will take the AMC for Jan, Feb, Mar, Apr, May
* and Jun
*
- * @param ssot
+ * @param ssot StockStatusOverTimeInput
* @param auth
- * @return
+ * @return list of StockStatusOverTimeOutput
*/
// ActualConsumption = 0 -- Forecasted Consumption
// ActualConsumption = 1 -- Actual Consumption
// ActualConsumption = null -- No consumption data
+ @Operation(description = "API used to get the StockStatusOverTimeOutput list.", summary = "get the StockStatusOverTimeOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the StockStatusOverTimeOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of StockStatusOverTimeOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/stockStatusOverTime")
public ResponseEntity getStockStatusOverTime(@RequestBody StockStatusOverTimeInput ssot, Authentication auth) {
@@ -568,6 +656,8 @@ public ResponseEntity getStockStatusOverTime(@RequestBody StockStatusOverTimeInp
// Report no 18
// Reports -> Stock Status -> Stock Status Matrix
/**
+ * API used to get list of StockStatusMatrixOutput
+ *
*
* Sample JSON
* {"programId":2030, "versionId":2, "startDate":"2019-10-01", "stopDate":"2020-07-01", "planningUnitIds":[4115], "tracerCategoryIds":[21,28], "includePlannedShipments":1}
@@ -581,10 +671,13 @@ public ResponseEntity getStockStatusOverTime(@RequestBody StockStatusOverTimeInp
* -- Current month is always included in AMC
*
*
- * @param ssm
+ * @param ssm StockStatusMatrixInput
* @param auth
- * @return
+ * @return list of StockStatusMatrixOutput
*/
+ @Operation(description = "API used to get the StockStatusMatrixOutput list.", summary = "get the StockStatusMatrixOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the StockStatusMatrixOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of StockStatusMatrixOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/stockStatusMatrix")
public ResponseEntity getStockStatusMatrix(@RequestBody StockStatusMatrixInput ssm, Authentication auth) {
@@ -600,6 +693,8 @@ public ResponseEntity getStockStatusMatrix(@RequestBody StockStatusMatrixInput s
// Report no 19
/**
+ * API used to get ShipmentDetailsOutput object
+ *
*
* Sample JSON
* { "programId": 2030, "versionId": 9, "startDate": "2019-10-01", "stopDate": "2020-07-01", "planningUnitIds": [1354], "fundingSourceIds": [1,4], "budgetIds": [8,9], "reportView": 1}
@@ -611,11 +706,14 @@ public ResponseEntity getStockStatusMatrix(@RequestBody StockStatusMatrixInput s
* -- Report view 1 = Planning Units, 2 = Forecasting Units
*
*
- * @param sd
+ * @param sd ShipmentDetailsInput
* @param auth
- * @return
+ * @return ShipmentDetailsOutput object
*/
// Report -> Shipment Reports -> Shipment Details
+ @Operation(description = "API used to get the ShipmentDetailsOutput object.", summary = "get the ShipmentDetailsOutput object", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ShipmentDetailsOutput object")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ShipmentDetailsOutput object")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/shipmentDetails")
public ResponseEntity getShipmentDetails(@RequestBody ShipmentDetailsInput sd, Authentication auth) {
@@ -632,15 +730,20 @@ public ResponseEntity getShipmentDetails(@RequestBody ShipmentDetailsInput sd, A
// Report -> Shipment Reports -> Shipments Overview
// Global Report
/**
+ * API used to get ShipmentOverviewOutput object
+ *
*
* Sample JSON
* {"curUser":20, "realmId":1, "startDate":"2019-10-01", "stopDate":"2021-07-01", "shipmentStatusIds":[],"planningUnitIds":[], "fundingSourceIds":[], "procurementAgentIds":[], "useApprovedSupplyPlansOnly":0}
*
*
- * @param so
+ * @param so ShipmentOverviewInput
* @param auth
- * @return
+ * @return ShipmentOverviewOutput object
*/
+ @Operation(description = "API used to get the ShipmentOverviewOutput object.", summary = "get the ShipmentOverviewOutput object", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ShipmentOverviewOutput object")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ShipmentOverviewOutput object")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/shipmentOverview")
public ResponseEntity getShipmentOverview(@RequestBody ShipmentOverviewInput so, Authentication auth) {
@@ -657,15 +760,20 @@ public ResponseEntity getShipmentOverview(@RequestBody ShipmentOverviewInput so,
// Report -> Shipment Reports -> Shipments (Global)
// Global Report
/**
+ * API used to get ShipmentGlobalDemandOutput object
+ *
*
* Sample JSON
* {"curUser": 20,"realmId": 1,"realmCountryIds": [5,51],"programIds": [2028,2029,2535],"planningUnitId": 2692,"startDate": 2019-01-01","stopDate": "2019-12-01","fundingSourceProcurementAgentIds": [],"reportView": 1,"useApprovedSupplyPlanOnly": 0,"includePlannedShipments": 1}
*
*
- * @param sgd
+ * @param sgd ShipmentGlobalDemandInput
* @param auth
- * @return
+ * @return ShipmentGlobalDemandOutput object
*/
+ @Operation(description = "API used to get the ShipmentGlobalDemandOutput object.", summary = "get the ShipmentGlobalDemandOutput object", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ShipmentGlobalDemandOutput object")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ShipmentGlobalDemandOutput object")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/shipmentGlobalDemand")
public ResponseEntity getShipmentGlobalDemand(@RequestBody ShipmentGlobalDemandInput sgd, Authentication auth) {
@@ -681,6 +789,8 @@ public ResponseEntity getShipmentGlobalDemand(@RequestBody ShipmentGlobalDemandI
// Report no 22
// Report -> Shipment Reports -> Shipment Cost Overview
/**
+ * API used to get list of AnnualShipmentCostOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "startDate":"2019-10-01", "stopDate":"2020-07-01", "planningUnitId":152, "procurementAgentId":-1, "fundingSourceId":-1, "shipmentStatusId":-1}
@@ -691,10 +801,13 @@ public ResponseEntity getShipmentGlobalDemand(@RequestBody ShipmentGlobalDemandI
* -- If ProcurementAgent has not been selected as yet in the Shipment, that Shipment will be excluded
*
*
- * @param asci
+ * @param asci AnnualShipmentCostInput
* @param auth
- * @return
+ * @return list of AnnualShipmentCostOutput
*/
+ @Operation(description = "API used to get the AnnualShipmentCostOutput list.", summary = "get the AnnualShipmentCostOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the AnnualShipmentCostOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of AnnualShipmentCostOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/annualShipmentCost")
public ResponseEntity getAnnualShipmentCost(@RequestBody AnnualShipmentCostInput asci, Authentication auth) {
@@ -709,6 +822,8 @@ public ResponseEntity getAnnualShipmentCost(@RequestBody AnnualShipmentCostInput
// Report no 24
/**
+ * API used to get list of ShipmentReportOutput
+ *
*
* Sample JSON
* {"programId":3, "versionId":2, "startDate":"2019-10-01", "stopDate":"2020-10-01", "planningUnitIds":[152,157], "includePlannedShipments":1}
@@ -722,11 +837,14 @@ public ResponseEntity getAnnualShipmentCost(@RequestBody AnnualShipmentCostInput
* -- FreightPerc is in SUM(FREIGHT_COST)/SUM(PRODUCT_COST) for that ProcurementAgent and that PlanningUnit
*
*
- * @param fsri
+ * @param fsri ShipmentReportInput
* @param auth
- * @return
+ * @return list of ShipmentReportOutput
*/
// Report -> Shipment Reports -> Shipment Cost Details (Planning Unit view)
+ @Operation(description = "API used to get the ShipmentReportOutput list.", summary = "get the ShipmentReportOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ShipmentReportOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ShipmentReportOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/aggregateShipmentByProduct")
public ResponseEntity getAggregateShipmentByProduct(@RequestBody ShipmentReportInput fsri, Authentication auth) {
@@ -742,6 +860,8 @@ public ResponseEntity getAggregateShipmentByProduct(@RequestBody ShipmentReportI
// Report no 28
// Reports -> Stock Status -> Stock Status Snapshot
/**
+ * API used to get list of StockStatusForProgramOutput
+ *
*
* Sample JSON
* {"programId":2028, "versionId":1, "dt":"2019-10-01", "includePlannedShipments":1, "tracerCategoryIds":[]}
@@ -757,10 +877,13 @@ public ResponseEntity getAggregateShipmentByProduct(@RequestBody ShipmentReportI
* -- MaxMonthsOfStock is Min of Min of MinMonthOfStock+ReorderFrequency and 15
*
*
- * @param sspi
+ * @param sspi StockStatusForProgramInput
* @param auth
- * @return
+ * @return list of StockStatusForProgramOutput
*/
+ @Operation(description = "API used to get the StockStatusForProgramOutput list.", summary = "get the StockStatusForProgramOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the StockStatusForProgramOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of StockStatusForProgramOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/stockStatusForProgram")
public ResponseEntity getStockStatusForProgram(@RequestBody StockStatusForProgramInput sspi, Authentication auth) {
@@ -776,13 +899,18 @@ public ResponseEntity getStockStatusForProgram(@RequestBody StockStatusForProgra
// Report no 29
// Report -> Shipment Reports -> Budget reports
/**
+ * API used to get list of BudgetReportOutput
+ *
* Sample JSON {"programId":2028, "versionId":1, "startDate":"2019-01-01",
* "stopDate":"2021-12-01", "fundingSourceIds":[], "shippingStatusIds":[]}
*
- * @param br
+ * @param br BudgetReportInput
* @param auth
- * @return
+ * @return list of BudgetReportOutput
*/
+ @Operation(description = "API used to get the BudgetReportOutput list.", summary = "get the BudgetReportOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the BudgetReportOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of BudgetReportOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/budgetReport")
public ResponseEntity getBudgetReport(@RequestBody BudgetReportInput br, Authentication auth) {
@@ -799,6 +927,8 @@ public ResponseEntity getBudgetReport(@RequestBody BudgetReportInput br, Authent
// Reports -> Stock Status -> Stock Status Snapshot (Global)
// Global Report
/**
+ * API used to get list of StockStatusAcrossProductsOutput
+ *
*
* Sample JSON
* { "curUser": 20, "realmId": 1, "realmCountryIds": [ 5, 51 ], "tracerCategoryIds":[], "dt":"2020-09-01"}
@@ -814,10 +944,13 @@ public ResponseEntity getBudgetReport(@RequestBody BudgetReportInput br, Authent
* -- MaxMonthsOfStock is Min of Min of MinMonthOfStock+ReorderFrequency and 15
*
*
- * @param sspi
+ * @param ssap StockStatusAcrossProductsInput
* @param auth
- * @return
+ * @return list of StockStatusAcrossProductsOutput
*/
+ @Operation(description = "API used to get the StockStatusAcrossProductsOutput list.", summary = "get the StockStatusAcrossProductsOutput list", tags = ("report"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the StockStatusAcrossProductsOutput list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of StockStatusAcrossProductsOutput list")
@JsonView(Views.ReportView.class)
@PostMapping(value = "/stockStatusAcrossProducts")
public ResponseEntity getStockStatusAcrossProducts(@RequestBody StockStatusAcrossProductsInput ssap, Authentication auth) {
diff --git a/src/main/java/cc/altius/FASP/rest/controller/ShipmentStatusRestController.java b/src/main/java/cc/altius/FASP/rest/controller/ShipmentStatusRestController.java
index 7a27f9143..f293bd9a3 100644
--- a/src/main/java/cc/altius/FASP/rest/controller/ShipmentStatusRestController.java
+++ b/src/main/java/cc/altius/FASP/rest/controller/ShipmentStatusRestController.java
@@ -5,12 +5,11 @@
*/
package cc.altius.FASP.rest.controller;
-import cc.altius.FASP.model.CustomUserDetails;
import cc.altius.FASP.model.ResponseCode;
import cc.altius.FASP.service.ShipmentStatusService;
-import cc.altius.FASP.service.UserService;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -18,7 +17,6 @@
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -27,32 +25,23 @@
* @author altius
*/
@RestController
-@RequestMapping("/api")
+@RequestMapping("/api/shipmentStatus")
public class ShipmentStatusRestController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Autowired
private ShipmentStatusService shipmentStatusService;
- @Autowired
- private UserService userService;
-
- @GetMapping(value = "/sync/shipmentStatus/{lastSyncDate}")
- public ResponseEntity getShipmentStatusListForSync(@PathVariable("lastSyncDate") String lastSyncDate, Authentication auth) {
- try {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
- sdf.parse(lastSyncDate);
- CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
- return new ResponseEntity(this.shipmentStatusService.getShipmentStatusListForSync(lastSyncDate, curUser), HttpStatus.OK);
- } catch (ParseException p) {
- logger.error("Error while listing Shipment status", p);
- return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.PRECONDITION_FAILED);
- } catch (Exception e) {
- logger.error("Error while listing Shipment status", e);
- return new ResponseEntity(new ResponseCode("static.message.listFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- }
+ /**
+ * API used to get the active ShipmentStatus list.
+ *
+ * @param auth
+ * @return returns the active ShipmentStatus list.
+ */
+ @Operation(description = "API used to get the active ShipmentStatus list.", summary = "Get Active ShipmentStatus list.", tags = ("shipmentStatus"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the ShipmentStatus list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of ShipmentStatus list")
@GetMapping(value = "/getShipmentStatusListActive")
public ResponseEntity getShipmentStatusListActive(Authentication auth) {
try {
diff --git a/src/main/java/cc/altius/FASP/rest/controller/SupplierRestController.java b/src/main/java/cc/altius/FASP/rest/controller/SupplierRestController.java
index c1bf729c5..3ae195b2d 100644
--- a/src/main/java/cc/altius/FASP/rest/controller/SupplierRestController.java
+++ b/src/main/java/cc/altius/FASP/rest/controller/SupplierRestController.java
@@ -18,20 +18,25 @@
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cc.altius.FASP.service.SupplierService;
import cc.altius.FASP.service.UserService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import org.springframework.web.bind.annotation.PostMapping;
/**
*
* @author altius
*/
@RestController
-@RequestMapping("/api")
+@RequestMapping("/api/supplier")
public class SupplierRestController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@@ -41,37 +46,16 @@ public class SupplierRestController {
@Autowired
private UserService userService;
- @PostMapping(path = "/supplier")
- public ResponseEntity postSupplier(@RequestBody Supplier supplier, Authentication auth) {
- try {
- CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
- this.supplierService.addSupplier(supplier, curUser);
- return new ResponseEntity(new ResponseCode("static.message.addSuccess"), HttpStatus.OK);
- } catch (AccessDeniedException ae) {
- logger.error("Error while trying to add Supplier", ae);
- return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.FORBIDDEN);
- } catch (Exception e) {
- logger.error("Error while trying to add Supplier", e);
- return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- }
-
- @PutMapping(path = "/supplier")
- public ResponseEntity putSupplier(@RequestBody Supplier supplier, Authentication auth) {
- try {
- CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
- this.supplierService.updateSupplier(supplier, curUser);
- return new ResponseEntity(new ResponseCode("static.message.updateSuccess"), HttpStatus.OK);
- } catch (AccessDeniedException ae) {
- logger.error("Error while trying to add Supplier", ae);
- return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.FORBIDDEN);
- } catch (Exception e) {
- logger.error("Error while trying to add Supplier", e);
- return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
- }
- }
-
- @GetMapping("/supplier")
+ /**
+ * API used to get the complete Supplier list.
+ *
+ * @param auth
+ * @return returns the complete list of Suppliers
+ */
+ @GetMapping("/")
+ @Operation(description = "API used to get the complete Supplier list.", summary = "Get Supplier list", tags = ("supplier"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Supplier list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Supplier list")
public ResponseEntity getSupplier(Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -82,7 +66,21 @@ public ResponseEntity getSupplier(Authentication auth) {
}
}
- @GetMapping("/supplier/{supplierId}")
+ /**
+ * API used to get the Supplier for a specific SupplierId
+ *
+ * @param supplierId SupplierId that you want the Supplier Object for
+ * @param auth
+ * @return returns the Supplier object based on SupplierId specified
+ */
+ @GetMapping(value = "/{supplierId}")
+ @Operation(description = "API used to get the Supplier for a specific SupplierId", summary = "Get Supplier for a SupplierId", tags = ("supplier"))
+ @Parameters(
+ @Parameter(name = "supplierId", description = "SupplierId that you want to the Supplier for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Supplier")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if the SupplierId specified does not exist")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Supplier")
public ResponseEntity getSupplier(@PathVariable("supplierId") int supplierId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -99,7 +97,21 @@ public ResponseEntity getSupplier(@PathVariable("supplierId") int supplierId, Au
}
}
- @GetMapping("/supplier/realmId/{realmId}")
+ /**
+ * API used to get the Supplier list for a Realm
+ *
+ * @param realmId RealmId that you want the Supplier List from
+ * @param auth
+ * @return returns the complete list of Suppliers
+ */
+ @GetMapping("/realmId/{realmId}")
+ @Operation(description = "API used to get the complete Supplier list for a Realm", summary = "Get Supplier list for Realm", tags = ("supplier"))
+ @Parameters(
+ @Parameter(name = "realmId", description = "RealmId that you want the Supplier list for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the Supplier list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "404", description = "Returns a HttpStatus.NOT_FOUND if the RealmId specified does not exist")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of Supplier list")
public ResponseEntity getSupplierForRealm(@PathVariable("realmId") int realmId, Authentication auth) {
try {
CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
@@ -116,6 +128,62 @@ public ResponseEntity getSupplierForRealm(@PathVariable("realmId") int realmId,
}
}
+ /**
+ * API used to add a Supplier
+ *
+ * @param supplier Supplier object that you want to add
+ * @param auth
+ * @return returns a Success code if the operation was successful
+ */
+ @PostMapping(value = "/")
+ @Operation(description = "API used to add a Supplier", summary = "Add Supplier", tags = ("supplier"))
+ @Parameters(
+ @Parameter(name = "supplier", description = "The Supplier object that you want to add"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns a Success code if the operation was successful")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Returns a HttpStatus.INTERNAL_SERVER_ERROR if there was some other error that did not allow the operation to complete")
+ public ResponseEntity addSupplier(@RequestBody Supplier supplier, Authentication auth) {
+ try {
+ CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
+ this.supplierService.addSupplier(supplier, curUser);
+ return new ResponseEntity(new ResponseCode("static.message.addSuccess"), HttpStatus.OK);
+ } catch (AccessDeniedException ae) {
+ logger.error("Error while trying to add Supplier", ae);
+ return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.FORBIDDEN);
+ } catch (Exception e) {
+ logger.error("Error while trying to add Supplier", e);
+ return new ResponseEntity(new ResponseCode("static.message.addFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
+ /**
+ * API used to update Suppliers
+ *
+ * @param supplier Object of Supplier that you want to update
+ * @param auth
+ * @return returns a Success code if the operation was successful
+ */
+ @PutMapping(path = "/")
+ @Operation(description = "API used to update a Supplier", summary = "Update Supplier", tags = ("supplier"))
+ @Parameters(
+ @Parameter(name = "supplier", description = "The Supplier object that you want to update"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns a Success code if the operation was successful")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Returns a HttpStatus.INTERNAL_SERVER_ERROR if there was some other error that did not allow the operation to complete")
+ public ResponseEntity updateSupplier(@RequestBody Supplier supplier, Authentication auth) {
+ try {
+ CustomUserDetails curUser = this.userService.getCustomUserByUserId(((CustomUserDetails) auth.getPrincipal()).getUserId());
+ this.supplierService.updateSupplier(supplier, curUser);
+ return new ResponseEntity(new ResponseCode("static.message.updateSuccess"), HttpStatus.OK);
+ } catch (AccessDeniedException ae) {
+ logger.error("Error while trying to add Supplier", ae);
+ return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.FORBIDDEN);
+ } catch (Exception e) {
+ logger.error("Error while trying to add Supplier", e);
+ return new ResponseEntity(new ResponseCode("static.message.updateFailed"), HttpStatus.INTERNAL_SERVER_ERROR);
+ }
+ }
+
// @GetMapping(value = "/sync/supplier/{lastSyncDate}")
// public ResponseEntity getSupplierListForSync(@PathVariable("lastSyncDate") String lastSyncDate, Authentication auth) {
// try {
diff --git a/src/main/java/cc/altius/FASP/rest/controller/SupplyPlanRestController.java b/src/main/java/cc/altius/FASP/rest/controller/SupplyPlanRestController.java
index ec8d065cf..8c04ea0fe 100644
--- a/src/main/java/cc/altius/FASP/rest/controller/SupplyPlanRestController.java
+++ b/src/main/java/cc/altius/FASP/rest/controller/SupplyPlanRestController.java
@@ -13,6 +13,11 @@
import cc.altius.FASP.service.ProgramDataService;
import cc.altius.FASP.service.ProgramService;
import cc.altius.FASP.service.UserService;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Parameters;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -38,7 +43,7 @@
* @author akil
*/
@RestController
-@RequestMapping("/api")
+@RequestMapping("/api/supplyPlan")
public class SupplyPlanRestController {
@Autowired
@@ -64,7 +69,27 @@ public class SupplyPlanRestController {
// System.out.println(new Date());
// return new ResponseEntity(simplifiedSupplyPlan, HttpStatus.OK);
// }
+ /**
+ * API is to rebuild supply plan based on rebuild true or false
+ *
+ * @param programId programId that you want to rebuild supply plan for
+ * @param versionId versionId that you want to rebuild supply plan for
+ * @param rebuild rebuild true for rebuild supply plan , rebuild false for
+ * do not rebuild supply plan
+ * @param auth
+ * @return returns success message if rebuild true, returns
+ * SimplifiedSupplyPlan list if rebuild false
+ */
@GetMapping("/newSupplyPlan/programId/{programId}/versionId/{versionId}/rebuild/{rebuild}")
+ @Operation(description = "API is to rebuild supply plan based on rebuild true or false ", summary = "To rebuild supply plan based on rebuild true or false ", tags = ("supplyPlan"))
+ @Parameters({
+ @Parameter(name = "programId", description = "programId that you want to rebuild supply plan for"),
+ @Parameter(name = "versionId", description = "versionId that you want to rebuild supply plan for"),
+ @Parameter(name = "rebuild", description = "rebuild true for rebuild supply plan , rebuild false for do not rebuild supply plan")})
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the success message or SimplifiedSupplyPlan list")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "412", description = "Returns a HttpStatus.PRECONDITION_FAILED if certain conditions to rebuild supply plan does not met")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "403", description = "Returns a HttpStatus.FORBIDDEN if the User does not have access")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented the retreival of SimplifiedSupplyPlan list or rebuild supply plan")
@ResponseBody
public ResponseEntity buildNewSupplyPlan(
@PathVariable(value = "programId", required = true) int programId,
@@ -103,7 +128,21 @@ public ResponseEntity buildNewSupplyPlan(
}
}
+ /**
+ * API is to rebuild supply plan for listed programIds and versionIds
+ *
+ * @param pvList pvList list of programIds and versionIds to rebuild supply
+ * plan for
+ * @param auth
+ * @return success/error message for rebuild supply plan
+ */
@PostMapping("/rebuildSupplyPlans")
+ @Operation(description = "API is to rebuild supply plan for listed programIds and versionIds ", summary = "To rebuild supply plan for listed programIds and versionIds ", tags = ("supplyPlan"))
+ @Parameters(
+ @Parameter(name = "pvList", description = "pvList list of programIds and versionIds to rebuild supply plan for"))
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "200", description = "Returns the success/error message")
+ @ApiResponse(content = @Content(mediaType = "text/json"), responseCode = "500", description = "Internal error that prevented rebuild supply plan")
+
@ResponseBody
public ResponseEntity rebuildSupplyPlans(@RequestBody List pvList, Authentication auth) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@@ -112,7 +151,7 @@ public ResponseEntity rebuildSupplyPlans(@RequestBody List
+
@@ -99,6 +100,7 @@
+
diff --git a/test b/test
new file mode 100644
index 000000000..9daeafb98
--- /dev/null
+++ b/test
@@ -0,0 +1 @@
+test