Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,16 @@ public ResponseEntity<SBApiResponse> generateBPReportV2(@RequestHeader(Constants
SBApiResponse response = bpReportsServiceV2.generateBPReportV2(requestBody, authToken);
return new ResponseEntity<>(response, response.getResponseCode());
}

@PostMapping("/v2/bpreport/status")
public ResponseEntity<SBApiResponse> getBPReportStatusV2(@RequestHeader(Constants.X_AUTH_TOKEN) String authToken, @RequestBody Map<String, Object> requestBody) {
SBApiResponse response = bpReportsServiceV2.getBPReportStatusV2(requestBody, authToken);
return new ResponseEntity<>(response, response.getResponseCode());
}

@PostMapping("/v2/bpreport/list")
public ResponseEntity<SBApiResponse> getBPReportList(@RequestHeader(Constants.X_AUTH_TOKEN) String authToken, @RequestBody Map<String, Object> requestBody) {
SBApiResponse response = bpReportsServiceV2.getBPReportList(requestBody, authToken);
return new ResponseEntity<>(response, response.getResponseCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,29 @@ public interface BPReportsServiceV2 {
* orgId, reportRequester, and optional surveyId
*/
void processBPReportV2(Map<String, Object> request);

/**
* Returns the current status of a V2 BP report for a given batch and requester.
* Queries bp_enrolment_report_v2 using orgId, courseId, batchId, reportRequester,
* and contextType as composite key — ensuring V2 records are never mixed with V1.
*
* @param requestBody the API request body containing a nested {@code request} map
* with orgId, courseId, batchId, and reportRequester
* @param authToken bearer token used to resolve and validate the calling user
* @return {@link SBApiResponse} with report status, downloadLink, and enrolment counts
* if found, or an informational error if no report exists for the given key
*/
SBApiResponse getBPReportStatusV2(Map<String, Object> requestBody, String authToken);

/**
* Returns a combined list of BP reports from both V1 (bp_enrolment_report) and
* V2 (bp_enrolment_report_v2) tables for the given orgId, courseId, batchId,
* and reportRequester. Response structure is identical to the individual status APIs.
*
* @param requestBody the API request body containing a nested {@code request} map
* with orgId, courseId, batchId, and reportRequester
* @param authToken bearer token used to resolve and validate the calling user
* @return {@link SBApiResponse} with combined content list and total count
*/
SBApiResponse getBPReportList(Map<String, Object> requestBody, String authToken);
}
184 changes: 163 additions & 21 deletions src/main/java/org/sunbird/bpreports/service/BPReportsServiceV2Impl.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,4 @@ public Map<String, Object> fetchResultUsingGet(String uri, Map<String, String> h
return response;
}

}
}
11 changes: 11 additions & 0 deletions src/main/java/org/sunbird/common/util/CbExtServerProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -1308,6 +1308,9 @@ public String getPublicAssessmentCloudCertificateFolderName() {
@Value("${bp.report.excel.row.window.size:100}")
private int bpReportExcelRowWindowSize;

@Value("${bp.report.v2.file.name.prefix:BlendedProgramConsumptionReport_}")
private String bpReportV2FileNamePrefix;


public int getUserSearchLimit() {
return userSearchLimit;
Expand Down Expand Up @@ -4399,4 +4402,12 @@ public void setBpReportExcelRowWindowSize(int bpReportExcelRowWindowSize) {
this.bpReportExcelRowWindowSize = bpReportExcelRowWindowSize;
}

public String getBpReportV2FileNamePrefix() {
return bpReportV2FileNamePrefix;
}

public void setBpReportV2FileNamePrefix(String bpReportV2FileNamePrefix) {
this.bpReportV2FileNamePrefix = bpReportV2FileNamePrefix;
}

}
4 changes: 4 additions & 0 deletions src/main/java/org/sunbird/common/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -1604,4 +1604,8 @@ private Constants() {
public static final String CERTIFICATE_ISSUED_DATE = "certificateIssuedDate";
public static final String BP_REPORT_GENERATE_API_V2 ="api.generate.bp.report.v2";
public static final String ENROLMENT_END_DATE_COLUMN = "enrollment_enddate";
public static final String BP_ENROLMENT_REPORT_TABLE_V2= "bp_enrolment_report_v2";
public static final String BP_REPORT_V2_CONTEXT_TYPE = "Blended Program Consumption Report";
public static final String API_BP_REPORT_STATUS_V2 = "api.bp.report.status.v2";
public static final String API_BP_REPORT_LIST = "api.bp.report.list";
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;
import org.sunbird.common.model.SBApiResponse;
import org.sunbird.common.util.Constants;
import org.sunbird.course.service.ExploreCourseService;

/**
Expand All @@ -31,6 +33,13 @@ public ResponseEntity<SBApiResponse> getPublicCourseList() {
return new ResponseEntity<>(response, response.getResponseCode());
}

@GetMapping("/ngo/course/v1/explore")
public ResponseEntity<SBApiResponse> getPublicCourseListWrapper(
@RequestHeader(Constants.X_AUTH_TOKEN) String authToken) {
SBApiResponse response = courseService.getExploreCourseListWithToken(authToken);
return new ResponseEntity<>(response, response.getResponseCode());
}

@GetMapping("course/v1/refreshCache")
public ResponseEntity<SBApiResponse> refreshCourseListInCache() {
SBApiResponse response = courseService.refreshCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public interface ExploreCourseService {
*/
public SBApiResponse getExploreCourseList();

public SBApiResponse getExploreCourseListWithToken(String authToken);

/**
* Refreshes the cache by re-reading the details from DB.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.sunbird.cassandra.utils.CassandraOperation;
import org.sunbird.common.model.SBApiResponse;
import org.sunbird.common.service.OutboundRequestHandlerServiceImpl;
import org.sunbird.common.util.AccessTokenValidator;
import org.sunbird.common.util.CbExtServerProperties;
import org.sunbird.common.util.Constants;
import org.sunbird.common.util.ProjectUtil;
Expand Down Expand Up @@ -48,6 +49,22 @@ public class ExploreCourseServiceImpl implements ExploreCourseService {
@Autowired
OutboundRequestHandlerServiceImpl outboundRequestHandlerService;

@Autowired
AccessTokenValidator accessTokenValidator;

@Override
public SBApiResponse getExploreCourseListWithToken(String authToken) {
SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.API_GET_EXPLORE_COURSE_DETAIL);
String userId = accessTokenValidator.fetchUserIdFromAccessToken(authToken, response);
if (StringUtils.isBlank(userId)) {
response.getParams().setStatus(Constants.FAILED);
response.getParams().setErrmsg(Constants.USER_ID_DOESNT_EXIST);
response.setResponseCode(HttpStatus.UNAUTHORIZED);
return response;
}
return getExploreCourseList();
}

@Override
public SBApiResponse getExploreCourseList() {
SBApiResponse response = ProjectUtil.createDefaultResponse(Constants.API_GET_EXPLORE_COURSE_DETAIL);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package org.sunbird.insights.controller;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.sunbird.common.model.SBApiResponse;
import static org.sunbird.common.util.Constants.*;
import static org.sunbird.common.util.ProjectUtil.updateErrorDetails;

import org.sunbird.common.util.AccessTokenValidator;
import org.sunbird.common.util.Constants;
import org.sunbird.common.util.ProjectUtil;
import org.sunbird.insights.controller.service.InsightsService;

import java.util.*;
Expand All @@ -14,6 +21,9 @@ public class InsightsController {
@Autowired
private InsightsService insightsService;

@Autowired
AccessTokenValidator accessTokenValidator;

@PostMapping("/user/v2/insights")
public ResponseEntity<?> insights(
@RequestBody Map<String, Object> requestBody,@RequestHeader("x-authenticated-userid") String userId) throws Exception {
Expand Down Expand Up @@ -52,4 +62,18 @@ public ResponseEntity<?> landingPageMatrix() throws Exception {
SBApiResponse response = insightsService.landingPageMatrix();
return new ResponseEntity<>(response, response.getResponseCode());
}

@PostMapping("/volunteer/user/v2/insights")
public ResponseEntity<?> volunteeInsights(
@RequestBody Map<String, Object> requestBody,@RequestHeader(value = Constants.X_AUTH_TOKEN, required = true) String authToken) throws Exception {
SBApiResponse response = ProjectUtil.createDefaultResponse(API_USER_INSIGHTS);
String userId = accessTokenValidator.fetchUserIdFromAccessToken(authToken);

if (StringUtils.isNotBlank(userId)){
response = insightsService.insights(requestBody,userId);
}else{
updateErrorDetails(response, UNAUTHORIZED, HttpStatus.UNAUTHORIZED);
}
return new ResponseEntity<>(response, response.getResponseCode());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,31 @@

import javax.validation.Valid;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.sunbird.common.model.SBApiResponse;
import org.sunbird.common.util.AccessTokenValidator;
import org.sunbird.common.util.Constants;
import org.sunbird.common.util.ProjectUtil;
import org.sunbird.ratings.model.LookupRequest;
import org.sunbird.ratings.model.RequestRating;
import org.sunbird.ratings.service.RatingService;

import static org.sunbird.common.util.Constants.API_RATINGS_READ;
import static org.sunbird.common.util.Constants.UNAUTHORIZED;
import static org.sunbird.common.util.ProjectUtil.updateErrorDetails;

@RestController
public class RatingsController {

@Autowired
RatingService ratingService;

@Autowired
AccessTokenValidator accessTokenValidator;
// ----------------- Public APIs --------------------

@PostMapping("/ratings/v1/upsert")
Expand Down Expand Up @@ -71,5 +81,21 @@ public ResponseEntity<?> getRatingTopReviewsSummary(@PathVariable(Constants.ORG_
SBApiResponse response = ratingService.getTopReviewsForUserByOrgID(userOrgId);
return new ResponseEntity<>(response, response.getResponseCode());
}


@GetMapping("volunteer/ratings/v1/read/{activityId}/{activityType}")
public ResponseEntity<?> getRatingForVolunteer(@PathVariable("activityId") String activityId,
@PathVariable("activityType") String activityType,
@RequestHeader(value = Constants.X_AUTH_TOKEN, required = true) String authToken) {
SBApiResponse response = ProjectUtil.createDefaultResponse(API_RATINGS_READ);
String userId = accessTokenValidator.fetchUserIdFromAccessToken(authToken);

if (StringUtils.isNotBlank(userId)){
response = ratingService.getRatings(activityId, activityType, userId);
}else{
updateErrorDetails(response, UNAUTHORIZED, HttpStatus.UNAUTHORIZED);
}
return new ResponseEntity<>(response, response.getResponseCode());
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.sunbird.common.model.SBApiResponse;
import org.sunbird.common.service.ContentService;
import org.sunbird.common.service.OutboundRequestHandlerServiceImpl;
import org.sunbird.common.util.AccessTokenValidator;
import org.sunbird.common.util.CbExtServerProperties;
import org.sunbird.common.util.Constants;
import org.sunbird.common.util.ProjectUtil;
Expand Down Expand Up @@ -78,6 +79,9 @@ public class RatingServiceImpl implements RatingService {
@Autowired
UserUtilityService userUtilityService;

@Autowired
AccessTokenValidator accessTokenValidator;

@Override
public SBApiResponse getRatings(String activityId, String activityType, String userId) {
SBApiResponse response = new SBApiResponse(Constants.API_RATINGS_READ);
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -692,4 +692,5 @@ bp.report.wf.page.size=100
bp.report.sheet.name=Enrollment Report
bp.report.excel.row.window.size=100
bp.report.batch.detail.fields=batchId,courseId,name,status,start_date,end_date,enrollment_enddate,createdBy,createdDate,createdFor,batch_attributes
bp.report.v2.headers=Batch ID,Batch Name,Program ID,Program Name,Program Type,MDO / Department Name,Program Coordinator Name,Batch Status,Batch Start Date,Batch End Date,Enrollment Start Date,Enrollment End Date,Batch Duration (Days),Total Enrolled Learners,Batch Created Date,Batch Created By,Name,Organisation,Group,Designation,Employee ID,Email,Mobile Number,Gender,Date of Birth,Mother Tongue,Category,Office Pin Code,Are you a Cadre Employee,Type of Service,Service,Cadre,Cadre Batch,Cadre Controlling Authority Name,eHRMS ID / External System ID,Date of Retirement,Enrollment Status,Designation (filled during enrollment),Group (filled during enrollment),Learner Name,Email ID,Department / Ministry,Enrollment Date,Instructor Name,Certificate Issued (Y/N),Certificate Issued Date
bp.report.v2.headers=Batch ID,Batch Name,Program ID,Program Name,Program Type,MDO / Department Name,Program Coordinator Name,Batch Status,Batch Start Date,Batch End Date,Enrollment Start Date,Enrollment End Date,Batch Duration (Days),Total Enrolled Learners,Batch Created Date,Batch Created By,Name,Organisation,Group,Designation,Employee ID,Email,Mobile Number,Gender,Date of Birth,Mother Tongue,Category,Office Pin Code,Are you a Cadre Employee,Type of Service,Service,Cadre,Cadre Batch,Cadre Controlling Authority Name,eHRMS ID / External System ID,Date of Retirement,Enrollment Status,Designation (filled during enrollment),Group (filled during enrollment),Learner Name,Email ID,Department / Ministry,Enrollment Date,Instructor Name,Certificate Issued (Y/N),Certificate Issued Date
bp.report.v2.file.name.prefix=BlendedProgramConsumptionReport_