Skip to content

Commit

Permalink
Merge pull request Sunbird-Knowlg#1299 from PradyumnaNagendra/release…
Browse files Browse the repository at this point in the history
…-3.5.0

Merge branch 'release-3.4.0' into release-3.5.0
  • Loading branch information
maheshkumargangula authored Dec 16, 2020
2 parents 14e2bdc + c653746 commit e8f7511
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ private void generateCertificate(List<Map<String, String>> certificates, String
if(CollectionUtils.isNotEmpty(updatedCerts)) {
Map<String, Object> dataToUpdate = new HashMap<String, Object>() {{
put(CourseCertificateParams.issued_certificates.name(), updatedCerts);
put(CourseCertificateParams.certstatus.name(), 2);
}};
Map<String, Object> dataToSelect = new HashMap<String, Object>() {{
put(CourseCertificateParams.userId.name(), userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ private void fetchUsersAndIssueCertificates(String batchId, String courseId, Boo
LOGGER.info("IssueCertificate:fetchUsersAndIssueCertificates: userIds " + userIds);
for (String key : templates.keySet()) {
Map<String, String> template = templates.get(key);
//String certName = template.getOrDefault("name", "");
String criteriaString = template.get("criteria");
if (StringUtils.isNotBlank(criteriaString)) {
Map<String, Object> criteria = mapper.readValue(criteriaString, new TypeReference<Map<String, Object>>() {
Expand All @@ -118,6 +117,10 @@ private void fetchUsersAndIssueCertificates(String batchId, String courseId, Boo
}).orElse(Arrays.asList());

generateCertificatesForEnrollment(usersToIssue, batchId, courseId, reIssue, template, collector);

List<String> criteriaNotMatchedList = userIds.stream().filter(u -> !usersToIssue.contains(u)).collect(Collectors.toList());
// certstatus = 3 means - the criteria didn't match.
updateEnrolmentCertStatus(criteriaNotMatchedList, courseId, batchId, 3);
} else {
LOGGER.info("IssueCertificate:fetchUsersAndIssueCertificates: Certificate template has empty/invalid criteria: " + criteria);
throw new ClientException("ERR_INVALID_CERTIFICATE_TEMPLATE", "Certificate template has empty/invalid criteria: " + criteria);
Expand All @@ -133,6 +136,20 @@ private void fetchUsersAndIssueCertificates(String batchId, String courseId, Boo
}
}

private void updateEnrolmentCertStatus(List<String> userIds, String courseId, String batchId, Integer certStatus) {
for (String userId: userIds) {
Map<String, Object> dataToUpdate = new HashMap<String, Object>() {{
put(CourseCertificateParams.certstatus.name(), certStatus);
}};
Map<String, Object> dataToSelect = new HashMap<String, Object>() {{
put(CourseCertificateParams.userId.name(), userId);
put(CourseCertificateParams.courseId.name(), courseId);
put(CourseCertificateParams.batchId.name(), batchId);
}};
SunbirdCassandraUtil.update(cassandraSession, KEYSPACE, USER_COURSES_TABLE, dataToUpdate, dataToSelect);
}
}

private static List<String> getUsersFromUserCriteria(Map<String, Object> criteria, List<String> userIds) throws Exception {
if(MapUtils.isEmpty(criteria))
return new ArrayList<>();
Expand Down Expand Up @@ -321,7 +338,6 @@ private void generateCertificatesForEnrollment(List<String> usersToIssue, String
}
} else {
LOGGER.info("IssueCertificate:generateCertificatesForEnrollment: NO users satisfied the criteria for batchId: " + batchId + " and courseId: " + courseId);
throw new ClientException("ERR_GENERATE_CERTIFICATE", "NO users satisfied the criteria for batchId: " + batchId + " and courseId: " + courseId);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ public enum CourseCertificateParams {
edata, object, iteration, id, batchId, userId, certificates, reIssue, request,certificate, data, recipientName,
recipientId, courseName, name, issuer, signatoryList, tag, orgId, htmlTemplate, url, pdfUrl, lastIssuedOn,
jsonData, issuedDate, token, accessCode, jsonUrl, courseId, oldId, keys, criteria, narrative, basePath, userIds,
svgTemplate, identifier, type, rollup, l1, channel, pdata, pid, ver, env, cdata, props, mid, eid, issued_certificates
svgTemplate, identifier, type, rollup, l1, channel, pdata, pid, ver, env, cdata, props, mid, eid, issued_certificates, certstatus
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ public static void update(Session session, String keyspace, String table, Map<St
else
updateQuery.and(QueryBuilder.eq(entry.getKey(), entry.getValue()));
});



session.execute(updateQuery);
}

Expand Down
7 changes: 0 additions & 7 deletions platform-jobs/samza/distribution/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,6 @@
<type>tar.gz</type>
<classifier>distribution</classifier>
</dependency>
<dependency>
<groupId>org.ekstep</groupId>
<artifactId>course-certificate-generator</artifactId>
<version>0.0.68</version>
<type>tar.gz</type>
<classifier>distribution</classifier>
</dependency>
<dependency>
<groupId>org.ekstep</groupId>
<artifactId>course-certificate-generator-v2</artifactId>
Expand Down
1 change: 0 additions & 1 deletion platform-jobs/samza/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<module>post-publish-processor</module>
<module>qr-image-generator</module>
<module>merge-user-courses</module>
<module>course-certificate-generator</module>
<module>course-certificate-generator-v2</module>
<module>auto-creator</module>
<module>mvc-processor-indexer</module>
Expand Down

0 comments on commit e8f7511

Please sign in to comment.