├── .gitignore ├── .settings ├── org.eclipse.m2e.core.prefs ├── org.eclipse.core.resources.prefs └── org.eclipse.jdt.core.prefs ├── src └── main │ ├── resources │ ├── government-of-india.jpg │ ├── templates │ │ ├── pdf-published-footer.html │ │ ├── pdf-draft-footer.html │ │ └── pdf-header.vm │ ├── elasticsearch │ │ └── index │ │ │ └── workorderv1.json │ └── application.properties │ └── java │ └── org │ └── sunbird │ ├── catalog │ ├── model │ │ ├── Catalog.java │ │ ├── FrameworkResponseResult.java │ │ ├── FrameworkResponseParams.java │ │ ├── Category.java │ │ ├── FrameworkResponse.java │ │ ├── Framework.java │ │ └── Term.java │ ├── controller │ │ └── CatalogController.java │ └── service │ │ └── CatalogServiceImpl.java │ ├── core │ ├── config │ │ ├── PropertiesConfig.java │ │ ├── CassandraConfig.java │ │ ├── ProducerConfiguration.java │ │ ├── EsConfig.java │ │ ├── SunbirdConfig.java │ │ ├── ConsumerConfiguration.java │ │ └── PostgresDataSourceConfig.java │ ├── exception │ │ ├── BadRequestException.java │ │ ├── ApplicationLogicError.java │ │ └── InvalidDataInputException.java │ ├── producer │ │ └── Producer.java │ └── logger │ │ └── CbExtLogger.java │ ├── progress │ ├── service │ │ └── MandatoryContentService.java │ ├── cassandraRepo │ │ ├── MandatoryContentRepository.java │ │ ├── MandatoryContentModel.java │ │ └── MandatoryContentPrimaryKeyModel.java │ ├── model │ │ ├── MandatoryContentResponse.java │ │ └── MandatoryContentInfo.java │ └── controller │ │ └── MandatoryContentController.java │ ├── common │ ├── service │ │ ├── UserUtilityService.java │ │ └── ContentService.java │ ├── model │ │ ├── SunbirdApiUserCourseResult.java │ │ ├── OpenSaberApiRespResult.java │ │ ├── SunbirdApiHierarchyResultBatch.java │ │ ├── SunbirdApiResultResponse.java │ │ ├── SunbirdApiRespResult.java │ │ ├── OpenSaberApiUserProfile.java │ │ ├── SunbirdApiRespParam.java │ │ ├── OpenSaberApiPersonalDetail.java │ │ ├── SunbirdApiRespOragainsation.java │ │ ├── SunbirdApiResp.java │ │ ├── Response.java │ │ ├── OpenSaberApiResp.java │ │ ├── SunbirdApiUserCourseListResp.java │ │ ├── SunbirdApiBatchResp.java │ │ ├── SunbirdApiBatch.java │ │ ├── SunbirdApiRespContent.java │ │ └── SunbirdApiHierarchyResultContent.java │ └── util │ │ └── DataValidator.java │ ├── assessment │ ├── repo │ │ ├── UserQuizMasterRepositoryCustom.java │ │ ├── UserQuizMasterRepository.java │ │ ├── UserAssessmentMasterRepository.java │ │ ├── UserAssessmentMasterRepositoryCustom.java │ │ ├── UserAssessmentSummaryRepository.java │ │ ├── UserQuizMasterRepositoryImpl.java │ │ ├── UserAssessmentTopPerformerRepository.java │ │ ├── UserAssessmentMasterRepositoryImpl.java │ │ ├── UserQuizSummaryModel.java │ │ ├── AssessmentRepository.java │ │ ├── UserQuizSummaryPrimaryKeyModel.java │ │ ├── UserAssessmentSummaryPrimaryKeyModel.java │ │ ├── UserQuizMasterPrimaryKeyModel.java │ │ ├── CohortUsers.java │ │ ├── UserAssessmentTopPerformerModel.java │ │ ├── UserAssessmentSummaryModel.java │ │ ├── UserAssessmentMasterPrimaryKeyModel.java │ │ ├── UserAssessmentTopPerformerPrimaryKeyModel.java │ │ └── UserQuizMasterModel.java │ ├── service │ │ ├── AssessmentUtilService.java │ │ ├── CohortsService.java │ │ └── AssessmentService.java │ └── dto │ │ └── AssessmentSubmissionDTO.java │ ├── portal │ ├── department │ │ ├── repo │ │ │ ├── RoleRepository.java │ │ │ ├── UserDepartmentRoleAuditRepo.java │ │ │ ├── DepartmentTypeRepository.java │ │ │ ├── DepartmentRepository.java │ │ │ ├── UserDepartmentRoleRepository.java │ │ │ └── DepartmentRoleRepository.java │ │ ├── service │ │ │ ├── DepartmentTypeService.java │ │ │ ├── MdoPortalService.java │ │ │ ├── SpvPortalService.java │ │ │ ├── RoleService.java │ │ │ ├── OrgCreationConsumer.java │ │ │ ├── MdoPortalServiceImpl.java │ │ │ ├── UserDepartmentRoleAuditProcessing.java │ │ │ ├── PortalService.java │ │ │ ├── OrgCreationProcessService.java │ │ │ ├── SpvPortalServiceImpl.java │ │ │ └── DepartmentTypeServiceImpl.java │ │ ├── model │ │ │ ├── DeptPublicInfo.java │ │ │ ├── SearchUserInfo.java │ │ │ ├── UserDepartmentInfo.java │ │ │ ├── DeptTypeInfo.java │ │ │ └── PortalUserInfo.java │ │ ├── PortalConstants.java │ │ ├── dto │ │ │ ├── Role.java │ │ │ ├── DepartmentRole.java │ │ │ ├── DepartmentType.java │ │ │ ├── GenericArrayUserType.java │ │ │ ├── UserDepartmentRole.java │ │ │ └── UserDepartmentRoleAudit.java │ │ └── controller │ │ │ ├── DepartmentTypeController.java │ │ │ └── RoleController.java │ └── SbCbExtApplication.java │ └── workallocation │ ├── service │ └── PdfGeneratorService.java │ ├── repo │ ├── WorkOrderRepo.java │ └── WorkAllocationRepo.java │ ├── util │ ├── FRACReqBuilder.java │ └── WorkAllocationConstants.java │ ├── model │ ├── AdditionalProperties.java │ ├── RoleCompetency.java │ ├── PdfGeneratorRequest.java │ ├── FracResponse.java │ ├── WorkAllocationPrimaryKeyModel.java │ ├── WorkOrderPrimaryKeyModel.java │ ├── FracStatusInfo.java │ ├── WorkOrderCassandraModel.java │ ├── WorkAllocationCassandraModel.java │ ├── Child.java │ ├── SearchCriteria.java │ ├── FracRequest.java │ ├── UserBasicInfo.java │ ├── ResponseData.java │ ├── WorkAllocation.java │ ├── WorkAllocationDTO.java │ ├── WAObject.java │ ├── ContentCreateRequest.java │ └── ChildNode.java │ └── controller │ ├── PdfGeneratorController.java │ └── AllocationController.java ├── Dockerfile.build ├── dockbuild.sh ├── .project ├── Dockerfile ├── LICENSE ├── .classpath ├── Jenkinsfile-sun └── Jenkinsfile /.gitignore: -------------------------------------------------------------------------------- 1 | /target/ 2 | -------------------------------------------------------------------------------- /.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /src/main/resources/government-of-india.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sphere/sunbird-cb-ext/main/src/main/resources/government-of-india.jpg -------------------------------------------------------------------------------- /Dockerfile.build: -------------------------------------------------------------------------------- 1 | FROM openjdk:8 2 | 3 | RUN apt update && apt install maven -y 4 | 5 | COPY . /opt 6 | WORKDIR /opt 7 | RUN mvn clean install 8 | 9 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding//src/main/java=UTF-8 3 | encoding//src/main/resources=UTF-8 4 | encoding/=UTF-8 5 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/model/Catalog.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.model; 2 | 3 | import java.util.List; 4 | 5 | public class Catalog { 6 | private List terms; 7 | 8 | public List getTerms() { 9 | return terms; 10 | } 11 | 12 | public void setTerms(List terms) { 13 | this.terms = terms; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/config/PropertiesConfig.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.config; 2 | 3 | import org.springframework.context.annotation.Configuration; 4 | import org.springframework.context.annotation.PropertySource; 5 | 6 | @Configuration 7 | @PropertySource(value = { "classpath:application.properties" }) 8 | public class PropertiesConfig { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/progress/service/MandatoryContentService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.progress.service; 2 | 3 | import org.sunbird.progress.model.MandatoryContentResponse; 4 | 5 | public interface MandatoryContentService { 6 | 7 | public MandatoryContentResponse getMandatoryContentStatusForUser(String authUserToken, String rootOrg, String org, String userId); 8 | } 9 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/service/UserUtilityService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public interface UserUtilityService { 7 | 8 | boolean validateUser(String rootOrg, String userId); 9 | 10 | Map getUsersDataFromUserIds(String rootOrg, List userIds, List source); 11 | 12 | } 13 | -------------------------------------------------------------------------------- /src/main/resources/templates/pdf-published-footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserQuizMasterRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | public interface UserQuizMasterRepositoryCustom { 4 | /** 5 | * update quiz and quiz summary 6 | * 7 | * @param quiz 8 | * @param quizSummary 9 | * @return 10 | */ 11 | public UserQuizMasterModel updateQuiz(UserQuizMasterModel quiz, UserQuizSummaryModel quizSummary); 12 | } 13 | -------------------------------------------------------------------------------- /dockbuild.sh: -------------------------------------------------------------------------------- 1 | docker build --no-cache -f ./Dockerfile.build -t sb-cb-ext-build . 2 | 3 | docker run --name sb-cb-ext-build sb-cb-ext-build:latest && docker cp sb-cb-ext-build:/opt/target/sb-cb-ext-0.0.1-SNAPSHOT.jar . 4 | 5 | docker rm -f sb-cb-ext-build 6 | docker rmi -f sb-cb-ext-build 7 | 8 | docker build --no-cache -t eagle-docker.tarento.com/lex-core-service:gold . 9 | docker push eagle-docker.tarento.com/lex-core-service:gold 10 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserQuizMasterRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import org.springframework.data.cassandra.repository.CassandraRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface UserQuizMasterRepository extends 8 | CassandraRepository, UserQuizMasterRepositoryCustom { 9 | } 10 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/repo/RoleRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.repo; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.sunbird.portal.department.dto.Role; 7 | 8 | public interface RoleRepository extends CrudRepository { 9 | Role findRoleByRoleName(String roleName); 10 | List findAllByRoleNameIn(List roleNames); 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/repo/UserDepartmentRoleAuditRepo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.repo; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.stereotype.Repository; 5 | import org.sunbird.portal.department.dto.UserDepartmentRoleAudit; 6 | 7 | @Repository 8 | public interface UserDepartmentRoleAuditRepo extends JpaRepository { 9 | 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiUserCourseResult.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | public class SunbirdApiUserCourseResult { 6 | private List courses; 7 | 8 | public List getCourses() { 9 | return courses; 10 | } 11 | 12 | public void setCourses(List courses) { 13 | this.courses = courses; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentMasterRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import org.springframework.data.cassandra.repository.CassandraRepository; 4 | import org.springframework.stereotype.Repository; 5 | 6 | @Repository 7 | public interface UserAssessmentMasterRepository 8 | extends CassandraRepository, 9 | UserAssessmentMasterRepositoryCustom { 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/model/FrameworkResponseResult.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | @JsonIgnoreProperties(ignoreUnknown = true) 6 | public class FrameworkResponseResult { 7 | private Framework framework; 8 | 9 | public Framework getFramework() { 10 | return framework; 11 | } 12 | 13 | public void setFramework(Framework framework) { 14 | this.framework = framework; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentMasterRepositoryCustom.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | public interface UserAssessmentMasterRepositoryCustom { 4 | 5 | /** 6 | * updates assessment and assessment summary 7 | * 8 | * @param assessment 9 | * @param assessmentSummary 10 | * @return 11 | */ 12 | public UserAssessmentMasterModel updateAssessment(UserAssessmentMasterModel assessment, 13 | UserAssessmentSummaryModel assessmentSummary); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/service/PdfGeneratorService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.service; 2 | 3 | import org.sunbird.workallocation.model.PdfGeneratorRequest; 4 | 5 | public interface PdfGeneratorService { 6 | public byte[] generatePdf(PdfGeneratorRequest request) throws Exception; 7 | public byte[] generatePdf(String woId) throws Exception; 8 | public String getPublishedPdfLink(String woId); 9 | public String generatePdfAndGetFilePath(String woId); 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/repo/WorkOrderRepo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.repo; 2 | 3 | import org.springframework.data.cassandra.repository.CassandraRepository; 4 | import org.springframework.stereotype.Repository; 5 | import org.sunbird.workallocation.model.WorkOrderCassandraModel; 6 | import org.sunbird.workallocation.model.WorkOrderPrimaryKeyModel; 7 | 8 | @Repository 9 | public interface WorkOrderRepo extends CassandraRepository { 10 | 11 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/service/AssessmentUtilService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.service; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | public interface AssessmentUtilService { 7 | 8 | Map validateAssessment(List> questions); 9 | 10 | Map validateAssessment(List> questions, Map answers); 11 | 12 | Map getAnswerKeyForAssessmentAuthoringPreview(Map contentMeta); 13 | } 14 | -------------------------------------------------------------------------------- /src/main/resources/templates/pdf-draft-footer.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 |
________________________________________________________
Approved OnSignature
21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.methodParameters=generate 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 4 | org.eclipse.jdt.core.compiler.compliance=1.8 5 | org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled 6 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 7 | org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore 8 | org.eclipse.jdt.core.compiler.release=disabled 9 | org.eclipse.jdt.core.compiler.source=1.8 10 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/repo/WorkAllocationRepo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.repo; 2 | 3 | import org.springframework.data.cassandra.repository.CassandraRepository; 4 | import org.springframework.stereotype.Repository; 5 | import org.sunbird.workallocation.model.WorkAllocationCassandraModel; 6 | import org.sunbird.workallocation.model.WorkAllocationPrimaryKeyModel; 7 | 8 | @Repository 9 | public interface WorkAllocationRepo extends CassandraRepository { 10 | 11 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/OpenSaberApiRespResult.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | import com.fasterxml.jackson.annotation.JsonProperty; 6 | 7 | public class OpenSaberApiRespResult { 8 | @JsonProperty("UserProfile") 9 | private List userProfile; 10 | 11 | public List getUserProfile() { 12 | return userProfile; 13 | } 14 | 15 | public void setUserProfile(List userProfile) { 16 | this.userProfile = userProfile; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/util/FRACReqBuilder.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.util; 2 | 3 | import org.springframework.stereotype.Service; 4 | import org.sunbird.workallocation.model.FracRequest; 5 | 6 | @Service 7 | public class FRACReqBuilder { 8 | public FracRequest getPositionRequest(String source, String name) { 9 | FracRequest req = new FracRequest(); 10 | req.setName(source); 11 | req.setName(name); 12 | req.setType("POSITION"); 13 | req.setId(null); 14 | return req; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/DepartmentTypeService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import org.sunbird.portal.department.dto.DepartmentType; 4 | 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public interface DepartmentTypeService { 9 | 10 | Map> getAllDepartmentTypes(); 11 | 12 | List getDepartmentByType(String deptType); 13 | 14 | DepartmentType getDepartmentTypeById(Integer id) throws Exception; 15 | 16 | Map> getDepartmentTypeNames(); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiHierarchyResultBatch.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | public class SunbirdApiHierarchyResultBatch { 6 | 7 | private int count; 8 | private List participants; 9 | 10 | public int getCount() { 11 | return count; 12 | } 13 | 14 | public void setCount(int count) { 15 | this.count = count; 16 | } 17 | 18 | public List getParticipants() { 19 | return participants; 20 | } 21 | 22 | public void setParticipants(List participants) { 23 | this.participants = participants; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiResultResponse.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | public class SunbirdApiResultResponse { 6 | 7 | private int count; 8 | private List content; 9 | 10 | public int getCount() { 11 | return count; 12 | } 13 | 14 | public void setCount(int count) { 15 | this.count = count; 16 | } 17 | 18 | public List getContent() { 19 | return content; 20 | } 21 | 22 | public void setContent(List content) { 23 | this.content = content; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | sb-cb-ext 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.jdt.core.javanature 21 | org.eclipse.m2e.core.maven2Nature 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/util/DataValidator.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.util; 2 | 3 | import java.util.List; 4 | 5 | public class DataValidator { 6 | 7 | private DataValidator() { 8 | throw new IllegalStateException("DataValidator class"); 9 | } 10 | public static boolean isStringEmpty(String str) { 11 | return str == null || str.isEmpty(); 12 | } 13 | 14 | public static boolean isCollectionEmpty(List list) { 15 | return list == null || list.isEmpty(); 16 | } 17 | 18 | public static boolean isCollectionEmpty(Iterable list) { 19 | return list == null || !list.iterator().hasNext(); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/resources/templates/pdf-header.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/service/ContentService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.service; 2 | 3 | import java.util.List; 4 | 5 | import org.sunbird.common.model.SunbirdApiResp; 6 | import org.sunbird.common.model.SunbirdApiUserCourseListResp; 7 | 8 | public interface ContentService { 9 | 10 | public SunbirdApiResp getHeirarchyResponse(String contentId); 11 | 12 | public List getParticipantsList(String xAuthUser, List batchIdList); 13 | 14 | public List getParticipantsForBatch(String xAuthUser, String batchId); 15 | 16 | public SunbirdApiUserCourseListResp getUserCourseListResponse(String authToken, String userId); 17 | } 18 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/MdoPortalService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import org.sunbird.portal.department.model.DepartmentInfo; 4 | 5 | public interface MdoPortalService { 6 | DepartmentInfo updateDepartment(DepartmentInfo deptInfo,String rootOrg) throws Exception; 7 | 8 | DepartmentInfo getMyDepartment(String userId, boolean isUserInfoRequired,String rootOrg) throws Exception; 9 | 10 | DepartmentInfo getMyFracDepartment(String userId, boolean isUserInfoRequired, String rootOrg) throws Exception; 11 | 12 | DepartmentInfo getMyCBCDepartment(String userId, boolean isUserInfoRequired, String rootOrg) throws Exception; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/service/CohortsService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.service; 2 | 3 | import java.util.List; 4 | 5 | import org.sunbird.assessment.repo.CohortUsers; 6 | import org.sunbird.common.model.Response; 7 | 8 | public interface CohortsService { 9 | List getTopPerformers(String rootOrg, String resourceId, String userUUID, int count) throws Exception; 10 | 11 | List getActiveUsers(String xAuthUser, String rootOrg, String contentId, String userUUID, int count, Boolean toFilter) 12 | throws Exception; 13 | Response autoEnrollmentInCourse(String authUserToken, String rootOrg, String contentId, String userUUID)throws Exception; 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/AdditionalProperties.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | public class AdditionalProperties { 4 | 5 | private String competencyArea; 6 | 7 | private String competencyType; 8 | 9 | public String getCompetencyArea() { 10 | return competencyArea; 11 | } 12 | 13 | public void setCompetencyArea(String competencyArea) { 14 | this.competencyArea = competencyArea; 15 | } 16 | 17 | public String getCompetencyType() { 18 | return competencyType; 19 | } 20 | 21 | public void setCompetencyType(String competencyType) { 22 | this.competencyType = competencyType; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/RoleCompetency.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import java.util.List; 4 | 5 | public class RoleCompetency { 6 | private Role roleDetails; 7 | private List competencyDetails; 8 | 9 | public Role getRoleDetails() { 10 | return roleDetails; 11 | } 12 | 13 | public void setRoleDetails(Role roleDetails) { 14 | this.roleDetails = roleDetails; 15 | } 16 | 17 | public List getCompetencyDetails() { 18 | return competencyDetails; 19 | } 20 | 21 | public void setCompetencyDetails(List competencyDetails) { 22 | this.competencyDetails = competencyDetails; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/PdfGeneratorRequest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import java.util.Map; 4 | 5 | public class PdfGeneratorRequest { 6 | 7 | private String templateId; 8 | 9 | private Map tagValuePair; 10 | 11 | public String getTemplateId() { 12 | return templateId; 13 | } 14 | 15 | public void setTemplateId(String templateId) { 16 | this.templateId = templateId; 17 | } 18 | 19 | public Map getTagValuePair() { 20 | return tagValuePair; 21 | } 22 | 23 | public void setTagValuePair(Map tagValuePair) { 24 | this.tagValuePair = tagValuePair; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/exception/BadRequestException.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseBody; 5 | import org.springframework.web.bind.annotation.ResponseStatus; 6 | 7 | @ResponseStatus(value = HttpStatus.BAD_REQUEST) 8 | @ResponseBody 9 | public class BadRequestException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | @Override 14 | public String getMessage() { 15 | return message; 16 | } 17 | 18 | private final String message; 19 | 20 | public BadRequestException(String message) { 21 | super(message); 22 | this.message = message; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/FracResponse.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | @JsonIgnoreProperties(ignoreUnknown = true) 6 | public class FracResponse { 7 | private FracStatusInfo statusInfo; 8 | private ResponseData responseData; 9 | 10 | public FracStatusInfo getStatusInfo() { 11 | return statusInfo; 12 | } 13 | 14 | public void setStatusInfo(FracStatusInfo statusInfo) { 15 | this.statusInfo = statusInfo; 16 | } 17 | 18 | public ResponseData getResponseData() { 19 | return responseData; 20 | } 21 | 22 | public void setResponseData(ResponseData responseData) { 23 | this.responseData = responseData; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/WorkAllocationPrimaryKeyModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import org.springframework.data.cassandra.core.cql.PrimaryKeyType; 4 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; 5 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; 6 | 7 | @PrimaryKeyClass 8 | public class WorkAllocationPrimaryKeyModel { 9 | private static final long serialVersionUID = 1L; 10 | @PrimaryKeyColumn(name = "id", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 11 | private String id; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | 17 | public void setId(String id) { 18 | this.id = id; 19 | } 20 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/WorkOrderPrimaryKeyModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import org.springframework.data.cassandra.core.cql.PrimaryKeyType; 4 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; 5 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; 6 | 7 | @PrimaryKeyClass 8 | public class WorkOrderPrimaryKeyModel { 9 | 10 | private static final long serialVersionUID = 1L; 11 | @PrimaryKeyColumn(name = "id", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 12 | private String id; 13 | 14 | public String getId() { 15 | return id; 16 | } 17 | 18 | public void setId(String id) { 19 | this.id = id; 20 | } 21 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/model/FrameworkResponseParams.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | @JsonIgnoreProperties(ignoreUnknown = true) 6 | public class FrameworkResponseParams { 7 | private String status; 8 | private String err; 9 | private String errmsg; 10 | public String getStatus() { 11 | return status; 12 | } 13 | public void setStatus(String status) { 14 | this.status = status; 15 | } 16 | public String getErr() { 17 | return err; 18 | } 19 | public void setErr(String err) { 20 | this.err = err; 21 | } 22 | public String getErrmsg() { 23 | return errmsg; 24 | } 25 | public void setErrmsg(String errmsg) { 26 | this.errmsg = errmsg; 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/repo/DepartmentTypeRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.repo; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.sunbird.portal.department.dto.DepartmentType; 7 | 8 | public interface DepartmentTypeRepository extends CrudRepository { 9 | 10 | DepartmentType findByDeptTypeAndDeptSubType(String deptType, String deptSubType); 11 | 12 | // @Query("select * from department_types where dept_type = ?0") 13 | List findByDeptTypeIgnoreCase(String deptType); 14 | 15 | // @Query("select distinct d.dept_type, d.dept_subtype from department_types d") 16 | // List findDistinctDeptTypeAndDeptSubType(); 17 | } 18 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8 2 | 3 | RUN apt-get update \ 4 | && apt-get install -y \ 5 | curl \ 6 | libxrender1 \ 7 | libjpeg62-turbo \ 8 | fontconfig \ 9 | libxtst6 \ 10 | xfonts-75dpi \ 11 | xfonts-base \ 12 | xz-utils 13 | 14 | RUN curl "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.buster_amd64.deb" -L -o "wkhtmltopdf.deb" 15 | RUN dpkg -i wkhtmltopdf.deb 16 | 17 | COPY sb-cb-ext-0.0.1-SNAPSHOT.jar /opt/ 18 | #HEALTHCHECK --interval=30s --timeout=30s CMD curl --fail http://localhost:7001/actuator/health || exit 1 19 | CMD ["java", "-XX:+PrintFlagsFinal", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-jar", "/opt/sb-cb-ext-0.0.1-SNAPSHOT.jar"] 20 | 21 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentSummaryRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import org.springframework.data.cassandra.repository.CassandraRepository; 4 | import org.springframework.data.cassandra.repository.Query; 5 | import org.springframework.stereotype.Repository; 6 | 7 | @Repository 8 | public interface UserAssessmentSummaryRepository 9 | extends CassandraRepository { 10 | 11 | /** 12 | * returns assessment count for a user 13 | * 14 | * @param userId 15 | * @return 16 | */ 17 | @Query("select count(*) from user_assessment_summary where root_org=?0 and user_id=?1") 18 | public long countByPrimaryKeyRootOrgAndPrimaryKeyUserId(String rootOrg, String userId); 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserQuizMasterRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.cassandra.core.CassandraBatchOperations; 5 | import org.springframework.data.cassandra.core.CassandraOperations; 6 | 7 | public class UserQuizMasterRepositoryImpl implements UserQuizMasterRepositoryCustom { 8 | 9 | @Autowired 10 | CassandraOperations cassandraOperations; 11 | 12 | @Override 13 | public UserQuizMasterModel updateQuiz(UserQuizMasterModel quiz, UserQuizSummaryModel quizSummary) { 14 | CassandraBatchOperations batchOps = cassandraOperations.batchOps(); 15 | batchOps.insert(quiz); 16 | batchOps.insert(quizSummary); 17 | batchOps.execute(); 18 | return quiz; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/FracStatusInfo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | public class FracStatusInfo { 4 | private int statusCode; 5 | private String statusMessage; 6 | private String errorMessage; 7 | 8 | public int getStatusCode() { 9 | return statusCode; 10 | } 11 | 12 | public void setStatusCode(int statusCode) { 13 | this.statusCode = statusCode; 14 | } 15 | 16 | public String getStatusMessage() { 17 | return statusMessage; 18 | } 19 | 20 | public void setStatusMessage(String statusMessage) { 21 | this.statusMessage = statusMessage; 22 | } 23 | 24 | public String getErrorMessage() { 25 | return errorMessage; 26 | } 27 | 28 | public void setErrorMessage(String errorMessage) { 29 | this.errorMessage = errorMessage; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/util/WorkAllocationConstants.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.util; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | public class WorkAllocationConstants { 8 | public static final String ALLOCATION_DETAILS = "allocationDetails"; 9 | public static final String USER_DETAILS = "userDetails"; 10 | 11 | public static final String DRAFT_STATUS = "Draft"; 12 | public static final String PUBLISHED_STATUS = "Published"; 13 | public static final String ARCHIVED_STATUS = "Archived"; 14 | public static final List STATUS_LIST = Collections 15 | .unmodifiableList(Arrays.asList(DRAFT_STATUS, PUBLISHED_STATUS, ARCHIVED_STATUS)); 16 | public static final String ADD = "add"; 17 | public static final String UPDATE = "update"; 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiRespResult.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | public class SunbirdApiRespResult { 4 | private SunbirdApiResultResponse response; 5 | private SunbirdApiHierarchyResultContent content; 6 | private SunbirdApiHierarchyResultBatch batch; 7 | 8 | public SunbirdApiResultResponse getResponse() { 9 | return response; 10 | } 11 | 12 | public void setResponse(SunbirdApiResultResponse response) { 13 | this.response = response; 14 | } 15 | 16 | public SunbirdApiHierarchyResultContent getContent() { 17 | return content; 18 | } 19 | 20 | public void setContent(SunbirdApiHierarchyResultContent content) { 21 | this.content = content; 22 | } 23 | 24 | public SunbirdApiHierarchyResultBatch getBatch() { 25 | return batch; 26 | } 27 | 28 | public void setBatch(SunbirdApiHierarchyResultBatch batch) { 29 | this.batch = batch; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/progress/cassandraRepo/MandatoryContentRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.progress.cassandraRepo; 2 | 3 | import org.springframework.data.cassandra.repository.CassandraRepository; 4 | import org.springframework.data.cassandra.repository.Query; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Repository 10 | public interface MandatoryContentRepository extends 11 | CassandraRepository { 12 | /** 13 | * Fetch the mandatory content for Org 14 | * 15 | * @param rootOrg 16 | * @param org 17 | * @return 18 | */ 19 | @Query("select content_id, content_type, minprogressforcompletion, batch_id from mandatory_user_content where root_org=?0 and org=?1") 20 | public List getMandatoryContentsInfo(String rootOrg, String org); 21 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/model/DeptPublicInfo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.model; 2 | 3 | public class DeptPublicInfo { 4 | int id; 5 | String root_org; 6 | String friendly_name; 7 | String description; 8 | 9 | public int getId() { 10 | return id; 11 | } 12 | 13 | public void setId(int id) { 14 | this.id = id; 15 | } 16 | 17 | public String getRoot_org() { 18 | return root_org; 19 | } 20 | 21 | public void setRoot_org(String root_org) { 22 | this.root_org = root_org; 23 | } 24 | 25 | public String getFriendly_name() { 26 | return friendly_name; 27 | } 28 | 29 | public void setFriendly_name(String friendly_name) { 30 | this.friendly_name = friendly_name; 31 | } 32 | 33 | public String getDescription() { 34 | return description; 35 | } 36 | 37 | public void setDescription(String description) { 38 | this.description = description; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/SpvPortalService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import java.util.List; 4 | 5 | import org.sunbird.common.model.Response; 6 | import org.sunbird.portal.department.model.DepartmentInfo; 7 | 8 | public interface SpvPortalService { 9 | public List getAllDepartments(String rootOrg) throws Exception; 10 | 11 | public DepartmentInfo addDepartment(String authUserToken, String userId, DepartmentInfo deptInfo,String rootOrg) throws Exception; 12 | 13 | DepartmentInfo updateDepartment(DepartmentInfo deptInfo,String rootOrg) throws Exception; 14 | 15 | DepartmentInfo getMyDepartment(String userId, boolean isUserInfoRequired,String rootOrg) throws Exception; 16 | 17 | DepartmentInfo getDepartmentById(Integer deptId, boolean isUserInfoRequired,String rootOrg) throws Exception; 18 | 19 | Response deleteDepartment(String userId, Integer deptId); 20 | } 21 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/exception/ApplicationLogicError.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseBody; 5 | import org.springframework.web.bind.annotation.ResponseStatus; 6 | 7 | @ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR) 8 | @ResponseBody 9 | public class ApplicationLogicError extends RuntimeException { 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 1L; 15 | String message; 16 | 17 | public ApplicationLogicError(String message) 18 | { 19 | this.message = message; 20 | } 21 | 22 | public ApplicationLogicError(String message,Throwable e) 23 | { 24 | super(message,e); 25 | this.message = message; 26 | } 27 | 28 | public String getMessage() { 29 | return message; 30 | } 31 | 32 | public void setMessage(String message) { 33 | this.message = message; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentTopPerformerRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import org.springframework.data.cassandra.repository.CassandraRepository; 7 | import org.springframework.data.cassandra.repository.Query; 8 | import org.springframework.stereotype.Repository; 9 | 10 | @Repository 11 | public interface UserAssessmentTopPerformerRepository 12 | extends CassandraRepository { 13 | /** 14 | * finds the top performers of given assessments(limit 250) 15 | * 16 | * @param ids 17 | * @return 18 | */ 19 | 20 | @Query("select * from user_assessment_top_performer where root_org = ?0 and parent_source_id in ?1 limit 250") 21 | public List> findByPrimaryKeyRootOrgAndPrimaryKeyParentSourceIdIn(String rootOrg, 22 | List ids); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/OpenSaberApiUserProfile.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | public class OpenSaberApiUserProfile { 4 | private String id; 5 | private String userId; 6 | private String osid; 7 | private OpenSaberApiPersonalDetail personalDetails; 8 | 9 | public String getId() { 10 | return id; 11 | } 12 | 13 | public void setId(String id) { 14 | this.id = id; 15 | } 16 | 17 | public String getUserId() { 18 | return userId; 19 | } 20 | 21 | public void setUserId(String userId) { 22 | this.userId = userId; 23 | } 24 | 25 | public String getOsid() { 26 | return osid; 27 | } 28 | 29 | public void setOsid(String osid) { 30 | this.osid = osid; 31 | } 32 | 33 | public OpenSaberApiPersonalDetail getPersonalDetails() { 34 | return personalDetails; 35 | } 36 | 37 | public void setPersonalDetails(OpenSaberApiPersonalDetail personalDetails) { 38 | this.personalDetails = personalDetails; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/RoleService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import java.util.List; 4 | import java.util.Set; 5 | 6 | import org.sunbird.portal.department.dto.DepartmentRole; 7 | import org.sunbird.portal.department.dto.Role; 8 | 9 | public interface RoleService { 10 | 11 | Role addRole(Role role) throws Exception; 12 | 13 | Role updateRole(Role role) throws Exception; 14 | 15 | Role getRoleById(Integer roleId) throws Exception; 16 | 17 | Iterable getAllRoles(); 18 | 19 | DepartmentRole addDepartmentRole(DepartmentRole deptRole) throws Exception; 20 | 21 | DepartmentRole getDepartmentRoleById(String deptRoleId); 22 | 23 | boolean removeDepartmentRole(Integer deptRoleId) throws Exception; 24 | 25 | Iterable getAllDepartmentRoles(); 26 | 27 | public List getUserDepartMentRoles(String userId); 28 | 29 | Set getUserRoles(String userId); 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiRespParam.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | public class SunbirdApiRespParam { 4 | 5 | private String resmsgid; 6 | private String msgid; 7 | private String err; 8 | private String status; 9 | private String errmsg; 10 | public String getResmsgid() { 11 | return resmsgid; 12 | } 13 | public void setResmsgid(String resmsgid) { 14 | this.resmsgid = resmsgid; 15 | } 16 | public String getMsgid() { 17 | return msgid; 18 | } 19 | public void setMsgid(String msgid) { 20 | this.msgid = msgid; 21 | } 22 | public String getErr() { 23 | return err; 24 | } 25 | public void setErr(String err) { 26 | this.err = err; 27 | } 28 | public String getStatus() { 29 | return status; 30 | } 31 | public void setStatus(String status) { 32 | this.status = status; 33 | } 34 | public String getErrmsg() { 35 | return errmsg; 36 | } 37 | public void setErrmsg(String errmsg) { 38 | this.errmsg = errmsg; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/producer/Producer.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.producer; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.kafka.core.KafkaTemplate; 5 | import org.springframework.stereotype.Service; 6 | import com.fasterxml.jackson.core.JsonProcessingException; 7 | import com.fasterxml.jackson.databind.ObjectMapper; 8 | import org.sunbird.core.logger.CbExtLogger; 9 | 10 | @Service 11 | public class Producer { 12 | 13 | private CbExtLogger log = new CbExtLogger(getClass().getName()); 14 | 15 | 16 | @Autowired 17 | KafkaTemplate kafkaTemplate; 18 | 19 | public void push(String topic, Object value) { 20 | ObjectMapper mapper = new ObjectMapper(); 21 | String message = null; 22 | try { 23 | message = mapper.writeValueAsString(value); 24 | kafkaTemplate.send(topic, message); 25 | } catch (JsonProcessingException e) { 26 | log.error(e); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/repo/DepartmentRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.repo; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | import org.springframework.data.repository.CrudRepository; 7 | import org.sunbird.portal.department.dto.Department; 8 | 9 | public interface DepartmentRepository extends CrudRepository { 10 | 11 | Optional findByIdAndIsDeleted(Integer id, boolean isDeleted); 12 | 13 | List findAll(); 14 | 15 | List findAllByIsDeletedOrderByDeptNameAsc(boolean isDeleted); 16 | 17 | boolean existsByDeptNameIgnoreCase(String deptName); 18 | 19 | List findAllByIdIn(Iterable deptTypeIds); 20 | 21 | Department findByDeptNameIgnoreCaseAndIsDeleted(String deptKey, boolean isDeleted); 22 | 23 | // @Query("select dept from departments where dept.dept_type_id in (select id from department_types where dept_type = ?0)") 24 | // List findDeptUsingType(String deptTypeKey); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/service/AssessmentService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.service; 2 | 3 | import java.util.Map; 4 | 5 | import org.sunbird.assessment.dto.AssessmentSubmissionDTO; 6 | 7 | public interface AssessmentService { 8 | /** 9 | * submits an assessment 10 | * 11 | * @param data 12 | * @return 13 | * @throws Exception 14 | */ 15 | public Map submitAssessment(String rootOrg, AssessmentSubmissionDTO data, String userEmail) 16 | throws Exception; 17 | 18 | /** 19 | * gets assessments given a content id and user id 20 | * 21 | * @param course_id 22 | * @param user_id 23 | * @return 24 | * @throws Exception 25 | */ 26 | Map getAssessmentByContentUser(String rootOrg, String courseId, String userId) throws Exception; 27 | 28 | /** 29 | * submits assessments coming from iframe 30 | * 31 | * @param request 32 | * @return 33 | * @throws Exception 34 | */ 35 | Map submitAssessmentByIframe(String rootOrg, Map request) throws Exception; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/model/SearchUserInfo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.model; 2 | 3 | public class SearchUserInfo { 4 | private String department_name; 5 | private String wid; 6 | private String email; 7 | private String first_name; 8 | private String last_name; 9 | public String getDepartment_name() { 10 | return department_name; 11 | } 12 | public void setDepartment_name(String department_name) { 13 | this.department_name = department_name; 14 | } 15 | public String getWid() { 16 | return wid; 17 | } 18 | public void setWid(String wid) { 19 | this.wid = wid; 20 | } 21 | public String getEmail() { 22 | return email; 23 | } 24 | public void setEmail(String email) { 25 | this.email = email; 26 | } 27 | public String getFirst_name() { 28 | return first_name; 29 | } 30 | public void setFirst_name(String first_name) { 31 | this.first_name = first_name; 32 | } 33 | public String getLast_name() { 34 | return last_name; 35 | } 36 | public void setLast_name(String last_name) { 37 | this.last_name = last_name; 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/config/CassandraConfig.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.config; 2 | 3 | import org.springframework.data.cassandra.config.AbstractCassandraConfiguration; 4 | 5 | public abstract class CassandraConfig extends AbstractCassandraConfiguration { 6 | 7 | protected String contactPoints; 8 | protected int port; 9 | protected String keyspaceName; 10 | 11 | public void setContactPoints(String contactPoints) { 12 | this.contactPoints = contactPoints; 13 | } 14 | 15 | @Override 16 | protected String getKeyspaceName() { 17 | return keyspaceName; 18 | } 19 | 20 | @Override 21 | protected boolean getMetricsEnabled() { 22 | return false; 23 | } 24 | 25 | @Override 26 | public int getPort() { 27 | return port; 28 | } 29 | 30 | @Override 31 | public String getContactPoints() { 32 | return contactPoints; 33 | } 34 | 35 | public void setPort(Integer port) { 36 | this.port = port; 37 | } 38 | 39 | public void setKeyspaceName(String keyspaceName) { 40 | this.keyspaceName = keyspaceName; 41 | } 42 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/OpenSaberApiPersonalDetail.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | public class OpenSaberApiPersonalDetail { 4 | private String firstname; 5 | private String surname; 6 | private String primaryEmail; 7 | private String username; 8 | private String osid; 9 | 10 | public String getFirstname() { 11 | return firstname; 12 | } 13 | 14 | public void setFirstname(String firstname) { 15 | this.firstname = firstname; 16 | } 17 | 18 | public String getSurname() { 19 | return surname; 20 | } 21 | 22 | public void setSurname(String surname) { 23 | this.surname = surname; 24 | } 25 | 26 | public String getPrimaryEmail() { 27 | return primaryEmail; 28 | } 29 | 30 | public void setPrimaryEmail(String primaryEmail) { 31 | this.primaryEmail = primaryEmail; 32 | } 33 | 34 | public String getUsername() { 35 | return username; 36 | } 37 | 38 | public void setUsername(String username) { 39 | this.username = username; 40 | } 41 | 42 | public String getOsid() { 43 | return osid; 44 | } 45 | 46 | public void setOsid(String osid) { 47 | this.osid = osid; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Sunbird for Capacity Building 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/progress/model/MandatoryContentResponse.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.progress.model; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | public class MandatoryContentResponse { 7 | private boolean mandatoryCourseCompleted; 8 | private Map contentDetails; 9 | 10 | public void addContentInfo(String contentId, MandatoryContentInfo contentInfo) { 11 | if (contentDetails == null) { 12 | contentDetails = new HashMap<>(); 13 | } 14 | contentDetails.put(contentId, contentInfo); 15 | } 16 | 17 | public boolean isMandatoryCourseCompleted() { 18 | return mandatoryCourseCompleted; 19 | } 20 | 21 | public void setMandatoryCourseCompleted(boolean mandatoryCourseCompleted) { 22 | this.mandatoryCourseCompleted = mandatoryCourseCompleted; 23 | } 24 | 25 | public Map getContentDetails() { 26 | return contentDetails; 27 | } 28 | 29 | public void setContentDetails(Map contentDetails) { 30 | this.contentDetails = contentDetails; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiRespOragainsation.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | public class SunbirdApiRespOragainsation { 6 | 7 | private String organisationId; 8 | private List roles; 9 | private String userId; 10 | private String parentOrgId; 11 | private String id; 12 | 13 | public String getOrganisationId() { 14 | return organisationId; 15 | } 16 | 17 | public void setOrganisationId(String organisationId) { 18 | this.organisationId = organisationId; 19 | } 20 | 21 | public List getRoles() { 22 | return roles; 23 | } 24 | 25 | public void setRoles(List roles) { 26 | this.roles = roles; 27 | } 28 | 29 | public String getUserId() { 30 | return userId; 31 | } 32 | 33 | public void setUserId(String userId) { 34 | this.userId = userId; 35 | } 36 | 37 | public String getParentOrgId() { 38 | return parentOrgId; 39 | } 40 | 41 | public void setParentOrgId(String parentOrgId) { 42 | this.parentOrgId = parentOrgId; 43 | } 44 | 45 | public String getId() { 46 | return id; 47 | } 48 | 49 | public void setId(String id) { 50 | this.id = id; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/repo/UserDepartmentRoleRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.repo; 2 | 3 | import org.springframework.data.jpa.repository.JpaRepository; 4 | import org.springframework.data.jpa.repository.Query; 5 | import org.sunbird.portal.department.dto.UserDepartmentRole; 6 | 7 | import java.util.List; 8 | 9 | public interface UserDepartmentRoleRepository extends JpaRepository { 10 | 11 | List findByUserId(String userId); 12 | 13 | List findAllByUserIdAndIsActiveAndIsBlocked(String userId, boolean isActive, boolean isBlocked); 14 | 15 | List findByDeptId(Integer deptId); 16 | 17 | // List findByDeptRoleId(List userDeptIds); 18 | 19 | UserDepartmentRole findByUserIdAndDeptId(String userId, Integer deptId); 20 | 21 | List findAllByUserIdAndDeptId(String userId, List deptIds); 22 | 23 | @Query(value = "SELECT count(*) FROM wingspan.user_department_role WHERE ?1 = ANY (role_ids) and dept_id = ?2", nativeQuery = true) 24 | int getTotalUserCountOnRoleIdAndDeptId(Integer roleId, Integer deptId); 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiResp.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | public class SunbirdApiResp { 4 | private String id; 5 | private String ver; 6 | private String ts; 7 | private SunbirdApiRespParam params; 8 | private String responseCode; 9 | private SunbirdApiRespResult result; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | public void setId(String id) { 15 | this.id = id; 16 | } 17 | public String getVer() { 18 | return ver; 19 | } 20 | public void setVer(String ver) { 21 | this.ver = ver; 22 | } 23 | public String getTs() { 24 | return ts; 25 | } 26 | public void setTs(String ts) { 27 | this.ts = ts; 28 | } 29 | public SunbirdApiRespParam getParams() { 30 | return params; 31 | } 32 | public void setParams(SunbirdApiRespParam params) { 33 | this.params = params; 34 | } 35 | public String getResponseCode() { 36 | return responseCode; 37 | } 38 | public void setResponseCode(String responseCode) { 39 | this.responseCode = responseCode; 40 | } 41 | public SunbirdApiRespResult getResult() { 42 | return result; 43 | } 44 | public void setResult(SunbirdApiRespResult result) { 45 | this.result = result; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentMasterRepositoryImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.data.cassandra.core.CassandraBatchOperations; 5 | import org.springframework.data.cassandra.core.CassandraOperations; 6 | 7 | public class UserAssessmentMasterRepositoryImpl implements UserAssessmentMasterRepositoryCustom { 8 | 9 | @Autowired 10 | CassandraOperations cassandraOperations; 11 | 12 | /* 13 | * (non-Javadoc) 14 | * 15 | * @see org.sunbird.assessment.repo. 16 | * UserAssessmentMasterRepositoryCustom#updateAssessment(org.sunbird.assessment. 17 | * repo.UserAssessmentMasterModel, 18 | * org.sunbird.assessment.repo.UserAssessmentSummaryModel) 19 | */ 20 | @Override 21 | public UserAssessmentMasterModel updateAssessment(UserAssessmentMasterModel assessment, 22 | UserAssessmentSummaryModel assessmentSummary) { 23 | CassandraBatchOperations batchOps = cassandraOperations.batchOps(); 24 | batchOps.insert(assessment); 25 | if (assessmentSummary.getPrimaryKey() != null) 26 | batchOps.insert(assessmentSummary); 27 | batchOps.execute(); 28 | return assessment; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/WorkOrderCassandraModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import org.springframework.data.cassandra.core.mapping.Column; 4 | import org.springframework.data.cassandra.core.mapping.PrimaryKey; 5 | import org.springframework.data.cassandra.core.mapping.Table; 6 | 7 | @Table("work_order") 8 | public class WorkOrderCassandraModel { 9 | 10 | public WorkOrderCassandraModel(){ 11 | super(); 12 | } 13 | 14 | public WorkOrderCassandraModel(String id, String data){ 15 | this.primaryKey = new WorkOrderPrimaryKeyModel(); 16 | this.primaryKey.setId(id); 17 | this.data = data; 18 | } 19 | 20 | @PrimaryKey 21 | private WorkOrderPrimaryKeyModel primaryKey; 22 | 23 | @Column("data") 24 | private String data; 25 | 26 | public WorkOrderPrimaryKeyModel getPrimaryKey() { 27 | return primaryKey; 28 | } 29 | 30 | public void setPrimaryKey(WorkOrderPrimaryKeyModel primaryKey) { 31 | this.primaryKey = primaryKey; 32 | } 33 | 34 | public String getData() { 35 | return data; 36 | } 37 | 38 | public void setData(String data) { 39 | this.data = data; 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/controller/CatalogController.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestHeader; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RequestParam; 10 | import org.springframework.web.bind.annotation.RestController; 11 | import org.sunbird.catalog.model.Catalog; 12 | import org.sunbird.catalog.service.CatalogServiceImpl; 13 | 14 | @RestController 15 | @RequestMapping("/v1/catalog") 16 | public class CatalogController { 17 | @Autowired 18 | private CatalogServiceImpl catalogService; 19 | 20 | @GetMapping("/") 21 | public ResponseEntity getCatalog(@RequestHeader("x-authenticated-user-token") String authUserToken, 22 | @RequestParam(name = "consumption", required = false) boolean isEnrichConsumption){ 23 | return new ResponseEntity<>(catalogService.getCatalog(authUserToken, isEnrichConsumption), HttpStatus.OK); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/model/Category.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.model; 2 | 3 | import java.util.List; 4 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown = true) 8 | public class Category { 9 | private String identifier; 10 | private String code; 11 | private String name; 12 | private String description; 13 | private List terms; 14 | 15 | public String getIdentifier() { 16 | return identifier; 17 | } 18 | 19 | public void setIdentifier(String identifier) { 20 | this.identifier = identifier; 21 | } 22 | 23 | public String getCode() { 24 | return code; 25 | } 26 | 27 | public void setCode(String code) { 28 | this.code = code; 29 | } 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getDescription() { 40 | return description; 41 | } 42 | 43 | public void setDescription(String description) { 44 | this.description = description; 45 | } 46 | 47 | public List getTerms() { 48 | return terms; 49 | } 50 | 51 | public void setTerms(List terms) { 52 | this.terms = terms; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/Response.java: -------------------------------------------------------------------------------- 1 | /* 2 | * "Copyright 2020 Infosys Ltd. 3 | * Use of this source code is governed by GPL v3 license that can be found in the LICENSE file or at https://opensource.org/licenses/GPL-3.0 4 | * This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License version 3" 5 | * 6 | */ 7 | 8 | package org.sunbird.common.model; 9 | 10 | 11 | import java.io.Serializable; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | public class Response implements Serializable{ 16 | 17 | private static final long serialVersionUID = -3773253896160786443L; 18 | 19 | private transient Map result = new HashMap<>(); 20 | 21 | public Map getResult() { 22 | return result; 23 | } 24 | 25 | public Object get(String key) { 26 | return result.get(key); 27 | } 28 | 29 | public void put(String key, Object vo) { 30 | result.put(key, vo); 31 | } 32 | 33 | public void putAll(Map map) { 34 | result.putAll(map); 35 | } 36 | 37 | public boolean containsKey(String key) { 38 | return result.containsKey(key); 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/exception/InvalidDataInputException.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.exception; 2 | 3 | import org.springframework.http.HttpStatus; 4 | import org.springframework.web.bind.annotation.ResponseBody; 5 | import org.springframework.web.bind.annotation.ResponseStatus; 6 | 7 | @ResponseStatus(value = HttpStatus.BAD_REQUEST) 8 | @ResponseBody 9 | public class InvalidDataInputException extends RuntimeException { 10 | 11 | private static final long serialVersionUID = 1L; 12 | private String code; 13 | private Object[] params; 14 | 15 | public String getCode() { 16 | return code; 17 | } 18 | 19 | public void setCode(String code) { 20 | this.code = code; 21 | } 22 | 23 | public Object[] getParams() { 24 | return params; 25 | } 26 | 27 | public void setParams(Object[] params) { 28 | this.params = params; 29 | } 30 | 31 | public InvalidDataInputException(String code, Object[] params) { 32 | super(); 33 | this.code = code; 34 | this.params = params; 35 | } 36 | 37 | public InvalidDataInputException(String code) { 38 | super(code); 39 | this.code = code; 40 | } 41 | 42 | public InvalidDataInputException(String code, Throwable e) { 43 | super(code, e); 44 | this.code = code; 45 | } 46 | 47 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/model/UserDepartmentInfo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.model; 2 | 3 | import org.sunbird.portal.department.dto.Role; 4 | 5 | public class UserDepartmentInfo { 6 | private String userId; 7 | private DepartmentInfo deptInfo; 8 | private Iterable roleInfo; 9 | private Boolean isActive; 10 | private Boolean isBlocked; 11 | 12 | public String getUserId() { 13 | return userId; 14 | } 15 | 16 | public void setUserId(String userId) { 17 | this.userId = userId; 18 | } 19 | 20 | public DepartmentInfo getDeptInfo() { 21 | return deptInfo; 22 | } 23 | 24 | public void setDeptInfo(DepartmentInfo deptInfo) { 25 | this.deptInfo = deptInfo; 26 | } 27 | 28 | public Iterable getRoleInfo() { 29 | return roleInfo; 30 | } 31 | 32 | public void setRoleInfo(Iterable roleInfo) { 33 | this.roleInfo = roleInfo; 34 | } 35 | 36 | public Boolean getIsActive() { 37 | return isActive; 38 | } 39 | 40 | public void setIsActive(Boolean isActive) { 41 | this.isActive = isActive; 42 | } 43 | 44 | public Boolean getIsBlocked() { 45 | return isBlocked; 46 | } 47 | 48 | public void setIsBlocked(Boolean isBlocked) { 49 | this.isBlocked = isBlocked; 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/model/FrameworkResponse.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | @JsonIgnoreProperties(ignoreUnknown = true) 6 | public class FrameworkResponse { 7 | private String id; 8 | private String ver; 9 | private FrameworkResponseParams params; 10 | private String responseCode; 11 | private FrameworkResponseResult result; 12 | 13 | public String getId() { 14 | return id; 15 | } 16 | 17 | public void setId(String id) { 18 | this.id = id; 19 | } 20 | 21 | public String getVer() { 22 | return ver; 23 | } 24 | 25 | public void setVer(String ver) { 26 | this.ver = ver; 27 | } 28 | 29 | public FrameworkResponseParams getParams() { 30 | return params; 31 | } 32 | 33 | public void setParams(FrameworkResponseParams params) { 34 | this.params = params; 35 | } 36 | 37 | public String getResponseCode() { 38 | return responseCode; 39 | } 40 | 41 | public void setResponseCode(String responseCode) { 42 | this.responseCode = responseCode; 43 | } 44 | 45 | public FrameworkResponseResult getResult() { 46 | return result; 47 | } 48 | 49 | public void setResult(FrameworkResponseResult result) { 50 | this.result = result; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/WorkAllocationCassandraModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import org.springframework.data.cassandra.core.mapping.Column; 4 | import org.springframework.data.cassandra.core.mapping.PrimaryKey; 5 | import org.springframework.data.cassandra.core.mapping.Table; 6 | 7 | @Table("work_allocation") 8 | public class WorkAllocationCassandraModel { 9 | 10 | public WorkAllocationCassandraModel() { 11 | super(); 12 | } 13 | 14 | public WorkAllocationCassandraModel(String id, String data) { 15 | this.primaryKey = new WorkAllocationPrimaryKeyModel(); 16 | this.primaryKey.setId(id); 17 | this.data = data; 18 | } 19 | 20 | @PrimaryKey 21 | private WorkAllocationPrimaryKeyModel primaryKey; 22 | 23 | @Column("data") 24 | private String data; 25 | 26 | public WorkAllocationPrimaryKeyModel getPrimaryKey() { 27 | return primaryKey; 28 | } 29 | 30 | public void setPrimaryKey(WorkAllocationPrimaryKeyModel primaryKey) { 31 | this.primaryKey = primaryKey; 32 | } 33 | 34 | public String getData() { 35 | return data; 36 | } 37 | 38 | public void setData(String data) { 39 | this.data = data; 40 | } 41 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/OpenSaberApiResp.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | public class OpenSaberApiResp { 4 | private String id; 5 | private String ver; 6 | private String ets; 7 | private SunbirdApiRespParam params; 8 | private String responseCode; 9 | private OpenSaberApiRespResult result; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | public String getVer() { 20 | return ver; 21 | } 22 | 23 | public void setVer(String ver) { 24 | this.ver = ver; 25 | } 26 | 27 | public String getEts() { 28 | return ets; 29 | } 30 | 31 | public void setEts(String ets) { 32 | this.ets = ets; 33 | } 34 | 35 | public SunbirdApiRespParam getParams() { 36 | return params; 37 | } 38 | 39 | public void setParams(SunbirdApiRespParam params) { 40 | this.params = params; 41 | } 42 | 43 | public String getResponseCode() { 44 | return responseCode; 45 | } 46 | 47 | public void setResponseCode(String responseCode) { 48 | this.responseCode = responseCode; 49 | } 50 | 51 | public OpenSaberApiRespResult getResult() { 52 | return result; 53 | } 54 | 55 | public void setResult(OpenSaberApiRespResult result) { 56 | this.result = result; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/model/DeptTypeInfo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.model; 2 | 3 | public class DeptTypeInfo { 4 | private Integer id; 5 | private String deptType; 6 | private String deptSubType; 7 | private String description; 8 | 9 | public Integer getId() { 10 | return id; 11 | } 12 | 13 | public void setId(Integer id) { 14 | this.id = id; 15 | } 16 | 17 | public String getDeptType() { 18 | return deptType; 19 | } 20 | 21 | public void setDeptType(String deptType) { 22 | this.deptType = deptType; 23 | } 24 | 25 | public String getDeptSubType() { 26 | return deptSubType; 27 | } 28 | 29 | public void setDeptSubType(String deptSubType) { 30 | this.deptSubType = deptSubType; 31 | } 32 | 33 | public String getDescription() { 34 | return description; 35 | } 36 | 37 | public void setDescription(String description) { 38 | this.description = description; 39 | } 40 | 41 | public String toString() { 42 | StringBuilder str = new StringBuilder("DeptTypeInfo: "); 43 | str.append(", Id: ").append(id); 44 | str.append(", DeptType: ").append(deptType); 45 | str.append(", deptSubType: ").append(deptSubType); 46 | str.append(", description: ").append(description); 47 | str.append("]"); 48 | return str.toString(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/PortalConstants.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class PortalConstants { 7 | 8 | private PortalConstants() { 9 | throw new IllegalStateException("PortalConstants class"); 10 | } 11 | 12 | public static final String MDO_ROLE_NAME = "MDO ADMIN"; 13 | public static final String MDO_DEPT_TYPE = "MDO"; 14 | public static final String SPV_ROLE_NAME = "SPV ADMIN"; 15 | public static final String SPV_DEPT_TYPE = "SPV"; 16 | public static final String CBP_DEPT_TYPE = "CBP"; 17 | public static final String CBP_ROLE_NAME = "CBP ADMIN"; 18 | public static final String CBC_ROLE_NAME = "CBC ADMIN"; 19 | public static final String CBC_MEMBER_NAME = "CBC_MEMBER"; 20 | public static final String CBC_DEPT_TYPE = "CBC"; 21 | public static final List MDO_ROLES = Arrays.asList(MDO_ROLE_NAME, "WAT_USER"); 22 | public static final List CBP_ROLES = Arrays.asList("EDITOR", "REVIEWER", "PUBLISHER", "CONTENT_CREATOR"); 23 | public static final List FRAC_ROLES = Arrays.asList("IFUMember", "fracAdmin", "fracReviewerOne", 24 | "fracReviewerTwo", "fracAccessCompetency", "competencyReviewer"); 25 | public static final List CBC_ROLE_LIST = Arrays.asList(CBC_ROLE_NAME, CBC_MEMBER_NAME); 26 | } 27 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/Child.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | public class Child { 4 | private String id; 5 | private String type; 6 | private String name; 7 | private String description; 8 | private Object status; 9 | private String source; 10 | private String level; 11 | 12 | public String getId() { 13 | return id; 14 | } 15 | 16 | public void setId(String id) { 17 | this.id = id; 18 | } 19 | 20 | public String getType() { 21 | return type; 22 | } 23 | 24 | public void setType(String type) { 25 | this.type = type; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String getDescription() { 37 | return description; 38 | } 39 | 40 | public void setDescription(String description) { 41 | this.description = description; 42 | } 43 | 44 | public Object getStatus() { 45 | return status; 46 | } 47 | 48 | public void setStatus(Object status) { 49 | this.status = status; 50 | } 51 | 52 | public String getSource() { 53 | return source; 54 | } 55 | 56 | public void setSource(String source) { 57 | this.source = source; 58 | } 59 | 60 | public String getLevel() { 61 | return level; 62 | } 63 | 64 | public void setLevel(String level) { 65 | this.level = level; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserQuizSummaryModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.data.cassandra.core.mapping.Column; 6 | import org.springframework.data.cassandra.core.mapping.PrimaryKey; 7 | import org.springframework.data.cassandra.core.mapping.Table; 8 | 9 | @Table("user_quiz_summary") 10 | public class UserQuizSummaryModel { 11 | @PrimaryKey 12 | private UserQuizSummaryPrimaryKeyModel primaryKey; 13 | 14 | @Column("date_updated") 15 | private Date dateUpdated; 16 | 17 | public UserQuizSummaryModel() { 18 | super(); 19 | } 20 | 21 | public UserQuizSummaryModel(UserQuizSummaryPrimaryKeyModel primaryKey, Date dateUpdated) { 22 | super(); 23 | this.primaryKey = primaryKey; 24 | this.dateUpdated = dateUpdated; 25 | } 26 | 27 | public UserQuizSummaryPrimaryKeyModel getPrimaryKey() { 28 | return primaryKey; 29 | } 30 | 31 | public void setPrimaryKey(UserQuizSummaryPrimaryKeyModel primaryKey) { 32 | this.primaryKey = primaryKey; 33 | } 34 | 35 | public Date getDateUpdated() { 36 | return dateUpdated; 37 | } 38 | 39 | public void setDateUpdated(Date dateUpdated) { 40 | this.dateUpdated = dateUpdated; 41 | } 42 | 43 | @Override 44 | public String toString() { 45 | return "UserQuizSummaryModel [primaryKey=" + primaryKey + ", dateUpdated=" + dateUpdated + "]"; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/AssessmentRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import org.sunbird.assessment.dto.AssessmentSubmissionDTO; 7 | 8 | public interface AssessmentRepository { 9 | 10 | /** 11 | * gets answer key for the assessment given the url 12 | * 13 | * @param artifactUrl 14 | * @return 15 | * @throws Exception 16 | */ 17 | public Map getAssessmentAnswerKey(String artifactUrl) throws Exception; 18 | 19 | /** 20 | * gets answerkey for the quiz submission 21 | * 22 | * @param quizMap 23 | * @return 24 | * @throws Exception 25 | */ 26 | public Map getQuizAnswerKey(AssessmentSubmissionDTO quizMap) throws Exception; 27 | 28 | /** 29 | * inserts quiz or assessments for a user 30 | * 31 | * @param persist 32 | * @param isAssessment 33 | * @return 34 | * @throws Exception 35 | */ 36 | public Map insertQuizOrAssessment(Map persist, Boolean isAssessment) 37 | throws Exception; 38 | 39 | /** 40 | * gets assessment for a user given a content id 41 | * 42 | * @param courseId 43 | * @param userId 44 | * @return 45 | * @throws Exception 46 | */ 47 | public List> getAssessmetbyContentUser(String rootOrg, String courseId, String userId) 48 | throws Exception; 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/OrgCreationConsumer.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.apache.kafka.clients.consumer.ConsumerRecord; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.kafka.annotation.KafkaListener; 7 | import org.springframework.kafka.annotation.TopicPartition; 8 | import org.springframework.stereotype.Service; 9 | import org.sunbird.core.logger.CbExtLogger; 10 | 11 | import java.io.IOException; 12 | import java.util.Map; 13 | 14 | @Service 15 | public class OrgCreationConsumer { 16 | 17 | @Autowired 18 | OrgCreationProcessService processService; 19 | 20 | private CbExtLogger log = new CbExtLogger(getClass().getName()); 21 | 22 | @KafkaListener(id = "id0", groupId = "orgCreationTopic-consumer", topicPartitions = { 23 | @TopicPartition(topic = "${kafka.topics.org.creation}", partitions = {"0", "1", "2", "3"})}) 24 | public void processMessage(ConsumerRecord data) { 25 | 26 | try { 27 | ObjectMapper mapper = new ObjectMapper(); 28 | Map orgObject = mapper.readValue(String.valueOf(data.value()), Map.class); 29 | processService.createOrg(orgObject); 30 | } catch (IOException e) { 31 | log.error(e); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/progress/controller/MandatoryContentController.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.progress.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.http.ResponseEntity; 6 | import org.springframework.web.bind.annotation.GetMapping; 7 | import org.springframework.web.bind.annotation.RequestHeader; 8 | import org.springframework.web.bind.annotation.RestController; 9 | import org.sunbird.progress.model.MandatoryContentResponse; 10 | import org.sunbird.progress.service.MandatoryContentService; 11 | 12 | @RestController 13 | public class MandatoryContentController { 14 | 15 | @Autowired 16 | private MandatoryContentService service; 17 | 18 | /** 19 | * @param rootOrg 20 | * @param userId 21 | * @return Status of mandatory content 22 | * @throws Exception 23 | */ 24 | @GetMapping("/v1/check/mandatoryContentStatus") 25 | public ResponseEntity getMandatoryContentStatus( 26 | @RequestHeader("xAuthUser") String authUserToken, 27 | @RequestHeader("rootOrg") String rootOrg, 28 | @RequestHeader("org") String org, 29 | @RequestHeader("wid") String userId){ 30 | return new ResponseEntity<>(service.getMandatoryContentStatusForUser(authUserToken, rootOrg, org, userId), HttpStatus.OK); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/SearchCriteria.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | public class SearchCriteria { 4 | private int pageSize; 5 | private int pageNo; 6 | private String status; 7 | private String userId; 8 | private String departmentName; 9 | private String query; 10 | 11 | public int getPageSize() { 12 | return pageSize; 13 | } 14 | 15 | public void setPageSize(int pageSize) { 16 | this.pageSize = pageSize; 17 | } 18 | 19 | public int getPageNo() { 20 | return pageNo; 21 | } 22 | 23 | public void setPageNo(int pageNo) { 24 | this.pageNo = pageNo; 25 | } 26 | 27 | public String getDepartmentName() { 28 | return departmentName; 29 | } 30 | 31 | public void setDepartmentName(String departmentName) { 32 | this.departmentName = departmentName; 33 | } 34 | 35 | public String getStatus() { 36 | return status; 37 | } 38 | 39 | public void setStatus(String status) { 40 | this.status = status; 41 | } 42 | 43 | public String getUserId() { 44 | return userId; 45 | } 46 | 47 | public void setUserId(String userId) { 48 | this.userId = userId; 49 | } 50 | 51 | public String getQuery() { 52 | return query; 53 | } 54 | 55 | public void setQuery(String query) { 56 | this.query = query; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/config/ProducerConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.config; 2 | 3 | import org.apache.kafka.clients.producer.ProducerConfig; 4 | import org.apache.kafka.common.serialization.StringSerializer; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.kafka.core.DefaultKafkaProducerFactory; 9 | import org.springframework.kafka.core.KafkaTemplate; 10 | import org.springframework.kafka.core.ProducerFactory; 11 | 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @Configuration 16 | public class ProducerConfiguration { 17 | 18 | @Value("${spring.kafka.bootstrap.servers}") 19 | private String kafkabootstrapAddress; 20 | 21 | @Bean 22 | public ProducerFactory producerFactory() { 23 | 24 | Map config = new HashMap<>(); 25 | config.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkabootstrapAddress); 26 | config.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class); 27 | config.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, StringSerializer.class); 28 | return new DefaultKafkaProducerFactory<>(config); 29 | } 30 | 31 | @Bean 32 | public KafkaTemplate kafkaTemplate() { 33 | return new KafkaTemplate<>(producerFactory()); 34 | } 35 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiUserCourseListResp.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | public class SunbirdApiUserCourseListResp { 4 | private String id; 5 | private String ver; 6 | private String ts; 7 | private SunbirdApiRespParam params; 8 | private String responseCode; 9 | private SunbirdApiUserCourseResult result; 10 | 11 | public String getId() { 12 | return id; 13 | } 14 | 15 | public void setId(String id) { 16 | this.id = id; 17 | } 18 | 19 | public String getVer() { 20 | return ver; 21 | } 22 | 23 | public void setVer(String ver) { 24 | this.ver = ver; 25 | } 26 | 27 | public String getTs() { 28 | return ts; 29 | } 30 | 31 | public void setTs(String ts) { 32 | this.ts = ts; 33 | } 34 | 35 | public SunbirdApiRespParam getParams() { 36 | return params; 37 | } 38 | 39 | public void setParams(SunbirdApiRespParam params) { 40 | this.params = params; 41 | } 42 | 43 | public String getResponseCode() { 44 | return responseCode; 45 | } 46 | 47 | public void setResponseCode(String responseCode) { 48 | this.responseCode = responseCode; 49 | } 50 | 51 | public SunbirdApiUserCourseResult getResult() { 52 | return result; 53 | } 54 | 55 | public void setResult(SunbirdApiUserCourseResult result) { 56 | this.result = result; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/MdoPortalServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.stereotype.Service; 5 | import org.sunbird.portal.department.PortalConstants; 6 | import org.sunbird.portal.department.model.DepartmentInfo; 7 | 8 | @Service 9 | public class MdoPortalServiceImpl implements MdoPortalService { 10 | @Autowired 11 | PortalService portalService; 12 | 13 | @Override 14 | public DepartmentInfo updateDepartment(DepartmentInfo deptInfo, String rootOrg) throws Exception { 15 | return portalService.updateDepartment(deptInfo, rootOrg); 16 | } 17 | 18 | @Override 19 | public DepartmentInfo getMyDepartment(String userId, boolean isUserInfoRequired, String rootOrg) throws Exception { 20 | return portalService.getMyDepartmentForRoles(PortalConstants.MDO_ROLES, userId, isUserInfoRequired, rootOrg); 21 | } 22 | 23 | public DepartmentInfo getMyFracDepartment(String userId, boolean isUserInfoRequired, String rootOrg) 24 | throws Exception { 25 | return portalService.getMyDepartmentForRoles(PortalConstants.FRAC_ROLES, userId, isUserInfoRequired, rootOrg); 26 | } 27 | 28 | @Override 29 | public DepartmentInfo getMyCBCDepartment(String userId, boolean isUserInfoRequired, String rootOrg) throws Exception { 30 | return portalService.getMyDepartmentForRoles(PortalConstants.CBC_ROLE_LIST, userId, isUserInfoRequired, rootOrg); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/repo/DepartmentRoleRepository.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.repo; 2 | 3 | import java.util.List; 4 | 5 | import org.springframework.data.repository.CrudRepository; 6 | import org.sunbird.portal.department.dto.DepartmentRole; 7 | 8 | public interface DepartmentRoleRepository extends CrudRepository { 9 | DepartmentRole findByDeptTypeIgnoreCase(String deptType); 10 | List findAllByDeptTypeIn(List deptTypes); 11 | 12 | // DepartmentRole findByRoleIdAndDeptId(Integer roleId, Integer deptId); 13 | // 14 | // List findByRoleId(Integer roleId); 15 | // 16 | // List findAllByRoleIdAndDeptTypeIdIn(Integer roleId, List deptIds); 17 | // 18 | // Iterable findByDeptTypeIds(List deptTypeIds); 19 | 20 | // @Query("select dRole from department_roles where dRole.role_id in (:role_ids)") 21 | // Iterable findByRoleIds(@Param("role_ids") List role_ids); 22 | 23 | // @Query("select id from department_roles where id = (select dept_role_id from user_department_role where user_id = ?0)") 24 | // Iterable findDepartmentRoleForUser_old(String userId); 25 | 26 | // @Query(value = "select * from department_roles where role_id in (select id from roles where role_name='ADMIN') and id in (select dept_role_id from user_department_role where user_id =:user_id)", nativeQuery = true) 27 | // Iterable findDepartmentRoleForUser(@Param("user_id") String userId); 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/dto/Role.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.dto; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import javax.persistence.Transient; 10 | import javax.validation.constraints.NotNull; 11 | 12 | @Entity 13 | @Table(name = "roles", schema = "wingspan") 14 | public class Role { 15 | @Id 16 | @Column(name = "id") 17 | @GeneratedValue(strategy = GenerationType.IDENTITY) 18 | private Integer id; 19 | 20 | @Column(name = "role_name") 21 | @NotNull 22 | private String roleName; 23 | 24 | @Column(name = "description") 25 | @NotNull 26 | private String description; 27 | 28 | @Transient 29 | private int noOfUsers; 30 | 31 | public Integer getId() { 32 | return id; 33 | } 34 | 35 | public void setId(Integer id) { 36 | this.id = id; 37 | } 38 | 39 | public String getRoleName() { 40 | return roleName; 41 | } 42 | 43 | public void setRoleName(String roleName) { 44 | this.roleName = roleName; 45 | } 46 | 47 | public String getDescription() { 48 | return description; 49 | } 50 | 51 | public void setDescription(String description) { 52 | this.description = description; 53 | } 54 | 55 | public int getNoOfUsers() { 56 | return noOfUsers; 57 | } 58 | 59 | public void setNoOfUsers(int noOfUsers) { 60 | this.noOfUsers = noOfUsers; 61 | } 62 | 63 | public void incrementUserCount() { 64 | noOfUsers++; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/progress/cassandraRepo/MandatoryContentModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.progress.cassandraRepo; 2 | 3 | import org.springframework.data.cassandra.core.mapping.Column; 4 | import org.springframework.data.cassandra.core.mapping.PrimaryKey; 5 | import org.springframework.data.cassandra.core.mapping.Table; 6 | 7 | @Table("mandatory_user_content") 8 | public class MandatoryContentModel { 9 | 10 | @PrimaryKey 11 | private MandatoryContentPrimaryKeyModel primaryKey; 12 | 13 | @Column("content_type") 14 | private String contentType; 15 | 16 | @Column("batch_id") 17 | private String batchId; 18 | 19 | @Column("minProgressForCompletion") 20 | private Float minProgressCheck; 21 | 22 | public MandatoryContentPrimaryKeyModel getPrimaryKey() { 23 | return primaryKey; 24 | } 25 | 26 | public void setPrimaryKey(MandatoryContentPrimaryKeyModel primaryKey) { 27 | this.primaryKey = primaryKey; 28 | } 29 | 30 | public String getContentType() { 31 | return contentType; 32 | } 33 | 34 | public void setContentType(String contentType) { 35 | this.contentType = contentType; 36 | } 37 | 38 | public Float getMinProgressCheck() { 39 | return minProgressCheck; 40 | } 41 | 42 | public void setMinProgressCheck(Float minProgressCheck) { 43 | this.minProgressCheck = minProgressCheck; 44 | } 45 | 46 | public String getBatchId() { 47 | return batchId; 48 | } 49 | 50 | public void setBatchId(String batchId) { 51 | this.batchId = batchId; 52 | } 53 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/progress/model/MandatoryContentInfo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.progress.model; 2 | 3 | public class MandatoryContentInfo { 4 | private String rootOrg; 5 | private String org; 6 | private String contentType; 7 | private String batchId; 8 | private Float minProgressForCompletion = 0.0f; 9 | 10 | private Float userProgress = 0.0f; 11 | 12 | public String getRootOrg() { 13 | return rootOrg; 14 | } 15 | 16 | public void setRootOrg(String rootOrg) { 17 | this.rootOrg = rootOrg; 18 | } 19 | 20 | public String getOrg() { 21 | return org; 22 | } 23 | 24 | public void setOrg(String org) { 25 | this.org = org; 26 | } 27 | 28 | public String getContentType() { 29 | return contentType; 30 | } 31 | 32 | public void setContentType(String contentType) { 33 | this.contentType = contentType; 34 | } 35 | 36 | public Float getMinProgressForCompletion() { 37 | return minProgressForCompletion; 38 | } 39 | 40 | public void setMinProgressForCompletion(Float minProgressForCompletion) { 41 | this.minProgressForCompletion = minProgressForCompletion; 42 | } 43 | 44 | public Float getUserProgress() { 45 | return userProgress; 46 | } 47 | 48 | public void setUserProgress(Float userProgress) { 49 | this.userProgress = userProgress; 50 | } 51 | 52 | public String getBatchId() { 53 | return batchId; 54 | } 55 | 56 | public void setBatchId(String batchId) { 57 | this.batchId = batchId; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/FracRequest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import java.util.List; 4 | 5 | public class FracRequest { 6 | private String type; 7 | private String name; 8 | private String source; 9 | private String id; 10 | private String description; 11 | private List children; 12 | private AdditionalProperties additionalProperties; 13 | 14 | public String getType() { 15 | return type; 16 | } 17 | 18 | public void setType(String type) { 19 | this.type = type; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public String getSource() { 31 | return source; 32 | } 33 | 34 | public void setSource(String source) { 35 | this.source = source; 36 | } 37 | 38 | public List getChildren() { 39 | return children; 40 | } 41 | 42 | public void setChildren(List children) { 43 | this.children = children; 44 | } 45 | 46 | public String getId() { 47 | return id; 48 | } 49 | 50 | public void setId(String id) { 51 | this.id = id; 52 | } 53 | 54 | public String getDescription() { 55 | return description; 56 | } 57 | 58 | public void setDescription(String description) { 59 | this.description = description; 60 | } 61 | 62 | public AdditionalProperties getAdditionalProperties() { 63 | return additionalProperties; 64 | } 65 | 66 | public void setAdditionalProperties(AdditionalProperties additionalProperties) { 67 | this.additionalProperties = additionalProperties; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/model/PortalUserInfo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.model; 2 | 3 | import java.util.List; 4 | 5 | import org.sunbird.portal.department.dto.Role; 6 | 7 | public class PortalUserInfo { 8 | private String userId; 9 | private String firstName; 10 | private String lastName; 11 | private String emailId; 12 | private boolean isActive; 13 | private boolean isBlocked; 14 | private List roleInfo; 15 | 16 | public String getUserId() { 17 | return userId; 18 | } 19 | 20 | public void setUserId(String userId) { 21 | this.userId = userId; 22 | } 23 | 24 | public String getFirstName() { 25 | return firstName; 26 | } 27 | 28 | public void setFirstName(String firstName) { 29 | this.firstName = firstName; 30 | } 31 | 32 | public String getLastName() { 33 | return lastName; 34 | } 35 | 36 | public void setLastName(String lastName) { 37 | this.lastName = lastName; 38 | } 39 | 40 | public String getEmailId() { 41 | return emailId; 42 | } 43 | 44 | public void setEmailId(String emailId) { 45 | this.emailId = emailId; 46 | } 47 | 48 | public boolean isActive() { 49 | return isActive; 50 | } 51 | 52 | public void setActive(boolean isActive) { 53 | this.isActive = isActive; 54 | } 55 | 56 | public boolean isBlocked() { 57 | return isBlocked; 58 | } 59 | 60 | public void setBlocked(boolean isBlocked) { 61 | this.isBlocked = isBlocked; 62 | } 63 | 64 | public List getRoleInfo() { 65 | return roleInfo; 66 | } 67 | 68 | public void setRoleInfo(List roleInfo) { 69 | this.roleInfo = roleInfo; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/dto/DepartmentRole.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.dto; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import javax.persistence.Transient; 10 | import javax.validation.constraints.NotNull; 11 | 12 | import org.hibernate.annotations.Type; 13 | 14 | @Entity 15 | @Table(name = "department_roles", schema = "wingspan") 16 | public class DepartmentRole { 17 | @Id 18 | @Column(name = "id") 19 | @GeneratedValue(strategy = GenerationType.IDENTITY) 20 | private Integer id; 21 | 22 | @Column(name = "role_ids") 23 | @NotNull 24 | @Type(type = "org.sunbird.portal.department.dto.GenericArrayUserType") 25 | private Integer[] roleIds; 26 | 27 | @Column(name = "dept_type") 28 | @NotNull 29 | private String deptType; 30 | 31 | @Transient 32 | private Iterable roles; 33 | 34 | public Integer getId() { 35 | return id; 36 | } 37 | 38 | public void setId(Integer id) { 39 | this.id = id; 40 | } 41 | 42 | public Integer[] getRoleIds() { 43 | return roleIds; 44 | } 45 | 46 | public void setRoleIds(Integer[] roleIds) { 47 | this.roleIds = roleIds; 48 | } 49 | 50 | public String getDeptType() { 51 | return deptType; 52 | } 53 | 54 | public void setDeptType(String deptType) { 55 | this.deptType = deptType; 56 | } 57 | 58 | public Iterable getRoles() { 59 | return roles; 60 | } 61 | 62 | public void setRoles(Iterable roles) { 63 | this.roles = roles; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/model/Framework.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.model; 2 | 3 | import java.util.List; 4 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown = true) 8 | public class Framework { 9 | private String identifier; 10 | private String code; 11 | private String name; 12 | private String description; 13 | private String type; 14 | private String objectType; 15 | private List categories; 16 | 17 | public String getIdentifier() { 18 | return identifier; 19 | } 20 | 21 | public void setIdentifier(String identifier) { 22 | this.identifier = identifier; 23 | } 24 | 25 | public String getCode() { 26 | return code; 27 | } 28 | 29 | public void setCode(String code) { 30 | this.code = code; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | 41 | public String getDescription() { 42 | return description; 43 | } 44 | 45 | public void setDescription(String description) { 46 | this.description = description; 47 | } 48 | 49 | public String getType() { 50 | return type; 51 | } 52 | 53 | public void setType(String type) { 54 | this.type = type; 55 | } 56 | 57 | public String getObjectType() { 58 | return objectType; 59 | } 60 | 61 | public void setObjectType(String objectType) { 62 | this.objectType = objectType; 63 | } 64 | 65 | public List getCategories() { 66 | return categories; 67 | } 68 | 69 | public void setCategories(List categories) { 70 | this.categories = categories; 71 | } 72 | 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/config/EsConfig.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.config; 2 | 3 | import org.apache.http.HttpHost; 4 | import org.apache.http.auth.AuthScope; 5 | import org.apache.http.auth.UsernamePasswordCredentials; 6 | import org.apache.http.client.CredentialsProvider; 7 | import org.apache.http.impl.client.BasicCredentialsProvider; 8 | import org.elasticsearch.client.RestClient; 9 | import org.elasticsearch.client.RestClientBuilder; 10 | import org.elasticsearch.client.RestHighLevelClient; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.context.annotation.Bean; 13 | import org.springframework.context.annotation.Configuration; 14 | import org.sunbird.common.util.CbExtServerProperties; 15 | 16 | @Configuration 17 | public class EsConfig { 18 | 19 | @Autowired 20 | CbExtServerProperties configuration; 21 | 22 | @Bean(destroyMethod = "close") 23 | public RestHighLevelClient restHighLevelClient(CbExtServerProperties configuration) { 24 | 25 | final CredentialsProvider credentialsProvider = new BasicCredentialsProvider(); 26 | credentialsProvider.setCredentials(AuthScope.ANY, 27 | new UsernamePasswordCredentials(configuration.getEsUser(), configuration.getEsPassword())); 28 | 29 | RestClientBuilder builder = RestClient 30 | .builder(new HttpHost(configuration.getEsHost(), Integer.parseInt(configuration.getEsPort()))) 31 | .setHttpClientConfigCallback( 32 | httpClientBuilder -> httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider)); 33 | 34 | return new RestHighLevelClient(builder); 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/UserBasicInfo.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnore; 4 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown = true) 7 | public class UserBasicInfo { 8 | private String wid; 9 | private String department_name; 10 | private String last_name; 11 | private String first_name; 12 | private String email; 13 | private String designation; 14 | 15 | public String getWid() { 16 | return wid; 17 | } 18 | 19 | public void setWid(String wid) { 20 | this.wid = wid; 21 | } 22 | 23 | public String getDepartment_name() { 24 | return department_name; 25 | } 26 | 27 | public void setDepartment_name(String department_name) { 28 | this.department_name = department_name; 29 | } 30 | 31 | public String getLast_name() { 32 | return last_name; 33 | } 34 | 35 | public void setLast_name(String last_name) { 36 | this.last_name = last_name; 37 | } 38 | 39 | public String getFirst_name() { 40 | return first_name; 41 | } 42 | 43 | public void setFirst_name(String first_name) { 44 | this.first_name = first_name; 45 | } 46 | 47 | public String getEmail() { 48 | return email; 49 | } 50 | 51 | public void setEmail(String email) { 52 | this.email = email; 53 | } 54 | 55 | public String getDesignation() { 56 | return designation; 57 | } 58 | 59 | public void setDesignation(String designation) { 60 | this.designation = designation; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/progress/cassandraRepo/MandatoryContentPrimaryKeyModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.progress.cassandraRepo; 2 | 3 | import org.springframework.data.cassandra.core.cql.PrimaryKeyType; 4 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; 5 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; 6 | 7 | import java.io.Serializable; 8 | 9 | @PrimaryKeyClass 10 | public class MandatoryContentPrimaryKeyModel implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | @PrimaryKeyColumn(name = "root_org", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 14 | private String rootOrg; 15 | 16 | @PrimaryKeyColumn(name = "org", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 17 | private String org; 18 | 19 | @PrimaryKeyColumn(name = "content_id", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 20 | private String content_id; 21 | 22 | public String getRootOrg() { 23 | return rootOrg; 24 | } 25 | 26 | public void setRootOrg(String rootOrg) { 27 | this.rootOrg = rootOrg; 28 | } 29 | 30 | public String getOrg() { 31 | return org; 32 | } 33 | 34 | public void setOrg(String org) { 35 | this.org = org; 36 | } 37 | 38 | public String getContent_id() { 39 | return content_id; 40 | } 41 | 42 | public void setContent_id(String content_id) { 43 | this.content_id = content_id; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return "MandatoryContentPrimaryKeyModel [rootOrg=" + rootOrg + ", org=" + org + ", content_id=" + content_id 49 | + "]"; 50 | } 51 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiBatchResp.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | public class SunbirdApiBatchResp { 6 | private List createdFor; 7 | private String endDate; 8 | private String name; 9 | private String batchId; 10 | private String enrollmentType; 11 | private String enrollmentEndDate; 12 | private String startDate; 13 | private int status; 14 | public List getCreatedFor() { 15 | return createdFor; 16 | } 17 | public void setCreatedFor(List createdFor) { 18 | this.createdFor = createdFor; 19 | } 20 | public String getEndDate() { 21 | return endDate; 22 | } 23 | public void setEndDate(String endDate) { 24 | this.endDate = endDate; 25 | } 26 | public String getName() { 27 | return name; 28 | } 29 | public void setName(String name) { 30 | this.name = name; 31 | } 32 | public String getBatchId() { 33 | return batchId; 34 | } 35 | public void setBatchId(String batchId) { 36 | this.batchId = batchId; 37 | } 38 | public String getEnrollmentType() { 39 | return enrollmentType; 40 | } 41 | public void setEnrollmentType(String enrollmentType) { 42 | this.enrollmentType = enrollmentType; 43 | } 44 | public String getEnrollmentEndDate() { 45 | return enrollmentEndDate; 46 | } 47 | public void setEnrollmentEndDate(String enrollmentEndDate) { 48 | this.enrollmentEndDate = enrollmentEndDate; 49 | } 50 | public String getStartDate() { 51 | return startDate; 52 | } 53 | public void setStartDate(String startDate) { 54 | this.startDate = startDate; 55 | } 56 | public int getStatus() { 57 | return status; 58 | } 59 | public void setStatus(int status) { 60 | this.status = status; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/UserDepartmentRoleAuditProcessing.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import com.fasterxml.jackson.databind.ObjectMapper; 4 | import org.apache.kafka.clients.consumer.ConsumerRecord; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.kafka.annotation.KafkaListener; 7 | import org.springframework.kafka.annotation.TopicPartition; 8 | import org.springframework.stereotype.Service; 9 | import org.sunbird.core.logger.CbExtLogger; 10 | import org.sunbird.portal.department.dto.UserDepartmentRoleAudit; 11 | import org.sunbird.portal.department.repo.UserDepartmentRoleAuditRepo; 12 | 13 | import java.io.IOException; 14 | import java.util.Date; 15 | 16 | @Service 17 | public class UserDepartmentRoleAuditProcessing { 18 | 19 | @Autowired 20 | private UserDepartmentRoleAuditRepo userDepartmentRoleAuditRepo; 21 | 22 | private CbExtLogger logger = new CbExtLogger(getClass().getName()); 23 | 24 | @KafkaListener(id = "id1", groupId = "userRoleAuditTopic-consumer", topicPartitions = { 25 | @TopicPartition(topic = "${kafka.topics.userrole.audit}", partitions = {"0", "1", "2", "3"})}) 26 | public void processMessage(ConsumerRecord data) { 27 | try { 28 | logger.info("Consuming the audit records ....."); 29 | ObjectMapper mapper = new ObjectMapper(); 30 | UserDepartmentRoleAudit auditObject = mapper.readValue(String.valueOf(data.value()), UserDepartmentRoleAudit.class); 31 | auditObject.setCreatedTime(new Date().getTime()); 32 | userDepartmentRoleAuditRepo.save(auditObject); 33 | } catch (IOException e) { 34 | logger.error(e); 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/ResponseData.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import java.util.List; 4 | 5 | public class ResponseData { 6 | 7 | private String type; 8 | private String id; 9 | private String name; 10 | private String description; 11 | private String status; 12 | private String source; 13 | private List children; 14 | private AdditionalProperties additionalProperties; 15 | 16 | public String getType() { 17 | return type; 18 | } 19 | 20 | public void setType(String type) { 21 | this.type = type; 22 | } 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | 28 | public void setId(String id) { 29 | this.id = id; 30 | } 31 | 32 | public String getName() { 33 | return name; 34 | } 35 | 36 | public void setName(String name) { 37 | this.name = name; 38 | } 39 | 40 | public String getDescription() { 41 | return description; 42 | } 43 | 44 | public void setDescription(String description) { 45 | this.description = description; 46 | } 47 | 48 | public String getStatus() { 49 | return status; 50 | } 51 | 52 | public void setStatus(String status) { 53 | this.status = status; 54 | } 55 | 56 | public String getSource() { 57 | return source; 58 | } 59 | 60 | public void setSource(String source) { 61 | this.source = source; 62 | } 63 | 64 | public List getChildren() { 65 | return children; 66 | } 67 | 68 | public void setChildren(List children) { 69 | this.children = children; 70 | } 71 | 72 | public AdditionalProperties getAdditionalProperties() { 73 | return additionalProperties; 74 | } 75 | 76 | public void setAdditionalProperties(AdditionalProperties additionalProperties) { 77 | this.additionalProperties = additionalProperties; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/model/Term.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.model; 2 | 3 | import java.util.List; 4 | 5 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown = true) 8 | public class Term { 9 | private String identifier; 10 | private String code; 11 | private String name; 12 | private String description; 13 | private int index; 14 | private String status; 15 | private List children; 16 | private int noOfHoursConsumed; 17 | 18 | public String getIdentifier() { 19 | return identifier; 20 | } 21 | 22 | public void setIdentifier(String identifier) { 23 | this.identifier = identifier; 24 | } 25 | 26 | public String getCode() { 27 | return code; 28 | } 29 | 30 | public void setCode(String code) { 31 | this.code = code; 32 | } 33 | 34 | public String getName() { 35 | return name; 36 | } 37 | 38 | public void setName(String name) { 39 | this.name = name; 40 | } 41 | 42 | public String getDescription() { 43 | return description; 44 | } 45 | 46 | public void setDescription(String description) { 47 | this.description = description; 48 | } 49 | 50 | public int getIndex() { 51 | return index; 52 | } 53 | 54 | public void setIndex(int index) { 55 | this.index = index; 56 | } 57 | 58 | public String getStatus() { 59 | return status; 60 | } 61 | 62 | public void setStatus(String status) { 63 | this.status = status; 64 | } 65 | 66 | public List getChildren() { 67 | return children; 68 | } 69 | 70 | public void setChildren(List children) { 71 | this.children = children; 72 | } 73 | 74 | public int getNoOfHoursConsumed() { 75 | return noOfHoursConsumed; 76 | } 77 | 78 | public void setNoOfHoursConsumed(int noOfHoursConsumed) { 79 | this.noOfHoursConsumed = noOfHoursConsumed; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserQuizSummaryPrimaryKeyModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.io.Serializable; 4 | 5 | import org.springframework.data.cassandra.core.cql.PrimaryKeyType; 6 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; 7 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; 8 | 9 | @PrimaryKeyClass 10 | public class UserQuizSummaryPrimaryKeyModel implements Serializable { 11 | 12 | private static final long serialVersionUID = 1L; 13 | 14 | @PrimaryKeyColumn(name = "root_org", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 15 | private String rootOrg; 16 | 17 | @PrimaryKeyColumn(name = "user_id", ordinal = 1, type = PrimaryKeyType.PARTITIONED) 18 | private String userId; 19 | 20 | @PrimaryKeyColumn(name = "content_id", ordinal = 2, type = PrimaryKeyType.CLUSTERED) 21 | private String contentId; 22 | 23 | public String getRootOrg() { 24 | return rootOrg; 25 | } 26 | 27 | public void setRootOrg(String rootOrg) { 28 | this.rootOrg = rootOrg; 29 | } 30 | 31 | public String getUserId() { 32 | return userId; 33 | } 34 | 35 | public void setUserId(String userId) { 36 | this.userId = userId; 37 | } 38 | 39 | public String getContentId() { 40 | return contentId; 41 | } 42 | 43 | public void setContentId(String contentId) { 44 | this.contentId = contentId; 45 | } 46 | 47 | public UserQuizSummaryPrimaryKeyModel() { 48 | super(); 49 | } 50 | 51 | public UserQuizSummaryPrimaryKeyModel(String rootOrg, String userId, String contentId) { 52 | this.rootOrg = rootOrg; 53 | this.userId = userId; 54 | this.contentId = contentId; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "UserQuizSummaryPrimaryKeyModel [rootOrg=" + rootOrg + ", userId=" + userId + ", contentId=" + contentId 60 | + "]"; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/SbCbExtApplication.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal; 2 | 3 | import org.apache.http.client.config.RequestConfig; 4 | import org.apache.http.impl.client.CloseableHttpClient; 5 | import org.apache.http.impl.client.HttpClientBuilder; 6 | import org.springframework.boot.SpringApplication; 7 | import org.springframework.boot.autoconfigure.SpringBootApplication; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.ComponentScan; 10 | import org.springframework.http.client.ClientHttpRequestFactory; 11 | import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; 12 | import org.springframework.web.client.RestTemplate; 13 | 14 | @ComponentScan(basePackages = "org.sunbird") 15 | @SpringBootApplication 16 | public class SbCbExtApplication { 17 | 18 | /** 19 | * Runs The application 20 | * 21 | * @param args 22 | */ 23 | public static void main(String[] args) { 24 | SpringApplication.run(SbCbExtApplication.class, args); 25 | } 26 | 27 | /** 28 | * Initializes the rest template 29 | * 30 | * @return 31 | * @throws Exception 32 | */ 33 | 34 | @Bean 35 | public RestTemplate restTemplate() throws Exception { 36 | 37 | return new RestTemplate(getClientHttpRequestFactory()); 38 | } 39 | 40 | private ClientHttpRequestFactory getClientHttpRequestFactory() { 41 | 42 | int timeout = 5000; 43 | RequestConfig config = RequestConfig.custom().setConnectTimeout(timeout).setConnectionRequestTimeout(timeout) 44 | .setSocketTimeout(timeout).build(); 45 | CloseableHttpClient client = HttpClientBuilder.create().setMaxConnTotal(2000).setMaxConnPerRoute(500) 46 | .setDefaultRequestConfig(config).build(); 47 | return new HttpComponentsClientHttpRequestFactory(client); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentSummaryPrimaryKeyModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.io.Serializable; 4 | 5 | import org.springframework.data.cassandra.core.cql.PrimaryKeyType; 6 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; 7 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; 8 | 9 | @PrimaryKeyClass 10 | public class UserAssessmentSummaryPrimaryKeyModel implements Serializable { 11 | private static final long serialVersionUID = 1L; 12 | 13 | @PrimaryKeyColumn(name = "root_org", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 14 | private String rootOrg; 15 | 16 | @PrimaryKeyColumn(name = "user_id", ordinal = 1, type = PrimaryKeyType.PARTITIONED) 17 | private String userId; 18 | 19 | @PrimaryKeyColumn(name = "content_id", ordinal = 2, type = PrimaryKeyType.CLUSTERED) 20 | private String contentId; 21 | 22 | public String getRootOrg() { 23 | return rootOrg; 24 | } 25 | 26 | public void setRootOrg(String rootOrg) { 27 | this.rootOrg = rootOrg; 28 | } 29 | 30 | public String getUserId() { 31 | return userId; 32 | } 33 | 34 | public void setUserId(String userId) { 35 | this.userId = userId; 36 | } 37 | 38 | public String getContentId() { 39 | return contentId; 40 | } 41 | 42 | public void setContentId(String contentId) { 43 | this.contentId = contentId; 44 | } 45 | 46 | public UserAssessmentSummaryPrimaryKeyModel() { 47 | super(); 48 | } 49 | 50 | public UserAssessmentSummaryPrimaryKeyModel(String rootOrg, String userId, String contentId) { 51 | this.rootOrg = rootOrg; 52 | this.userId = userId; 53 | this.contentId = contentId; 54 | } 55 | 56 | @Override 57 | public String toString() { 58 | return "UserAssessmentSummaryPrimaryKeyModel [rootOrg=" + rootOrg + ", userId=" + userId + ", contentId=" 59 | + contentId + "]"; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/controller/DepartmentTypeController.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.controller; 2 | 3 | import java.util.List; 4 | import java.util.Map; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.http.ResponseEntity; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PathVariable; 11 | import org.springframework.web.bind.annotation.RestController; 12 | import org.sunbird.portal.department.dto.DepartmentType; 13 | import org.sunbird.portal.department.service.DepartmentTypeService; 14 | 15 | @RestController 16 | public class DepartmentTypeController { 17 | @Autowired 18 | private DepartmentTypeService deptService; 19 | 20 | @GetMapping("/portal/departmentType") 21 | public ResponseEntity>> getAllDepartmentTypes() { 22 | return new ResponseEntity>>(deptService.getAllDepartmentTypes(), 23 | HttpStatus.OK); 24 | } 25 | 26 | @GetMapping("/portal/departmentType/{deptTypeName}") 27 | public ResponseEntity> getDepartmentByTypeName( 28 | @PathVariable("deptTypeName") String deptTypeName) { 29 | return new ResponseEntity>(deptService.getDepartmentByType(deptTypeName), HttpStatus.OK); 30 | } 31 | 32 | @GetMapping("/portal/departmentTypeById/{deptTypeId}") 33 | public ResponseEntity getDepartmentByTypeId(@PathVariable("deptTypeId") Integer deptTypeId) throws Exception { 34 | return new ResponseEntity(deptService.getDepartmentTypeById(deptTypeId), HttpStatus.OK); 35 | } 36 | 37 | @GetMapping("portal/departmentTypeName") 38 | public ResponseEntity>> getDepartmentTypeNames() { 39 | return new ResponseEntity>>(deptService.getDepartmentTypeNames(), HttpStatus.OK); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/dto/AssessmentSubmissionDTO.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.dto; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import java.util.Map; 6 | 7 | import javax.validation.constraints.NotNull; 8 | 9 | public class AssessmentSubmissionDTO implements Serializable { 10 | private static final long serialVersionUID = 1L; 11 | 12 | @NotNull(message = "{submission.timeLimit.mandatory}") 13 | private Long timeLimit; 14 | 15 | @NotNull(message = "{submission.isAssessment.mandatory}") 16 | private Boolean isAssessment; 17 | 18 | @NotNull(message = "{submission.questions.mandatory}") 19 | private List> questions; 20 | 21 | @NotNull(message = "{submission.identifier.mandatory}") 22 | private String identifier; 23 | 24 | @NotNull(message = "{submission.title.mandatory}") 25 | private String title; 26 | 27 | public Long getTimeLimit() { 28 | return timeLimit; 29 | } 30 | 31 | public void setTimeLimit(Long timeLimit) { 32 | this.timeLimit = timeLimit; 33 | } 34 | 35 | public Boolean isAssessment() { 36 | return isAssessment; 37 | } 38 | 39 | public void setIsAssessment(Boolean isAssessment) { 40 | this.isAssessment = isAssessment; 41 | } 42 | 43 | public List> getQuestions() { 44 | return questions; 45 | } 46 | 47 | public void setQuestions(List> questions) { 48 | this.questions = questions; 49 | } 50 | 51 | public String getIdentifier() { 52 | return identifier; 53 | } 54 | 55 | public void setIdentifier(String identifier) { 56 | this.identifier = identifier; 57 | } 58 | 59 | public String getTitle() { 60 | return title; 61 | } 62 | 63 | public void setTitle(String title) { 64 | this.title = title; 65 | } 66 | 67 | @Override 68 | public String toString() { 69 | return "AssessmentSubmissionDTO [timeLimit=" + timeLimit + ", isAssessment=" + isAssessment + ", questions=" 70 | + questions + ", identifier=" + identifier + ", title=" + title + "]"; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/dto/DepartmentType.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.dto; 2 | 3 | import javax.persistence.Column; 4 | import javax.persistence.Entity; 5 | import javax.persistence.GeneratedValue; 6 | import javax.persistence.GenerationType; 7 | import javax.persistence.Id; 8 | import javax.persistence.Table; 9 | import javax.validation.constraints.NotNull; 10 | 11 | @Entity 12 | @Table(name = "department_types", schema = "wingspan") 13 | public class DepartmentType { 14 | @Id 15 | @Column(name = "id") 16 | @GeneratedValue(strategy = GenerationType.IDENTITY) 17 | Integer id; 18 | 19 | @Column(name = "dept_type") 20 | @NotNull 21 | private String deptType; 22 | 23 | @Column(name = "dept_subtype") 24 | @NotNull 25 | private String deptSubType; 26 | 27 | @Column(name = "description") 28 | @NotNull 29 | private String description; 30 | 31 | public DepartmentType() { 32 | } 33 | 34 | public DepartmentType(Integer id, String deptType, String deptSubType, String description) { 35 | this.id = id; 36 | this.deptType = deptType; 37 | this.deptSubType = deptSubType; 38 | this.description = description; 39 | } 40 | 41 | public Integer getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Integer id) { 46 | this.id = id; 47 | } 48 | 49 | public String getDeptType() { 50 | return deptType; 51 | } 52 | 53 | public void setDeptType(String deptType) { 54 | this.deptType = deptType; 55 | } 56 | 57 | public String getDeptSubType() { 58 | return deptSubType; 59 | } 60 | 61 | public void setDeptSubType(String deptSubType) { 62 | this.deptSubType = deptSubType; 63 | } 64 | 65 | public String getDescription() { 66 | return description; 67 | } 68 | 69 | public void setDescription(String description) { 70 | this.description = description; 71 | } 72 | 73 | public String toString() { 74 | return "[DepartmentType=id:" + id + ", deptType: " + deptType + ", deptSubType: " + deptSubType 75 | + ", description: " + description + "]"; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiBatch.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | public class SunbirdApiBatch { 6 | private List createdFor; 7 | private String identifier; 8 | private String endDate; 9 | private String name; 10 | private String batchId; 11 | private String enrollmentType; 12 | private String enrollmentEndDate; 13 | private String startDate; 14 | private int status; 15 | public List getCreatedFor() { 16 | return createdFor; 17 | } 18 | public void setCreatedFor(List createdFor) { 19 | this.createdFor = createdFor; 20 | } 21 | public String getEndDate() { 22 | return endDate; 23 | } 24 | public void setEndDate(String endDate) { 25 | this.endDate = endDate; 26 | } 27 | public String getName() { 28 | return name; 29 | } 30 | public void setName(String name) { 31 | this.name = name; 32 | } 33 | public String getBatchId() { 34 | return batchId; 35 | } 36 | public void setBatchId(String batchId) { 37 | this.batchId = batchId; 38 | } 39 | public String getEnrollmentType() { 40 | return enrollmentType; 41 | } 42 | public void setEnrollmentType(String enrollmentType) { 43 | this.enrollmentType = enrollmentType; 44 | } 45 | public String getEnrollmentEndDate() { 46 | return enrollmentEndDate; 47 | } 48 | public void setEnrollmentEndDate(String enrollmentEndDate) { 49 | this.enrollmentEndDate = enrollmentEndDate; 50 | } 51 | public String getStartDate() { 52 | return startDate; 53 | } 54 | public void setStartDate(String startDate) { 55 | this.startDate = startDate; 56 | } 57 | public int getStatus() { 58 | return status; 59 | } 60 | public void setStatus(int status) { 61 | this.status = status; 62 | } 63 | 64 | public String getIdentifier() { 65 | return identifier; 66 | } 67 | 68 | public void setIdentifier(String identifier) { 69 | this.identifier = identifier; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/controller/PdfGeneratorController.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.HttpHeaders; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RestController; 13 | import org.sunbird.workallocation.model.PdfGeneratorRequest; 14 | import org.sunbird.workallocation.service.PdfGeneratorService; 15 | 16 | @RestController 17 | public class PdfGeneratorController { 18 | @Autowired 19 | private PdfGeneratorService pdfGeneratorService; 20 | 21 | @PostMapping("/generatePdf") 22 | public ResponseEntity generatePdf(@RequestBody PdfGeneratorRequest request) throws Exception { 23 | return new ResponseEntity<>(pdfGeneratorService.generatePdf(request), HttpStatus.OK); 24 | } 25 | 26 | @GetMapping(value = "/getWOPdf/{woId}", produces = MediaType.APPLICATION_PDF_VALUE) 27 | public ResponseEntity getWAPdf(@PathVariable("woId") String woId) 28 | throws Exception { 29 | byte[] out = null; 30 | try { 31 | out = pdfGeneratorService.generatePdf(woId); 32 | } catch (Exception e) { 33 | } 34 | 35 | if (out == null) { 36 | throw new InternalError("Failed to generate PDF file."); 37 | } 38 | 39 | HttpHeaders headers = new HttpHeaders(); 40 | headers.setContentType(MediaType.APPLICATION_PDF); 41 | headers.add("Content-Disposition", "inline; filename=wo_report.pdf"); 42 | 43 | ResponseEntity response = new ResponseEntity<>(out, headers, HttpStatus.OK); 44 | return response; 45 | } 46 | 47 | @GetMapping(value = "/getWOPublishedPdf/{woId}") 48 | public ResponseEntity getWOPublishedPdf(@PathVariable("woId") String woId) { 49 | return new ResponseEntity<>(pdfGeneratorService.getPublishedPdfLink(woId), HttpStatus.OK); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserQuizMasterPrimaryKeyModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | import java.util.UUID; 6 | 7 | import org.springframework.data.cassandra.core.cql.PrimaryKeyType; 8 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; 9 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; 10 | 11 | @PrimaryKeyClass 12 | public class UserQuizMasterPrimaryKeyModel { 13 | private static final long serialVersionUID = 1L; 14 | 15 | @PrimaryKeyColumn(name = "root_org", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 16 | private String rootOrg; 17 | 18 | @PrimaryKeyColumn(name = "ts_created", ordinal = 1, type = PrimaryKeyType.PARTITIONED) 19 | private Date tsCreated; 20 | 21 | @PrimaryKeyColumn(name = "result_percent", ordinal = 2, type = PrimaryKeyType.CLUSTERED) 22 | private BigDecimal resultPercent; 23 | 24 | @PrimaryKeyColumn(name = "id", ordinal = 3, type = PrimaryKeyType.CLUSTERED) 25 | private UUID id; 26 | 27 | public String getRootOrg() { 28 | return rootOrg; 29 | } 30 | 31 | public void setRootOrg(String rootOrg) { 32 | this.rootOrg = rootOrg; 33 | } 34 | 35 | public Date getTsCreated() { 36 | return tsCreated; 37 | } 38 | 39 | public void setTsCreated(Date tsCreated) { 40 | this.tsCreated = tsCreated; 41 | } 42 | 43 | public BigDecimal getResultPercent() { 44 | return resultPercent; 45 | } 46 | 47 | public void setResultPercent(BigDecimal resultPercent) { 48 | this.resultPercent = resultPercent; 49 | } 50 | 51 | public UUID getId() { 52 | return id; 53 | } 54 | 55 | public void setId(UUID id) { 56 | this.id = id; 57 | } 58 | 59 | public UserQuizMasterPrimaryKeyModel() { 60 | super(); 61 | } 62 | 63 | public UserQuizMasterPrimaryKeyModel(String rootOrg, Date tsCreated, BigDecimal resultPercent, UUID id) { 64 | this.rootOrg = rootOrg; 65 | this.tsCreated = tsCreated; 66 | this.resultPercent = resultPercent; 67 | this.id = id; 68 | } 69 | 70 | @Override 71 | public String toString() { 72 | return "UserQuizMasterPrimaryKeyModel [rootOrg=" + rootOrg + ", tsCreated=" + tsCreated + ", resultPercent=" 73 | + resultPercent + ", id=" + id + "]"; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/WorkAllocation.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import org.springframework.util.CollectionUtils; 5 | 6 | import java.util.ArrayList; 7 | import java.util.List; 8 | 9 | @JsonIgnoreProperties(ignoreUnknown = true) 10 | public class WorkAllocation { 11 | private String id; 12 | private String userId; 13 | private String userName; 14 | private String userEmail; 15 | private WAObject draftWAObject; 16 | private WAObject activeWAObject; 17 | private List archivedWAList; 18 | 19 | public String getId() { 20 | return id; 21 | } 22 | 23 | public void setId(String id) { 24 | this.id = id; 25 | } 26 | 27 | public String getUserId() { 28 | return userId; 29 | } 30 | 31 | public void setUserId(String userId) { 32 | this.userId = userId; 33 | } 34 | 35 | public String getUserName() { 36 | return userName; 37 | } 38 | 39 | public void setUserName(String userName) { 40 | this.userName = userName; 41 | } 42 | 43 | public String getUserEmail() { 44 | return userEmail; 45 | } 46 | 47 | public void setUserEmail(String userEmail) { 48 | this.userEmail = userEmail; 49 | } 50 | 51 | public WAObject getDraftWAObject() { 52 | return draftWAObject; 53 | } 54 | 55 | public void setDraftWAObject(WAObject draftWAObject) { 56 | this.draftWAObject = draftWAObject; 57 | } 58 | 59 | public WAObject getActiveWAObject() { 60 | return activeWAObject; 61 | } 62 | 63 | public void setActiveWAObject(WAObject activeWAObject) { 64 | this.activeWAObject = activeWAObject; 65 | } 66 | 67 | public List getArchivedWAList() { 68 | return archivedWAList; 69 | } 70 | 71 | public void setArchivedWAList(List archivedWAList) { 72 | this.archivedWAList = archivedWAList; 73 | } 74 | public void addArchivedWAList(WAObject archivedWAList) { 75 | if(CollectionUtils.isEmpty(this.archivedWAList)) 76 | this.archivedWAList = new ArrayList<>(); 77 | this.archivedWAList.add(archivedWAList); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/CohortUsers.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | @JsonIgnoreProperties(ignoreUnknown = true) 6 | public class CohortUsers { 7 | private String first_name; 8 | private String last_name; 9 | private String email; 10 | private String desc; 11 | private String user_id; 12 | private String department; 13 | private String phone_No; 14 | private String designation; 15 | private String userLocation; 16 | private String city; 17 | public String getDesc() { 18 | return desc; 19 | } 20 | 21 | public void setDesc(String desc) { 22 | this.desc = desc; 23 | } 24 | public String getFirst_name() { 25 | return first_name; 26 | } 27 | 28 | public void setFirst_name(String first_name) { 29 | this.first_name = first_name; 30 | } 31 | 32 | public String getLast_name() { 33 | return last_name; 34 | } 35 | 36 | public void setLast_name(String last_name) { 37 | this.last_name = last_name; 38 | } 39 | 40 | public String getEmail() { 41 | return email; 42 | } 43 | 44 | public void setEmail(String email) { 45 | this.email = email; 46 | } 47 | 48 | public String getUser_id() { 49 | return user_id; 50 | } 51 | 52 | public void setUser_id(String user_id) { 53 | this.user_id = user_id; 54 | } 55 | 56 | public String getDesignation() { 57 | return designation; 58 | } 59 | 60 | public void setDesignation(String designation) { 61 | this.designation = designation; 62 | } 63 | 64 | public String getDepartment() { 65 | return department; 66 | } 67 | 68 | public void setDepartment(String department) { 69 | this.department = department; 70 | } 71 | 72 | public String getPhone_No() { 73 | return phone_No; 74 | } 75 | 76 | public void setPhone_No(String phone_No) { 77 | this.phone_No = phone_No; 78 | } 79 | 80 | public String getUserLocation() { 81 | return userLocation; 82 | } 83 | 84 | public void setUserLocation(String userLocation) { 85 | this.userLocation = userLocation; 86 | } 87 | 88 | public String getCity() { 89 | return city; 90 | } 91 | 92 | public void setCity(String city) { 93 | this.city = city; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Jenkinsfile-sun: -------------------------------------------------------------------------------- 1 | @Library('deploy-conf') _ 2 | node('build-slave') { 3 | try { 4 | String ANSI_GREEN = "\u001B[32m" 5 | String ANSI_NORMAL = "\u001B[0m" 6 | String ANSI_BOLD = "\u001B[1m" 7 | String ANSI_RED = "\u001B[31m" 8 | String ANSI_YELLOW = "\u001B[33m" 9 | 10 | ansiColor('xterm') { 11 | stage('Checkout') { 12 | if (!env.hub_org) { 13 | println(ANSI_BOLD + ANSI_RED + "Uh Oh! Please set a Jenkins environment variable named hub_org with value as registery/sunbidrded" + ANSI_NORMAL) 14 | error 'Please resolve the errors and rerun..' 15 | } else 16 | println(ANSI_BOLD + ANSI_GREEN + "Found environment variable named hub_org with value as: " + hub_org + ANSI_NORMAL) 17 | } 18 | 19 | cleanWs() 20 | checkout scm 21 | commit_hash = sh(script: 'git rev-parse --short HEAD', returnStdout: true).trim() 22 | build_tag = sh(script: "echo " + params.github_release_tag.split('/')[-1] + "_" + commit_hash + "_" + env.BUILD_NUMBER, returnStdout: true).trim() 23 | echo "build_tag: " + build_tag 24 | 25 | stage('docker-pre-build') { 26 | sh ''' 27 | 28 | docker build -f ./Dockerfile.build -t $docker_pre_build . 29 | docker run --name $docker_pre_build $docker_pre_build:latest && docker cp $docker_pre_build:/opt/target/sb-cb-ext-0.0.1-SNAPSHOT.jar . 30 | sleep 30 31 | docker rm -f $docker_pre_build 32 | docker rmi -f $docker_pre_build 33 | ''' 34 | } 35 | stage('Build') { 36 | env.NODE_ENV = "build" 37 | print "Environment will be : ${env.NODE_ENV}" 38 | sh('chmod 777 build.sh') 39 | sh("bash -x build.sh ${build_tag} ${env.NODE_NAME} ${docker_server}") 40 | } 41 | stage('ArchiveArtifacts') { 42 | archiveArtifacts "metadata.json" 43 | currentBuild.description = "${build_tag}" 44 | } 45 | 46 | } 47 | 48 | } 49 | catch (err) { 50 | currentBuild.result = "FAILURE" 51 | throw err 52 | } 53 | finally { 54 | email_notify() 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | node() { 2 | try { 3 | String ANSI_GREEN = "\u001B[32m" 4 | String ANSI_NORMAL = "\u001B[0m" 5 | String ANSI_BOLD = "\u001B[1m" 6 | String ANSI_RED = "\u001B[31m" 7 | String ANSI_YELLOW = "\u001B[33m" 8 | 9 | ansiColor('xterm') { 10 | stage('Checkout') { 11 | cleanWs() 12 | checkout scm 13 | } 14 | } 15 | stage('docker-pre-build') { 16 | sh ''' 17 | cd $docker_file_path 18 | pwd 19 | docker build -f ./Dockerfile.build -t $docker_pre_build . 20 | docker run --name $docker_pre_build $docker_pre_build:latest && docker cp $docker_pre_build:/opt/target/sb-cb-ext-0.0.1-SNAPSHOT.jar . 21 | docker rm -f $docker_pre_build 22 | docker rmi -f $docker_pre_build 23 | ''' 24 | } 25 | 26 | stage('SonarQube analysis') { 27 | // requires SonarQube Scanner 2.8+ 28 | def scannerHome = tool 'sonar_scanner'; 29 | withSonarQubeEnv('sonarqube') { 30 | sh 'cd $docker_file_path && mvn clean package sonar:sonar' 31 | } 32 | } 33 | stage("Quality Gate") { 34 | timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout 35 | def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv 36 | if (qg.status != 'OK') { 37 | error "Pipeline aborted due to quality gate failure: ${qg.status}" 38 | } 39 | } 40 | } 41 | 42 | 43 | 44 | stage('docker-build') { 45 | sh ''' 46 | commit_id=$(git rev-parse --short HEAD) 47 | echo $commit_id> commit_id.txt 48 | cd $docker_file_path 49 | pwd 50 | docker build -t $docker_server/$docker_repo:$commit_id . 51 | docker tag $docker_server/$docker_repo:$commit_id $docker_server/$docker_repo:$image_tag 52 | ''' 53 | } 54 | stage('docker-push') { 55 | 56 | sh ''' 57 | pwd 58 | commit_id=$(git rev-parse --short HEAD) 59 | docker push $docker_server/$docker_repo:$commit_id 60 | docker push $docker_server/$docker_repo:$image_tag 61 | docker rmi -f $docker_server/$docker_repo:$commit_id 62 | docker rmi -f $docker_server/$docker_repo:$image_tag 63 | ''' 64 | } 65 | 66 | } 67 | catch (err) { 68 | currentBuild.result = "FAILURE" 69 | throw err 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentTopPerformerModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.math.BigDecimal; 4 | 5 | import org.springframework.data.cassandra.core.mapping.Column; 6 | import org.springframework.data.cassandra.core.mapping.PrimaryKey; 7 | import org.springframework.data.cassandra.core.mapping.Table; 8 | 9 | @Table("user_assessment_top_performer") 10 | public class UserAssessmentTopPerformerModel { 11 | @PrimaryKey 12 | private UserAssessmentTopPerformerPrimaryKeyModel primaryKey; 13 | @Column("pass_percent") 14 | private BigDecimal passPercent; 15 | @Column("source_id") 16 | private String sourceId; 17 | @Column("source_title") 18 | private String sourceTitle; 19 | @Column("user_id") 20 | private String userId; 21 | 22 | public UserAssessmentTopPerformerPrimaryKeyModel getPrimaryKey() { 23 | return primaryKey; 24 | } 25 | 26 | public void setPrimaryKey(UserAssessmentTopPerformerPrimaryKeyModel primaryKey) { 27 | this.primaryKey = primaryKey; 28 | } 29 | 30 | public BigDecimal getPassPercent() { 31 | return passPercent; 32 | } 33 | 34 | public void setPassPercent(BigDecimal passPercent) { 35 | this.passPercent = passPercent; 36 | } 37 | 38 | public String getSourceId() { 39 | return sourceId; 40 | } 41 | 42 | public void setSourceId(String sourceId) { 43 | this.sourceId = sourceId; 44 | } 45 | 46 | public String getSourceTitle() { 47 | return sourceTitle; 48 | } 49 | 50 | public void setSourceTitle(String sourceTitle) { 51 | this.sourceTitle = sourceTitle; 52 | } 53 | 54 | public String getUserId() { 55 | return userId; 56 | } 57 | 58 | public void setUserId(String userId) { 59 | this.userId = userId; 60 | } 61 | 62 | public UserAssessmentTopPerformerModel(UserAssessmentTopPerformerPrimaryKeyModel primaryKey, BigDecimal passPercent, 63 | String sourceId, String sourceTitle, String userId) { 64 | super(); 65 | this.primaryKey = primaryKey; 66 | this.passPercent = passPercent; 67 | this.sourceId = sourceId; 68 | this.sourceTitle = sourceTitle; 69 | this.userId = userId; 70 | } 71 | 72 | public UserAssessmentTopPerformerModel() { 73 | super(); 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return "UserAssessmentTopPerformerModel [primaryKey=" + primaryKey + ", passPercent=" + passPercent 79 | + ", sourceId=" + sourceId + ", sourceTitle=" + sourceTitle + ", userId=" + userId + "]"; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/WorkAllocationDTO.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | import java.util.List; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown = true) 8 | public class WorkAllocationDTO { 9 | private String userId; 10 | private String userName; 11 | private String userEmail; 12 | private String waId; 13 | private String deptId; 14 | private String deptName; 15 | private List roleCompetencyList; 16 | private String userPosition; 17 | private String positionId; 18 | private String status; 19 | 20 | public String getUserId() { 21 | return userId; 22 | } 23 | 24 | public void setUserId(String userId) { 25 | this.userId = userId; 26 | } 27 | 28 | public String getUserName() { 29 | return userName; 30 | } 31 | 32 | public void setUserName(String userName) { 33 | this.userName = userName; 34 | } 35 | 36 | public String getUserEmail() { 37 | return userEmail; 38 | } 39 | 40 | public void setUserEmail(String userEmail) { 41 | this.userEmail = userEmail; 42 | } 43 | 44 | public String getWaId() { 45 | return waId; 46 | } 47 | 48 | public void setWaId(String waId) { 49 | this.waId = waId; 50 | } 51 | 52 | public String getDeptId() { 53 | return deptId; 54 | } 55 | 56 | public void setDeptId(String deptId) { 57 | this.deptId = deptId; 58 | } 59 | 60 | public String getDeptName() { 61 | return deptName; 62 | } 63 | 64 | public void setDeptName(String deptName) { 65 | this.deptName = deptName; 66 | } 67 | 68 | public List getRoleCompetencyList() { 69 | return roleCompetencyList; 70 | } 71 | 72 | public void setRoleCompetencyList(List roleCompetencyList) { 73 | this.roleCompetencyList = roleCompetencyList; 74 | } 75 | 76 | public String getUserPosition() { 77 | return userPosition; 78 | } 79 | 80 | public void setUserPosition(String userPosition) { 81 | this.userPosition = userPosition; 82 | } 83 | 84 | public String getPositionId() { 85 | return positionId; 86 | } 87 | 88 | public void setPositionId(String positionId) { 89 | this.positionId = positionId; 90 | } 91 | 92 | public String getStatus() { 93 | return status; 94 | } 95 | 96 | public void setStatus(String status) { 97 | this.status = status; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/logger/CbExtLogger.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.logger; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | 6 | import org.apache.logging.log4j.Level; 7 | import org.apache.logging.log4j.LogManager; 8 | import org.apache.logging.log4j.Logger; 9 | 10 | import com.fasterxml.jackson.databind.ObjectMapper; 11 | import com.google.common.base.Throwables; 12 | 13 | public class CbExtLogger { 14 | private Logger logger; 15 | 16 | public CbExtLogger(String className) { 17 | this.logger = LogManager.getLogger(className); 18 | } 19 | 20 | public void debug(String message) { 21 | 22 | logger.log(Level.DEBUG, message); 23 | } 24 | 25 | public void info(String message) { 26 | 27 | logger.log(Level.INFO, message); 28 | } 29 | 30 | public void warn(String message) { 31 | 32 | logger.log(Level.WARN, message); 33 | } 34 | 35 | public void error(Exception exception) { 36 | 37 | ObjectMapper ow = new ObjectMapper(); 38 | 39 | // log the exception 40 | try { 41 | Map message = new HashMap<>(); 42 | message.put("event", exception.getClass()); 43 | message.put("message", exception.getMessage()); 44 | message.put("trace", Throwables.getStackTraceAsString(exception)); 45 | logger.log(Level.ERROR, ow.writeValueAsString(message)); 46 | } catch (Exception e) { 47 | logger.log(Level.ERROR, 48 | "{\"event\":\"" + exception.getClass() + "\", \"message\":\"" + exception.getMessage() 49 | + "\", \"trace\":\"" + Throwables.getStackTraceAsString(exception) + "\"}"); 50 | } 51 | } 52 | 53 | public void fatal(Exception exception) { 54 | 55 | ObjectMapper ow = new ObjectMapper(); 56 | 57 | // log the exception 58 | try { 59 | Map message = new HashMap<>(); 60 | message.put("event", exception.getClass()); 61 | message.put("message", exception.getMessage()); 62 | message.put("trace", Throwables.getStackTraceAsString(exception)); 63 | logger.log(Level.FATAL, ow.writeValueAsString(message)); 64 | } catch (Exception e) { 65 | logger.log(Level.FATAL, 66 | "{\"event\":\"" + exception.getClass() + "\", \"message\":\"" + exception.getMessage() 67 | + "\", \"trace\":\"" + Throwables.getStackTraceAsString(exception) + "\"}"); 68 | } 69 | } 70 | 71 | public void trace(String message) { 72 | 73 | logger.log(Level.TRACE, message); 74 | } 75 | 76 | public void performance(String message) { 77 | 78 | Level performance = Level.forName("PERF", 350); 79 | 80 | logger.log(performance, message); 81 | } 82 | 83 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/WAObject.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | import java.util.List; 6 | 7 | @JsonIgnoreProperties(ignoreUnknown = true) 8 | public class WAObject { 9 | private String id; 10 | private String deptId; 11 | private String deptName; 12 | private List roleCompetencyList; 13 | private String userPosition; 14 | private String positionId; 15 | private long updatedAt; 16 | private String updatedBy; 17 | private long createdAt; 18 | private String createdBy; 19 | private String status; 20 | 21 | public String getId() { 22 | return id; 23 | } 24 | 25 | public void setId(String id) { 26 | this.id = id; 27 | } 28 | 29 | public String getDeptId() { 30 | return deptId; 31 | } 32 | 33 | public void setDeptId(String deptId) { 34 | this.deptId = deptId; 35 | } 36 | 37 | public String getDeptName() { 38 | return deptName; 39 | } 40 | 41 | public void setDeptName(String deptName) { 42 | this.deptName = deptName; 43 | } 44 | 45 | public String getUserPosition() { 46 | return userPosition; 47 | } 48 | 49 | public void setUserPosition(String userPosition) { 50 | this.userPosition = userPosition; 51 | } 52 | 53 | public String getPositionId() { 54 | return positionId; 55 | } 56 | 57 | public void setPositionId(String positionId) { 58 | this.positionId = positionId; 59 | } 60 | 61 | public long getUpdatedAt() { 62 | return updatedAt; 63 | } 64 | 65 | public void setUpdatedAt(long updatedAt) { 66 | this.updatedAt = updatedAt; 67 | } 68 | 69 | public String getUpdatedBy() { 70 | return updatedBy; 71 | } 72 | 73 | public void setUpdatedBy(String updatedBy) { 74 | this.updatedBy = updatedBy; 75 | } 76 | 77 | public long getCreatedAt() { 78 | return createdAt; 79 | } 80 | 81 | public void setCreatedAt(long createdAt) { 82 | this.createdAt = createdAt; 83 | } 84 | 85 | public String getCreatedBy() { 86 | return createdBy; 87 | } 88 | 89 | public void setCreatedBy(String createdBy) { 90 | this.createdBy = createdBy; 91 | } 92 | 93 | public String getStatus() { 94 | return status; 95 | } 96 | 97 | public void setStatus(String status) { 98 | this.status = status; 99 | } 100 | 101 | public List getRoleCompetencyList() { 102 | return roleCompetencyList; 103 | } 104 | 105 | public void setRoleCompetencyList(List roleCompetencyList) { 106 | this.roleCompetencyList = roleCompetencyList; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/PortalService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import java.util.List; 4 | 5 | import org.sunbird.portal.department.dto.Department; 6 | import org.sunbird.portal.department.dto.UserDepartmentRole; 7 | import org.sunbird.portal.department.model.DepartmentInfo; 8 | import org.sunbird.portal.department.model.DeptPublicInfo; 9 | import org.sunbird.portal.department.model.SearchUserInfo; 10 | import org.sunbird.portal.department.model.UserDepartmentInfo; 11 | 12 | public interface PortalService { 13 | List getAllDepartments(String rootOrg); 14 | 15 | List getDeptNameList(); 16 | 17 | List getAllDept(); 18 | 19 | DeptPublicInfo searchDept(String deptName); 20 | 21 | DepartmentInfo getDepartmentById(Integer deptId, boolean isUserInfoRequired, String rootOrg); 22 | 23 | List getDepartmentsByUserId(String userId); 24 | 25 | UserDepartmentInfo addUserRoleInDepartment(UserDepartmentRole userDeptRole, String wid, String rootOrg, String org); 26 | 27 | UserDepartmentInfo updateUserRoleInDepartment(UserDepartmentRole userDeptRole, String wid, String rootOrg, 28 | String org); 29 | 30 | Boolean checkAdminPrivilage(Integer deptId, String userId, String rootOrg); 31 | 32 | Boolean checkMdoAdminPrivilage(String deptKey, String userId); 33 | 34 | DepartmentInfo getMyDepartmentDetails(String userId, boolean isUserInfoRequired); 35 | 36 | DepartmentInfo updateDepartment(DepartmentInfo deptInfo, String rootOrg); 37 | 38 | boolean isAdmin(String strDeptType, String roleName, String userId); 39 | 40 | boolean validateCBPUserLogin(String userId); 41 | 42 | boolean validateUserLogin(String userId, List roles, String departmentType); 43 | 44 | boolean validateUserLoginForDepartment(String userId, String departmentType); 45 | 46 | DepartmentInfo addDepartment(String authUserToken, String userId, String userRoleName, DepartmentInfo deptInfo, 47 | String rootOrg); 48 | 49 | DepartmentInfo getMyDepartment(String userId, String rootOrg); 50 | 51 | DepartmentInfo getMyDepartment(String deptType, String userId, boolean isUserInfoRequired, String rootOrg); 52 | 53 | DepartmentInfo getMyCbpDepartment(String userId, String rootOrg); 54 | 55 | DepartmentInfo getMyDepartmentForRole(String roleName, String userId, boolean isUserInfoRequired, String rootOrg); 56 | 57 | DepartmentInfo getMyDepartmentForRoles(List roleNames, String userId, boolean isUserInfoRequired, 58 | String rootOrg); 59 | 60 | List searchUserForRole(Integer deptId, String roleName, String userName); 61 | 62 | Boolean isUserActive(String userId); 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/OrgCreationProcessService.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import com.fasterxml.jackson.core.JsonProcessingException; 4 | import com.fasterxml.jackson.databind.ObjectMapper; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpEntity; 7 | import org.springframework.http.HttpHeaders; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.util.CollectionUtils; 10 | import org.springframework.util.ObjectUtils; 11 | import org.springframework.web.client.RestTemplate; 12 | import org.sunbird.common.util.CbExtServerProperties; 13 | import org.sunbird.core.logger.CbExtLogger; 14 | 15 | import java.util.HashMap; 16 | import java.util.Map; 17 | 18 | @Service 19 | public class OrgCreationProcessService { 20 | 21 | private CbExtLogger log = new CbExtLogger(getClass().getName()); 22 | 23 | @Autowired 24 | private CbExtServerProperties extServerProperties; 25 | 26 | @Autowired 27 | RestTemplate restTemplate; 28 | 29 | public void createOrg(Map orgObj) { 30 | log.info("Creating org to sb started ...."); 31 | ObjectMapper mapper = new ObjectMapper(); 32 | String orgName = (String) orgObj.get("orgName"); 33 | Map request = new HashMap<>(); 34 | HashMap innerReq = new HashMap<>(); 35 | innerReq.put("channel", orgName); 36 | innerReq.put("orgName", orgName); 37 | innerReq.put("isRootOrg", true); 38 | request.put("request", innerReq); 39 | HttpHeaders headers = new HttpHeaders(); 40 | headers.set("X-Authenticated-User-Token", (String) orgObj.get("userToken")); 41 | headers.set("Authorization", extServerProperties.getSbApiKey()); 42 | HttpEntity entity = new HttpEntity<>(request, headers); 43 | try { 44 | log.info(mapper.writeValueAsString(request)); 45 | } catch (JsonProcessingException e) { 46 | log.error(e); 47 | } 48 | Map response = restTemplate.postForObject(extServerProperties.getSbUrl() + extServerProperties.getOrgCreateEndPoint(), entity, Map.class); 49 | if(!CollectionUtils.isEmpty(response) && !ObjectUtils.isEmpty(response.get("result"))){ 50 | String orgId = (String)((Map)response.get("result")).get("organisationId"); 51 | log.info("Created org Id : " + orgId); 52 | log.info("Creating org to sb finished ...."); 53 | }else { 54 | log.info("Some exception occurred while creating the org ...."); 55 | } 56 | 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentSummaryModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.util.Date; 4 | 5 | import org.springframework.data.cassandra.core.mapping.Column; 6 | import org.springframework.data.cassandra.core.mapping.PrimaryKey; 7 | import org.springframework.data.cassandra.core.mapping.Table; 8 | 9 | @Table("user_assessment_summary") 10 | public class UserAssessmentSummaryModel { 11 | 12 | @PrimaryKey 13 | private UserAssessmentSummaryPrimaryKeyModel primaryKey; 14 | 15 | @Column("max_score") 16 | private Float firstMaxScore; 17 | 18 | @Column("max_score_date") 19 | private Date firstMaxScoreDate; 20 | 21 | @Column("first_passed_score") 22 | private Float firstPassesScore; 23 | 24 | @Column("first_passed_score_date") 25 | private Date firstPassesScoreDate; 26 | 27 | public UserAssessmentSummaryModel() { 28 | super(); 29 | } 30 | 31 | public UserAssessmentSummaryModel(UserAssessmentSummaryPrimaryKeyModel primaryKey, Float firstMaxScore, 32 | Date firstMaxScoreDate, Float firstPassesScore, Date firstPassesScoreDate) { 33 | super(); 34 | this.primaryKey = primaryKey; 35 | this.firstMaxScore = firstMaxScore; 36 | this.firstMaxScoreDate = firstMaxScoreDate; 37 | this.firstPassesScore = firstPassesScore; 38 | this.firstPassesScoreDate = firstPassesScoreDate; 39 | } 40 | 41 | public UserAssessmentSummaryPrimaryKeyModel getPrimaryKey() { 42 | return primaryKey; 43 | } 44 | 45 | public void setPrimaryKey(UserAssessmentSummaryPrimaryKeyModel primaryKey) { 46 | this.primaryKey = primaryKey; 47 | } 48 | 49 | public Float getFirstMaxScore() { 50 | return firstMaxScore; 51 | } 52 | 53 | public void setFirstMaxScore(Float firstMaxScore) { 54 | this.firstMaxScore = firstMaxScore; 55 | } 56 | 57 | public Date getFirstMaxScoreDate() { 58 | return firstMaxScoreDate; 59 | } 60 | 61 | public void setFirstMaxScoreDate(Date firstMaxScoreDate) { 62 | this.firstMaxScoreDate = firstMaxScoreDate; 63 | } 64 | 65 | public Float getFirstPassesScore() { 66 | return firstPassesScore; 67 | } 68 | 69 | public void setFirstPassesScore(Float firstPassesScore) { 70 | this.firstPassesScore = firstPassesScore; 71 | } 72 | 73 | public Date getFirstPassesScoreDate() { 74 | return firstPassesScoreDate; 75 | } 76 | 77 | public void setFirstPassesScoreDate(Date firstPassesScoreDate) { 78 | this.firstPassesScoreDate = firstPassesScoreDate; 79 | } 80 | 81 | @Override 82 | public String toString() { 83 | return "UserAssessmentSummaryModel [primaryKey=" + primaryKey + ", firstMaxScore=" + firstMaxScore 84 | + ", firstMaxScoreDate=" + firstMaxScoreDate + ", firstPassesScore=" + firstPassesScore 85 | + ", firstPassesScoreDate=" + firstPassesScoreDate + "]"; 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentMasterPrimaryKeyModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.io.Serializable; 4 | import java.math.BigDecimal; 5 | import java.util.Date; 6 | import java.util.UUID; 7 | 8 | import org.springframework.data.cassandra.core.cql.PrimaryKeyType; 9 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; 10 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; 11 | 12 | @PrimaryKeyClass 13 | public class UserAssessmentMasterPrimaryKeyModel implements Serializable { 14 | 15 | private static final long serialVersionUID = 1L; 16 | 17 | @PrimaryKeyColumn(name = "root_org", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 18 | private String rootOrg; 19 | 20 | @PrimaryKeyColumn(name = "ts_created", ordinal = 1, type = PrimaryKeyType.PARTITIONED) 21 | private Date tsCreated; 22 | 23 | @PrimaryKeyColumn(name = "parent_source_id", ordinal = 2, type = PrimaryKeyType.CLUSTERED) 24 | private String parentSourceId; 25 | 26 | @PrimaryKeyColumn(name = "result_percent", ordinal = 3, type = PrimaryKeyType.CLUSTERED) 27 | private BigDecimal resultPercent; 28 | 29 | @PrimaryKeyColumn(name = "id", ordinal = 3, type = PrimaryKeyType.CLUSTERED) 30 | private UUID id; 31 | 32 | public String getRootOrg() { 33 | return rootOrg; 34 | } 35 | 36 | public void setRootOrg(String rootOrg) { 37 | this.rootOrg = rootOrg; 38 | } 39 | 40 | public Date getTsCreated() { 41 | return tsCreated; 42 | } 43 | 44 | public void setTsCreated(Date tsCreated) { 45 | this.tsCreated = tsCreated; 46 | } 47 | 48 | public String getParentSourceId() { 49 | return parentSourceId; 50 | } 51 | 52 | public void setParentSourceId(String parentSourceId) { 53 | this.parentSourceId = parentSourceId; 54 | } 55 | 56 | public BigDecimal getResultPercent() { 57 | return resultPercent; 58 | } 59 | 60 | public void setResultPercent(BigDecimal resultPercent) { 61 | this.resultPercent = resultPercent; 62 | } 63 | 64 | public UUID getId() { 65 | return id; 66 | } 67 | 68 | public void setId(UUID id) { 69 | this.id = id; 70 | } 71 | 72 | public UserAssessmentMasterPrimaryKeyModel() { 73 | super(); 74 | } 75 | 76 | public UserAssessmentMasterPrimaryKeyModel(String rootOrg, Date tsCreated, String parentSourceId, 77 | BigDecimal resultPercent, UUID id) { 78 | this.rootOrg = rootOrg; 79 | this.tsCreated = tsCreated; 80 | this.parentSourceId = parentSourceId; 81 | this.resultPercent = resultPercent; 82 | this.id = id; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "UserAssessmentMasterPrimaryKeyModel [rootOrg=" + rootOrg + ", tsCreated=" + tsCreated 88 | + ", parentSourceId=" + parentSourceId + ", resultPercent=" + resultPercent + ", id=" + id + "]"; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserAssessmentTopPerformerPrimaryKeyModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.io.Serializable; 4 | import java.math.BigDecimal; 5 | import java.util.Date; 6 | import java.util.UUID; 7 | 8 | import org.springframework.data.cassandra.core.cql.PrimaryKeyType; 9 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass; 10 | import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn; 11 | 12 | @PrimaryKeyClass 13 | public class UserAssessmentTopPerformerPrimaryKeyModel implements Serializable { 14 | private static final long serialVersionUID = 1L; 15 | 16 | @PrimaryKeyColumn(name = "root_org", ordinal = 0, type = PrimaryKeyType.PARTITIONED) 17 | private String rootOrg; 18 | 19 | @PrimaryKeyColumn(name = "parent_source_id", ordinal = 1, type = PrimaryKeyType.PARTITIONED) 20 | private String parentSourceId; 21 | 22 | @PrimaryKeyColumn(name = "ts_created", ordinal = 2, type = PrimaryKeyType.CLUSTERED) 23 | private Date tsCreated; 24 | 25 | @PrimaryKeyColumn(name = "result_percent", ordinal = 3, type = PrimaryKeyType.CLUSTERED) 26 | private BigDecimal resultPercent; 27 | 28 | @PrimaryKeyColumn(name = "id", ordinal = 4, type = PrimaryKeyType.CLUSTERED) 29 | private UUID id; 30 | 31 | public String getRootOrg() { 32 | return rootOrg; 33 | } 34 | 35 | public void setRootOrg(String rootOrg) { 36 | this.rootOrg = rootOrg; 37 | } 38 | 39 | public String getParentSourceId() { 40 | return parentSourceId; 41 | } 42 | 43 | public void setParentSourceId(String parentSourceId) { 44 | this.parentSourceId = parentSourceId; 45 | } 46 | 47 | public Date getTsCreated() { 48 | return tsCreated; 49 | } 50 | 51 | public void setTsCreated(Date tsCreated) { 52 | this.tsCreated = tsCreated; 53 | } 54 | 55 | public BigDecimal getResultPercent() { 56 | return resultPercent; 57 | } 58 | 59 | public void setResultPercent(BigDecimal resultPercent) { 60 | this.resultPercent = resultPercent; 61 | } 62 | 63 | public UUID getId() { 64 | return id; 65 | } 66 | 67 | public void setId(UUID id) { 68 | this.id = id; 69 | } 70 | 71 | public UserAssessmentTopPerformerPrimaryKeyModel() { 72 | super(); 73 | } 74 | 75 | public UserAssessmentTopPerformerPrimaryKeyModel(String rootOrg, String parentSourceId, Date tsCreated, 76 | BigDecimal resultPercent, UUID id) { 77 | this.rootOrg = rootOrg; 78 | this.parentSourceId = parentSourceId; 79 | this.tsCreated = tsCreated; 80 | this.resultPercent = resultPercent; 81 | this.id = id; 82 | this.rootOrg = rootOrg; 83 | } 84 | 85 | @Override 86 | public String toString() { 87 | return "UserAssessmentTopPerformerPrimaryKeyModel [rootOrg=" + rootOrg + ", parentSourceId=" + parentSourceId 88 | + ", tsCreated=" + tsCreated + ", resultPercent=" + resultPercent + ", id=" + id + "]"; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/dto/GenericArrayUserType.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.dto; 2 | 3 | import java.io.Serializable; 4 | import java.sql.Array; 5 | import java.sql.Connection; 6 | import java.sql.PreparedStatement; 7 | import java.sql.ResultSet; 8 | import java.sql.SQLException; 9 | import java.sql.Types; 10 | 11 | import org.hibernate.HibernateException; 12 | import org.hibernate.engine.spi.SharedSessionContractImplementor; 13 | import org.hibernate.usertype.UserType; 14 | 15 | public class GenericArrayUserType implements UserType { 16 | protected static final int[] SQL_TYPES = { Types.ARRAY }; 17 | private Class typeParameterClass; 18 | 19 | @Override 20 | public Object assemble(Serializable cached, Object owner) throws HibernateException { 21 | return this.deepCopy(cached); 22 | } 23 | 24 | @Override 25 | public Object deepCopy(Object value) throws HibernateException { 26 | return value; 27 | } 28 | 29 | @SuppressWarnings("unchecked") 30 | @Override 31 | public Serializable disassemble(Object value) throws HibernateException { 32 | return (T) this.deepCopy(value); 33 | } 34 | 35 | @Override 36 | public boolean equals(Object x, Object y) throws HibernateException { 37 | if (x == null) { 38 | return y == null; 39 | } 40 | return x.equals(y); 41 | } 42 | 43 | @Override 44 | public int hashCode(Object x) throws HibernateException { 45 | return x.hashCode(); 46 | } 47 | 48 | @Override 49 | public boolean isMutable() { 50 | return true; 51 | } 52 | 53 | @Override 54 | public Object replace(Object original, Object target, Object owner) throws HibernateException { 55 | return original; 56 | } 57 | 58 | @Override 59 | public Class returnedClass() { 60 | return typeParameterClass; 61 | } 62 | 63 | @Override 64 | public int[] sqlTypes() { 65 | return new int[] { Types.ARRAY }; 66 | } 67 | 68 | @Override 69 | public Object nullSafeGet(ResultSet rs, String[] names, SharedSessionContractImplementor session, Object owner) 70 | throws HibernateException, SQLException { 71 | if (rs.wasNull()) { 72 | return null; 73 | } 74 | if (rs.getArray(names[0]) == null) { 75 | return new Integer[0]; 76 | } 77 | 78 | Array array = rs.getArray(names[0]); 79 | @SuppressWarnings("unchecked") 80 | T javaArray = (T) array.getArray(); 81 | return javaArray; 82 | } 83 | 84 | @Override 85 | public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) 86 | throws HibernateException, SQLException { 87 | Connection connection = st.getConnection(); 88 | if (value == null) { 89 | st.setNull(index, SQL_TYPES[0]); 90 | } else { 91 | @SuppressWarnings("unchecked") 92 | T castObject = (T) value; 93 | Array array = connection.createArrayOf("integer", (Object[]) castObject); 94 | st.setArray(index, array); 95 | } 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/config/SunbirdConfig.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.config; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Primary; 10 | import org.springframework.data.cassandra.config.CassandraClusterFactoryBean; 11 | import org.springframework.data.cassandra.config.CassandraSessionFactoryBean; 12 | import org.springframework.data.cassandra.core.CassandraAdminTemplate; 13 | import org.springframework.data.cassandra.repository.config.EnableCassandraRepositories; 14 | 15 | import com.datastax.driver.core.AuthProvider; 16 | import com.datastax.driver.core.PlainTextAuthProvider; 17 | 18 | @Configuration 19 | @ConfigurationProperties("spring.data.cassandra.sb") 20 | @EnableCassandraRepositories(basePackages = { "org.sunbird.progress.cassandraRepo", "org.sunbird.assessment.repo", 21 | "org.sunbird.workallocation.repo" }, cassandraTemplateRef = "sunbirdTemplate") 22 | public class SunbirdConfig extends CassandraConfig { 23 | 24 | private Logger logger = LoggerFactory.getLogger(SunbirdConfig.class); 25 | 26 | @Value("${spring.data.cassandra.sb.username}") 27 | private String sunbirdUser; 28 | 29 | @Value("${spring.data.cassandra.sb.password}") 30 | private String sunbirdPassword; 31 | 32 | @Override 33 | @Primary 34 | @Bean(name = "sunbirdTemplate") 35 | public CassandraAdminTemplate cassandraTemplate() throws Exception { 36 | return new CassandraAdminTemplate(session().getObject(), cassandraConverter()); 37 | } 38 | 39 | @Override 40 | @Bean(name = "sunbirdSession") 41 | public CassandraSessionFactoryBean session() { 42 | 43 | AuthProvider authProvider = new PlainTextAuthProvider(sunbirdUser, sunbirdPassword); 44 | 45 | CassandraClusterFactoryBean cluster = new CassandraClusterFactoryBean(); 46 | cluster.setContactPoints(getContactPoints()); 47 | cluster.setPort(getPort()); 48 | cluster.setAuthProvider(authProvider); 49 | cluster.setJmxReportingEnabled(false); 50 | try { 51 | cluster.afterPropertiesSet(); 52 | } catch (Exception e) { 53 | logger.error("Failed to construct Cassandra Cluster Object. ", e); 54 | return null; 55 | } 56 | 57 | CassandraSessionFactoryBean session = new CassandraSessionFactoryBean(); 58 | session.setCluster(cluster.getObject()); 59 | session.setConverter(cassandraConverter()); 60 | session.setKeyspaceName(getKeyspaceName()); 61 | session.setSchemaAction(getSchemaAction()); 62 | session.setStartupScripts(getStartupScripts()); 63 | session.setShutdownScripts(getShutdownScripts()); 64 | logger.info(String.format("Cassandra session created for %s keyspace with IP : %s", getKeyspaceName(), 65 | getContactPoints())); 66 | return session; 67 | } 68 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/catalog/service/CatalogServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.catalog.service; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpEntity; 7 | import org.springframework.http.HttpHeaders; 8 | import org.springframework.http.HttpMethod; 9 | import org.springframework.http.ResponseEntity; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.web.client.RestTemplate; 12 | import org.sunbird.catalog.model.Catalog; 13 | import org.sunbird.catalog.model.Category; 14 | import org.sunbird.catalog.model.Framework; 15 | import org.sunbird.catalog.model.FrameworkResponse; 16 | import org.sunbird.common.util.CbExtServerProperties; 17 | 18 | import com.fasterxml.jackson.databind.ObjectMapper; 19 | 20 | @Service 21 | public class CatalogServiceImpl { 22 | 23 | private Logger log = LoggerFactory.getLogger(CatalogServiceImpl.class); 24 | 25 | @Autowired 26 | RestTemplate restTemplate; 27 | 28 | @Autowired 29 | private CbExtServerProperties extServerProperties; 30 | 31 | public Catalog getCatalog(String authUserToken, boolean isEnrichConsumption) { 32 | return fetchCatalog(authUserToken, isEnrichConsumption); 33 | } 34 | 35 | private Catalog fetchCatalog(String authUserToken, boolean isEnrichConsumption) { 36 | log.info("Fetching Framework details..."); 37 | ObjectMapper mapper = new ObjectMapper(); 38 | HttpHeaders headers = new HttpHeaders(); 39 | headers.set("X-Authenticated-User-Token", authUserToken); 40 | headers.set("Authorization", extServerProperties.getSbApiKey()); 41 | HttpEntity entity = new HttpEntity<>(headers); 42 | 43 | ResponseEntity responseStr = restTemplate.exchange(extServerProperties.getKmBaseHost() 44 | + extServerProperties.getKmFrameWorkPath() + extServerProperties.getTaxonomyFrameWorkName(), 45 | HttpMethod.GET, entity, String.class); 46 | FrameworkResponse response; 47 | try { 48 | response = mapper.readValue(responseStr.getBody(), FrameworkResponse.class); 49 | if (response != null && "successful".equalsIgnoreCase(response.getParams().getStatus())) { 50 | return processResponse(response.getResult().getFramework(), isEnrichConsumption); 51 | } else { 52 | log.info("Some exception occurred while creating the org ...."); 53 | } 54 | } catch (Exception e) { 55 | log.error("Failed to read response data. Exception: ", e); 56 | } 57 | return new Catalog(); 58 | } 59 | 60 | private Catalog processResponse(Framework framework, boolean isEnrichConsumption) { 61 | Catalog catalog = new Catalog(); 62 | for (Category c : framework.getCategories()) { 63 | if (c.getName() != null && c.getName().equalsIgnoreCase(extServerProperties.getTaxonomyCategoryName())) { 64 | catalog.setTerms(c.getTerms()); 65 | } 66 | } 67 | 68 | // TODO - Enrich Consumption details for the given term name. 69 | return catalog; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/config/ConsumerConfiguration.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.config; 2 | 3 | import org.apache.kafka.clients.consumer.ConsumerConfig; 4 | import org.apache.kafka.common.serialization.StringDeserializer; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory; 9 | import org.springframework.kafka.config.KafkaListenerContainerFactory; 10 | import org.springframework.kafka.core.ConsumerFactory; 11 | import org.springframework.kafka.core.DefaultKafkaConsumerFactory; 12 | import org.springframework.kafka.listener.ConcurrentMessageListenerContainer; 13 | 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | 17 | @Configuration 18 | public class ConsumerConfiguration { 19 | 20 | @Value("${spring.kafka.bootstrap.servers}") 21 | private String kafkabootstrapAddress; 22 | 23 | @Value("${kakfa.offset.reset.value}") 24 | private String kafkaOffsetResetValue; 25 | 26 | @Value("${kafka.max.poll.interval.ms}") 27 | private Integer kafkaMaxPollInterval; 28 | 29 | @Value("${kafka.max.poll.records}") 30 | private Integer kafkaMaxPollRecords; 31 | 32 | 33 | @Bean 34 | KafkaListenerContainerFactory> kafkaListenerContainerFactory() { 35 | 36 | ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory<>(); 37 | factory.setConsumerFactory(consumerFactory()); 38 | factory.setConcurrency(4); 39 | factory.getContainerProperties().setPollTimeout(3000); 40 | return factory; 41 | } 42 | 43 | @Bean 44 | public ConsumerFactory consumerFactory() { 45 | return new DefaultKafkaConsumerFactory<>(consumerConfigs()); 46 | 47 | } 48 | 49 | @Bean 50 | public Map consumerConfigs() { 51 | Map propsMap = new HashMap<>(); 52 | propsMap.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, kafkabootstrapAddress); 53 | propsMap.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, true); 54 | propsMap.put(ConsumerConfig.FETCH_MAX_WAIT_MS_CONFIG, "1000"); 55 | propsMap.put(ConsumerConfig.AUTO_COMMIT_INTERVAL_MS_CONFIG, "1000"); 56 | propsMap.put(ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG, "15000"); 57 | propsMap.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 58 | propsMap.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class); 59 | propsMap.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, kafkaOffsetResetValue); 60 | propsMap.put(ConsumerConfig.MAX_POLL_INTERVAL_MS_CONFIG, kafkaMaxPollInterval); 61 | propsMap.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, kafkaMaxPollRecords); 62 | return propsMap; 63 | } 64 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/ContentCreateRequest.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import java.util.List; 4 | public class ContentCreateRequest { 5 | private String name; 6 | private String creator; 7 | private String createdBy; 8 | private String code; 9 | private String mimeType; 10 | private String contentType; 11 | private String primaryCategory; 12 | private List organisation; 13 | 14 | public ContentCreateRequest(String name, String creator, String createdBy, String code, String mimeType, String contentType, String primaryCategory, List organisation, List createdFor) { 15 | this.name = name; 16 | this.creator = creator; 17 | this.createdBy = createdBy; 18 | this.code = code; 19 | this.mimeType = mimeType; 20 | this.contentType = contentType; 21 | this.primaryCategory = primaryCategory; 22 | this.organisation = organisation; 23 | this.createdFor = createdFor; 24 | } 25 | public ContentCreateRequest () { 26 | 27 | } 28 | 29 | private List createdFor; 30 | 31 | public String getName() { 32 | return name; 33 | } 34 | 35 | public void setName(String name) { 36 | this.name = name; 37 | } 38 | 39 | public String getCreator() { 40 | return creator; 41 | } 42 | 43 | public void setCreator(String creator) { 44 | this.creator = creator; 45 | } 46 | 47 | public String getCreatedBy() { 48 | return createdBy; 49 | } 50 | 51 | public void setCreatedBy(String createdBy) { 52 | this.createdBy = createdBy; 53 | } 54 | 55 | public String getCode() { 56 | return code; 57 | } 58 | 59 | public void setCode(String code) { 60 | this.code = code; 61 | } 62 | 63 | public String getMimeType() { 64 | return mimeType; 65 | } 66 | 67 | public void setMimeType(String mimeType) { 68 | this.mimeType = mimeType; 69 | } 70 | 71 | public String getContentType() { 72 | return contentType; 73 | } 74 | 75 | public void setContentType(String contentType) { 76 | this.contentType = contentType; 77 | } 78 | 79 | public String getPrimaryCategory() { 80 | return primaryCategory; 81 | } 82 | 83 | public void setPrimaryCategory(String primaryCategory) { 84 | this.primaryCategory = primaryCategory; 85 | } 86 | 87 | public List getOrganisation() { 88 | return organisation; 89 | } 90 | 91 | public void setOrganisation(List organisation) { 92 | this.organisation = organisation; 93 | } 94 | 95 | public List getCreatedFor() { 96 | return createdFor; 97 | } 98 | 99 | public void setCreatedFor(List createdFor) { 100 | this.createdFor = createdFor; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/SpvPortalServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import java.util.List; 4 | import java.util.Optional; 5 | 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | import org.springframework.http.HttpStatus; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.util.ObjectUtils; 10 | import org.sunbird.common.model.Response; 11 | import org.sunbird.common.util.Constants; 12 | import org.sunbird.core.exception.BadRequestException; 13 | import org.sunbird.portal.department.PortalConstants; 14 | import org.sunbird.portal.department.dto.Department; 15 | import org.sunbird.portal.department.model.DepartmentInfo; 16 | import org.sunbird.portal.department.repo.DepartmentRepository; 17 | import org.sunbird.portal.department.repo.DepartmentTypeRepository; 18 | import org.sunbird.portal.department.repo.RoleRepository; 19 | import org.sunbird.portal.department.repo.UserDepartmentRoleRepository; 20 | 21 | @Service 22 | public class SpvPortalServiceImpl implements SpvPortalService { 23 | @Autowired 24 | PortalService portalService; 25 | 26 | @Autowired 27 | UserDepartmentRoleRepository userDepartmentRoleRepo; 28 | 29 | @Autowired 30 | RoleRepository roleRepo; 31 | 32 | @Autowired 33 | DepartmentRepository deptRepo; 34 | 35 | @Autowired 36 | DepartmentTypeRepository deptTypeRepo; 37 | 38 | @Override 39 | public List getAllDepartments(String rootOrg) throws Exception { 40 | return portalService.getAllDepartments(rootOrg); 41 | } 42 | 43 | @Override 44 | public DepartmentInfo getMyDepartment(String userId, boolean isUserInfoRequired, String rootOrg) throws Exception { 45 | return portalService.getMyDepartment(PortalConstants.SPV_DEPT_TYPE, userId, isUserInfoRequired, rootOrg); 46 | } 47 | 48 | @Override 49 | public DepartmentInfo addDepartment(String authUserToken, String userId, DepartmentInfo deptInfo, String rootOrg) throws Exception { 50 | return portalService.addDepartment(authUserToken, userId, PortalConstants.SPV_ROLE_NAME, deptInfo, rootOrg); 51 | } 52 | 53 | @Override 54 | public DepartmentInfo updateDepartment(DepartmentInfo deptInfo, String rootOrg) throws Exception { 55 | return portalService.updateDepartment(deptInfo, rootOrg); 56 | } 57 | 58 | @Override 59 | public DepartmentInfo getDepartmentById(Integer deptId, boolean isUserInfoRequired, String rootOrg) 60 | throws Exception { 61 | return portalService.getDepartmentById(deptId, isUserInfoRequired, rootOrg); 62 | } 63 | 64 | @Override 65 | public Response deleteDepartment(String userId, Integer deptId) { 66 | Optional dept = deptRepo.findByIdAndIsDeleted(deptId, false); 67 | if (dept.isPresent()) { 68 | Department department = dept.get(); 69 | department.setIsDeleted(true); 70 | deptRepo.save(department); 71 | } 72 | else { 73 | throw new BadRequestException("No department exists on given id!"); 74 | } 75 | Response response = new Response(); 76 | response.put(Constants.MESSAGE, Constants.SUCCESSFUL); 77 | response.put(Constants.STATUS, HttpStatus.OK); 78 | return response; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/service/DepartmentTypeServiceImpl.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.service; 2 | 3 | import java.util.*; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import org.sunbird.core.exception.BadRequestException; 8 | import org.sunbird.portal.department.dto.DepartmentType; 9 | import org.sunbird.portal.department.repo.DepartmentTypeRepository; 10 | 11 | import org.sunbird.common.util.DataValidator; 12 | 13 | @Service 14 | public class DepartmentTypeServiceImpl implements DepartmentTypeService { 15 | 16 | @Autowired 17 | private DepartmentTypeRepository deptTypeRepo; 18 | 19 | @Override 20 | public Map> getAllDepartmentTypes() { 21 | 22 | Iterable deptTypes = deptTypeRepo.findAll(); 23 | if (!DataValidator.isCollectionEmpty(deptTypes)) { 24 | Map> retValue = new HashMap<>(); 25 | Iterator it = deptTypes.iterator(); 26 | while (it.hasNext()) { 27 | DepartmentType dType = it.next(); 28 | if (retValue.containsKey(dType.getDeptType())) { 29 | retValue.get(dType.getDeptType()).add(dType); 30 | } else { 31 | List deptTypeList = new ArrayList<>(); 32 | deptTypeList.add(dType); 33 | retValue.put(dType.getDeptType(), deptTypeList); 34 | } 35 | } 36 | 37 | return retValue; 38 | } 39 | 40 | return null; 41 | } 42 | 43 | @Override 44 | public List getDepartmentByType(String deptType) { 45 | return deptTypeRepo.findByDeptTypeIgnoreCase(deptType); 46 | } 47 | 48 | @Override 49 | public DepartmentType getDepartmentTypeById(Integer id) throws Exception { 50 | Optional departmentType = deptTypeRepo.findById(id); 51 | if (departmentType.isPresent()) { 52 | return departmentType.get(); 53 | } else { 54 | throw new BadRequestException("Failed to get the Department type . On Id : " + id); 55 | } 56 | } 57 | 58 | @Override 59 | public Map> getDepartmentTypeNames() { 60 | Iterable deptTypes = deptTypeRepo.findAll(); 61 | if (!DataValidator.isCollectionEmpty(deptTypes)) { 62 | Map> retValue = new HashMap<>(); 63 | // for (Object o : deptTypes) { 64 | // Object[] dTypes = (Object[]) o; 65 | // String deptType = (String) dTypes[0]; 66 | // String deptSubType = (String) dTypes[1]; 67 | // if (retValue.containsKey(deptType)) { 68 | // retValue.get(deptType).add(deptSubType); 69 | // } else { 70 | // List deptSubTypes = new ArrayList(); 71 | // deptSubTypes.add(deptSubType); 72 | // retValue.put(deptType, deptSubTypes); 73 | // } 74 | // } 75 | for(DepartmentType dType : deptTypes) { 76 | if (retValue.containsKey(dType.getDeptType())) { 77 | retValue.get(dType.getDeptType()).add(dType.getDeptSubType()); 78 | } else { 79 | List deptTypeList = new ArrayList<>(); 80 | deptTypeList.add(dType.getDeptSubType()); 81 | retValue.put(dType.getDeptType(), deptTypeList); 82 | } 83 | } 84 | return retValue; 85 | } 86 | return null; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/controller/AllocationController.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.controller; 2 | 3 | import org.springframework.beans.factory.annotation.Autowired; 4 | import org.springframework.http.HttpHeaders; 5 | import org.springframework.http.HttpStatus; 6 | import org.springframework.http.MediaType; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.GetMapping; 9 | import org.springframework.web.bind.annotation.PathVariable; 10 | import org.springframework.web.bind.annotation.PostMapping; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestHeader; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.bind.annotation.RestController; 16 | import org.sunbird.common.model.Response; 17 | import org.sunbird.workallocation.model.SearchCriteria; 18 | import org.sunbird.workallocation.model.WorkAllocationDTO; 19 | import org.sunbird.workallocation.service.AllocationService; 20 | 21 | @RestController 22 | @RequestMapping("/v1/workallocation") 23 | public class AllocationController { 24 | 25 | @Autowired 26 | private AllocationService allocationService; 27 | 28 | @PostMapping("/add") 29 | public ResponseEntity add(@RequestHeader("Authorization") String authUserToken, 30 | @RequestHeader("userId") String userId, @RequestBody WorkAllocationDTO workAllocation) { 31 | return new ResponseEntity<>(allocationService.addWorkAllocation(authUserToken, userId, workAllocation), 32 | HttpStatus.OK); 33 | } 34 | 35 | @PostMapping("/update") 36 | public ResponseEntity update(@RequestHeader("Authorization") String authUserToken, 37 | @RequestHeader("userId") String userId, @RequestBody WorkAllocationDTO workAllocation) { 38 | return new ResponseEntity<>(allocationService.updateWorkAllocation(authUserToken, userId, workAllocation), 39 | HttpStatus.OK); 40 | } 41 | 42 | @PostMapping("/getUsers") 43 | public ResponseEntity getUsers(@RequestBody SearchCriteria searchCriteria) { 44 | return new ResponseEntity<>(allocationService.getUsers(searchCriteria), HttpStatus.OK); 45 | } 46 | 47 | @GetMapping("/users/autocomplete") 48 | public ResponseEntity userAutoComplete(@RequestParam("searchTerm") String searchTerm) { 49 | return new ResponseEntity<>(allocationService.userAutoComplete(searchTerm), HttpStatus.OK); 50 | } 51 | 52 | @GetMapping(value = "/getWAPdf/{userId}/{waId}", produces = MediaType.APPLICATION_PDF_VALUE) 53 | public ResponseEntity getWAPdf(@PathVariable("userId") String userId, @PathVariable("waId") String waId) 54 | throws Exception { 55 | byte[] out = null; 56 | try { 57 | out = allocationService.getWaPdf(userId, waId); 58 | } catch (Exception e) { 59 | } 60 | 61 | if (out == null) { 62 | throw new InternalError("Failed to generate PDF file."); 63 | } 64 | 65 | HttpHeaders headers = new HttpHeaders(); 66 | headers.setContentType(MediaType.APPLICATION_PDF); 67 | headers.add("Content-Disposition", "inline; filename=wa_report.pdf"); 68 | 69 | ResponseEntity response = new ResponseEntity<>(out, headers, HttpStatus.OK); 70 | 71 | return response; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/controller/RoleController.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.controller; 2 | 3 | import javax.validation.Valid; 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.http.HttpStatus; 7 | import org.springframework.http.ResponseEntity; 8 | import org.springframework.web.bind.annotation.DeleteMapping; 9 | import org.springframework.web.bind.annotation.GetMapping; 10 | import org.springframework.web.bind.annotation.PatchMapping; 11 | import org.springframework.web.bind.annotation.PathVariable; 12 | import org.springframework.web.bind.annotation.PostMapping; 13 | import org.springframework.web.bind.annotation.RequestBody; 14 | import org.springframework.web.bind.annotation.RestController; 15 | import org.sunbird.core.exception.BadRequestException; 16 | import org.sunbird.portal.department.dto.DepartmentRole; 17 | import org.sunbird.portal.department.dto.Role; 18 | import org.sunbird.portal.department.service.RoleService; 19 | 20 | import java.util.Set; 21 | 22 | @RestController 23 | public class RoleController { 24 | 25 | @Autowired 26 | RoleService roleService; 27 | 28 | @GetMapping("/portal/role") 29 | public ResponseEntity> getAllRoles(){ 30 | return new ResponseEntity<>(roleService.getAllRoles(), HttpStatus.OK); 31 | } 32 | 33 | @GetMapping("/portal/role/{role_id}") 34 | public ResponseEntity getRoleById(@PathVariable("role_id") Integer roleId) throws Exception { 35 | return new ResponseEntity<>(roleService.getRoleById(roleId), HttpStatus.OK); 36 | } 37 | 38 | @PostMapping("/portal/role") 39 | public ResponseEntity addRole(@Valid @RequestBody Role role) throws Exception { 40 | return new ResponseEntity<>(roleService.addRole(role), HttpStatus.OK); 41 | } 42 | 43 | @PatchMapping("/portal/role") 44 | public ResponseEntity updateRole(@Valid @RequestBody Role role) throws Exception { 45 | return new ResponseEntity<>(roleService.updateRole(role), HttpStatus.OK); 46 | } 47 | 48 | @GetMapping("/portal/deptRole") 49 | public ResponseEntity> getAllDepartmentRoles(){ 50 | return new ResponseEntity<>(roleService.getAllDepartmentRoles(), HttpStatus.OK); 51 | } 52 | 53 | @GetMapping("/portal/deptRole/{deptType}") 54 | public ResponseEntity getDepartmentRolesById(@PathVariable("deptType") String deptType) 55 | throws BadRequestException { 56 | return new ResponseEntity<>(roleService.getDepartmentRoleById(deptType), HttpStatus.OK); 57 | } 58 | 59 | @PostMapping("/portal/deptRole") 60 | public ResponseEntity addDepartmentRole(@Valid @RequestBody DepartmentRole deptRole) 61 | throws Exception { 62 | return new ResponseEntity<>(roleService.addDepartmentRole(deptRole), HttpStatus.OK); 63 | } 64 | 65 | @DeleteMapping("/portal/deptRole/{dept_role_id}") 66 | public ResponseEntity removeDepartmentRole(@PathVariable("dept_role_id") Integer deptRoleId) 67 | throws Exception { 68 | return new ResponseEntity<>(roleService.removeDepartmentRole(deptRoleId), HttpStatus.OK); 69 | } 70 | 71 | @GetMapping("/portal/{user_id}/roles") 72 | public ResponseEntity> getUserRoles(@PathVariable("user_id") String userId) 73 | throws BadRequestException { 74 | return new ResponseEntity<>(roleService.getUserRoles(userId), HttpStatus.OK); 75 | } 76 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiRespContent.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | public class SunbirdApiRespContent { 6 | 7 | private String rootOrgName; 8 | private String channel; 9 | private String id; 10 | 11 | private String identifier; 12 | private String rootOrgId; 13 | 14 | private String firstName; 15 | private String dob; 16 | 17 | private String userType; 18 | 19 | private String lastName; 20 | 21 | private String gender; 22 | 23 | private List roles; 24 | 25 | private String countryCode; 26 | 27 | private String email; 28 | 29 | private String userName; 30 | 31 | private List organisations; 32 | 33 | public String getRootOrgName() { 34 | return rootOrgName; 35 | } 36 | 37 | public void setRootOrgName(String rootOrgName) { 38 | this.rootOrgName = rootOrgName; 39 | } 40 | 41 | public String getChannel() { 42 | return channel; 43 | } 44 | 45 | public void setChannel(String channel) { 46 | this.channel = channel; 47 | } 48 | 49 | public String getId() { 50 | return id; 51 | } 52 | 53 | public void setId(String id) { 54 | this.id = id; 55 | } 56 | 57 | public String getIdentifier() { 58 | return identifier; 59 | } 60 | 61 | public void setIdentifier(String identifier) { 62 | this.identifier = identifier; 63 | } 64 | 65 | public String getRootOrgId() { 66 | return rootOrgId; 67 | } 68 | 69 | public void setRootOrgId(String rootOrgId) { 70 | this.rootOrgId = rootOrgId; 71 | } 72 | 73 | public String getFirstName() { 74 | return firstName; 75 | } 76 | 77 | public void setFirstName(String firstName) { 78 | this.firstName = firstName; 79 | } 80 | 81 | public String getDob() { 82 | return dob; 83 | } 84 | 85 | public void setDob(String dob) { 86 | this.dob = dob; 87 | } 88 | 89 | public String getUserType() { 90 | return userType; 91 | } 92 | 93 | public void setUserType(String userType) { 94 | this.userType = userType; 95 | } 96 | 97 | public String getLastName() { 98 | return lastName; 99 | } 100 | 101 | public void setLastName(String lastName) { 102 | this.lastName = lastName; 103 | } 104 | 105 | public String getGender() { 106 | return gender; 107 | } 108 | 109 | public void setGender(String gender) { 110 | this.gender = gender; 111 | } 112 | 113 | public List getRoles() { 114 | return roles; 115 | } 116 | 117 | public void setRoles(List roles) { 118 | this.roles = roles; 119 | } 120 | 121 | public String getCountryCode() { 122 | return countryCode; 123 | } 124 | 125 | public void setCountryCode(String countryCode) { 126 | this.countryCode = countryCode; 127 | } 128 | 129 | public String getEmail() { 130 | return email; 131 | } 132 | 133 | public void setEmail(String email) { 134 | this.email = email; 135 | } 136 | 137 | public String getUserName() { 138 | return userName; 139 | } 140 | 141 | public void setUserName(String userName) { 142 | this.userName = userName; 143 | } 144 | 145 | public List getOrganisations() { 146 | return organisations; 147 | } 148 | 149 | public void setOrganisations(List organisations) { 150 | this.organisations = organisations; 151 | } 152 | 153 | 154 | } 155 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/dto/UserDepartmentRole.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.dto; 2 | 3 | import java.util.List; 4 | 5 | import javax.persistence.Column; 6 | import javax.persistence.Entity; 7 | import javax.persistence.GeneratedValue; 8 | import javax.persistence.GenerationType; 9 | import javax.persistence.Id; 10 | import javax.persistence.Table; 11 | import javax.persistence.Transient; 12 | import javax.validation.constraints.NotNull; 13 | 14 | import org.hibernate.annotations.Type; 15 | 16 | @Entity 17 | @Table(name = "user_department_role", schema = "wingspan") 18 | public class UserDepartmentRole { 19 | @Id 20 | @Column(name = "id") 21 | @GeneratedValue(strategy = GenerationType.IDENTITY) 22 | private Integer id; 23 | 24 | @Column(name = "user_id") 25 | @NotNull 26 | private String userId; 27 | 28 | @Column(name = "dept_id") 29 | @NotNull 30 | private Integer deptId; 31 | 32 | @Column(name = "role_ids") 33 | @NotNull 34 | @Type(type = "org.sunbird.portal.department.dto.GenericArrayUserType") 35 | private Integer[] roleIds; 36 | 37 | @Column(name = "isactive") 38 | @NotNull 39 | private Boolean isActive; 40 | 41 | @Column(name = "isblocked") 42 | @NotNull 43 | private Boolean isBlocked; 44 | 45 | @Transient 46 | private List roles; 47 | 48 | @Column(name = "source_user_id") 49 | private String sourceUserId; 50 | 51 | public UserDepartmentRole() { 52 | } 53 | 54 | public UserDepartmentRole(Integer id, String userId, String sourceUserId, Integer deptId, Integer[] roleIds, 55 | Boolean isActive) { 56 | this.id = id; 57 | this.userId = userId; 58 | this.sourceUserId = sourceUserId; 59 | this.deptId = deptId; 60 | this.roleIds = roleIds; 61 | this.isActive = isActive; 62 | } 63 | 64 | public Integer getId() { 65 | return id; 66 | } 67 | 68 | public void setId(int id) { 69 | this.id = id; 70 | } 71 | 72 | public String getUserId() { 73 | return userId; 74 | } 75 | 76 | public void setUserId(String userId) { 77 | this.userId = userId; 78 | } 79 | 80 | public Integer getDeptId() { 81 | return deptId; 82 | } 83 | 84 | public void setDeptId(Integer deptId) { 85 | this.deptId = deptId; 86 | } 87 | 88 | public Integer[] getRoleIds() { 89 | return roleIds; 90 | } 91 | 92 | public void setRoleIds(Integer[] roleIds) { 93 | this.roleIds = roleIds; 94 | } 95 | 96 | public Boolean getIsActive() { 97 | return isActive; 98 | } 99 | 100 | public void setIsActive(Boolean isActive) { 101 | this.isActive = isActive; 102 | } 103 | 104 | public Boolean getIsBlocked() { 105 | return isBlocked; 106 | } 107 | 108 | public void setIsBlocked(Boolean isBlocked) { 109 | this.isBlocked = isBlocked; 110 | } 111 | 112 | public List getRoles() { 113 | return roles; 114 | } 115 | 116 | public void setRoles(List roles) { 117 | this.roles = roles; 118 | } 119 | 120 | public String getSourceUserId() { 121 | return sourceUserId; 122 | } 123 | 124 | public void setSourceUserId(String sourceUserId) { 125 | this.sourceUserId = sourceUserId; 126 | } 127 | 128 | public void setId(Integer id) { 129 | this.id = id; 130 | } 131 | 132 | public String toString() { 133 | return "[UserDepartmentRole = " + ", Id: " + ((id == null) ? 0 : id) + ", userId: " + userId 134 | + ", sourceUserId: " + sourceUserId + ", DeptRoleId: " + roleIds + ", isActive: " + isActive 135 | + ", isBlocked: " + isBlocked + "]"; 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/workallocation/model/ChildNode.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.workallocation.model; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | @JsonIgnoreProperties(ignoreUnknown = true) 6 | public class ChildNode { 7 | private String type; 8 | private String id; 9 | private String name; 10 | private String description; 11 | private String status; 12 | private String source; 13 | private String parentRole; 14 | private String submittedFromId; 15 | private String submittedFromName; 16 | private String submittedFromEmail; 17 | private String submittedToId; 18 | private String submittedToName; 19 | private String submittedToEmail; 20 | private String level; 21 | 22 | public String getType() { 23 | return type; 24 | } 25 | 26 | public void setType(String type) { 27 | this.type = type; 28 | } 29 | 30 | public String getId() { 31 | return id; 32 | } 33 | 34 | public void setId(String id) { 35 | this.id = id; 36 | } 37 | 38 | public String getName() { 39 | return name; 40 | } 41 | 42 | public void setName(String name) { 43 | this.name = name; 44 | } 45 | 46 | public String getDescription() { 47 | return description; 48 | } 49 | 50 | public void setDescription(String description) { 51 | this.description = description; 52 | } 53 | 54 | public String getStatus() { 55 | return status; 56 | } 57 | 58 | public void setStatus(String status) { 59 | this.status = status; 60 | } 61 | 62 | public String getSource() { 63 | return source; 64 | } 65 | 66 | public void setSource(String source) { 67 | this.source = source; 68 | } 69 | 70 | public String getParentRole() { 71 | return parentRole; 72 | } 73 | 74 | public void setParentRole(String parentRole) { 75 | this.parentRole = parentRole; 76 | } 77 | 78 | public String getLevel() { 79 | return level; 80 | } 81 | 82 | public void setLevel(String level) { 83 | this.level = level; 84 | } 85 | 86 | public ChildNode getFracRequest(String source) { 87 | ChildNode newCN = new ChildNode(); 88 | newCN.setName(name); 89 | newCN.setSource(source); 90 | newCN.setType("ACTIVITY"); 91 | return newCN; 92 | } 93 | 94 | public String getSubmittedFromId() { 95 | return submittedFromId; 96 | } 97 | 98 | public void setSubmittedFromId(String submittedFromId) { 99 | this.submittedFromId = submittedFromId; 100 | } 101 | 102 | public String getSubmittedFromName() { 103 | return submittedFromName; 104 | } 105 | 106 | public void setSubmittedFromName(String submittedFromName) { 107 | this.submittedFromName = submittedFromName; 108 | } 109 | 110 | public String getSubmittedFromEmail() { 111 | return submittedFromEmail; 112 | } 113 | 114 | public void setSubmittedFromEmail(String submittedFromEmail) { 115 | this.submittedFromEmail = submittedFromEmail; 116 | } 117 | 118 | public String getSubmittedToId() { 119 | return submittedToId; 120 | } 121 | 122 | public void setSubmittedToId(String submittedToId) { 123 | this.submittedToId = submittedToId; 124 | } 125 | 126 | public String getSubmittedToName() { 127 | return submittedToName; 128 | } 129 | 130 | public void setSubmittedToName(String submittedToName) { 131 | this.submittedToName = submittedToName; 132 | } 133 | 134 | public String getSubmittedToEmail() { 135 | return submittedToEmail; 136 | } 137 | 138 | public void setSubmittedToEmail(String submittedToEmail) { 139 | this.submittedToEmail = submittedToEmail; 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/core/config/PostgresDataSourceConfig.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.core.config; 2 | 3 | import javax.sql.DataSource; 4 | 5 | import org.springframework.boot.context.properties.ConfigurationProperties; 6 | import org.springframework.boot.jdbc.DataSourceBuilder; 7 | import org.springframework.context.annotation.Bean; 8 | import org.springframework.context.annotation.Configuration; 9 | import org.springframework.context.annotation.Primary; 10 | 11 | @Configuration 12 | public class PostgresDataSourceConfig { 13 | @Bean 14 | @Primary 15 | @ConfigurationProperties(prefix = "spring.datasource") 16 | public DataSource primaryDataSource() { 17 | return DataSourceBuilder.create().build(); 18 | } 19 | } 20 | 21 | //@Configuration 22 | //@EnableTransactionManagement 23 | //substitute url based on requirement 24 | //@ConfigurationProperties(prefix = "spring.datasource") 25 | //substitute url based on requirement 26 | //substitute url based on requirement 27 | //public class PostgresDataSourceConfig { 28 | // 29 | // // Providing connection params 30 | //// @Value("${spring.datasource.jdbc-url}") 31 | //// private String url; 32 | //// @Value("${spring.datasource.username}") 33 | //// private String username; 34 | //substitute based on requirement 35 | //substitute based on requirement 36 | // 37 | //// @Bean("primaryDataSource") 38 | // @Primary 39 | // public DataSource primaryDataSource() { 40 | //// DriverManagerDataSource dataSourceBuilder = new DriverManagerDataSource(); 41 | //// dataSourceBuilder.setUrl(url); 42 | //// dataSourceBuilder.setUsername(username); 43 | //substitute based on requirement 44 | //// return dataSourceBuilder; 45 | // 46 | // return DataSourceBuilder.create().build(); 47 | // } 48 | 49 | //---------------------------------------------------------------- 50 | // @Bean(name = "EntityManagerPrimary") 51 | // public LocalContainerEntityManagerFactoryBean EntityManagerPrimary() { 52 | // LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean(); 53 | // em.setDataSource(primaryDataSource()); 54 | //substitute url based on requirement 55 | // HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter(); 56 | // em.setJpaVendorAdapter(vendorAdapter); 57 | // em.setJpaProperties(hibernateProperties()); 58 | // return em; 59 | // } 60 | // 61 | // @Bean("TransactionManagerPrimary") 62 | // public PlatformTransactionManager TransactionManagerPrimary() { 63 | // 64 | // JpaTransactionManager transactionManager = new JpaTransactionManager(); 65 | // transactionManager.setEntityManagerFactory(EntityManagerPrimary().getObject()); 66 | // return transactionManager; 67 | // } 68 | // 69 | // @Bean(name = "SessionFactoryPrimary") 70 | // @Primary 71 | // public LocalSessionFactoryBean SessionFactoryPrimary() { 72 | // LocalSessionFactoryBean sessionFactoryBean = new LocalSessionFactoryBean(); 73 | // sessionFactoryBean.setDataSource(primaryDataSource()); 74 | //substitute url based on requirement 75 | // sessionFactoryBean.setHibernateProperties(hibernateProperties()); 76 | // return sessionFactoryBean; 77 | // } 78 | // 79 | // private Properties hibernateProperties() { 80 | // Properties properties = new Properties(); 81 | //// properties.put("hibernate.hbm2ddl.auto", false); 82 | // properties.put("hibernate.dialect", "org.hibernate.dialect.PostgreSQLDialect"); 83 | // properties.put("hibernate.temp.use_jdbc_metadata_defaults", false); 84 | // properties.put("hibernate.show_sql", true); 85 | // properties.put("hibernate.format_sql", true); 86 | //substitute url based on requirement 87 | // properties.put("connection.release_mode", "auto"); 88 | // return properties; 89 | // } 90 | //} 91 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/common/model/SunbirdApiHierarchyResultContent.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.common.model; 2 | 3 | import java.util.List; 4 | 5 | public class SunbirdApiHierarchyResultContent { 6 | private String parent; 7 | private String identifier; 8 | private String downloadUrl; 9 | private String channel; 10 | private String source; 11 | private String mimeType; 12 | private String objectType; 13 | private String primaryCategory; 14 | private String artifactUrl; 15 | private String contentType; 16 | private String status; 17 | private String name; 18 | private String code; 19 | private String streamingUrl; 20 | private List children; 21 | private List batches; 22 | 23 | public String getParent() { 24 | return parent; 25 | } 26 | 27 | public void setParent(String parent) { 28 | this.parent = parent; 29 | } 30 | 31 | public String getIdentifier() { 32 | return identifier; 33 | } 34 | 35 | public void setIdentifier(String identifier) { 36 | this.identifier = identifier; 37 | } 38 | 39 | public String getDownloadUrl() { 40 | return downloadUrl; 41 | } 42 | 43 | public void setDownloadUrl(String downloadUrl) { 44 | this.downloadUrl = downloadUrl; 45 | } 46 | 47 | public String getChannel() { 48 | return channel; 49 | } 50 | 51 | public void setChannel(String channel) { 52 | this.channel = channel; 53 | } 54 | 55 | public String getSource() { 56 | return source; 57 | } 58 | 59 | public void setSource(String source) { 60 | this.source = source; 61 | } 62 | 63 | public String getMimeType() { 64 | return mimeType; 65 | } 66 | 67 | public void setMimeType(String mimeType) { 68 | this.mimeType = mimeType; 69 | } 70 | 71 | public String getObjectType() { 72 | return objectType; 73 | } 74 | 75 | public void setObjectType(String objectType) { 76 | this.objectType = objectType; 77 | } 78 | 79 | public String getPrimaryCategory() { 80 | return primaryCategory; 81 | } 82 | 83 | public void setPrimaryCategory(String primaryCategory) { 84 | this.primaryCategory = primaryCategory; 85 | } 86 | 87 | public String getArtifactUrl() { 88 | return artifactUrl; 89 | } 90 | 91 | public void setArtifactUrl(String artifactUrl) { 92 | this.artifactUrl = artifactUrl; 93 | } 94 | 95 | public String getContentType() { 96 | return contentType; 97 | } 98 | 99 | public void setContentType(String contentType) { 100 | this.contentType = contentType; 101 | } 102 | 103 | public String getStatus() { 104 | return status; 105 | } 106 | 107 | public void setStatus(String status) { 108 | this.status = status; 109 | } 110 | 111 | public String getName() { 112 | return name; 113 | } 114 | 115 | public void setName(String name) { 116 | this.name = name; 117 | } 118 | 119 | public String getCode() { 120 | return code; 121 | } 122 | 123 | public void setCode(String code) { 124 | this.code = code; 125 | } 126 | 127 | public String getStreamingUrl() { 128 | return streamingUrl; 129 | } 130 | 131 | public void setStreamingUrl(String streamingUrl) { 132 | this.streamingUrl = streamingUrl; 133 | } 134 | 135 | public List getChildren() { 136 | return children; 137 | } 138 | 139 | public void setChildren(List children) { 140 | this.children = children; 141 | } 142 | 143 | public List getBatches() { 144 | return batches; 145 | } 146 | 147 | public void setBatches(List batches) { 148 | this.batches = batches; 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/main/java/org/sunbird/portal/department/dto/UserDepartmentRoleAudit.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.portal.department.dto; 2 | 3 | 4 | import org.hibernate.annotations.Type; 5 | 6 | import javax.persistence.*; 7 | import javax.validation.constraints.NotNull; 8 | import java.util.Arrays; 9 | 10 | @Entity 11 | @Table(name = "user_department_role_audit", schema = "wingspan") 12 | public class UserDepartmentRoleAudit { 13 | @Id 14 | @Column(name = "id") 15 | @GeneratedValue(strategy = GenerationType.IDENTITY) 16 | Integer id; 17 | 18 | @Column(name = "user_id") 19 | @NotNull 20 | String userId; 21 | 22 | @Column(name = "dept_id") 23 | @NotNull 24 | Integer deptId; 25 | 26 | @Column(name = "role_ids") 27 | @NotNull 28 | @Type(type = "org.sunbird.portal.department.dto.GenericArrayUserType") 29 | Integer[] roleIds; 30 | 31 | @Column(name = "isactive") 32 | @NotNull 33 | Boolean isActive; 34 | 35 | @Column(name = "isblocked") 36 | @NotNull 37 | Boolean isBlocked; 38 | 39 | @Column(name = "created_by") 40 | @NotNull 41 | String createdBy; 42 | 43 | 44 | @Column(name = "created_time") 45 | long createdTime; 46 | 47 | public UserDepartmentRoleAudit() { 48 | } 49 | 50 | public UserDepartmentRoleAudit(@NotNull String userId, @NotNull Integer deptId, @NotNull Integer[] roleIds, @NotNull Boolean isActive, @NotNull Boolean isBlocked, @NotNull String createdBy) { 51 | this.userId = userId; 52 | this.deptId = deptId; 53 | this.roleIds = roleIds; 54 | this.isActive = isActive; 55 | this.isBlocked = isBlocked; 56 | this.createdBy = createdBy; 57 | } 58 | 59 | public Integer getId() { 60 | return id; 61 | } 62 | 63 | public void setId(int id) { 64 | this.id = id; 65 | } 66 | 67 | public String getUserId() { 68 | return userId; 69 | } 70 | 71 | public void setUserId(String userId) { 72 | this.userId = userId; 73 | } 74 | 75 | public Integer getDeptId() { 76 | return deptId; 77 | } 78 | 79 | public void setDeptId(Integer deptId) { 80 | this.deptId = deptId; 81 | } 82 | 83 | public Integer[] getRoleIds() { 84 | return roleIds; 85 | } 86 | 87 | public void setRoleIds(Integer[] roleIds) { 88 | this.roleIds = roleIds; 89 | } 90 | 91 | public Boolean getIsActive() { 92 | return isActive; 93 | } 94 | 95 | public void setIsActive(Boolean isActive) { 96 | this.isActive = isActive; 97 | } 98 | 99 | public Boolean getIsBlocked() { 100 | return isBlocked; 101 | } 102 | 103 | public void setIsBlocked(Boolean isBlocked) { 104 | this.isBlocked = isBlocked; 105 | } 106 | 107 | public String getCreatedBy() { 108 | return createdBy; 109 | } 110 | 111 | public void setCreatedBy(String createdBy) { 112 | this.createdBy = createdBy; 113 | } 114 | 115 | 116 | public long getCreatedTime() { 117 | return createdTime; 118 | } 119 | 120 | public void setCreatedTime(long createdTime) { 121 | this.createdTime = createdTime; 122 | } 123 | 124 | @Override 125 | public String toString() { 126 | return "UserDepartmentRoleAudit{" + 127 | "userId='" + userId + '\'' + 128 | ", deptId=" + deptId + 129 | ", roleIds=" + Arrays.toString(roleIds) + 130 | ", isActive=" + isActive + 131 | ", isBlocked=" + isBlocked + 132 | ", createdBy='" + createdBy + '\'' + 133 | ", createdTime=" + createdTime + 134 | '}'; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /src/main/resources/elasticsearch/index/workorderv1.json: -------------------------------------------------------------------------------- 1 | { 2 | "mappings" : { 3 | "_doc" : { 4 | "properties" : { 5 | "id" : { 6 | "type" : "text", 7 | "fields" : { 8 | "keyword" : { 9 | "type" : "keyword", 10 | "ignore_above" : 256 11 | } 12 | } 13 | }, 14 | "deptId" : { 15 | "type" : "text", 16 | "fields" : { 17 | "keyword" : { 18 | "type" : "keyword", 19 | "ignore_above" : 256 20 | } 21 | } 22 | }, 23 | "deptName" : { 24 | "type" : "text", 25 | "fields" : { 26 | "keyword" : { 27 | "type" : "keyword", 28 | "ignore_above" : 256 29 | } 30 | } 31 | }, 32 | "userIds" : { 33 | "type" : "text", 34 | "fields" : { 35 | "keyword" : { 36 | "type" : "keyword", 37 | "ignore_above" : 256 38 | } 39 | } 40 | }, 41 | "name" : { 42 | "type" : "text", 43 | "fields" : { 44 | "keyword" : { 45 | "type" : "keyword", 46 | "ignore_above" : 256 47 | } 48 | } 49 | }, 50 | "status" : { 51 | "type" : "text", 52 | "fields" : { 53 | "keyword" : { 54 | "type" : "keyword", 55 | "ignore_above" : 256 56 | } 57 | } 58 | }, 59 | "progress" : { 60 | "type" : "integer" 61 | }, 62 | "errorCount" : { 63 | "type" : "integer" 64 | }, 65 | "rolesCount" : { 66 | "type" : "integer" 67 | }, 68 | "activitiesCount" : { 69 | "type" : "integer" 70 | }, 71 | "competenciesCount" : { 72 | "type" : "integer" 73 | }, 74 | "publishedPdfLink" : { 75 | "type" : "text", 76 | "fields" : { 77 | "keyword" : { 78 | "type" : "keyword", 79 | "ignore_above" : 256 80 | } 81 | } 82 | }, 83 | "signedPdfLink" : { 84 | "type" : "text", 85 | "fields" : { 86 | "keyword" : { 87 | "type" : "keyword", 88 | "ignore_above" : 256 89 | } 90 | } 91 | }, 92 | "createdAt" : { 93 | "type" : "date", 94 | "format" : "epoch_millis" 95 | }, 96 | "createdBy" : { 97 | "type" : "text", 98 | "fields" : { 99 | "keyword" : { 100 | "type" : "keyword", 101 | "ignore_above" : 256 102 | } 103 | } 104 | }, 105 | "createdByName" : { 106 | "type" : "text", 107 | "fields" : { 108 | "keyword" : { 109 | "type" : "keyword", 110 | "ignore_above" : 256 111 | } 112 | } 113 | }, 114 | "updatedAt" : { 115 | "type" : "date", 116 | "format" : "epoch_millis" 117 | }, 118 | "updatedBy" : { 119 | "type" : "text", 120 | "fields" : { 121 | "keyword" : { 122 | "type" : "keyword", 123 | "ignore_above" : 256 124 | } 125 | } 126 | }, 127 | "updatedByName" : { 128 | "type" : "text", 129 | "fields" : { 130 | "keyword" : { 131 | "type" : "keyword", 132 | "ignore_above" : 256 133 | } 134 | } 135 | } 136 | } 137 | } 138 | } 139 | } -------------------------------------------------------------------------------- /src/main/java/org/sunbird/assessment/repo/UserQuizMasterModel.java: -------------------------------------------------------------------------------- 1 | package org.sunbird.assessment.repo; 2 | 3 | import java.math.BigDecimal; 4 | import java.util.Date; 5 | 6 | import org.springframework.data.cassandra.core.mapping.Column; 7 | import org.springframework.data.cassandra.core.mapping.PrimaryKey; 8 | import org.springframework.data.cassandra.core.mapping.Table; 9 | 10 | @Table("user_quiz_master") 11 | public class UserQuizMasterModel { 12 | 13 | @PrimaryKey 14 | private UserQuizMasterPrimaryKeyModel primaryKey; 15 | 16 | @Column("correct_count") 17 | private Integer correctCount; 18 | @Column("date_created") 19 | private Date dateCreated; 20 | @Column("incorrect_count") 21 | private Integer incorrectCount; 22 | @Column("not_answered_count") 23 | private Integer notAnsweredCount; 24 | @Column("pass_percent") 25 | private BigDecimal passPercent; 26 | @Column("source_id") 27 | private String sourceId; 28 | @Column("source_title") 29 | private String sourceTitle; 30 | @Column("user_id") 31 | private String userId; 32 | 33 | public UserQuizMasterPrimaryKeyModel getPrimaryKey() { 34 | return primaryKey; 35 | } 36 | 37 | public void setPrimaryKey(UserQuizMasterPrimaryKeyModel primaryKey) { 38 | this.primaryKey = primaryKey; 39 | } 40 | 41 | public Integer getCorrectCount() { 42 | return correctCount; 43 | } 44 | 45 | public void setCorrectCount(Integer correctCount) { 46 | this.correctCount = correctCount; 47 | } 48 | 49 | public Date getDateCreated() { 50 | return dateCreated; 51 | } 52 | 53 | public void setDateCreated(Date dateCreated) { 54 | this.dateCreated = dateCreated; 55 | } 56 | 57 | public Integer getIncorrectCount() { 58 | return incorrectCount; 59 | } 60 | 61 | public void setIncorrectCount(Integer incorrectCount) { 62 | this.incorrectCount = incorrectCount; 63 | } 64 | 65 | public Integer getNotAnsweredCount() { 66 | return notAnsweredCount; 67 | } 68 | 69 | public void setNotAnsweredCount(Integer notAnsweredCount) { 70 | this.notAnsweredCount = notAnsweredCount; 71 | } 72 | 73 | public BigDecimal getPassPercent() { 74 | return passPercent; 75 | } 76 | 77 | public void setPassPercent(BigDecimal passPercent) { 78 | this.passPercent = passPercent; 79 | } 80 | 81 | public String getSourceId() { 82 | return sourceId; 83 | } 84 | 85 | public void setSourceId(String sourceId) { 86 | this.sourceId = sourceId; 87 | } 88 | 89 | public String getSourceTitle() { 90 | return sourceTitle; 91 | } 92 | 93 | public void setSourceTitle(String sourceTitle) { 94 | this.sourceTitle = sourceTitle; 95 | } 96 | 97 | public String getUserId() { 98 | return userId; 99 | } 100 | 101 | public void setUserId(String userId) { 102 | this.userId = userId; 103 | } 104 | 105 | public UserQuizMasterModel(UserQuizMasterPrimaryKeyModel primaryKey, Integer correctCount, Date dateCreated, 106 | Integer incorrectCount, Integer notAnsweredCount, BigDecimal passPercent, String sourceId, 107 | String sourceTitle, String userId) { 108 | super(); 109 | this.primaryKey = primaryKey; 110 | this.correctCount = correctCount; 111 | this.dateCreated = dateCreated; 112 | this.incorrectCount = incorrectCount; 113 | this.notAnsweredCount = notAnsweredCount; 114 | this.passPercent = passPercent; 115 | this.sourceId = sourceId; 116 | this.sourceTitle = sourceTitle; 117 | this.userId = userId; 118 | } 119 | 120 | public UserQuizMasterModel() { 121 | super(); 122 | } 123 | 124 | @Override 125 | public String toString() { 126 | return "UserQuizMasterModel [primaryKey=" + primaryKey + ", correctCount=" + correctCount + ", dateCreated=" 127 | + dateCreated + ", incorrectCount=" + incorrectCount + ", notAnsweredCount=" + notAnsweredCount 128 | + ", passPercent=" + passPercent + ", sourceId=" + sourceId + ", sourceTitle=" + sourceTitle 129 | + ", userId=" + userId + "]"; 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | server.connection-timeout=5000 2 | server.tomcat.max-threads=2048 3 | server.tomcat.min-spare-threads=20 4 | server.tomcat.max-connections=15000 5 | server.tomcat.accept-count=500 6 | server.port=7001 7 | 8 | #spring data jpa for postgres 9 | spring.datasource.jdbc-url=jdbc:postgresql://localhost:5432/wingspan 10 | spring.datasource.username=postgres 11 | spring.datasource.password=postgres 12 | spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQLDialect 13 | spring.jpa.properties.hibernate.format_sql=true 14 | spring.jpa.show-sql=false 15 | 16 | #Workflow - Service details 17 | wf.service.host=http://localhost:5099/ 18 | wf.service.updateUserProfilePath=v1/workflow/updateUserProfileWF 19 | 20 | #Configuration for Multi Department Mapping for User 21 | user.enable.multidept.mapping=false 22 | 23 | #learner.service.url=learner-service:9000 24 | sb.service.url= http://learner-service:9000/ 25 | 26 | sb.hub.graph.service.url=http://hub-graph-service:4013 27 | 28 | spring.data.cassandra.sb.startupTimeoutInSeconds=100000 29 | spring.data.cassandra.sb.contact-points=localhost 30 | spring.data.cassandra.sb.port=9042 31 | spring.data.cassandra.sb.keyspace-name=sunbird 32 | spring.data.cassandra.sb.username=cassandra 33 | spring.data.cassandra.sb.password=cassandra 34 | 35 | sunbird.course.service.host=http://lms-service:9000/ 36 | progress.api.endpoint=v1/content/state/read 37 | participants.api.endpoint=v1/batch/participants/list 38 | sb.api.key=api_key 39 | 40 | #Elastic search config 41 | 42 | es.auth.enabled=false 43 | es.host=localhost 44 | es.port=9200 45 | es.username= 46 | es.password= 47 | es.profile.index=userprofile 48 | es.profile.index.type=_doc 49 | es.profile.source.fields=photo,id,employmentDetails,personalDetails 50 | 51 | #workallocation es config 52 | 53 | workallocation.index.name=workallocation 54 | workallocation.index.type=_doc 55 | workallocationv2.index.name=workallocationv2 56 | workorder.index.name=workorderv1 57 | workorder.index.type=_doc 58 | 59 | #Kafka Topics 60 | kafka.topics.org.creation=orgCreation 61 | kafka.topics.userrole.audit=userRoleAuditTopic 62 | 63 | #Kafka Server 64 | spring.kafka.bootstrap.servers=localhost:9092 65 | 66 | #kafka properties 67 | kakfa.offset.reset.value=latest 68 | kafka.max.poll.interval.ms=5000 69 | kafka.max.poll.records=100 70 | 71 | org.create.endpoint=v1/org/create 72 | 73 | #Knowledge Base API Endpoints 74 | km.base.host=http://knowledge-mw-service:5000/ 75 | km.base.framework.path=action/framework/v3/read/ 76 | 77 | #Taxonomy Framework and Category 78 | igot.taxonomy.framework.name=igot 79 | igot.taxonomy.category.name=Taxonomy 80 | 81 | #FRAC EndPoints 82 | frac.host=https://frac.igot-dev.in/ 83 | frac.node.path=fracapis/frac/addDataNodeBulk 84 | frac.activity.path=fracapis/frac/addDataNode 85 | frac.node.source=WAT 86 | frac.node.source.useDeptName=false 87 | 88 | 89 | #Hierarchy end point 90 | content-service-host=http://content-service:9000/ 91 | content-hierarchy-endpoint=content/v3/hierarchy 92 | content-create-endpoint=content/v3/create 93 | content-upload-endpoint=content/v3/upload/{identifier} 94 | #QR Code Properties 95 | domain.host.name=http://igot-dev.in/apis/public/v8/workallocation/getWaPdf/ 96 | course.batch.create.endpoint=v1/course/batch/create 97 | user.course.list=v1/user/courses/list/{userUUID}?orgdetails=orgName,email&licenseDetails=name,description,url&fields=contentType,topic,name,channel,mimeType,appIcon,gradeLevel,resourceType,identifier,medium,pkgVersion,board,subject,trackable,posterImage,duration,creatorLogo,license&batchDetails=name,endDate,startDate,status,enrollmentType,createdBy,certificates 98 | user.course.enroll=v1/course/enroll 99 | 100 | html.store.path=/tmp/htmlFiles 101 | pdf.store.path=/tmp/pdfFiles 102 | pdf.draft.template.name=workallocationdraft 103 | pdf.published.template.name=workallocationpublished 104 | content.default.channelId=0131397178949058560 105 | content.default.orgId=igot-karmayogi 106 | --------------------------------------------------------------------------------