├── .gitignore ├── .travis.yml ├── Dockerfile ├── LICENSE ├── LICENSE_HEADER ├── README.md ├── lapHome ├── extracts │ ├── README.md │ ├── README.txt │ ├── activity.csv │ ├── course.csv │ ├── enrollment.csv │ ├── grade.csv │ ├── personal.csv │ └── sample1_input.json ├── kettle │ ├── Marist_OAAI_ACADEMIC_RISK.xml │ ├── plugins │ │ └── steps │ │ │ └── WekaScoringDeploy │ │ │ ├── WS.png │ │ │ ├── plugin.xml │ │ │ ├── weka.jar │ │ │ ├── xpp3_min-1.1.3.4.O.jar │ │ │ └── xstream-1.2.2.jar │ ├── sample1.ktr.xml │ ├── sample2.kjb.xml │ ├── sample2_1.kjb.xml │ └── scoring_sample │ │ ├── LAP_Scoring_Sample.ktr │ │ ├── Sample_Pipeline1_ETL_Gradebook_AssignWeightsJob.kjb │ │ ├── Sample_Pipeline1_ETL_MainJob.kjb │ │ ├── oaai.lap.logistic.pmml.xml │ │ └── sample predictive pipeline output.csv ├── pipelines │ └── sample.xml └── pmml │ └── oaai.marist.logistic.pmml.xml ├── pom.xml ├── repo └── pentaho │ └── di │ └── scoring │ ├── 1.0.0 │ ├── scoring-1.0.0.jar │ └── scoring-1.0.0.pom │ └── maven-metadata-local.xml └── src ├── main ├── java │ └── org │ │ └── apereo │ │ └── lap │ │ ├── LearningAnalyticsProcessor.java │ │ ├── controllers │ │ ├── FeatureFlagController.java │ │ ├── LapControllerAdvice.java │ │ ├── ModelRunController.java │ │ ├── PipelineController.java │ │ ├── SSPConfigController.java │ │ └── api │ │ │ └── ModelOutputController.java │ │ ├── exception │ │ ├── MissingPipelineException.java │ │ └── MissingTenantException.java │ │ ├── kettle │ │ ├── KettleConfiguration.java │ │ └── KettleProperties.java │ │ ├── model │ │ ├── ExceptionResponseDto.java │ │ ├── Output.java │ │ ├── Pipeline.java │ │ ├── PipelineConfig.java │ │ ├── Processor.java │ │ ├── SSPConfig.java │ │ └── api │ │ │ ├── ModelOutputRecord.java │ │ │ ├── ModelOutputResourceAssembler.java │ │ │ ├── ModelRunRecord.java │ │ │ └── ModelRunResourceAssembler.java │ │ ├── security │ │ └── SecurityConfig.java │ │ └── services │ │ ├── ProcessingManagerService.java │ │ ├── TenantService.java │ │ ├── configuration │ │ └── ConfigurationService.java │ │ ├── input │ │ ├── BaseInputHandlerService.java │ │ ├── CSVInputHandlerService.java │ │ ├── SampleCSVInputHandlerService.java │ │ └── handlers │ │ │ ├── BaseInputHandler.java │ │ │ ├── InputHandler.java │ │ │ └── csv │ │ │ ├── ActivityCSVInputHandler.java │ │ │ ├── BaseCSVInputHandler.java │ │ │ ├── CSVInputHandler.java │ │ │ ├── CourseCSVInputHandler.java │ │ │ ├── EnrollmentCSVInputHandler.java │ │ │ ├── GradeCSVInputHandler.java │ │ │ └── PersonalCSVInputHandler.java │ │ ├── notification │ │ ├── NotificationService.java │ │ └── handlers │ │ │ ├── LogNotificationHandler.java │ │ │ └── NotificationHandler.java │ │ ├── output │ │ ├── OutputHandlerService.java │ │ └── handlers │ │ │ ├── BaseOutputHandler.java │ │ │ ├── CSVOutputHandler.java │ │ │ ├── OutputHandler.java │ │ │ ├── SSPEarlyAlertOutputHandler.java │ │ │ └── StorageOutputHandler.java │ │ ├── pipelines │ │ ├── KettleBasePipelineProcessor.java │ │ ├── KettleDataPipelineProcessor.java │ │ ├── KettleJobPipelineProcessor.java │ │ ├── KettleTransformPipelineProcessor.java │ │ └── PipelineProcessor.java │ │ └── storage │ │ ├── DatasourceProperties.java │ │ ├── ModelOutput.java │ │ ├── ModelRun.java │ │ ├── ModelRunPersistentStorage.java │ │ ├── PersistentLAPEntity.java │ │ ├── PersistentStorage.java │ │ ├── SSPConfigPersistentStorage.java │ │ ├── StorageFactory.java │ │ ├── StorageService.java │ │ ├── h2 │ │ ├── H2ModelRunPersistentStorage.java │ │ ├── H2PersistentConfig.java │ │ ├── H2PersistentStorage.java │ │ ├── H2SSPConfigPersistentStorage.java │ │ ├── H2TempConfig.java │ │ └── model │ │ │ ├── BaseEntity.java │ │ │ ├── JpaSSPConfig.java │ │ │ ├── RiskConfidence.java │ │ │ ├── RiskConfidenceRepository.java │ │ │ ├── Run.java │ │ │ ├── RunRepository.java │ │ │ └── SSPConfigRepository.java │ │ └── mongo │ │ ├── MongoConfig.java │ │ ├── MongoModelRunPersistentStorage.java │ │ ├── MongoMultiTenantConfiguration.java │ │ ├── MongoMultiTenantFilter.java │ │ ├── MongoPersistentStorage.java │ │ ├── MongoSSPConfigPersistentStorage.java │ │ ├── MultiTenantMongoDbFactory.java │ │ └── model │ │ ├── MongoModelOutputRepository.java │ │ ├── MongoModelRunRepository.java │ │ └── MongoSSPConfigRepository.java └── resources │ ├── application-mongo-multitenant.properties │ ├── application-mongo.properties │ ├── application-test.properties │ ├── application.properties │ ├── log4j.xml │ ├── public │ └── assets │ │ ├── css │ │ ├── angular-notification-min.css │ │ └── lap.css │ │ ├── img │ │ ├── locales │ │ │ ├── cy_GB.png │ │ │ ├── en_GB.png │ │ │ └── en_US.png │ │ └── spinner.gif │ │ ├── js │ │ ├── app.js │ │ ├── auth-ctrl.js │ │ ├── directives.js │ │ ├── index-ctrl.js │ │ ├── lib │ │ │ └── angular-notification-min.js │ │ ├── login-ctrl.js │ │ ├── pipelines │ │ │ ├── controllers.js │ │ │ └── service.js │ │ ├── services.js │ │ └── settings │ │ │ └── controllers.js │ │ ├── templates │ │ ├── index.html │ │ ├── login.html │ │ ├── pipelines.html │ │ └── settings.html │ │ └── translations │ │ ├── cy_GB │ │ └── overview.json │ │ ├── en_GB │ │ └── overview.json │ │ └── en_US │ │ └── overview.json │ ├── sample.sql │ ├── schema.sql │ └── templates │ └── index.html └── test └── java └── org └── apereo └── lap ├── controllers ├── ModelOutputControllerTest.java └── PipelineControllerTest.java ├── services ├── InputHandlerServiceTest.java ├── LapControllerAdviceTest.java ├── OutputHandlerServiceTest.java ├── ProcessingManagerServiceTest.java ├── StorageServiceTest.java └── storage │ └── mongo │ └── tests │ └── MongoMultiTenantFilterTest.java └── test ├── AbstractIntegrationTest.java ├── AbstractUnitTest.java ├── MongoUnitTests.java └── group ├── IntegrationTests.java ├── MongoUnitTests.java └── UnitTests.java /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | target/ 3 | bin/ 4 | .settings/ 5 | .classpath 6 | .project 7 | .idea 8 | *.iml 9 | .DS_Store 10 | F:/ 11 | .springBeans 12 | lapHome/outputs/ 13 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | jdk: 3 | - oraclejdk7 4 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # DOCKER-VERSION 1.8.1 2 | FROM ubuntu:14.04 3 | MAINTAINER Jason Brown "jbrown@unicon.net" 4 | 5 | # make sure the package repository is up to date 6 | RUN echo "deb http://archive.ubuntu.com/ubuntu trusty main universe" > /etc/apt/sources.list 7 | RUN apt-get -y update 8 | 9 | # install python-software-properties (so you can do add-apt-repository) 10 | RUN DEBIAN_FRONTEND=noninteractive apt-get install -y -q python-software-properties software-properties-common 11 | 12 | # Install Java. 13 | RUN \ 14 | echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | debconf-set-selections && \ 15 | add-apt-repository -y ppa:webupd8team/java && \ 16 | apt-get update && \ 17 | apt-get install -y oracle-java8-installer && \ 18 | rm -rf /var/lib/apt/lists/* && \ 19 | rm -rf /var/cache/oracle-jdk8-installer 20 | 21 | # Add $HOME/.kettle/shared.xml 22 | RUN mkdir $HOME/.kettle/ 23 | RUN echo '\ 24 | \ 25 | \ 26 | LAP_connect\ 27 | \ 28 | H2\ 29 | Native\ 30 | mem:temp-db;MODE=MYSQL;DB_CLOSE_DELAY=-1\ 31 | -1\ 32 | sa\ 33 | Encrypted \ 34 | \ 35 | \ 36 | \ 37 | \ 38 | PORT_NUMBER-1\ 39 | \ 40 | \ 41 | ' >> $HOME/.kettle/shared.xml 42 | 43 | RUN mkdir opt/lap/ 44 | 45 | EXPOSE 8080 46 | 47 | # java.security.edge reduces start up time due to 48 | # INFO: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [5172] milliseconds. 49 | 50 | WORKDIR /opt/lap/ 51 | CMD java -server -jar -Djava.security.egd=file:/dev/./urandom -Dspring.config.location=/opt/lap/dev.properties target/lap-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /LICENSE_HEADER: -------------------------------------------------------------------------------- 1 | Copyright ${year} ${holder} Licensed under the 2 | Educational Community License, Version 2.0 (the "License"); you may 3 | not use this file except in compliance with the License. You may 4 | obtain a copy of the License at 5 | 6 | http://www.osedu.org/licenses/ECL-2.0 7 | 8 | Unless required by applicable law or agreed to in writing, 9 | software distributed under the License is distributed on an "AS IS" 10 | BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 11 | or implied. See the License for the specific language governing 12 | permissions and limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Learning Analytics Processor 2 | ======= 3 | An open source, Java-based analytics workflow manager. Find detailed documentation on our [github.io site](http://apereo-learning-analytics-initiative.github.io/LearningAnalyticsProcessor/). 4 | 5 | ************************************************************************************* 6 | 7 | License 8 | ------- 9 | ECL - a slightly less permissive Apache2 10 | http://opensource.org/licenses/ECL-2.0 11 | 12 | Contact 13 | ------- 14 | Send questions or comments to the mailing list: lap-user@apereo.org 15 | -------------------------------------------------------------------------------- /lapHome/extracts/README.txt: -------------------------------------------------------------------------------- 1 | See README.md (markdown formatted text) 2 | https://github.com/Unicon/OpenAcademicAnalytics/blob/master/src/main/resources/extracts/README.md 3 | -------------------------------------------------------------------------------- /lapHome/extracts/course.csv: -------------------------------------------------------------------------------- 1 | COURSE_ID,SUBJECT,ENROLLMENT,ONLINE_FLAG 2 | MNG_333N_222_08F,Management,29,1 3 | -------------------------------------------------------------------------------- /lapHome/extracts/enrollment.csv: -------------------------------------------------------------------------------- 1 | ALTERNATIVE_ID,COURSE_ID,FINAL_GRADE,WITHDRAWAL_DATE 2 | STUDENT1,MNG_333N_222_08F,B, 3 | STUDENT2,MNG_333N_222_08F,D+, 4 | STUDENT3,MNG_333N_222_08F,A-, 5 | STUDENT4,MNG_333N_222_08F,B-, 6 | STUDENT5,MNG_333N_222_08F,A, 7 | STUDENT6,MNG_333N_222_08F,B+, 8 | STUDENT7,MNG_333N_222_08F,B-, 9 | STUDENT8,MNG_333N_222_08F,A-, 10 | STUDENT9,MNG_333N_222_08F,A, 11 | STUDENT10,MNG_333N_222_08F,B+, 12 | STUDENT11,MNG_333N_222_08F,B-, 13 | STUDENT12,MNG_333N_222_08F,A, 14 | STUDENT13,MNG_333N_222_08F,A-, 15 | STUDENT14,MNG_333N_222_08F,B+, 16 | STUDENT15,MNG_333N_222_08F,C, 17 | STUDENT16,MNG_333N_222_08F,A-, 18 | STUDENT17,MNG_333N_222_08F,B+, 19 | STUDENT18,MNG_333N_222_08F,A-, 20 | STUDENT19,MNG_333N_222_08F,A-, 21 | STUDENT20,MNG_333N_222_08F,A, 22 | STUDENT21,MNG_333N_222_08F,B-, 23 | STUDENT22,MNG_333N_222_08F,B+, 24 | STUDENT23,MNG_333N_222_08F,B-, 25 | STUDENT24,MNG_333N_222_08F,A, 26 | STUDENT25,MNG_333N_222_08F,B, 27 | STUDENT26,MNG_333N_222_08F,A, 28 | STUDENT27,MNG_333N_222_08F,B, 29 | STUDENT28,MNG_333N_222_08F,D, 30 | STUDENT29,MNG_333N_222_08F,A-, 31 | -------------------------------------------------------------------------------- /lapHome/extracts/personal.csv: -------------------------------------------------------------------------------- 1 | ALTERNATIVE_ID,PERCENTILE,SAT_VERBAL,SAT_MATH,ACT_COMPOSITE,AGE,RACE,GENDER,ENROLLMENT_STATUS,EARNED_CREDIT_HOURS,GPA_CUMULATIVE,GPA_SEMESTER,STANDING,PELL_STATUS,CLASS_CODE 2 | STUDENT1,,590,540,,22,,F,F,70,3.4225,3.54,1,Y,SR 3 | STUDENT10,82,600,650,,21,,M,F,55,3.0267,3.24,1,N,JR 4 | STUDENT11,,,,,23,,M,P,70,2.9308,2.4667,1,Y,SO 5 | STUDENT12,74,460,480,,22,,M,F,50,3.631,3.72,2,N,JR 6 | STUDENT13,94,620,660,,22,,M,F,12,3.8729,3.68,2,Y,FR 7 | STUDENT14,92,580,590,,21,,F,F,65,3.5438,3.65,2,Y,SR 8 | STUDENT15,87,570,600,,22,,M,F,26,2.5,2.34,0,Y,JR 9 | STUDENT16,,450,480,20,22,,M,F,77,3.33,3.2,1,Y,SR 10 | STUDENT17,,560,630,,21,,M,F,56,3.325,3.4,1,N,JR 11 | STUDENT18,85,540,550,,21,,M,F,33,3.3867,3.36,1,N,SO 12 | STUDENT19,,510,560,,20,,F,F,48,3.8214,3.925,2,Y,JR 13 | STUDENT2,,600,650,26,22,,M,F,80,2.2182,2.66,0,Y,SR 14 | STUDENT20,,580,570,,20,,F,F,65,3.5184,3.94,2,Y,JR 15 | STUDENT21,,440,460,20,21,,F,F,82,3.0667,3.2,1,Y,SR 16 | STUDENT22,,,,,20,,M,F,60,3.1714,3.06,1,N,JR 17 | STUDENT23,,590,530,,21,,F,F,36,3.3025,2.86,1,N,SO 18 | STUDENT24,95,550,640,,21,,F,F,63,3.672,3.72,2,N,JR 19 | STUDENT25,76,630,690,,21,,M,F,63,3.232,3.26,1,N,JR 20 | STUDENT26,,570,590,26,21,,M,F,38,3.9571,4,2,N,SO 21 | STUDENT27,,600,560,,21,,F,F,42,3.2141,2.72,1,N,JR 22 | STUDENT28,,,,,36,,F,P,60,2.335,1.7667,0,N,SR 23 | STUDENT29,,,,,21,,F,F,23,3.4474,3.575,1,N,SO 24 | STUDENT3,,570,690,,21,,M,F,23,3.6081,3.62,2,N,SO 25 | STUDENT4,,670,690,30,22,,F,F,63,3.3758,3.08,1,N,SR 26 | STUDENT5,,470,640,,22,,M,F,22,3.725,3.775,2,N,SO 27 | STUDENT6,40,600,470,,21,,F,F,21,3.3172,3.66,2,Y,SO 28 | STUDENT7,,410,480,,21,,F,F,73,3.0938,2.6,1,Y,SR 29 | STUDENT8,33,560,540,23,21,,M,F,59,2.78,3.12,1,Y,JR 30 | STUDENT9,,580,690,,21,,M,F,57,3.9576,3.9357,2,N,JR 31 | -------------------------------------------------------------------------------- /lapHome/kettle/plugins/steps/WekaScoringDeploy/WS.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/lapHome/kettle/plugins/steps/WekaScoringDeploy/WS.png -------------------------------------------------------------------------------- /lapHome/kettle/plugins/steps/WekaScoringDeploy/plugin.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Transform 18 | 19 | 20 | Weka Scoring 21 | 22 | 23 | Appends predictions from a pre-built Weka model 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /lapHome/kettle/plugins/steps/WekaScoringDeploy/weka.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/lapHome/kettle/plugins/steps/WekaScoringDeploy/weka.jar -------------------------------------------------------------------------------- /lapHome/kettle/plugins/steps/WekaScoringDeploy/xpp3_min-1.1.3.4.O.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/lapHome/kettle/plugins/steps/WekaScoringDeploy/xpp3_min-1.1.3.4.O.jar -------------------------------------------------------------------------------- /lapHome/kettle/plugins/steps/WekaScoringDeploy/xstream-1.2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/lapHome/kettle/plugins/steps/WekaScoringDeploy/xstream-1.2.2.jar -------------------------------------------------------------------------------- /lapHome/kettle/scoring_sample/sample predictive pipeline output.csv: -------------------------------------------------------------------------------- 1 | ALTERNATIVE_ID,COURSE_ID,MODEL_RISK_CONFIDENCE 2 | STUDENT1,MNG_333N_222_08F,"NO RISK" 3 | STUDENT10,MNG_333N_222_08F,"NO RISK" 4 | STUDENT11,MNG_333N_222_08F,"NO RISK" 5 | STUDENT12,MNG_333N_222_08F,"NO RISK" 6 | STUDENT13,MNG_333N_222_08F,"NO RISK" 7 | STUDENT14,MNG_333N_222_08F,"NO RISK" 8 | STUDENT15,MNG_333N_222_08F,"LOW RISK" 9 | STUDENT16,MNG_333N_222_08F,"NO RISK" 10 | STUDENT17,MNG_333N_222_08F,"NO RISK" 11 | STUDENT18,MNG_333N_222_08F,"NO RISK" 12 | STUDENT19,MNG_333N_222_08F,"NO RISK" 13 | STUDENT2,MNG_333N_222_08F,"MEDIUM RISK" 14 | STUDENT20,MNG_333N_222_08F,"NO RISK" 15 | STUDENT21,MNG_333N_222_08F,"NO RISK" 16 | STUDENT22,MNG_333N_222_08F,"NO RISK" 17 | STUDENT23,MNG_333N_222_08F,"NO RISK" 18 | STUDENT24,MNG_333N_222_08F,"NO RISK" 19 | STUDENT25,MNG_333N_222_08F,"NO RISK" 20 | STUDENT26,MNG_333N_222_08F,"NO RISK" 21 | STUDENT27,MNG_333N_222_08F,"NO RISK" 22 | STUDENT28,MNG_333N_222_08F,"HIGH RISK" 23 | STUDENT29,MNG_333N_222_08F,"NO RISK" 24 | STUDENT3,MNG_333N_222_08F,"NO RISK" 25 | STUDENT4,MNG_333N_222_08F,"NO RISK" 26 | STUDENT5,MNG_333N_222_08F,"NO RISK" 27 | STUDENT6,MNG_333N_222_08F,"NO RISK" 28 | STUDENT7,MNG_333N_222_08F,"NO RISK" 29 | STUDENT8,MNG_333N_222_08F,"NO RISK" 30 | STUDENT9,MNG_333N_222_08F,"NO RISK" 31 | -------------------------------------------------------------------------------- /repo/pentaho/di/scoring/1.0.0/scoring-1.0.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/repo/pentaho/di/scoring/1.0.0/scoring-1.0.0.jar -------------------------------------------------------------------------------- /repo/pentaho/di/scoring/1.0.0/scoring-1.0.0.pom: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | pentaho.di 6 | scoring 7 | 1.0.0 8 | POM was created from install:install-file 9 | 10 | -------------------------------------------------------------------------------- /repo/pentaho/di/scoring/maven-metadata-local.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | pentaho.di 4 | scoring 5 | 6 | 1.0.0 7 | 8 | 1.0.0 9 | 10 | 20150821042027 11 | 12 | 13 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/controllers/FeatureFlagController.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.controllers; 19 | 20 | import java.util.Collections; 21 | import java.util.HashMap; 22 | import java.util.Map; 23 | 24 | import org.springframework.boot.context.properties.ConfigurationProperties; 25 | import org.springframework.web.bind.annotation.PathVariable; 26 | import org.springframework.web.bind.annotation.RequestMapping; 27 | import org.springframework.web.bind.annotation.RequestMethod; 28 | import org.springframework.web.bind.annotation.RestController; 29 | 30 | /** 31 | * @author ggilbert 32 | * 33 | */ 34 | @ConfigurationProperties("") 35 | @RestController 36 | public class FeatureFlagController { 37 | 38 | private final Map features = new HashMap(); 39 | 40 | public Map getFeatures() { 41 | return features; 42 | } 43 | 44 | @RequestMapping(value = {"/features"}, method = RequestMethod.GET, produces="application/json;charset=utf-8") 45 | public Map features() { 46 | return features; 47 | } 48 | 49 | @RequestMapping(value = {"/features/{key}"}, method = RequestMethod.GET, produces="application/json;charset=utf-8") 50 | public Map featuresByKey(@PathVariable("key") final String key) { 51 | Object value = features.get(key); 52 | return Collections.singletonMap(key, value); 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/controllers/LapControllerAdvice.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.controllers; 16 | 17 | import java.io.IOException; 18 | import java.util.Calendar; 19 | 20 | import javassist.NotFoundException; 21 | 22 | import javax.servlet.http.HttpServletRequest; 23 | 24 | import org.apereo.lap.exception.MissingPipelineException; 25 | import org.apereo.lap.exception.MissingTenantException; 26 | import org.apereo.lap.model.ExceptionResponseDto; 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | import org.springframework.http.HttpStatus; 30 | import org.springframework.http.ResponseEntity; 31 | import org.springframework.web.bind.annotation.ControllerAdvice; 32 | import org.springframework.web.bind.annotation.ExceptionHandler; 33 | 34 | @ControllerAdvice 35 | public class LapControllerAdvice { 36 | private static final Logger logger = LoggerFactory.getLogger(LapControllerAdvice.class); 37 | 38 | public LapControllerAdvice(){ 39 | super(); 40 | } 41 | 42 | @ExceptionHandler({Exception.class}) 43 | public Object handleAppException(HttpServletRequest request, Exception ex) throws IOException { 44 | if (ex instanceof MissingPipelineException 45 | || ex instanceof MissingTenantException 46 | || ex instanceof NotFoundException) { 47 | return handleExceptionWithMessageAndStatusCode(request, ex, 404); 48 | } 49 | // Everything else gets a generic 500 exception 50 | return handleGenericExceptionWithoutMessage(request, ex); 51 | } 52 | 53 | private Object handleExceptionWithMessageAndStatusCode(HttpServletRequest request, Exception ex, int statusCode) { 54 | logger.error("Exception", ex); 55 | 56 | ExceptionResponseDto response = new ExceptionResponseDto(); 57 | response.setError(ex.getClass().toString()); 58 | response.setTimestamp(Calendar.getInstance().getTimeInMillis()); 59 | response.setPath(request.getRequestURL().toString()); 60 | response.setStatus(statusCode); 61 | response.setMessage(ex.getMessage()); 62 | 63 | return new ResponseEntity<>(response, HttpStatus.valueOf(statusCode)); 64 | 65 | } 66 | private Object handleGenericExceptionWithoutMessage(HttpServletRequest request, Exception ex) { 67 | logger.error("Exception", ex); 68 | 69 | ExceptionResponseDto response = new ExceptionResponseDto(); 70 | response.setError(ex.getClass().toString()); 71 | response.setTimestamp(Calendar.getInstance().getTimeInMillis()); 72 | response.setPath(request.getRequestURL().toString()); 73 | response.setStatus(500); 74 | response.setMessage("No message available"); 75 | 76 | return new ResponseEntity<>(response, HttpStatus.INTERNAL_SERVER_ERROR); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/controllers/ModelRunController.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.controllers; 19 | 20 | import java.util.ArrayList; 21 | 22 | import org.apereo.lap.model.api.ModelRunRecord; 23 | import org.apereo.lap.model.api.ModelRunResourceAssembler; 24 | import org.apereo.lap.services.storage.ModelRun; 25 | import org.apereo.lap.services.storage.ModelRunPersistentStorage; 26 | import org.apereo.lap.services.storage.StorageFactory; 27 | import org.springframework.beans.factory.annotation.Autowired; 28 | import org.springframework.data.domain.Page; 29 | import org.springframework.data.domain.PageImpl; 30 | import org.springframework.data.domain.Pageable; 31 | import org.springframework.data.web.PageableDefault; 32 | import org.springframework.data.web.PagedResourcesAssembler; 33 | import org.springframework.hateoas.PagedResources; 34 | import org.springframework.web.bind.annotation.RequestMapping; 35 | import org.springframework.web.bind.annotation.RequestMethod; 36 | import org.springframework.web.bind.annotation.RestController; 37 | 38 | /** 39 | * @author ggilbert 40 | * 41 | */ 42 | @RestController 43 | public class ModelRunController { 44 | @Autowired private StorageFactory storageFactory; 45 | @Autowired private ModelRunResourceAssembler modelRunResourceAssembler; 46 | 47 | @RequestMapping(method = RequestMethod.GET, produces = {"application/json"}, value="/history") 48 | public PagedResources runs(@PageableDefault(size = 10, page = 0) Pageable pageable, 49 | PagedResourcesAssembler assembler) { 50 | 51 | ModelRunPersistentStorage persistentStorage = storageFactory.getModelRunPersistentStorage(); 52 | Page output = persistentStorage.findAll(pageable); 53 | if (output == null) { 54 | output = new PageImpl(new ArrayList(), pageable, 0); 55 | } 56 | return assembler.toResource(output, modelRunResourceAssembler); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/controllers/SSPConfigController.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.controllers; 16 | 17 | import org.apereo.lap.model.SSPConfig; 18 | import org.apereo.lap.services.storage.SSPConfigPersistentStorage; 19 | import org.apereo.lap.services.storage.StorageFactory; 20 | import org.springframework.beans.factory.annotation.Autowired; 21 | import org.springframework.stereotype.Controller; 22 | import org.springframework.web.bind.annotation.RequestBody; 23 | import org.springframework.web.bind.annotation.RequestMapping; 24 | import org.springframework.web.bind.annotation.RequestMethod; 25 | import org.springframework.web.bind.annotation.ResponseBody; 26 | 27 | /** 28 | * @author ggilbert 29 | * 30 | */ 31 | @Controller 32 | public class SSPConfigController { 33 | @Autowired private StorageFactory storageFactory; 34 | 35 | @RequestMapping(method = RequestMethod.GET, produces = {"application/json"}, value="/api/sspconfig") 36 | public @ResponseBody SSPConfig sspConfigForAPI() { 37 | 38 | return sspConfig(); 39 | } 40 | 41 | @RequestMapping(method = RequestMethod.GET, produces = {"application/json"}, value="/sspconfig") 42 | public @ResponseBody SSPConfig sspConfig() { 43 | 44 | SSPConfigPersistentStorage persistentStorage = storageFactory.getSSPConfigPersistentStorage(); 45 | return persistentStorage.get(); 46 | } 47 | 48 | @RequestMapping(value = "/sspconfig", method = RequestMethod.POST, 49 | produces = "application/json;charset=utf-8", consumes = "application/json") 50 | public @ResponseBody SSPConfig save(@RequestBody SSPConfig sspConfig) { 51 | 52 | SSPConfigPersistentStorage persistentStorage = storageFactory.getSSPConfigPersistentStorage(); 53 | return persistentStorage.save(sspConfig); 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/exception/MissingPipelineException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.exception; 16 | 17 | import javax.servlet.ServletException; 18 | 19 | import org.springframework.http.HttpStatus; 20 | import org.springframework.web.bind.annotation.ResponseStatus; 21 | 22 | @ResponseStatus(value=HttpStatus.NOT_FOUND, reason="Pipeline Not Found") //404 23 | public class MissingPipelineException extends ServletException { 24 | private static final long serialVersionUID = 156338621418684633L; 25 | private String message; 26 | 27 | public MissingPipelineException(){ 28 | super(); 29 | } 30 | 31 | public MissingPipelineException(String message){ 32 | this.message = message; 33 | } 34 | 35 | public String getMessage() { 36 | return message; 37 | } 38 | 39 | public void setMessage(String message) { 40 | this.message = message; 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/exception/MissingTenantException.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.exception; 16 | 17 | import javax.servlet.ServletException; 18 | 19 | import org.springframework.http.HttpStatus; 20 | import org.springframework.web.bind.annotation.ResponseStatus; 21 | @ResponseStatus(value=HttpStatus.NOT_FOUND, reason="Tenant Not Found") //404 22 | public class MissingTenantException extends ServletException{ 23 | private static final long serialVersionUID = 156338621418684632L; 24 | private String message; 25 | 26 | public MissingTenantException(){ 27 | super(); 28 | } 29 | 30 | public MissingTenantException(String message){ 31 | this.message = message; 32 | } 33 | 34 | public String getMessage() { 35 | return message; 36 | } 37 | 38 | public void setMessage(String message) { 39 | this.message = message; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/kettle/KettleProperties.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.kettle; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import org.springframework.boot.context.properties.ConfigurationProperties; 21 | import org.springframework.stereotype.Component; 22 | 23 | @Component 24 | @ConfigurationProperties(prefix = "kettle") 25 | public class KettleProperties { 26 | private List databaseConnectionNames = new ArrayList<>(); 27 | 28 | public List getDatabaseConnectionNames() { 29 | return databaseConnectionNames; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/model/ExceptionResponseDto.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.model; 16 | 17 | public class ExceptionResponseDto { 18 | 19 | private Long timestamp; 20 | private Integer status; 21 | private String error; 22 | private String message; 23 | private String path; 24 | 25 | 26 | public Long getTimestamp() { 27 | return timestamp; 28 | } 29 | 30 | 31 | public void setTimestamp(Long timestamp) { 32 | this.timestamp = timestamp; 33 | } 34 | 35 | 36 | public Integer getStatus() { 37 | return status; 38 | } 39 | 40 | 41 | public void setStatus(Integer status) { 42 | this.status = status; 43 | } 44 | 45 | 46 | public String getError() { 47 | return error; 48 | } 49 | 50 | 51 | public void setError(String error) { 52 | this.error = error; 53 | } 54 | 55 | 56 | public String getMessage() { 57 | return message; 58 | } 59 | 60 | 61 | public void setMessage(String message) { 62 | this.message = message; 63 | } 64 | 65 | public String getPath() { 66 | return path; 67 | } 68 | 69 | 70 | public void setPath(String path) { 71 | this.path = path; 72 | } 73 | 74 | 75 | @Override 76 | public String toString() { 77 | return "ExceptionResponseDto [timestamp=" + timestamp + ", status=" + status + ", error=" + error + ", message=" 78 | + message + ", path=" + path + "]"; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/model/Pipeline.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.model; 16 | 17 | /** 18 | * This is an object that represents a pipeline which is being processed. 19 | * It will serve as the holder for data while the pipeline is being processed 20 | * and also will keep track of the metadata related to each executing pipeline. 21 | * 22 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 23 | */ 24 | public class Pipeline { 25 | 26 | /** 27 | * unique ID for this instance of the pipeline (should be unique for each run of the pipeline) 28 | */ 29 | public String pipelineId; 30 | /** 31 | * the type of pipeline (e.g. marist_student_risk) 32 | */ 33 | public String pipelineType; 34 | 35 | /** 36 | * The UTC timecode at which we initialized this pipeline 37 | */ 38 | public long timeInit; 39 | /** 40 | * The UTC timecode for the start of data loading 41 | */ 42 | public long timeInput; 43 | /** 44 | * The UTC timecode for the start of pipeline processing 45 | */ 46 | public long timeStart; 47 | /** 48 | * The UTC timecode for the end of pipeline processing 49 | */ 50 | public long timeEnd; 51 | /** 52 | * The UTC timecode for the start of output processing 53 | */ 54 | public long timeOutput; 55 | /** 56 | * The UTC timecode for the end of pipeline processing (after notifications) 57 | */ 58 | public long timeComplete; 59 | 60 | /** 61 | * The configuration settings for this pipeline 62 | */ 63 | PipelineConfig config; 64 | 65 | // TODO tracking fields for processing 66 | 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/model/Processor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.model; 16 | 17 | import org.apache.commons.lang.StringUtils; 18 | 19 | /** 20 | * Defines a pipeline processor. 21 | * This is where all the work in the pipeline happens. 22 | */ 23 | public class Processor { 24 | public ProcessorType type; 25 | /** 26 | * The name of this processor (for printing mostly) 27 | */ 28 | public String name; 29 | /** 30 | * The filename related to this processor (e.g. kettle kjb) 31 | */ 32 | public String filename; 33 | /** 34 | * The configured count (usually for iterations) 35 | */ 36 | public int count; 37 | 38 | Processor() {} 39 | 40 | /** 41 | * Create a Pentaho Kettle based processor object 42 | * @param name the name of this part of the processor (mostly for logging and visuals) 43 | * @param filename the complete path (or relative from the pipelines directory) to the kettle ktr or kjb xml file 44 | * @return the processor object 45 | */ 46 | public static Processor makeKettleJob(String name, String filename) { 47 | assert StringUtils.isNotBlank(name); 48 | assert StringUtils.isNotBlank(filename); 49 | Processor obj = new Processor(); 50 | obj.type = ProcessorType.KETTLE_JOB; 51 | obj.name = name; 52 | obj.filename = filename; 53 | return obj; 54 | } 55 | 56 | public static Processor makeKettleTransform(String name, String filename) { 57 | Processor obj = makeKettleJob(name, filename); 58 | obj.type = ProcessorType.KETTLE_TRANSFORM; 59 | return obj; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "Processor{" + 65 | type + ", name='" + name + '\'' + 66 | ", filename='" + filename + '\'' + 67 | '}'; 68 | } 69 | 70 | /** 71 | * Represents the possible processor types 72 | */ 73 | public static enum ProcessorType { 74 | /** 75 | * A Pentaho Kettle Job processor 76 | */ 77 | KETTLE_JOB, 78 | /** 79 | * A Pentaho Kettle transform processor 80 | */ 81 | KETTLE_TRANSFORM, 82 | /** 83 | * Pentaho Kettle output 84 | */ 85 | KETTLE_DATA; 86 | 87 | static ProcessorType fromString(String str) { 88 | return Enum.valueOf(ProcessorType.class, str.toUpperCase()); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/model/SSPConfig.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.apereo.lap.model; 5 | 6 | import java.io.Serializable; 7 | 8 | import javax.persistence.Id; 9 | 10 | /** 11 | * @author ggilbert 12 | * 13 | */ 14 | public class SSPConfig implements Serializable { 15 | 16 | private static final long serialVersionUID = 1L; 17 | 18 | @Id private String id; 19 | private String key; 20 | private String secret; 21 | private String url; 22 | private String riskRule; 23 | 24 | public String getId() { 25 | return id; 26 | } 27 | public void setId(String id) { 28 | this.id = id; 29 | } 30 | public String getKey() { 31 | return key; 32 | } 33 | public void setKey(String key) { 34 | this.key = key; 35 | } 36 | public String getSecret() { 37 | return secret; 38 | } 39 | public void setSecret(String secret) { 40 | this.secret = secret; 41 | } 42 | public String getUrl() { 43 | return url; 44 | } 45 | public void setUrl(String url) { 46 | this.url = url; 47 | } 48 | public String getRiskRule() { 49 | return riskRule; 50 | } 51 | public void setRiskRule(String riskRule) { 52 | this.riskRule = riskRule; 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/model/api/ModelOutputRecord.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.model.api; 19 | 20 | import org.apereo.lap.services.storage.ModelOutput; 21 | import org.springframework.hateoas.Resource; 22 | 23 | /** 24 | * @author ggilbert 25 | * 26 | */ 27 | public class ModelOutputRecord extends Resource { 28 | public ModelOutputRecord (ModelOutput data) { 29 | super(data); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/model/api/ModelOutputResourceAssembler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.model.api; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import org.apereo.lap.controllers.api.ModelOutputController; 21 | import org.apereo.lap.services.storage.ModelOutput; 22 | import org.springframework.hateoas.mvc.ResourceAssemblerSupport; 23 | import org.springframework.stereotype.Component; 24 | 25 | @Component 26 | public class ModelOutputResourceAssembler extends ResourceAssemblerSupport { 27 | 28 | public ModelOutputResourceAssembler() { 29 | super(ModelOutputController.class, ModelOutputRecord.class); 30 | } 31 | 32 | @Override 33 | public ModelOutputRecord toResource(ModelOutput modelOutput) { 34 | return new ModelOutputRecord(modelOutput); 35 | } 36 | 37 | @Override 38 | public List toResources(Iterable modelOutputEntities) { 39 | List modelOutputRecords = new ArrayList(); 40 | for (ModelOutput modelOutput : modelOutputEntities) { 41 | modelOutputRecords.add(new ModelOutputRecord(modelOutput)); 42 | } 43 | return modelOutputRecords; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/model/api/ModelRunRecord.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.model.api; 19 | 20 | import org.apereo.lap.services.storage.ModelRun; 21 | import org.springframework.hateoas.Resource; 22 | 23 | /** 24 | * @author ggilbert 25 | * 26 | */ 27 | public class ModelRunRecord extends Resource { 28 | public ModelRunRecord (ModelRun data) { 29 | super(data); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/model/api/ModelRunResourceAssembler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.model.api; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | import org.apereo.lap.controllers.ModelRunController; 24 | import org.apereo.lap.services.storage.ModelRun; 25 | import org.springframework.hateoas.mvc.ResourceAssemblerSupport; 26 | import org.springframework.stereotype.Component; 27 | 28 | /** 29 | * @author ggilbert 30 | * 31 | */ 32 | @Component 33 | public class ModelRunResourceAssembler extends ResourceAssemblerSupport { 34 | public ModelRunResourceAssembler() { 35 | super(ModelRunController.class, ModelRunRecord.class); 36 | } 37 | 38 | @Override 39 | public ModelRunRecord toResource(ModelRun modelRun) { 40 | return new ModelRunRecord(modelRun); 41 | } 42 | 43 | @Override 44 | public List toResources(Iterable modelRunEntities) { 45 | List modelRunRecords = new ArrayList(); 46 | for (ModelRun modelRun : modelRunEntities) { 47 | modelRunRecords.add(new ModelRunRecord(modelRun)); 48 | } 49 | return modelRunRecords; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/TenantService.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services; 19 | 20 | import java.util.HashMap; 21 | import java.util.Map; 22 | 23 | import javax.annotation.PostConstruct; 24 | 25 | import org.springframework.context.annotation.Scope; 26 | import org.springframework.context.annotation.ScopedProxyMode; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * @author ggilbert 31 | * 32 | */ 33 | @Component 34 | @Scope(value="session", proxyMode = ScopedProxyMode.TARGET_CLASS) 35 | public class TenantService { 36 | private String tenant; 37 | Map tenantKeyMap; 38 | 39 | @PostConstruct 40 | public void init() { 41 | // TODO - eventually moved to a singleton 42 | tenantKeyMap = new HashMap(); 43 | tenantKeyMap.put("opendash", "tenant1"); 44 | } 45 | 46 | public String getTenant() { 47 | String mappedValue = tenantKeyMap.get(tenant); 48 | if (org.apache.commons.lang.StringUtils.isNotBlank(mappedValue)) { 49 | return mappedValue; 50 | } 51 | return tenant; 52 | } 53 | 54 | public void setTenant(String tenant) { 55 | this.tenant = tenant; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/input/handlers/csv/ActivityCSVInputHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.input.handlers.csv; 16 | 17 | import java.sql.Types; 18 | 19 | import org.apereo.lap.services.configuration.ConfigurationService; 20 | import org.apereo.lap.services.input.BaseInputHandlerService; 21 | import org.springframework.jdbc.core.JdbcTemplate; 22 | 23 | import au.com.bytecode.opencsv.CSVReader; 24 | 25 | public class ActivityCSVInputHandler extends BaseCSVInputHandler { 26 | static final String SQL_INSERT = "INSERT INTO ACTIVITY (ALTERNATIVE_ID,COURSE_ID,EVENT,EVENT_DATE) VALUES (?,?,?,?)"; 27 | 28 | static final int[] SQL_TYPES = new int[] { 29 | // ALTERNATIVE_ID,COURSE_ID,EVENT,EVENT_DATE 30 | Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP 31 | }; 32 | 33 | public ActivityCSVInputHandler(ConfigurationService configuration, JdbcTemplate jdbcTemplate) { 34 | super(configuration, jdbcTemplate); 35 | } 36 | 37 | @Override 38 | public int getOrder() { 39 | return 5; 40 | } 41 | 42 | @Override 43 | public String makeInsertSQL() { 44 | return SQL_INSERT; 45 | } 46 | 47 | @Override 48 | public int[] makeInsertSQLParams() { 49 | return SQL_TYPES; 50 | } 51 | 52 | @Override 53 | public BaseInputHandlerService.InputCollection getInputCollection() { 54 | return BaseInputHandlerService.InputCollection.ACTIVITY; 55 | } 56 | 57 | @Override 58 | public CSVReader readCSV(boolean reRead) { 59 | return readCSV(4, "ALTERNATIVE_ID", reRead); 60 | } 61 | 62 | @Override 63 | public ReadResult readInputIntoDB() { 64 | CSVReader reader = readCSV(false); 65 | return readCSVFileIntoDB(reader); 66 | } 67 | 68 | @Override 69 | public Object[] validateAndConvertParams(String[] csvLine) { 70 | assert csvLine != null && csvLine.length > 0; 71 | Object[] params = new Object[csvLine.length]; 72 | params[0] = parseString(csvLine[0], null, true, "ALTERNATIVE_ID"); 73 | params[1] = parseString(csvLine[1], null, true, "COURSE_ID"); 74 | params[2] = parseString(csvLine[2], null, true, "EVENT"); 75 | params[3] = parseDateTime(csvLine[3], true, "EVENT_DATE"); 76 | return params; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/input/handlers/csv/CSVInputHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.input.handlers.csv; 16 | 17 | import org.apereo.lap.services.input.handlers.InputHandler; 18 | 19 | import au.com.bytecode.opencsv.CSVReader; 20 | 21 | /** 22 | * Handles the CSV input processing for a single CSV file 23 | * 24 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 25 | */ 26 | public interface CSVInputHandler extends InputHandler { 27 | 28 | /** 29 | * @return the path name of the CSV 30 | */ 31 | String getPath(); 32 | 33 | /** 34 | * Sets the filePath explicitly 35 | */ 36 | void setPath(String path); 37 | 38 | /** 39 | * Read in the CSV file (does not process it, only the header line) 40 | * NOTE: the implementation SHOULD cache this so it is not rebuilt every time this method is called (unless reRead is true) 41 | * @param reRead force reading the file again (otherwise it will use the cached copy) 42 | * @return the CSVReader 43 | * @throws IllegalStateException if we fail to produce the reader 44 | */ 45 | CSVReader readCSV(boolean reRead); 46 | 47 | int getOrder(); 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/input/handlers/csv/CourseCSVInputHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.input.handlers.csv; 16 | 17 | import java.sql.Types; 18 | 19 | import org.apereo.lap.services.configuration.ConfigurationService; 20 | import org.apereo.lap.services.input.BaseInputHandlerService; 21 | import org.springframework.jdbc.core.JdbcTemplate; 22 | 23 | import au.com.bytecode.opencsv.CSVReader; 24 | 25 | public class CourseCSVInputHandler extends BaseCSVInputHandler { 26 | 27 | static final String SQL_INSERT = "INSERT INTO COURSE (COURSE_ID,SUBJECT,ENROLLMENT,ONLINE_FLAG) VALUES (?,?,?,?)"; 28 | 29 | static final int[] SQL_TYPES = new int[] { 30 | // COURSE_ID,SUBJECT,ENROLLMENT,ONLINE_FLAG 31 | Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.BOOLEAN 32 | }; 33 | 34 | public CourseCSVInputHandler(ConfigurationService configuration, JdbcTemplate jdbcTemplate) { 35 | super(configuration, jdbcTemplate); 36 | } 37 | 38 | @Override 39 | public int getOrder() { 40 | return 2; 41 | } 42 | 43 | @Override 44 | public String makeInsertSQL() { 45 | return SQL_INSERT; 46 | } 47 | 48 | @Override 49 | public int[] makeInsertSQLParams() { 50 | return SQL_TYPES; 51 | } 52 | 53 | @Override 54 | public BaseInputHandlerService.InputCollection getInputCollection() { 55 | return BaseInputHandlerService.InputCollection.COURSE; 56 | } 57 | 58 | @Override 59 | public CSVReader readCSV(boolean reRead) { 60 | return readCSV(4, "COURSE_ID", reRead); 61 | } 62 | 63 | @Override 64 | public ReadResult readInputIntoDB() { 65 | CSVReader reader = readCSV(false); 66 | return readCSVFileIntoDB(reader); 67 | } 68 | 69 | @Override 70 | public Object[] validateAndConvertParams(String[] csvLine) { 71 | assert csvLine != null && csvLine.length > 0; 72 | Object[] params = new Object[csvLine.length]; 73 | params[0] = parseString(csvLine[0], null, true, "COURSE_ID"); 74 | params[1] = parseString(csvLine[1], null, false, "SUBJECT"); 75 | params[2] = parseInt(csvLine[2], 0, null, false, "ENROLLMENT"); 76 | params[3] = parseBoolean(csvLine[3], false, "ONLINE_FLAG"); 77 | return params; 78 | } 79 | 80 | } 81 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/input/handlers/csv/EnrollmentCSVInputHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.input.handlers.csv; 16 | 17 | import java.sql.Types; 18 | 19 | import org.apereo.lap.services.configuration.ConfigurationService; 20 | import org.apereo.lap.services.input.BaseInputHandlerService; 21 | import org.springframework.jdbc.core.JdbcTemplate; 22 | 23 | import au.com.bytecode.opencsv.CSVReader; 24 | 25 | public class EnrollmentCSVInputHandler extends BaseCSVInputHandler { 26 | 27 | public static final String FILENAME = "enrollment.csv"; 28 | 29 | static final String SQL_INSERT = "INSERT INTO ENROLLMENT (ALTERNATIVE_ID,COURSE_ID,FINAL_GRADE,WITHDRAWAL_DATE) VALUES (?,?,?,?)"; 30 | 31 | static final int[] SQL_TYPES = new int[] { 32 | // ALTERNATIVE_ID,COURSE_ID,FINAL_GRADE,WITHDRAWAL_DATE 33 | Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.TIMESTAMP 34 | }; 35 | 36 | public EnrollmentCSVInputHandler(ConfigurationService configuration, JdbcTemplate jdbcTemplate) { 37 | super(configuration, jdbcTemplate); 38 | } 39 | 40 | @Override 41 | public int getOrder() { 42 | return 3; 43 | } 44 | 45 | @Override 46 | public String makeInsertSQL() { 47 | return SQL_INSERT; 48 | } 49 | 50 | @Override 51 | public int[] makeInsertSQLParams() { 52 | return SQL_TYPES; 53 | } 54 | 55 | @Override 56 | public BaseInputHandlerService.InputCollection getInputCollection() { 57 | return BaseInputHandlerService.InputCollection.ENROLLMENT; 58 | } 59 | 60 | @Override 61 | public CSVReader readCSV(boolean reRead) { 62 | return readCSV(4, "ALTERNATIVE_ID", reRead); 63 | } 64 | 65 | @Override 66 | public ReadResult readInputIntoDB() { 67 | CSVReader reader = readCSV(false); 68 | return readCSVFileIntoDB(reader); 69 | } 70 | 71 | @Override 72 | public Object[] validateAndConvertParams(String[] csvLine) { 73 | assert csvLine != null && csvLine.length > 0; 74 | Object[] params = new Object[csvLine.length]; 75 | params[0] = parseString(csvLine[0], null, true, "ALTERNATIVE_ID"); 76 | params[1] = parseString(csvLine[1], null, true, "COURSE_ID"); 77 | params[2] = parseString(csvLine[2], new String[] {"A","A-","B+","B","B-","C+","C","C-","D+","D","D-","F","I","W"}, false, "FINAL_GRADE"); 78 | params[3] = parseDateTime(csvLine[3], false, "WITHDRAWAL_DATE"); 79 | return params; 80 | } 81 | 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/input/handlers/csv/GradeCSVInputHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.input.handlers.csv; 16 | 17 | import java.sql.Types; 18 | 19 | import org.apereo.lap.services.configuration.ConfigurationService; 20 | import org.apereo.lap.services.input.BaseInputHandlerService; 21 | import org.springframework.jdbc.core.JdbcTemplate; 22 | 23 | import au.com.bytecode.opencsv.CSVReader; 24 | 25 | public class GradeCSVInputHandler extends BaseCSVInputHandler { 26 | 27 | public static final String FILENAME = "grade.csv"; 28 | 29 | static final String SQL_INSERT = "INSERT INTO GRADE (ALTERNATIVE_ID,COURSE_ID,GRADABLE_OBJECT,CATEGORY,MAX_POINTS,EARNED_POINTS,WEIGHT,GRADE_DATE) VALUES (?,?,?,?,?,?,?,?)"; 30 | 31 | static final int[] SQL_TYPES = new int[] { 32 | // ALTERNATIVE_ID,COURSE_ID,GRADABLE_OBJECT,CATEGORY, 33 | Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, 34 | // MAX_POINTS,EARNED_POINTS,WEIGHT,GRADE_DATE 35 | Types.INTEGER, Types.INTEGER, Types.FLOAT, Types.TIMESTAMP 36 | }; 37 | 38 | public GradeCSVInputHandler(ConfigurationService configuration, JdbcTemplate jdbcTemplate) { 39 | super(configuration, jdbcTemplate); 40 | } 41 | 42 | @Override 43 | public int getOrder() { 44 | return 4; 45 | } 46 | @Override 47 | public String makeInsertSQL() { 48 | return SQL_INSERT; 49 | } 50 | 51 | @Override 52 | public int[] makeInsertSQLParams() { 53 | return SQL_TYPES; 54 | } 55 | 56 | @Override 57 | public BaseInputHandlerService.InputCollection getInputCollection() { 58 | return BaseInputHandlerService.InputCollection.GRADE; 59 | } 60 | 61 | @Override 62 | public CSVReader readCSV(boolean reRead) { 63 | return readCSV(8, "ALTERNATIVE_ID", reRead); 64 | } 65 | 66 | @Override 67 | public ReadResult readInputIntoDB() { 68 | CSVReader reader = readCSV(false); 69 | return readCSVFileIntoDB(reader); 70 | } 71 | 72 | @Override 73 | public Object[] validateAndConvertParams(String[] csvLine) { 74 | assert csvLine != null && csvLine.length > 0; 75 | Object[] params = new Object[csvLine.length]; 76 | params[0] = parseString(csvLine[0], null, true, "ALTERNATIVE_ID"); 77 | params[1] = parseString(csvLine[1], null, true, "COURSE_ID"); 78 | params[2] = parseString(csvLine[2], null, true, "GRADABLE_OBJECT"); 79 | params[3] = parseString(csvLine[3], null, false, "CATEGORY"); 80 | params[4] = parseFloat(csvLine[4], 0f, 1000f, false, "MAX_POINTS"); // default 0 81 | params[5] = parseFloat(csvLine[5], 0f, 1000f, false, "EARNED_POINTS"); // default 0 82 | params[6] = parseFloat(csvLine[6], 0f, 1f, false, "WEIGHT"); 83 | params[7] = parseDateTime(csvLine[7], false, "GRADE_DATE"); 84 | return params; 85 | } 86 | 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/notification/NotificationService.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.notification; 16 | 17 | import java.io.IOException; 18 | import java.util.List; 19 | 20 | import javax.annotation.PostConstruct; 21 | import javax.annotation.PreDestroy; 22 | 23 | import org.apereo.lap.services.configuration.ConfigurationService; 24 | import org.apereo.lap.services.notification.handlers.NotificationHandler; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | import org.springframework.beans.factory.annotation.Autowired; 28 | import org.springframework.stereotype.Component; 29 | 30 | /** 31 | * Handles all notifications from the app 32 | * 33 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 34 | */ 35 | @Component 36 | public class NotificationService { 37 | 38 | private static final Logger logger = LoggerFactory.getLogger(NotificationService.class); 39 | 40 | public static enum NotificationLevel { 41 | /** 42 | * Informational notification (non-critical) 43 | */ 44 | INFO, 45 | /** 46 | * Critical notification 47 | */ 48 | CRITICAL 49 | } 50 | 51 | @Autowired ConfigurationService config; 52 | 53 | @Autowired 54 | List notificationHandlers; 55 | 56 | @PostConstruct 57 | public void init() throws IOException { 58 | logger.info("INIT"); 59 | } 60 | 61 | @PreDestroy 62 | public void destroy() { 63 | logger.info("DESTROY"); 64 | } 65 | 66 | public void sendNotification(String message, NotificationLevel level) { 67 | if (level == null) { 68 | level = NotificationLevel.INFO; 69 | } 70 | for (NotificationHandler notificationHandler : notificationHandlers) { 71 | notificationHandler.sendNotification(level, message); 72 | } 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/notification/handlers/LogNotificationHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.notification.handlers; 16 | 17 | import org.apereo.lap.services.configuration.ConfigurationService; 18 | import org.apereo.lap.services.notification.NotificationService; 19 | import org.slf4j.Logger; 20 | import org.slf4j.LoggerFactory; 21 | import org.springframework.beans.factory.annotation.Autowired; 22 | import org.springframework.stereotype.Component; 23 | 24 | /** 25 | * Handles specific notifications by writing them to the logs 26 | * 27 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 28 | */ 29 | @Component 30 | public class LogNotificationHandler implements NotificationHandler { 31 | 32 | private static final Logger logger = LoggerFactory.getLogger(LogNotificationHandler.class); 33 | 34 | @Autowired 35 | ConfigurationService configuration; 36 | 37 | @Override 38 | public String getNotificationType() { 39 | return "Logger"; 40 | } 41 | 42 | @Override 43 | public void sendNotification(NotificationService.NotificationLevel type, String message) { 44 | if (NotificationService.NotificationLevel.CRITICAL == type) { 45 | logger.error(message); 46 | } else { 47 | logger.info(message); 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/notification/handlers/NotificationHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.notification.handlers; 16 | 17 | import org.apereo.lap.services.notification.NotificationService; 18 | 19 | /** 20 | * Handles a specific notification type 21 | * 22 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 23 | */ 24 | public interface NotificationHandler { 25 | 26 | /** 27 | * @return the name of this type of notification (e.g. EMAIL) 28 | */ 29 | String getNotificationType(); 30 | 31 | /** 32 | * Sends a notification after pipeline processing is complete 33 | * @param type 34 | * @param message 35 | */ 36 | public void sendNotification(NotificationService.NotificationLevel type, String message); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/output/OutputHandlerService.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.output; 16 | 17 | import java.util.List; 18 | 19 | import javax.annotation.PostConstruct; 20 | import javax.annotation.PreDestroy; 21 | 22 | import org.apereo.lap.model.Output; 23 | import org.apereo.lap.services.output.handlers.OutputHandler; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | import org.springframework.beans.factory.annotation.Autowired; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * Handles the the data outputs from the pipeline (including the generation of output formats) 31 | * 32 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 33 | */ 34 | @Component 35 | public class OutputHandlerService { 36 | 37 | private static final Logger logger = LoggerFactory.getLogger(OutputHandlerService.class); 38 | 39 | @Autowired 40 | List outputHandlers; 41 | 42 | @PostConstruct 43 | public void init() { 44 | logger.info("INIT"); 45 | } 46 | 47 | @PreDestroy 48 | public void destroy() { 49 | logger.info("DESTROY"); 50 | } 51 | 52 | /** 53 | * Process the output for the given Output 54 | * @param output defines the requested output type 55 | * @return the result of the output processing 56 | * @throws java.lang.IllegalArgumentException is the inputs are bad 57 | * @throws java.lang.IllegalStateException is the result is invalid (null) 58 | * @throws java.lang.RuntimeException if the output handler fails 59 | */ 60 | public OutputHandler.OutputResult doOutput(Output output) { 61 | assert output != null; 62 | OutputHandler.OutputResult result = null; 63 | boolean found = false; 64 | for (OutputHandler outputHandler : outputHandlers) { 65 | // NOTE: more than one output handler is allowed per type but only the last ones results will be passed back 66 | if (output.type == outputHandler.getHandledType()) { 67 | try { 68 | result = outputHandler.writeOutput(output); 69 | found = true; 70 | } catch (Exception e) { 71 | throw new RuntimeException("Handler failed during processing: "+output.type+" :"+e, e); 72 | } 73 | } 74 | } 75 | if (!found) { 76 | throw new IllegalArgumentException("No handler for output type: "+output.type); 77 | } else if (result == null) { 78 | throw new IllegalStateException("Handler returned null result: "+output.type); 79 | } 80 | return result; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/output/handlers/BaseOutputHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.output.handlers; 16 | 17 | import org.apereo.lap.services.configuration.ConfigurationService; 18 | import org.apereo.lap.services.storage.StorageService; 19 | import org.springframework.beans.factory.annotation.Autowired; 20 | 21 | /** 22 | * Handles the output processing for a single target output type 23 | * 24 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 25 | */ 26 | public abstract class BaseOutputHandler implements OutputHandler { 27 | 28 | @Autowired ConfigurationService configuration; 29 | 30 | @Autowired StorageService storage; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/output/handlers/OutputHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.output.handlers; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Date; 19 | 20 | import org.apereo.lap.model.Output; 21 | 22 | /** 23 | * Handles the output processing for a single target output type 24 | * 25 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 26 | */ 27 | public interface OutputHandler { 28 | 29 | /** 30 | * @return the name of the data type handled by this handler 31 | */ 32 | Output.OutputType getHandledType(); 33 | 34 | /** 35 | * Process this output request 36 | * @param output the output config 37 | * @return the results of the output processing 38 | * @throws java.lang.IllegalStateException if the output source will not accept the write 39 | */ 40 | OutputResult writeOutput(Output output); 41 | 42 | public static class OutputResult { 43 | public String modelRunId; 44 | public String name; 45 | public Output.OutputType handledType; 46 | public Output output; 47 | public long totalTimeMS; 48 | public long startTimeMS; 49 | public long endTimeMS; 50 | public int total = 0; 51 | public int loaded = 0; 52 | public int failed = 0; 53 | public ArrayList failures; 54 | 55 | public OutputResult(Output output) { 56 | this.output = output; 57 | this.handledType = output.type; 58 | this.name = output.getName(); 59 | startTimeMS = System.currentTimeMillis(); 60 | } 61 | 62 | public void done(int itemsCount, ArrayList failures) { 63 | this.total = itemsCount; 64 | this.failures = failures; 65 | this.failed = failures != null ? failures.size() : 0; 66 | this.loaded = total - this.failed; 67 | this.endTimeMS = System.currentTimeMillis(); 68 | this.totalTimeMS = this.endTimeMS - this.startTimeMS; 69 | } 70 | 71 | public void done(String modelRunId, int itemsCount) { 72 | this.modelRunId = modelRunId; 73 | this.total = itemsCount; 74 | this.endTimeMS = System.currentTimeMillis(); 75 | this.totalTimeMS = this.endTimeMS - this.startTimeMS; 76 | } 77 | 78 | @Override 79 | public String toString() { 80 | return "OutputResult:" + name + 81 | ", modelRunId=" + modelRunId + 82 | ", total=" + total + 83 | ", loaded=" + loaded + 84 | ", failed=" + failed + 85 | ", runSecs=" + String.format("%.2f", totalTimeMS/1000f) + 86 | ", started=" + new Date(startTimeMS); 87 | } 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/output/handlers/StorageOutputHandler.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.output.handlers; 16 | 17 | import java.util.ArrayList; 18 | import java.util.HashMap; 19 | import java.util.List; 20 | import java.util.Map; 21 | import java.util.UUID; 22 | 23 | 24 | 25 | //import org.apereo.lap.dao.RiskConfidenceRepository; 26 | //import org.apereo.lap.dao.model.RiskConfidence; 27 | import org.apereo.lap.model.Output; 28 | import org.apereo.lap.services.storage.ModelOutput; 29 | import org.apereo.lap.services.storage.PersistentStorage; 30 | import org.apereo.lap.services.storage.StorageFactory; 31 | import org.springframework.beans.factory.annotation.Autowired; 32 | import org.springframework.jdbc.InvalidResultSetAccessException; 33 | import org.springframework.jdbc.support.rowset.SqlRowSet; 34 | import org.springframework.jdbc.support.rowset.SqlRowSetMetaData; 35 | import org.springframework.stereotype.Component; 36 | 37 | /** 38 | * Handles the output processing for a single target output type 39 | * 40 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 41 | */ 42 | @Component 43 | public class StorageOutputHandler extends BaseOutputHandler implements OutputHandler { 44 | 45 | 46 | @Autowired 47 | private StorageFactory storageFactory; 48 | 49 | @Override 50 | public Output.OutputType getHandledType() { 51 | return Output.OutputType.STORAGE; 52 | } 53 | 54 | @Override 55 | public OutputResult writeOutput(Output output) { 56 | 57 | PersistentStorage persistentStorage = storageFactory.getPersistentStorage(); 58 | 59 | OutputResult result = new OutputResult(output); 60 | 61 | String selectSQL = output.makeTempDBSelectStarSQL(); 62 | 63 | SqlRowSet rowSet = null; 64 | SqlRowSetMetaData metadata = null; 65 | try { 66 | rowSet = storage.getTempJdbcTemplate().queryForRowSet(selectSQL); 67 | metadata = rowSet.getMetaData(); 68 | } catch (Exception e) { 69 | throw new RuntimeException("Failure while trying to retrieve the output data set: " + selectSQL); 70 | } 71 | 72 | List modelOutputEntities = new ArrayList(); 73 | String modelRunId = UUID.randomUUID().toString(); 74 | while (rowSet.next()) { 75 | ModelOutput modelOutput = new ModelOutput(); 76 | Map data = new HashMap(); 77 | for (String column : metadata.getColumnNames()) { 78 | data.put(column, rowSet.getObject(column)); 79 | } 80 | modelOutput.setOutput(data); 81 | modelOutput.setModelRunId(modelRunId); 82 | modelOutputEntities.add(modelOutput); 83 | } 84 | 85 | persistentStorage.saveAll(modelOutputEntities); 86 | result.done(modelRunId, modelOutputEntities.size()); 87 | 88 | return result; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/pipelines/KettleBasePipelineProcessor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.pipelines; 16 | 17 | import org.apereo.lap.kettle.KettleConfiguration; 18 | import org.apereo.lap.services.configuration.ConfigurationService; 19 | import org.apereo.lap.services.storage.StorageService; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | 24 | /** 25 | * Handles the pipeline processing for Kettle processors 26 | * 27 | * @author Robert Long (rlong @ unicon.net) 28 | */ 29 | public abstract class KettleBasePipelineProcessor implements PipelineProcessor{ 30 | 31 | protected final Logger logger = LoggerFactory.getLogger(getClass()); 32 | 33 | @Autowired ConfigurationService configurationService; 34 | 35 | @Autowired StorageService storage; 36 | 37 | @Autowired 38 | protected KettleConfiguration kettleConfiguration; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/pipelines/KettleJobPipelineProcessor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.pipelines; 16 | 17 | import org.apereo.lap.model.PipelineConfig; 18 | import org.apereo.lap.model.Processor; 19 | import org.pentaho.di.core.Result; 20 | import org.pentaho.di.job.Job; 21 | import org.pentaho.di.job.JobMeta; 22 | import org.springframework.stereotype.Component; 23 | 24 | /** 25 | * Handles the pipeline processing for Kettle Job processors 26 | * 27 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 28 | * @author Robert Long (rlong @ unicon.net) 29 | */ 30 | @Component 31 | public class KettleJobPipelineProcessor extends KettleBasePipelineProcessor { 32 | 33 | @Override 34 | public Processor.ProcessorType getProcessorType() { 35 | return Processor.ProcessorType.KETTLE_JOB; 36 | } 37 | 38 | @Override 39 | public ProcessorResult process(PipelineConfig pipelineConfig, Processor processorConfig, String inputJson) { 40 | ProcessorResult result = new ProcessorResult(Processor.ProcessorType.KETTLE_JOB); 41 | 42 | try { 43 | JobMeta jobMeta = new JobMeta(configurationService.getApplicationHomeDirectory().resolve(processorConfig.filename).toString(), null, null); 44 | 45 | // update the shared objects to use the pre-configured shared objects 46 | jobMeta.setSharedObjects(kettleConfiguration.getSharedObjects()); 47 | 48 | // run the job 49 | Job job = new Job(null, jobMeta); 50 | job.start(); 51 | job.waitUntilFinished(); 52 | 53 | // process the results 54 | Result jobResult = job.getResult(); 55 | result.done((int) jobResult.getNrErrors(), null); 56 | } catch(Exception e) { 57 | logger.error("An error occurred processing the job file: " + processorConfig.filename + ". Error: " + e, e); 58 | } 59 | 60 | return result; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/pipelines/KettleTransformPipelineProcessor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.pipelines; 16 | 17 | import org.apereo.lap.model.PipelineConfig; 18 | import org.apereo.lap.model.Processor; 19 | import org.apereo.lap.services.configuration.ConfigurationService; 20 | import org.pentaho.di.core.Result; 21 | import org.pentaho.di.trans.Trans; 22 | import org.pentaho.di.trans.TransMeta; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.stereotype.Component; 25 | 26 | /** 27 | * Handles the pipeline processing for Kettle processors 28 | * 29 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 30 | * @author Robert Long (rlong @ unicon.net) 31 | */ 32 | @Component 33 | public class KettleTransformPipelineProcessor extends KettleBasePipelineProcessor { 34 | 35 | 36 | @Autowired 37 | protected ConfigurationService configuration; 38 | 39 | 40 | @Override 41 | public Processor.ProcessorType getProcessorType() { 42 | return Processor.ProcessorType.KETTLE_TRANSFORM; 43 | } 44 | 45 | @Override 46 | public ProcessorResult process(PipelineConfig pipelineConfig, Processor processorConfig, String inputJson) { 47 | ProcessorResult result = new ProcessorResult(Processor.ProcessorType.KETTLE_TRANSFORM); 48 | try { 49 | TransMeta transMeta = new TransMeta(processorConfig.filename); 50 | 51 | // update the shared objects to use the pre-configured shared objects 52 | transMeta.setSharedObjects(kettleConfiguration.getSharedObjects()); 53 | 54 | // run the transformation 55 | Trans trans = new Trans(transMeta); 56 | trans.calculateBatchIdAndDateRange(); 57 | trans.beginProcessing(); 58 | trans.execute(new String[]{}); 59 | trans.waitUntilFinished(); 60 | 61 | // process the results 62 | Result transResult = trans.getResult(); 63 | result.done((int) transResult.getNrErrors(), null); 64 | } catch (Exception e) { 65 | logger.error("An error occurred processing the transformation file: " + processorConfig.filename + ". Error: " + e, e); 66 | } 67 | return result; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/pipelines/PipelineProcessor.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.pipelines; 16 | 17 | import java.util.ArrayList; 18 | import java.util.Date; 19 | 20 | import org.apereo.lap.model.PipelineConfig; 21 | import org.apereo.lap.model.Processor; 22 | 23 | /** 24 | * Handles the pipeline processing for a specific type of processor (e.g. Kettle) 25 | * 26 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 27 | */ 28 | public interface PipelineProcessor { 29 | 30 | /** 31 | * @return the name of the processor type handled by this processor 32 | */ 33 | Processor.ProcessorType getProcessorType(); 34 | 35 | /** 36 | * Do the actual processing for this processor (and populate the results data and temp store if needed) 37 | * 38 | * If there is a failure and the pipeline should be stopped then throw a RuntimeException 39 | * 40 | * @param pipelineConfig the pipeline config 41 | * @param processorConfig the processor config (within the pipeline config) 42 | * @param inputJson string of JSON for input (may be null) 43 | * @return the results of the processor run 44 | * @throws java.lang.RuntimeException if the processor fails 45 | */ 46 | ProcessorResult process(PipelineConfig pipelineConfig, Processor processorConfig, String inputJson); 47 | 48 | public static class ProcessorResult { 49 | public Processor.ProcessorType type; 50 | public int outputCount; 51 | public long totalTimeMS; 52 | public long startTimeMS; 53 | public long endTimeMS; 54 | public ArrayList failures; 55 | 56 | public ProcessorResult(Processor.ProcessorType processorType) { 57 | this.type = processorType; 58 | startTimeMS = System.currentTimeMillis(); 59 | } 60 | 61 | /** 62 | * @param outputCount the number of items output (e.g. rows written to DB) 63 | * @param failures List of String representing all failures that occurred (1 entry per failure) 64 | */ 65 | public void done(int outputCount, ArrayList failures) { 66 | this.outputCount = outputCount; 67 | if (failures == null) { 68 | this.failures = new ArrayList<>(0); 69 | } else { 70 | this.failures = failures; 71 | } 72 | this.endTimeMS = System.currentTimeMillis(); 73 | this.totalTimeMS = this.endTimeMS - this.startTimeMS; 74 | } 75 | 76 | @Override 77 | public String toString() { 78 | return "ProcessorResult{" + 79 | "type=" + type + 80 | ", outputCount=" + outputCount + 81 | ", failures=" + failures.size() + 82 | ", runSecs=" + String.format("%.2f", totalTimeMS/1000f) + 83 | ", started=" + new Date(startTimeMS) + 84 | '}'; 85 | } 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/DatasourceProperties.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage; 16 | 17 | import org.springframework.boot.context.properties.ConfigurationProperties; 18 | import org.springframework.stereotype.Component; 19 | 20 | @Component 21 | @ConfigurationProperties(prefix = "datasource") 22 | public class DatasourceProperties { 23 | public static class JdbcInfo { 24 | private String username; 25 | private String password; 26 | private String driverClassName; 27 | private String url; 28 | private String dialect; 29 | 30 | public String getUsername() { 31 | return username; 32 | } 33 | 34 | public void setUsername(String username) { 35 | this.username = username; 36 | } 37 | 38 | public String getPassword() { 39 | return password; 40 | } 41 | 42 | public void setPassword(String password) { 43 | this.password = password; 44 | } 45 | 46 | public String getDriverClassName() { 47 | return driverClassName; 48 | } 49 | 50 | public void setDriverClassName(String driverClassName) { 51 | this.driverClassName = driverClassName; 52 | } 53 | 54 | public String getUrl() { 55 | return url; 56 | } 57 | 58 | public void setUrl(String url) { 59 | this.url = url; 60 | } 61 | 62 | public String getDialect() { 63 | return dialect; 64 | } 65 | 66 | public void setDialect(String dialect) { 67 | this.dialect = dialect; 68 | } 69 | } 70 | 71 | private JdbcInfo temp = new JdbcInfo(); 72 | private JdbcInfo persistent = new JdbcInfo(); 73 | 74 | public JdbcInfo getTemp() { 75 | return temp; 76 | } 77 | 78 | public JdbcInfo getPersistent() { 79 | return persistent; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/ModelOutput.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage; 19 | 20 | import java.util.Date; 21 | import java.util.Map; 22 | 23 | import org.springframework.data.annotation.CreatedDate; 24 | import org.springframework.data.annotation.Id; 25 | import org.springframework.data.annotation.LastModifiedDate; 26 | 27 | import com.fasterxml.jackson.annotation.JsonPropertyOrder; 28 | 29 | 30 | /** 31 | * @author ggilbert 32 | * 33 | */ 34 | @JsonPropertyOrder({"id","output","modelRunId","createdDate","modifiedDate"}) 35 | public class ModelOutput implements PersistentLAPEntity { 36 | 37 | private static final long serialVersionUID = 1L; 38 | 39 | @Id private String id; 40 | private Map output; 41 | private String modelRunId; 42 | @CreatedDate 43 | private Date createdDate; 44 | @LastModifiedDate 45 | private Date modifiedDate; 46 | 47 | public String getId() { 48 | return id; 49 | } 50 | public void setId(String id) { 51 | this.id = id; 52 | } 53 | public Map getOutput() { 54 | return output; 55 | } 56 | public void setOutput(Map output) { 57 | this.output = output; 58 | } 59 | public String getModelRunId() { 60 | return modelRunId; 61 | } 62 | public void setModelRunId(String modelRunId) { 63 | this.modelRunId = modelRunId; 64 | } 65 | public Date getCreatedDate() { 66 | return createdDate; 67 | } 68 | public void setCreatedDate(Date createdDate) { 69 | this.createdDate = createdDate; 70 | } 71 | public Date getModifiedDate() { 72 | return modifiedDate; 73 | } 74 | public void setModifiedDate(Date modifiedDate) { 75 | this.modifiedDate = modifiedDate; 76 | } 77 | @Override 78 | public String toString() { 79 | return "ModelOutput [id=" + id + ", output=" + output + ", modelRunId=" + modelRunId + ", createdDate=" + createdDate + ", modifiedDate=" 80 | + modifiedDate + "]"; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/ModelRun.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage; 19 | 20 | import java.util.Date; 21 | 22 | import org.springframework.data.annotation.CreatedDate; 23 | import org.springframework.data.annotation.Id; 24 | 25 | import com.fasterxml.jackson.annotation.JsonProperty; 26 | 27 | /** 28 | * @author ggilbert 29 | * 30 | */ 31 | public class ModelRun implements PersistentLAPEntity { 32 | private static final long serialVersionUID = 1L; 33 | 34 | @Id private String id; 35 | 36 | @CreatedDate 37 | @JsonProperty("created_date") 38 | private Date createdDate; 39 | 40 | private String model_run_id; 41 | private String modelType; 42 | private String modelName; 43 | private int modelCount; 44 | private boolean success; 45 | 46 | public String getId() { 47 | return id; 48 | } 49 | public void setId(String id) { 50 | this.id = id; 51 | } 52 | public Date getCreatedDate() { 53 | return createdDate; 54 | } 55 | public void setCreatedDate(Date created_date) { 56 | this.createdDate = created_date; 57 | } 58 | public String getModel_run_id() { 59 | return model_run_id; 60 | } 61 | public void setModel_run_id(String model_run_id) { 62 | this.model_run_id = model_run_id; 63 | } 64 | 65 | public int getModelCount() { 66 | return modelCount; 67 | } 68 | public void setModelCount(int modelCount) { 69 | this.modelCount = modelCount; 70 | } 71 | public boolean isSuccess() { 72 | return success; 73 | } 74 | public void setSuccess(boolean success) { 75 | this.success = success; 76 | } 77 | public String getModelType() { 78 | return modelType; 79 | } 80 | public void setModelType(String modelType) { 81 | this.modelType = modelType; 82 | } 83 | public String getModelName() { 84 | return modelName; 85 | } 86 | public void setModelName(String modelName) { 87 | this.modelName = modelName; 88 | } 89 | @Override 90 | public String toString() { 91 | return "ModelRun [id=" + id + ", created_date=" + createdDate + ", model_run_id=" + model_run_id + ", modelType=" + modelType + ", modelName=" 92 | + modelName + ", modelCount=" + modelCount + ", success=" + success + "]"; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/ModelRunPersistentStorage.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage; 19 | 20 | 21 | import org.springframework.data.domain.Page; 22 | import org.springframework.data.domain.Pageable; 23 | 24 | /** 25 | * @author ggilbert 26 | * 27 | */ 28 | public interface ModelRunPersistentStorage { 29 | ModelRun save(ModelRun modelRun); 30 | Page findAll(Pageable pageable); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/PersistentLAPEntity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage; 19 | 20 | import java.io.Serializable; 21 | 22 | /** 23 | * @author ggilbert 24 | * 25 | */ 26 | public interface PersistentLAPEntity extends Serializable { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/PersistentStorage.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage; 16 | 17 | import java.util.Collection; 18 | import java.util.List; 19 | 20 | import org.springframework.data.domain.Page; 21 | import org.springframework.data.domain.Pageable; 22 | 23 | /** 24 | * @author ggilbert 25 | * 26 | */ 27 | public interface PersistentStorage { 28 | ModelOutput save(ModelOutput persistentLAPEntity); 29 | List saveAll(Collection persistentLAPentities); 30 | Page findAll(Pageable pageable); 31 | Page findByStudentId(String studentId, Pageable pageable); 32 | Page findByCourseId(String courseId, boolean onlyLastRun, Pageable pageable); 33 | Page findByStudentIdAndCourseId(String studentId, String courseId, boolean onlyLastRun, Pageable pageable); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/SSPConfigPersistentStorage.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package org.apereo.lap.services.storage; 5 | 6 | import org.apereo.lap.model.SSPConfig; 7 | 8 | /** 9 | * @author ggilbert 10 | * 11 | */ 12 | public interface SSPConfigPersistentStorage { 13 | SSPConfig save(SSPConfig sspConfig); 14 | SSPConfig get(); 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/StorageFactory.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage; 19 | 20 | import java.util.Map; 21 | 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.beans.factory.annotation.Value; 24 | import org.springframework.stereotype.Component; 25 | 26 | /** 27 | * @author ggilbert 28 | * 29 | */ 30 | @Component 31 | public class StorageFactory { 32 | @Value("${lap.persistentStorage:H2}") 33 | private String persistentStorage; 34 | 35 | @Autowired private Map> persistentStorageOptions; 36 | @Autowired private Map modelRunPersistentStorageOptions; 37 | @Autowired private Map sspConfigPersistentStorageOptions; 38 | 39 | public PersistentStorage getPersistentStorage() { 40 | return persistentStorageOptions.get(persistentStorage); 41 | } 42 | 43 | public ModelRunPersistentStorage getModelRunPersistentStorage() { 44 | 45 | String key = persistentStorage + "-ModelRunPersistentStorage"; 46 | 47 | return modelRunPersistentStorageOptions.get(key); 48 | } 49 | 50 | public SSPConfigPersistentStorage getSSPConfigPersistentStorage() { 51 | 52 | String key = persistentStorage + "-SSPConfigPersistentStorage"; 53 | 54 | return sspConfigPersistentStorageOptions.get(key); 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/StorageService.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage; 16 | 17 | import javax.annotation.PostConstruct; 18 | import javax.annotation.PreDestroy; 19 | 20 | import org.apache.commons.lang.StringUtils; 21 | import org.apereo.lap.services.configuration.ConfigurationService; 22 | import org.slf4j.Logger; 23 | import org.slf4j.LoggerFactory; 24 | import org.springframework.beans.factory.annotation.Autowired; 25 | import org.springframework.jdbc.core.JdbcTemplate; 26 | import org.springframework.stereotype.Component; 27 | import org.springframework.transaction.annotation.Transactional; 28 | 29 | /** 30 | * Manages the various types of storage (temporary and persistent), 31 | * probably would be good to have a service for each type of storage (temp and persistent) 32 | * 33 | * @author Aaron Zeckoski (azeckoski @ unicon.net) (azeckoski @ vt.edu) 34 | */ 35 | @Component 36 | @Transactional 37 | public class StorageService { 38 | 39 | private static final Logger logger = LoggerFactory.getLogger(StorageService.class); 40 | 41 | @Autowired ConfigurationService configuration; 42 | 43 | @Autowired JdbcTemplate tempJdbcTemplate; 44 | 45 | @PostConstruct 46 | public void init() { 47 | // Initialize the temp database connection 48 | logger.info("INIT"); 49 | } 50 | 51 | @PreDestroy 52 | public void destroy() { 53 | logger.info("DESTROY"); 54 | } 55 | 56 | /** 57 | * Clears the temp datastore tables for data reload 58 | */ 59 | public void resetTempStore() { 60 | // doesn't really make sense to reset the persistent store 61 | this.tempJdbcTemplate.execute("TRUNCATE TABLE ACTIVITY"); 62 | this.tempJdbcTemplate.execute("TRUNCATE TABLE GRADE"); 63 | this.tempJdbcTemplate.execute("TRUNCATE TABLE ENROLLMENT"); 64 | this.tempJdbcTemplate.execute("TRUNCATE TABLE COURSE"); 65 | this.tempJdbcTemplate.execute("TRUNCATE TABLE PERSONAL"); 66 | } 67 | 68 | /** 69 | * Check if a table exists and contains the given column 70 | * @param tableName the table name (should be all CAPS) 71 | * @param columnName the column name (should be all CAPS) 72 | * @return true if the table and column exist, false otherwise 73 | */ 74 | public boolean checkTableAndColumnExist(String tableName, String columnName) { 75 | assert StringUtils.isNotBlank(tableName); 76 | assert StringUtils.isNotBlank(columnName); 77 | String query = "SELECT COUNT(*) as COUNT FROM information_schema.COLUMNS WHERE TABLE_NAME = ? AND COLUMN_NAME = ?"; 78 | Integer count; 79 | count = this.getTempJdbcTemplate().queryForObject(query, Integer.class, tableName, columnName); 80 | return (count != null && count > 0); 81 | } 82 | 83 | public ConfigurationService getConfiguration() { 84 | return configuration; 85 | } 86 | 87 | public JdbcTemplate getTempJdbcTemplate() { 88 | return tempJdbcTemplate; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/H2ModelRunPersistentStorage.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.h2; 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | 23 | import org.apereo.lap.services.storage.ModelRun; 24 | import org.apereo.lap.services.storage.ModelRunPersistentStorage; 25 | import org.apereo.lap.services.storage.h2.model.Run; 26 | import org.apereo.lap.services.storage.h2.model.RunRepository; 27 | import org.springframework.beans.factory.annotation.Autowired; 28 | import org.springframework.data.domain.Page; 29 | import org.springframework.data.domain.PageImpl; 30 | import org.springframework.data.domain.Pageable; 31 | import org.springframework.stereotype.Component; 32 | 33 | /** 34 | * @author ggilbert 35 | * 36 | */ 37 | @Component("H2-ModelRunPersistentStorage") 38 | public class H2ModelRunPersistentStorage implements ModelRunPersistentStorage { 39 | 40 | @Autowired private RunRepository runRepository; 41 | 42 | @Override 43 | public ModelRun save(ModelRun modelRun) { 44 | 45 | Run run = toRun(modelRun); 46 | 47 | Run savedRun = runRepository.save(run); 48 | modelRun.setCreatedDate(savedRun.getDateCreated()); 49 | modelRun.setId(savedRun.getId().toString()); 50 | 51 | return modelRun; 52 | } 53 | 54 | @Override 55 | public Page findAll(Pageable pageable) { 56 | return convert(runRepository.findAllByOrderByDateCreatedDesc(pageable), pageable); 57 | } 58 | 59 | private Page convert(Page runEntities, Pageable pageable) { 60 | List runList = runEntities.getContent(); 61 | Page modelRunPage = null; 62 | if (runList != null && !runList.isEmpty()) { 63 | List modelRunEntites = new ArrayList(); 64 | for (Run run : runList) { 65 | modelRunEntites.add(fromRun(run)); 66 | } 67 | modelRunPage = new PageImpl(modelRunEntites, pageable, modelRunEntites.size()); 68 | } 69 | return modelRunPage; 70 | } 71 | 72 | private Run toRun(ModelRun modelRun) { 73 | Run run = new Run(); 74 | run.setModelCount(modelRun.getModelCount()); 75 | run.setModelName(modelRun.getModelName()); 76 | run.setModelType(modelRun.getModelType()); 77 | run.setModelRunId(modelRun.getModel_run_id()); 78 | run.setSuccess(modelRun.isSuccess()); 79 | 80 | return run; 81 | } 82 | 83 | private ModelRun fromRun(Run run) { 84 | ModelRun modelRun = new ModelRun(); 85 | modelRun.setId(String.valueOf(run.getId())); 86 | modelRun.setCreatedDate(run.getDateCreated()); 87 | modelRun.setModel_run_id(run.getModelRunId()); 88 | modelRun.setModelCount(run.getModelCount()); 89 | modelRun.setModelName(run.getModelName()); 90 | modelRun.setModelType(run.getModelType()); 91 | modelRun.setSuccess(run.isSuccess()); 92 | 93 | return modelRun; 94 | } 95 | 96 | 97 | } 98 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/H2PersistentConfig.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.h2; 19 | 20 | import javax.sql.DataSource; 21 | 22 | import org.apereo.lap.services.storage.DatasourceProperties; 23 | import org.apereo.lap.services.storage.h2.model.RiskConfidence; 24 | import org.springframework.beans.factory.annotation.Autowired; 25 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 26 | import org.springframework.context.annotation.Bean; 27 | import org.springframework.context.annotation.Configuration; 28 | import org.springframework.data.jpa.repository.config.EnableJpaRepositories; 29 | import org.springframework.orm.jpa.JpaTransactionManager; 30 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 31 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 32 | import org.springframework.transaction.PlatformTransactionManager; 33 | import org.springframework.transaction.annotation.EnableTransactionManagement; 34 | 35 | /** 36 | * @author ggilbert 37 | */ 38 | @Configuration 39 | @EnableTransactionManagement 40 | @EnableJpaRepositories(entityManagerFactoryRef = "persistentEntityManagerFactory", 41 | transactionManagerRef = "persistentTransactionManager", 42 | basePackages = "org.apereo.lap.services.storage.h2.model") 43 | public class H2PersistentConfig { 44 | @Autowired 45 | private DatasourceProperties datasourceProperties; 46 | 47 | @Bean 48 | public DataSource persistentDataSource() { 49 | DatasourceProperties.JdbcInfo p = datasourceProperties.getPersistent(); 50 | return DataSourceBuilder 51 | .create() 52 | .driverClassName(p.getDriverClassName()) 53 | .password(p.getPassword()) 54 | .url(p.getUrl()) 55 | .username(p.getUsername()) 56 | .build(); 57 | } 58 | 59 | @Bean 60 | PlatformTransactionManager persistentTransactionManager() { 61 | return new JpaTransactionManager(persistentEntityManagerFactory().getObject()); 62 | } 63 | 64 | @Bean 65 | LocalContainerEntityManagerFactoryBean persistentEntityManagerFactory() { 66 | 67 | HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter(); 68 | jpaVendorAdapter.setGenerateDdl(true); 69 | 70 | LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); 71 | 72 | factoryBean.setDataSource(persistentDataSource()); 73 | factoryBean.setJpaVendorAdapter(jpaVendorAdapter); 74 | factoryBean.setPackagesToScan(RiskConfidence.class.getPackage().getName()); 75 | 76 | return factoryBean; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/H2SSPConfigPersistentStorage.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.h2; 16 | 17 | import java.util.List; 18 | 19 | import org.apereo.lap.model.SSPConfig; 20 | import org.apereo.lap.services.storage.SSPConfigPersistentStorage; 21 | import org.apereo.lap.services.storage.h2.model.JpaSSPConfig; 22 | import org.apereo.lap.services.storage.h2.model.SSPConfigRepository; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.stereotype.Component; 25 | 26 | /** 27 | * @author ggilbert 28 | * 29 | */ 30 | @Component("H2-SSPConfigPersistentStorage") 31 | public class H2SSPConfigPersistentStorage implements SSPConfigPersistentStorage { 32 | 33 | @Autowired private SSPConfigRepository sspConfigRepository; 34 | 35 | @Override 36 | public SSPConfig save(SSPConfig sspConfig) { 37 | JpaSSPConfig jpaSSPConfig = new JpaSSPConfig(sspConfig); 38 | 39 | JpaSSPConfig saved = sspConfigRepository.save(jpaSSPConfig); 40 | 41 | sspConfig.setId(saved.getId().toString()); 42 | return sspConfig; 43 | } 44 | 45 | @Override 46 | public SSPConfig get() { 47 | List saved = sspConfigRepository.findAll(); 48 | 49 | if (saved != null && !saved.isEmpty()) { 50 | JpaSSPConfig jpaSSPConfig = saved.get(0); 51 | SSPConfig sspConfig = new SSPConfig(); 52 | sspConfig.setId(jpaSSPConfig.getId().toString()); 53 | sspConfig.setKey(jpaSSPConfig.getKey()); 54 | sspConfig.setSecret(jpaSSPConfig.getSecret()); 55 | sspConfig.setUrl(jpaSSPConfig.getUrl()); 56 | sspConfig.setRiskRule(jpaSSPConfig.getRiskRule()); 57 | 58 | return sspConfig; 59 | } 60 | 61 | return null; 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/H2TempConfig.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.h2; 19 | 20 | import javax.sql.DataSource; 21 | 22 | import org.apereo.lap.services.storage.DatasourceProperties; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; 25 | import org.springframework.context.annotation.Bean; 26 | import org.springframework.context.annotation.Configuration; 27 | import org.springframework.context.annotation.Primary; 28 | import org.springframework.jdbc.core.JdbcTemplate; 29 | import org.springframework.orm.jpa.JpaTransactionManager; 30 | import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; 31 | import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; 32 | import org.springframework.transaction.PlatformTransactionManager; 33 | 34 | /** 35 | * @author ggilbert 36 | */ 37 | @Configuration 38 | public class H2TempConfig { 39 | @Autowired 40 | private DatasourceProperties datasourceProperties; 41 | 42 | @Primary 43 | @Bean(name = "tempJdbcTemplate") 44 | public JdbcTemplate jdbcTemplate() { 45 | return new JdbcTemplate(tempDataSource()); 46 | } 47 | 48 | @Primary 49 | @Bean(name = "tempDataSource") 50 | public DataSource tempDataSource() { 51 | DatasourceProperties.JdbcInfo p = datasourceProperties.getTemp(); 52 | return DataSourceBuilder 53 | .create() 54 | .url(p.getUrl()) 55 | .username(p.getUsername()) 56 | .password(p.getPassword()) 57 | .driverClassName(p.getDriverClassName()) 58 | .build(); 59 | } 60 | 61 | @Bean(name = "transactionManager") 62 | @Primary 63 | PlatformTransactionManager transactionManager() { 64 | return new JpaTransactionManager(entityManagerFactory().getObject()); 65 | } 66 | 67 | @Primary 68 | @Bean(name = "entityManagerFactory") 69 | LocalContainerEntityManagerFactoryBean entityManagerFactory() { 70 | 71 | HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter(); 72 | jpaVendorAdapter.setGenerateDdl(true); 73 | 74 | LocalContainerEntityManagerFactoryBean factoryBean = new LocalContainerEntityManagerFactoryBean(); 75 | 76 | factoryBean.setDataSource(tempDataSource()); 77 | factoryBean.setJpaVendorAdapter(jpaVendorAdapter); 78 | factoryBean.setPackagesToScan(""); 79 | 80 | return factoryBean; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/model/BaseEntity.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.h2.model; 16 | 17 | import java.io.Serializable; 18 | 19 | import javax.persistence.GeneratedValue; 20 | import javax.persistence.GenerationType; 21 | import javax.persistence.Id; 22 | import javax.persistence.MappedSuperclass; 23 | 24 | /** 25 | * Base class for all JPA entities 26 | * 27 | */ 28 | @MappedSuperclass 29 | public abstract class BaseEntity implements Serializable { 30 | private static final long serialVersionUID = -8379618317974016042L; 31 | 32 | @Id 33 | @GeneratedValue(strategy=GenerationType.IDENTITY) 34 | private Long id; 35 | 36 | public Long getId() { 37 | return id; 38 | } 39 | 40 | public void setId(Long id) { 41 | this.id = id; 42 | } 43 | 44 | @Override 45 | public int hashCode() { 46 | return id == null ? 0 : id.hashCode(); 47 | } 48 | 49 | @Override 50 | public boolean equals(Object object) { 51 | if (this == object) 52 | return true; 53 | if (object == null) 54 | return false; 55 | return matchesClassAndId(object); 56 | } 57 | 58 | abstract protected boolean matchesClassAndId(Object other); 59 | 60 | protected final boolean matchesId(BaseEntity other) { 61 | // Unsaved Ids (null) *DO NOT MATCH* 62 | return id != null && other.id != null && id.equals(other.id); 63 | } 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/model/JpaSSPConfig.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.h2.model; 16 | 17 | import javax.persistence.Column; 18 | import javax.persistence.Entity; 19 | 20 | import org.apereo.lap.model.SSPConfig; 21 | 22 | /** 23 | * @author ggilbert 24 | * 25 | */ 26 | @Entity(name="ssp_config") 27 | public class JpaSSPConfig extends BaseEntity { 28 | 29 | private static final long serialVersionUID = 1L; 30 | 31 | public JpaSSPConfig() {} 32 | 33 | public JpaSSPConfig(SSPConfig sspConfig) { 34 | if (sspConfig.getId() != null) { 35 | this.setId(Long.getLong(sspConfig.getId())); 36 | } 37 | 38 | this.key = sspConfig.getKey(); 39 | this.secret = sspConfig.getSecret(); 40 | this.url = sspConfig.getUrl(); 41 | this.riskRule = sspConfig.getRiskRule(); 42 | } 43 | 44 | @Column(name="KEY") 45 | private String key; 46 | @Column(name="SECRET") 47 | private String secret; 48 | @Column(name="URL") 49 | private String url; 50 | @Column(name="RISK_RULE") 51 | private String riskRule; 52 | 53 | public String getKey() { 54 | return key; 55 | } 56 | public void setKey(String key) { 57 | this.key = key; 58 | } 59 | public String getSecret() { 60 | return secret; 61 | } 62 | public void setSecret(String secret) { 63 | this.secret = secret; 64 | } 65 | public String getUrl() { 66 | return url; 67 | } 68 | public void setUrl(String url) { 69 | this.url = url; 70 | } 71 | public String getRiskRule() { 72 | return riskRule; 73 | } 74 | public void setRiskRule(String riskRule) { 75 | this.riskRule = riskRule; 76 | } 77 | @Override 78 | protected boolean matchesClassAndId(Object other) { 79 | // TODO Auto-generated method stub 80 | return JpaSSPConfig.class.isInstance(other) ? matchesId((JpaSSPConfig)other) : false; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/model/RiskConfidence.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.h2.model; 16 | 17 | import java.util.Calendar; 18 | import java.util.Date; 19 | 20 | import javax.persistence.Column; 21 | import javax.persistence.Entity; 22 | 23 | /** 24 | * Represents a row in the risk_confidence table 25 | * 26 | */ 27 | @Entity(name="risk_confidence") 28 | public class RiskConfidence extends BaseEntity { 29 | private static final long serialVersionUID = -8050631804690469935L; 30 | 31 | @Column(name="ALTERNATIVE_ID") 32 | private String alternativeId; 33 | @Column(name="COURSE_ID") 34 | private String courseId; 35 | @Column(name="MODEL_RISK_CONFIDENCE") 36 | private String modelRiskConfidence; 37 | @Column(name="DATE_CREATED") 38 | private Date dateCreated = Calendar.getInstance().getTime(); 39 | @Column(name="GROUP_ID") 40 | private String groupId; 41 | 42 | public String getAlternativeId() { 43 | return alternativeId; 44 | } 45 | 46 | public void setAlternativeId(String alternativeId) { 47 | this.alternativeId = alternativeId; 48 | } 49 | 50 | public String getCourseId() { 51 | return courseId; 52 | } 53 | 54 | public void setCourseId(String courseId) { 55 | this.courseId = courseId; 56 | } 57 | 58 | public String getModelRiskConfidence() { 59 | return modelRiskConfidence; 60 | } 61 | 62 | public void setModelRiskConfidence(String modelRiskConfidence) { 63 | this.modelRiskConfidence = modelRiskConfidence; 64 | } 65 | 66 | protected boolean matchesClassAndId(Object other) { 67 | return RiskConfidence.class.isInstance(other) ? matchesId((RiskConfidence)other) : false; 68 | } 69 | 70 | public String getGroupId() { 71 | return groupId; 72 | } 73 | 74 | public void setGroupId(String groupId) { 75 | this.groupId = groupId; 76 | } 77 | 78 | public Date getDateCreated() { 79 | return dateCreated; 80 | } 81 | 82 | public void setDateCreated(Date dateCreated) { 83 | this.dateCreated = dateCreated; 84 | } 85 | 86 | @Override 87 | public String toString() { 88 | return "RiskConfidence [alternativeId=" + alternativeId + ", courseId=" 89 | + courseId + ", modelRiskConfidence=" + modelRiskConfidence 90 | + ", dateCreated=" + dateCreated + ", groupId=" + groupId 91 | + ", getId()=" + getId() + "]"; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/model/RiskConfidenceRepository.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.h2.model; 16 | 17 | import org.springframework.data.domain.Page; 18 | import org.springframework.data.domain.Pageable; 19 | import org.springframework.data.jpa.repository.JpaRepository; 20 | 21 | /** 22 | * Provides data access via JPA to the RiskConfidence table. 23 | * The risk confidence table contains a historical record of each processing run. 24 | * 25 | */ 26 | public interface RiskConfidenceRepository extends JpaRepository { 27 | Page findByAlternativeId(String alternativeId, Pageable pageable); 28 | Page findByCourseId(String courseId, Pageable pageable); 29 | Page findByAlternativeIdAndCourseId(String alternativeId, String courseId, Pageable pageable); 30 | RiskConfidence findTopByCourseIdOrderByDateCreatedDesc(String courseId); 31 | Page findByGroupIdAndCourseId(String groupId, String courseId, Pageable pageable); 32 | Page findTopByCourseIdAndAlternativeIdOrderByDateCreatedDesc(String courseId, String alternativeId, Pageable pageable); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/model/Run.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.h2.model; 19 | 20 | import java.util.Calendar; 21 | import java.util.Date; 22 | 23 | import javax.persistence.Column; 24 | import javax.persistence.Entity; 25 | 26 | /** 27 | * @author ggilbert 28 | * 29 | */ 30 | @Entity(name="model_run") 31 | public class Run extends BaseEntity { 32 | 33 | private static final long serialVersionUID = -8050631804690469935L; 34 | 35 | @Column(name="MODEL_RUN_ID") 36 | private String modelRunId; 37 | @Column(name="DATE_CREATED") 38 | private Date dateCreated = Calendar.getInstance().getTime(); 39 | @Column(name="MODEL_TYPE") 40 | private String modelType; 41 | @Column(name="MODEL_NAME") 42 | private String modelName; 43 | @Column(name="MODEL_COUNT") 44 | private int modelCount; 45 | @Column(name="SUCCESS") 46 | private boolean success; 47 | 48 | @Override 49 | protected boolean matchesClassAndId(Object other) { 50 | return Run.class.isInstance(other) ? matchesId((Run)other) : false; 51 | } 52 | 53 | public String getModelRunId() { 54 | return modelRunId; 55 | } 56 | 57 | public void setModelRunId(String modelRunId) { 58 | this.modelRunId = modelRunId; 59 | } 60 | 61 | public Date getDateCreated() { 62 | return dateCreated; 63 | } 64 | 65 | public void setDateCreated(Date dateCreated) { 66 | this.dateCreated = dateCreated; 67 | } 68 | 69 | public String getModelType() { 70 | return modelType; 71 | } 72 | 73 | public void setModelType(String modelType) { 74 | this.modelType = modelType; 75 | } 76 | 77 | public String getModelName() { 78 | return modelName; 79 | } 80 | 81 | public void setModelName(String modelName) { 82 | this.modelName = modelName; 83 | } 84 | 85 | public int getModelCount() { 86 | return modelCount; 87 | } 88 | 89 | public void setModelCount(int modelCount) { 90 | this.modelCount = modelCount; 91 | } 92 | 93 | public boolean isSuccess() { 94 | return success; 95 | } 96 | 97 | public void setSuccess(boolean success) { 98 | this.success = success; 99 | } 100 | 101 | @Override 102 | public String toString() { 103 | return "Run [modelRunId=" + modelRunId + ", dateCreated=" + dateCreated + ", modelType=" + modelType + ", modelName=" + modelName 104 | + ", modelCount=" + modelCount + ", success=" + success + "]"; 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/model/RunRepository.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.h2.model; 19 | 20 | import org.springframework.data.domain.Page; 21 | import org.springframework.data.domain.Pageable; 22 | import org.springframework.data.jpa.repository.JpaRepository; 23 | 24 | 25 | /** 26 | * @author ggilbert 27 | * 28 | */ 29 | public interface RunRepository extends JpaRepository { 30 | Page findAllByOrderByDateCreatedDesc(Pageable pageable); 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/h2/model/SSPConfigRepository.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.h2.model; 16 | 17 | import org.springframework.data.jpa.repository.JpaRepository; 18 | 19 | /** 20 | * @author ggilbert 21 | * 22 | */ 23 | public interface SSPConfigRepository extends JpaRepository { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/mongo/MongoConfig.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.mongo; 19 | 20 | import org.springframework.context.annotation.Configuration; 21 | import org.springframework.context.annotation.Profile; 22 | import org.springframework.data.mongodb.config.EnableMongoAuditing; 23 | 24 | /** 25 | * @author ggilbert 26 | * 27 | */ 28 | @Profile("mongo") 29 | @Configuration 30 | @EnableMongoAuditing 31 | public class MongoConfig { 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/mongo/MongoModelRunPersistentStorage.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.mongo; 19 | 20 | import org.apereo.lap.services.storage.ModelRun; 21 | import org.apereo.lap.services.storage.ModelRunPersistentStorage; 22 | import org.apereo.lap.services.storage.mongo.model.MongoModelRunRepository; 23 | import org.springframework.beans.factory.annotation.Autowired; 24 | import org.springframework.context.annotation.Profile; 25 | import org.springframework.data.domain.Page; 26 | import org.springframework.data.domain.Pageable; 27 | import org.springframework.stereotype.Component; 28 | 29 | /** 30 | * @author ggilbert 31 | * 32 | */ 33 | @Component("MongoDB-ModelRunPersistentStorage") 34 | @Profile({"mongo", "mongo-multitenant"}) 35 | public class MongoModelRunPersistentStorage implements ModelRunPersistentStorage { 36 | 37 | @Autowired private MongoModelRunRepository mongoModelRunRepository; 38 | 39 | @Override 40 | public ModelRun save(ModelRun modelRun) { 41 | return mongoModelRunRepository.save(modelRun); 42 | } 43 | 44 | @Override 45 | public Page findAll(Pageable pageable) { 46 | return mongoModelRunRepository.findAllByOrderByCreatedDateDesc(pageable); 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/mongo/MongoMultiTenantConfiguration.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.mongo; 16 | 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.beans.factory.annotation.Value; 24 | import org.springframework.boot.context.embedded.FilterRegistrationBean; 25 | import org.springframework.context.annotation.Bean; 26 | import org.springframework.context.annotation.Configuration; 27 | import org.springframework.context.annotation.Profile; 28 | import org.springframework.data.mongodb.config.AbstractMongoConfiguration; 29 | import org.springframework.data.mongodb.config.EnableMongoAuditing; 30 | import org.springframework.data.mongodb.core.MongoTemplate; 31 | import org.springframework.data.mongodb.repository.config.EnableMongoRepositories; 32 | 33 | import com.mongodb.Mongo; 34 | import com.mongodb.MongoClient; 35 | import com.mongodb.MongoClientURI; 36 | 37 | /** 38 | * @author jbrown 39 | * 40 | */ 41 | @Profile("mongo-multitenant") 42 | @Configuration 43 | @EnableMongoAuditing 44 | @EnableMongoRepositories({"org.apereo.lap.services.storage.mongo.model"}) 45 | public class MongoMultiTenantConfiguration extends AbstractMongoConfiguration { 46 | private static final Logger logger = LoggerFactory.getLogger(MongoMultiTenantConfiguration.class); 47 | 48 | @Autowired private MongoMultiTenantFilter mongoFilter; 49 | 50 | @Value("${lap.defaultDatabaseName:lap_default}") 51 | private String dbName; 52 | 53 | @Value("${spring.data.mongodb.uri:mongodb://localhost/lap_default}") 54 | private String dbUri; 55 | 56 | @Override 57 | @Bean 58 | public Mongo mongo() throws Exception { 59 | logger.warn("Mongo Db URI is set to: {}", dbUri); 60 | return new MongoClient(new MongoClientURI(dbUri)); 61 | } 62 | 63 | @Override 64 | protected String getDatabaseName() { 65 | return dbName; 66 | } 67 | 68 | @Bean 69 | public MongoTemplate mongoTemplate(final Mongo mongo, MultiTenantMongoDbFactory dbFactory) throws Exception { 70 | MongoTemplate template = new MongoTemplate(mongoDbFactory(mongo)); 71 | dbFactory.setMongoTemplate(template); 72 | return template; 73 | } 74 | 75 | @Bean 76 | public MultiTenantMongoDbFactory mongoDbFactory(final Mongo mongo) throws Exception { 77 | return new MultiTenantMongoDbFactory(mongo, dbName); 78 | } 79 | 80 | @Bean 81 | public FilterRegistrationBean mongoFilterBean() { 82 | FilterRegistrationBean registrationBean = new FilterRegistrationBean(); 83 | registrationBean.setFilter(mongoFilter); 84 | List urls = new ArrayList(); 85 | 86 | urls.add("/"); 87 | urls.add("/user"); 88 | urls.add("/login"); 89 | urls.add("/history/*"); 90 | urls.add("/features/*"); 91 | urls.add("/admin/*"); 92 | urls.add("/pipelines/*"); 93 | urls.add("/api/output/*"); 94 | 95 | registrationBean.setUrlPatterns(urls); 96 | return registrationBean; 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/mongo/MongoMultiTenantFilter.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.mongo; 16 | 17 | import java.io.IOException; 18 | 19 | import javax.servlet.FilterChain; 20 | import javax.servlet.ServletException; 21 | import javax.servlet.http.HttpServletRequest; 22 | import javax.servlet.http.HttpServletResponse; 23 | 24 | import org.apache.commons.lang.StringUtils; 25 | import org.apereo.lap.exception.MissingTenantException; 26 | import org.apereo.lap.services.TenantService; 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | import org.springframework.beans.factory.annotation.Autowired; 30 | import org.springframework.beans.factory.annotation.Value; 31 | import org.springframework.context.annotation.Profile; 32 | import org.springframework.stereotype.Component; 33 | import org.springframework.web.filter.OncePerRequestFilter; 34 | 35 | /** 36 | * @author jbrown 37 | */ 38 | @Profile("mongo-multitenant") 39 | @Component 40 | public class MongoMultiTenantFilter extends OncePerRequestFilter { 41 | private static final Logger logger = LoggerFactory.getLogger(MongoMultiTenantFilter.class); 42 | 43 | @Value("${lap.defaultDatabaseName:lap_default}") 44 | private String defaultDatabase; 45 | 46 | @Value("${lap.useDefaultDatabaseName:true}") 47 | private String useDefaultDatabaseName; 48 | 49 | @Autowired private TenantService tenantService; 50 | 51 | @Override 52 | public void doFilterInternal(HttpServletRequest req, HttpServletResponse res, FilterChain fc) throws ServletException, IOException { 53 | logger.debug("applying MongoMultiTenantFilter"); 54 | logger.debug("allow defaultDatabase: "+useDefaultDatabaseName); 55 | 56 | // For now header trumps all sources 57 | String tenant = req.getHeader("X-LAP-TENANT"); 58 | 59 | if (StringUtils.isBlank(tenant)) { 60 | // Next try path 61 | String requestURI = req.getRequestURI(); 62 | if (StringUtils.isBlank(tenant) && 63 | StringUtils.isNotBlank(requestURI) && StringUtils.startsWith(requestURI, "/api/output/")) { 64 | tenant = StringUtils.substringBetween(requestURI, "/api/output/", "/"); 65 | } 66 | 67 | if (StringUtils.isBlank(tenant)) { 68 | // Next try session 69 | tenant = tenantService.getTenant(); 70 | 71 | // If still blank and a default db is allowed 72 | if (StringUtils.isBlank(tenant)) { 73 | if (Boolean.valueOf(useDefaultDatabaseName)) { 74 | logger.warn("No tenant available in request. Using default database."); 75 | tenant = defaultDatabase; 76 | } 77 | else { 78 | throw new MissingTenantException("No tenant available in request and default database disabled."); 79 | } 80 | } 81 | } 82 | } 83 | 84 | tenantService.setTenant(tenant); 85 | logger.debug("Using tenant {}",tenantService.getTenant()); 86 | 87 | fc.doFilter(req, res); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/mongo/MongoSSPConfigPersistentStorage.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.mongo; 16 | 17 | import java.util.List; 18 | 19 | import org.apereo.lap.model.SSPConfig; 20 | import org.apereo.lap.services.storage.SSPConfigPersistentStorage; 21 | import org.apereo.lap.services.storage.mongo.model.MongoSSPConfigRepository; 22 | import org.springframework.beans.factory.annotation.Autowired; 23 | import org.springframework.context.annotation.Profile; 24 | import org.springframework.stereotype.Component; 25 | 26 | /** 27 | * @author ggilbert 28 | * 29 | */ 30 | @Component("MongoDB-SSPConfigPersistentStorage") 31 | @Profile({"mongo", "mongo-multitenant"}) 32 | public class MongoSSPConfigPersistentStorage implements SSPConfigPersistentStorage { 33 | 34 | @Autowired private MongoSSPConfigRepository mongoSSPConfigRepository; 35 | 36 | @Override 37 | public SSPConfig save(SSPConfig sspConfig) { 38 | return mongoSSPConfigRepository.save(sspConfig); 39 | } 40 | 41 | @Override 42 | public SSPConfig get() { 43 | List configList = mongoSSPConfigRepository.findAll(); 44 | if (configList != null && !configList.isEmpty()) { 45 | return configList.get(0); 46 | } 47 | return null; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/mongo/model/MongoModelOutputRepository.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.mongo.model; 19 | 20 | import org.apereo.lap.services.storage.ModelOutput; 21 | import org.springframework.context.annotation.Profile; 22 | import org.springframework.data.domain.Page; 23 | import org.springframework.data.domain.Pageable; 24 | import org.springframework.data.mongodb.repository.MongoRepository; 25 | import org.springframework.data.mongodb.repository.Query; 26 | 27 | /** 28 | * @author ggilbert 29 | * 30 | */ 31 | @Profile({"mongo", "mongo-multitenant"}) 32 | public interface MongoModelOutputRepository extends MongoRepository { 33 | 34 | @Query("{ 'output.ALTERNATIVE_ID' : ?0 }") 35 | Page findByStudentId(String student_id, Pageable pageable); 36 | 37 | @Query("{ 'output.COURSE_ID' : ?0 }") 38 | Page findByCourseId(String course_id, Pageable pageable); 39 | 40 | @Query("{ 'output.ALTERNATIVE_ID' : ?0, 'output.COURSE_ID' : ?1 }") 41 | Page findByStudentIdAndCourseId(String studentId, String courseId, Pageable pageable); 42 | 43 | @Query("{ 'output.COURSE_ID' : ?0 }") 44 | ModelOutput findTopByCourseIdOrderByCreatedDateDesc(String courseId); 45 | 46 | @Query("{ 'modelRunId' : ?0, 'output.COURSE_ID' : ?1 }") 47 | Page findByModelRunIdAndCourseId(String modelRunId, String courseId, Pageable pageable); 48 | 49 | @Query("{ 'output.COURSE_ID' : ?0, 'output.ALTERNATIVE_ID' : ?1 }") 50 | Page findTopByCourseIdAndStudentIdOrderByCreatedDateDesc(String courseId, String studentId, Pageable pageable); 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/mongo/model/MongoModelRunRepository.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /** 16 | * 17 | */ 18 | package org.apereo.lap.services.storage.mongo.model; 19 | 20 | import org.apereo.lap.services.storage.ModelRun; 21 | import org.springframework.context.annotation.Profile; 22 | import org.springframework.data.domain.Page; 23 | import org.springframework.data.domain.Pageable; 24 | import org.springframework.data.mongodb.repository.MongoRepository; 25 | 26 | /** 27 | * @author ggilbert 28 | * 29 | */ 30 | @Profile({"mongo", "mongo-multitenant"}) 31 | public interface MongoModelRunRepository extends MongoRepository { 32 | Page findAllByOrderByCreatedDateDesc(Pageable pageable); 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/org/apereo/lap/services/storage/mongo/model/MongoSSPConfigRepository.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services.storage.mongo.model; 16 | 17 | import org.apereo.lap.model.SSPConfig; 18 | import org.springframework.context.annotation.Profile; 19 | import org.springframework.data.mongodb.repository.MongoRepository; 20 | 21 | /** 22 | * @author ggilbert 23 | * 24 | */ 25 | @Profile({"mongo", "mongo-multitenant"}) 26 | public interface MongoSSPConfigRepository extends MongoRepository { 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/main/resources/application-mongo-multitenant.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2015 Unicon (R) Licensed under the 3 | # Educational Community License, Version 2.0 (the "License"); you may 4 | # not use this file except in compliance with the License. You may 5 | # obtain a copy of the License at 6 | # 7 | # http://www.osedu.org/licenses/ECL-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, 10 | # software distributed under the License is distributed on an "AS IS" 11 | # BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | # or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | ############################################################################### 15 | spring.profiles.active=mongo 16 | 17 | lap.persistentStorage=MongoDB 18 | 19 | # Feature Flags 20 | features.multitenant=true -------------------------------------------------------------------------------- /src/main/resources/application-mongo.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2015 Unicon (R) Licensed under the 3 | # Educational Community License, Version 2.0 (the "License"); you may 4 | # not use this file except in compliance with the License. You may 5 | # obtain a copy of the License at 6 | # 7 | # http://www.osedu.org/licenses/ECL-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, 10 | # software distributed under the License is distributed on an "AS IS" 11 | # BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | # or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | ############################################################################### 15 | lap.persistentStorage=MongoDB 16 | 17 | spring.data.mongodb.uri:mongodb://localhost/lap_default 18 | -------------------------------------------------------------------------------- /src/main/resources/application-test.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2015 Unicon (R) Licensed under the 3 | # Educational Community License, Version 2.0 (the "License"); you may 4 | # not use this file except in compliance with the License. You may 5 | # obtain a copy of the License at 6 | # 7 | # http://www.osedu.org/licenses/ECL-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, 10 | # software distributed under the License is distributed on an "AS IS" 11 | # BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | # or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | ############################################################################### 15 | spring.thymeleaf.cache=false 16 | 17 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 18 | 19 | # Temp DB - H2 20 | datasource.temp.username=sa 21 | datasource.temp.password= 22 | datasource.temp.driverClassName=org.h2.Driver 23 | datasource.temp.url=jdbc:h2:mem:temp-db-test;MODE=MYSQL;DB_CLOSE_DELAY=-1 24 | datasource.temp.dialect=org.hibernate.dialect.H2Dialect 25 | 26 | # Persistent DB - H2 27 | # For tests environment we will not persist data 28 | datasource.persistent.username=sa 29 | datasource.persistent.password= 30 | datasource.persistent.driverClassName=org.h2.Driver 31 | datasource.persistent.url=jdbc:h2:mem:lap-db-test;MODE=MYSQL;DB_CLOSE_DELAY=-1; 32 | datasource.persistent.dialect=org.hibernate.dialect.H2Dialect 33 | 34 | # Application properties 35 | app.name=Learning Analytics Processor 36 | ## Names of the database connections used in .ktr and .kjb files 37 | ## Comma-separated values list 38 | app.database.connection.names=LAP_connect 39 | 40 | ## for testing (comment these out when NOT testing) 41 | input.copy.samples=true 42 | #input.init.load.csv=true 43 | #process.pipeline.sample=true 44 | 45 | ## Files Directories 46 | ## Relative to (i.e. sub dir under) the application home dir UNLESS it starts with a "/" 47 | # Pipeline definition files will be loaded from this dir 48 | #dir.pipelines=pipelines 49 | # Default location to scan for input files 50 | #dir.inputs=inputs 51 | # Default location to scan for input files 52 | #dir.outputs=outputs 53 | 54 | logging.level.org.springframework.security.web.FilterChainProxy=DEBUG 55 | 56 | # Feature Flags 57 | features.multitenant=false 58 | 59 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Copyright (c) 2015 Unicon (R) Licensed under the 3 | # Educational Community License, Version 2.0 (the "License"); you may 4 | # not use this file except in compliance with the License. You may 5 | # obtain a copy of the License at 6 | # 7 | # http://www.osedu.org/licenses/ECL-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, 10 | # software distributed under the License is distributed on an "AS IS" 11 | # BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | # or implied. See the License for the specific language governing 13 | # permissions and limitations under the License. 14 | ############################################################################### 15 | spring.thymeleaf.cache=false 16 | 17 | spring.jpa.database-platform=org.hibernate.dialect.H2Dialect 18 | 19 | # Temp DB - H2 20 | datasource.temp.username=sa 21 | datasource.temp.password= 22 | datasource.temp.driverClassName=org.h2.Driver 23 | datasource.temp.url=jdbc:h2:mem:temp-db;MODE=MYSQL;DB_CLOSE_DELAY=-1 24 | datasource.temp.dialect=org.hibernate.dialect.H2Dialect 25 | 26 | # Persistent DB - H2 disk (/tmp/lap-db) 27 | datasource.persistent.username=sa 28 | datasource.persistent.password= 29 | datasource.persistent.driverClassName=org.h2.Driver 30 | datasource.persistent.url=jdbc:h2:file:/tmp/lap-db;MODE=MYSQL;DB_CLOSE_DELAY=-1;AUTO_SERVER=TRUE 31 | datasource.persistent.dialect=org.hibernate.dialect.H2Dialect 32 | 33 | # Application properties 34 | app.name=Learning Analytics Processor 35 | ## Names of the database connections used in .ktr and .kjb files 36 | ## Comma-separated values list 37 | kettle.databaseConnectionNames=LAP_connect 38 | 39 | ## Files Directories 40 | ## Relative to (i.e. sub dir under) the application home dir UNLESS it starts with a "/" 41 | 42 | ## lap.home 43 | ## File system path to lapHome 44 | ## Defaults to application home dir if not set 45 | # lap.home=/export/home/lap 46 | 47 | ## dir.pipelines 48 | ## Fully qualified path to pipeline configuration files 49 | ## Defaults to {lap.home}/pipelines if not set 50 | # dir.pipelines= 51 | 52 | ## dir.inputs 53 | ## Fully qualified path to data input (extract) files 54 | ## Defaults to {lap.home}/inputs if not set 55 | # dir.inputs= 56 | 57 | ## dir.outputs 58 | ## Fully qualified path for output files (must be writable) 59 | ## Defaults to {lap.home}/outputs if not set 60 | # dir.outputs= 61 | 62 | # Feature Flags 63 | features.multitenant=false 64 | 65 | -------------------------------------------------------------------------------- /src/main/resources/log4j.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/main/resources/public/assets/css/angular-notification-min.css: -------------------------------------------------------------------------------- 1 | /** 2 | * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating 3 | * @author Alex_Crack 4 | * @version v0.0.11 5 | * @link https://github.com/alexcrack/angular-ui-notification 6 | * @license MIT 7 | */ 8 | .ui-notification{position:fixed;z-index:9999;width:300px;cursor:pointer;-webkit-transition:all ease .5s;-o-transition:all ease .5s;transition:all ease .5s;color:#fff;background:#337ab7;box-shadow:5px 5px 10px rgba(0,0,0,.3)}.ui-notification.killed{-webkit-transition:opacity ease 1s;-o-transition:opacity ease 1s;transition:opacity ease 1s;opacity:0}.ui-notification>h3{font-size:14px;font-weight:700;display:block;margin:10px 10px 0;padding:0 0 5px;text-align:left;border-bottom:1px solid rgba(255,255,255,.3)}.ui-notification a{color:#fff}.ui-notification a:hover{text-decoration:underline}.ui-notification>.message{margin:10px}.ui-notification.warning{color:#fff;background:#f0ad4e}.ui-notification.error{color:#fff;background:#d9534f}.ui-notification.success{color:#fff;background:#5cb85c}.ui-notification.info{color:#fff;background:#5bc0de}.ui-notification:hover{opacity:.7} -------------------------------------------------------------------------------- /src/main/resources/public/assets/css/lap.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) Unicon (R) 2015 Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | /* 16 | * Base structure 17 | */ 18 | 19 | /* Move down content because we have a fixed navbar that is 50px tall */ 20 | body { 21 | padding-top: 50px; 22 | } 23 | 24 | 25 | /* 26 | * Global add-ons 27 | */ 28 | 29 | .sub-header { 30 | padding-bottom: 10px; 31 | border-bottom: 1px solid #eee; 32 | } 33 | 34 | /* 35 | * Top navigation 36 | * Hide default border to remove 1px line. 37 | */ 38 | .navbar-fixed-top { 39 | border: 0; 40 | } 41 | 42 | /* 43 | * Sidebar 44 | */ 45 | 46 | /* Hide for mobile, show later */ 47 | .sidebar { 48 | display: none; 49 | } 50 | @media (min-width: 768px) { 51 | .sidebar { 52 | position: fixed; 53 | top: 51px; 54 | bottom: 0; 55 | left: 0; 56 | z-index: 1000; 57 | display: block; 58 | padding: 20px; 59 | overflow-x: hidden; 60 | overflow-y: auto; /* Scrollable contents if viewport is shorter than content. */ 61 | background-color: #f5f5f5; 62 | border-right: 1px solid #eee; 63 | } 64 | } 65 | 66 | /* Sidebar navigation */ 67 | .nav-sidebar { 68 | margin-right: -21px; /* 20px padding + 1px border */ 69 | margin-bottom: 20px; 70 | margin-left: -20px; 71 | } 72 | .nav-sidebar > li > a { 73 | padding-right: 20px; 74 | padding-left: 20px; 75 | } 76 | .nav-sidebar > .active > a, 77 | .nav-sidebar > .active > a:hover, 78 | .nav-sidebar > .active > a:focus { 79 | color: #fff; 80 | background-color: #428bca; 81 | } 82 | 83 | 84 | /* 85 | * Main content 86 | */ 87 | 88 | .main { 89 | padding: 20px; 90 | } 91 | @media (min-width: 768px) { 92 | .main { 93 | padding-right: 40px; 94 | padding-left: 40px; 95 | } 96 | } 97 | .main .page-header { 98 | margin-top: 0; 99 | } 100 | 101 | 102 | /* 103 | * Placeholder dashboard ideas 104 | */ 105 | 106 | .placeholders { 107 | margin-bottom: 30px; 108 | text-align: center; 109 | } 110 | .placeholders h4 { 111 | margin-bottom: 0; 112 | } 113 | .placeholder { 114 | margin-bottom: 20px; 115 | } 116 | .placeholder img { 117 | display: inline-block; 118 | border-radius: 50%; 119 | } 120 | 121 | /* 122 | * Custom 123 | */ 124 | 125 | .spinner { 126 | position: fixed; 127 | width: 100%; 128 | height: 100%; 129 | background: black url('/assets/img/spinner.gif') center center no-repeat; 130 | opacity: .5; 131 | z-index: 500; 132 | } 133 | -------------------------------------------------------------------------------- /src/main/resources/public/assets/img/locales/cy_GB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/src/main/resources/public/assets/img/locales/cy_GB.png -------------------------------------------------------------------------------- /src/main/resources/public/assets/img/locales/en_GB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/src/main/resources/public/assets/img/locales/en_GB.png -------------------------------------------------------------------------------- /src/main/resources/public/assets/img/locales/en_US.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/src/main/resources/public/assets/img/locales/en_US.png -------------------------------------------------------------------------------- /src/main/resources/public/assets/img/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Apereo-Learning-Analytics-Initiative/LearningAnalyticsProcessor/22e2842a21601eb27231ea8cbed01fe76921258c/src/main/resources/public/assets/img/spinner.gif -------------------------------------------------------------------------------- /src/main/resources/public/assets/js/auth-ctrl.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | 'use strict'; 16 | 17 | angular 18 | .module('LAP') 19 | .controller('AuthCtrl', 20 | 21 | function AuthCtrl($scope, $state, SessionService) { 22 | if (!SessionService.isAuthenticated()) { 23 | SessionService 24 | .authenticate() 25 | .then( 26 | function (data) { 27 | if (!data) { 28 | $state.go('login'); 29 | return; 30 | } 31 | return; 32 | }, 33 | function (error) { 34 | $state.go('login'); 35 | return; 36 | } 37 | ); 38 | } 39 | 40 | }); -------------------------------------------------------------------------------- /src/main/resources/public/assets/js/directives.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | (function(angular) { 16 | 'use strict'; 17 | 18 | angular.module('LAP').directive( 19 | 'loadingWidget', 20 | function($timeout, requestNotification) { 21 | return { 22 | restrict : "AC", 23 | link : function(scope, element) { 24 | // hide the element initially 25 | element.hide(); 26 | 27 | // subscribe to listen when a request starts 28 | requestNotification 29 | .subscribeOnRequestStarted(function() { 30 | // show the spinner! 31 | element.show(); 32 | }); 33 | 34 | requestNotification.subscribeOnRequestEnded(function() { 35 | // hide the spinner if there are no more pending 36 | // requests 37 | if (requestNotification.getRequestCount() === 0) 38 | element.hide(); 39 | }); 40 | } 41 | }; 42 | }); 43 | })(angular); -------------------------------------------------------------------------------- /src/main/resources/public/assets/js/index-ctrl.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | 'use strict'; 16 | 17 | angular 18 | .module('LAP') 19 | .controller('IndexCtrl', 20 | 21 | function MasterCtrl($scope, $state, $http, $translate, runs, SessionService, LocaleService) { 22 | 23 | if(!SessionService.isAuthenticated()){ 24 | $state.go("login"); 25 | } 26 | 27 | $scope.localesDisplayNames = LocaleService.getLocalesDisplayNames(); 28 | 29 | $scope.changeLanguage = function (locale) { 30 | LocaleService.setLocaleByDisplayName(locale); 31 | }; 32 | 33 | $scope.getLocaleImgPath = function (locale) { 34 | var path = '/assets/img/locales/' 35 | 36 | if (locale) { 37 | var code = LocaleService.getLocaleForDisplayName(locale); 38 | path = path + code +'.png'; 39 | } 40 | else { 41 | var code = LocaleService.getLocaleForDisplayName(LocaleService.getLocaleDisplayName()); 42 | 43 | if (!code) { 44 | code = $translate.use(); 45 | if (!code) { 46 | code = 'en_US'; 47 | } 48 | } 49 | 50 | path = path + code +'.png'; 51 | } 52 | return path; 53 | }; 54 | 55 | $scope.runs = runs; 56 | $scope.isAuthenticated = SessionService.isAuthenticated(); 57 | $scope.logout = function() { 58 | SessionService.logout() 59 | .then( function(data) { 60 | $state.go('login', {loggedOutMessage:'USER_INITIATED'}); 61 | return; 62 | }, 63 | function (error) { 64 | $state.go('login', {loggedOutMessage:'USER_INITIATED'}); 65 | return; 66 | } 67 | ); 68 | } 69 | 70 | }); 71 | -------------------------------------------------------------------------------- /src/main/resources/public/assets/js/lib/angular-notification-min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating 3 | * @author Alex_Crack 4 | * @version v0.0.11 5 | * @link https://github.com/alexcrack/angular-ui-notification 6 | * @license MIT 7 | */ 8 | angular.module("ui-notification",[]),angular.module("ui-notification").value("uiNotificationTemplates","angular-ui-notification.html"),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1},this.setOptions=function(t){if(!angular.isObject(t))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,t)},this.$get=["$timeout","uiNotificationTemplates","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q",function(t,e,i,n,o,a,s,r,l){var p=this.options,c=p.startTop,u=p.startRight,d=p.verticalSpacing,m=p.horizontalSpacing,g=p.delay,f=[],h=function(s,h){var v=l.defer();return"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:a,s.template=s.template?s.template:e,s.delay=angular.isUndefined(s.delay)?g:s.delay,s.type=h?h:"",s.positionY=s.positionY?s.positionY:p.positionY,s.positionX=s.positionX?s.positionX:p.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:p.replaceMessage,i.get(s.template,{cache:o}).success(function(e){var i=s.scope.$new();i.message=r.trustAsHtml(s.message),i.title=r.trustAsHtml(s.title),i.t=s.type.substr(0,1),i.delay=s.delay;var o=function(){for(var t=0,e=0,i=c,n=u,o=[],a=f.length-1;a>=0;a--){var r=f[a];if(s.replaceMessage&&awindow.innerHeight&&(g=c,e++,t=0);var h=(i=g?g:c)+(0===t?0:d),v=n+e*(m+p);r.css(r._positionY,h+"px"),r.css(r._positionX,v+"px"),o[r._positionY+r._positionX]=h+l,t++}}},a=n(e)(i);a._positionY=s.positionY,a._positionX=s.positionX,a.addClass(s.type),a.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd click",function(t){t=t.originalEvent||t,("click"===t.type||"opacity"===t.propertyName&&t.elapsedTime>=1)&&(a.remove(),f.splice(f.indexOf(a),1),o())}),angular.isNumber(s.delay)&&t(function(){a.addClass("killed")},s.delay),angular.element(document.getElementsByTagName("body")).append(a);var l=-(parseInt(a[0].offsetHeight)+50);a.css(a._positionY,l+"px"),f.push(a),i._templateElement=a,i.kill=function(e){e?(f.splice(f.indexOf(i._templateElement),1),i._templateElement.remove(),t(o)):i._templateElement.addClass("killed")},t(o),v.resolve(i)}).error(function(t){throw new Error("Template ("+s.template+") could not be loaded. "+t)}),v.promise};return h.primary=function(t){return this(t,"primary")},h.error=function(t){return this(t,"error")},h.success=function(t){return this(t,"success")},h.info=function(t){return this(t,"info")},h.warning=function(t){return this(t,"warning")},h.clearAll=function(){var t=angular.element(document.getElementsByClassName("ui-notification"));t&&angular.forEach(t,function(t){t.remove()})},h}]}),angular.module("ui-notification").run(["$templateCache",function(t){t.put("angular-ui-notification.html",'

')}]); -------------------------------------------------------------------------------- /src/main/resources/public/assets/js/login-ctrl.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | 'use strict'; 16 | 17 | angular 18 | .module('LAP') 19 | .controller('LoginCtrl', 20 | 21 | function LoginCtrl($log, $scope, $state, SessionService, isMultiTenant) { 22 | $scope.isMultiTenant = isMultiTenant; 23 | $scope.hasLoggedOut = $state.params.loggedOutMessage; 24 | $scope.credentials = {}; 25 | $scope.login = function() { 26 | SessionService.authenticate($scope.credentials) 27 | .then( 28 | function (data) { 29 | $log.debug(data); 30 | // TODO fix this validate message 31 | $scope.validationError = !data; 32 | if(data) { 33 | $state.go('index'); 34 | return; 35 | } 36 | return; 37 | }, 38 | function (error) { 39 | $log.error(error); 40 | $scope.error = true; 41 | } 42 | ); 43 | }; 44 | }); -------------------------------------------------------------------------------- /src/main/resources/public/assets/js/pipelines/controllers.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | (function(angular, JSON) { 16 | 'use strict'; 17 | angular 18 | .module('LAP') 19 | .controller('PipelinesController', 20 | 21 | function PipelinesController($scope, $state, pipelines, PipelineDataService, Notification) { 22 | $scope.pipelines = pipelines; 23 | $scope.submitted = false; 24 | 25 | $scope.selectPipeline = function (pipeline) {$scope.selectedPipeline = pipeline;}; 26 | 27 | $scope.startPipeline = function (type) { 28 | $scope.submitted = true; 29 | 30 | PipelineDataService 31 | .runPipeline(type) 32 | .then ( 33 | function (data) { 34 | if (data) { 35 | Notification.success('Pipeline complete'); 36 | } 37 | else { 38 | Notification.error('Pipeline failed'); 39 | } 40 | 41 | $scope.submitted = false; 42 | } 43 | ); 44 | }; 45 | } 46 | 47 | ); 48 | })(angular, JSON); -------------------------------------------------------------------------------- /src/main/resources/public/assets/js/pipelines/service.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | (function(angular, JSON) { 16 | 'use strict'; 17 | angular.module('LAP').service('PipelineDataService', 18 | function($log, $http) { 19 | return { 20 | getPipelines : function() { 21 | 22 | var url = '/pipelines'; 23 | var promise = $http({ 24 | method : 'GET', 25 | url : url, 26 | headers : { 27 | 'Content-Type' : 'application/json' 28 | } 29 | }).then(function(response) { 30 | if (response && response.data) { 31 | return response.data; 32 | } 33 | $log.debug(response); 34 | return null; 35 | }, function(error) { 36 | $log.error(error); 37 | return null; 38 | }); 39 | return promise; 40 | }, 41 | 42 | runPipeline : function (type) { 43 | var url = '/pipelines/start/' + type; 44 | var promise = $http({ 45 | method: 'POST', 46 | url : url, 47 | headers : { 48 | 'Content-Type' : 'application/json' 49 | } 50 | }) 51 | .then( 52 | function (response) { 53 | if (response && response.data) { 54 | return response.data; 55 | } 56 | $log.debug(response); 57 | return false; 58 | }, 59 | function (error) { 60 | $log.error(error); 61 | return false; 62 | } 63 | ); 64 | return promise; 65 | } 66 | 67 | } 68 | }); 69 | 70 | })(angular, JSON); -------------------------------------------------------------------------------- /src/main/resources/public/assets/js/settings/controllers.js: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | (function(angular, JSON) { 16 | 'use strict'; 17 | angular 18 | .module('LAP') 19 | .controller('SettingsController', 20 | 21 | function SettingsController($scope, $state, sspConfig, SettingsService, Notification) { 22 | $scope.sspConfig = sspConfig; 23 | $scope.submitted = false; 24 | 25 | $scope.saveSSPConfig = function() { 26 | $scope.submitted = true; 27 | 28 | SettingsService 29 | .saveSSPConfig($scope.sspConfig) 30 | .then ( 31 | function (data) { 32 | if (data) { 33 | Notification.success('SSP Configuration updated'); 34 | } 35 | else { 36 | Notification.error('SSP Configuration update failed'); 37 | } 38 | 39 | $scope.submitted = false; 40 | } 41 | ); 42 | }; 43 | 44 | } 45 | 46 | ); 47 | })(angular, JSON); -------------------------------------------------------------------------------- /src/main/resources/public/assets/templates/login.html: -------------------------------------------------------------------------------- 1 | 15 |
16 |
17 | 51 |
52 |
53 | 54 | -------------------------------------------------------------------------------- /src/main/resources/public/assets/templates/pipelines.html: -------------------------------------------------------------------------------- 1 | 15 |
16 |
17 |
18 |
19 |
20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 |
{{pipeline.type}}{{pipeline.name}}{{pipeline.description}}
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |

{{selectedPipeline.name}} {{selectedPipeline.type}}

48 |

{{selectedPipeline.description}}

49 |
50 |
51 |
52 |
53 |
54 |
55 |
    56 |
  • {{key}} : {{value}}
  • 57 |
58 |
59 |
60 |
61 |
62 |
63 | 64 |
65 |
66 |
67 |
68 |
69 |
-------------------------------------------------------------------------------- /src/main/resources/public/assets/templates/settings.html: -------------------------------------------------------------------------------- 1 | 15 |
16 |
17 |
18 |
19 |
20 |

21 | 22 |
23 | 24 |
25 | 26 | 27 |
28 | 29 |
30 | 31 | 32 |
33 | 34 |
37 | 38 | 39 | 40 |
41 | 42 |
43 | 44 | 50 | 51 |
52 |
53 | 54 | 55 |
56 |
57 | 58 |
59 | 60 |
61 |
62 |
63 | -------------------------------------------------------------------------------- /src/main/resources/public/assets/translations/cy_GB/overview.json: -------------------------------------------------------------------------------- 1 | { 2 | "BUTTON_SAVE":"Save", 3 | "BUTTON_CANCEL":"Cancel", 4 | 5 | "TEXT_HEADER": "History", 6 | "TABLE_HEADER_DATE": "DATE", 7 | "TABLE_HEADER_TYPE": "TYPE", 8 | "TABLE_HEADER_NAME": "NAME", 9 | "TABLE_HEADER_SUCCESS": "SUCCESS", 10 | "TABLE_HEADER_COUNT": "COUNT", 11 | 12 | "LINK_INDEX_LOGIN": "Login", 13 | "LINK_INDEX_LOGOUT": "Logout", 14 | "LINK_INDEX_SETTINGS":"Settings", 15 | "LINK_INDEX_HELP":"Help", 16 | 17 | "PIPELINE_TEXT_HEADER": "Welsh Pipelines", 18 | "PIPELINE_TABLE_HEADER_TYPE": "TYPE", 19 | "PIPELINE_TABLE_HEADER_NAME": "NAME", 20 | "PIPELINE_TABLE_HEADER_DESC": "DESCRIPTION", 21 | "STATISTICS" : "Statistics", 22 | "RUN" : "Run", 23 | 24 | "SELECT_INSTITUTION": "Select your institution", 25 | "SIGN_IN": "Sign In", 26 | "USERNAME_REQUIRED_ERROR": "Username is required.", 27 | "PASSWORD_REQUIRED_ERROR": "Password is required.", 28 | "USERNAME": "Username", 29 | "PASSWORD": "Password", 30 | 31 | "ALERT_DANGER_USERNAME_PASSWORD_MISMATCH": "The username and password do not match our records, please try again.", 32 | "ALERT_SUCCESS_LOGOUT_USER_INITIATED":"You have been logged out.", 33 | 34 | "SSP_CONFIG_HEADER":"Student Success Plan Configuration", 35 | "SSP_CONFIG_INSTRUCTIONS":"Use this form to configure the technical details of the integration with Student Success Plan. Most importantly set the threshold that will be used to trigger early alerts.", 36 | "SSP_CONFIG_FORM_KEY_LABEL":"Key", 37 | "SSP_CONFIG_FORM_SECRET_LABEL":"Secret", 38 | "SSP_CONFIG_FORM_URL_LABEL":"Base URL", 39 | "SSP_CONFIG_FORM_RISKRULE_LABEL":"Early Alert Threshold", 40 | "SSP_CONFIG_FORM_URL_HELP":"The base URL of the target SSP instance (e.g., https://ssp.com/)", 41 | "SSP_CONFIG_FORM_RISKRULE_HELP":"Model output records that meet the selected threshold or above will trigger an early alert" 42 | } -------------------------------------------------------------------------------- /src/main/resources/public/assets/translations/en_GB/overview.json: -------------------------------------------------------------------------------- 1 | { 2 | "TEXT_HEADER": "History", 3 | "TABLE_HEADER_DATE": "DATE", 4 | "TABLE_HEADER_TYPE": "TYPE", 5 | "TABLE_HEADER_NAME": "NAME", 6 | "TABLE_HEADER_SUCCESS": "SUCCESS", 7 | "TABLE_HEADER_COUNT": "COUNT", 8 | 9 | "LINK_INDEX_LOGIN": "Login", 10 | "LINK_INDEX_LOGOUT": "Logout", 11 | "LINK_INDEX_SETTINGS":"Settings", 12 | "LINK_INDEX_HELP":"Help", 13 | 14 | "PIPELINE_TEXT_HEADER": "UK Pipelines", 15 | "PIPELINE_TABLE_HEADER_TYPE": "TYPE", 16 | "PIPELINE_TABLE_HEADER_NAME": "NAME", 17 | "PIPELINE_TABLE_HEADER_DESC": "DESCRIPTION", 18 | "STATISTICS" : "Statistics", 19 | "RUN" : "Run", 20 | 21 | "SELECT_INSTITUTION": "Select your institution", 22 | "SIGN_IN": "Sign In", 23 | "USERNAME_REQUIRED_ERROR": "Username is required.", 24 | "PASSWORD_REQUIRED_ERROR": "Password is required.", 25 | "USERNAME": "Username", 26 | "PASSWORD": "Password", 27 | 28 | "ALERT_DANGER_USERNAME_PASSWORD_MISMATCH": "The username and password do not match our records, please try again.", 29 | "ALERT_SUCCESS_LOGOUT_USER_INITIATED":"You have been logged out.", 30 | 31 | "SSP_CONFIG_HEADER":"Student Success Plan Configuration", 32 | "SSP_CONFIG_INSTRUCTIONS":"Use this form to configure the technical details of the integration with Student Success Plan. Most importantly set the threshold that will be used to trigger early alerts.", 33 | "SSP_CONFIG_FORM_KEY_LABEL":"Key", 34 | "SSP_CONFIG_FORM_SECRET_LABEL":"Secret", 35 | "SSP_CONFIG_FORM_URL_LABEL":"Base URL", 36 | "SSP_CONFIG_FORM_RISKRULE_LABEL":"Early Alert Threshold", 37 | "SSP_CONFIG_FORM_URL_HELP":"The base URL of the target SSP instance (e.g., https://ssp.com/)", 38 | "SSP_CONFIG_FORM_RISKRULE_HELP":"Model output records that meet the selected threshold or above will trigger an early alert" 39 | } -------------------------------------------------------------------------------- /src/main/resources/public/assets/translations/en_US/overview.json: -------------------------------------------------------------------------------- 1 | { 2 | "TEXT_HEADER": "History", 3 | "TABLE_HEADER_DATE": "DATE", 4 | "TABLE_HEADER_TYPE": "TYPE", 5 | "TABLE_HEADER_NAME": "NAME", 6 | "TABLE_HEADER_SUCCESS": "SUCCESS", 7 | "TABLE_HEADER_COUNT": "COUNT", 8 | 9 | "LINK_INDEX_LOGIN": "Login", 10 | "LINK_INDEX_LOGOUT": "Logout", 11 | "LINK_INDEX_SETTINGS":"Settings", 12 | "LINK_INDEX_HELP":"Help", 13 | 14 | "PIPELINE_TEXT_HEADER": "Pipelines", 15 | "PIPELINE_TABLE_HEADER_TYPE": "TYPE", 16 | "PIPELINE_TABLE_HEADER_NAME": "NAME", 17 | "PIPELINE_TABLE_HEADER_DESC": "DESCRIPTION", 18 | "STATISTICS" : "Statistics", 19 | "RUN" : "Run", 20 | 21 | "SELECT_INSTITUTION": "Select your institution", 22 | "SIGN_IN": "Sign In", 23 | "USERNAME_REQUIRED_ERROR": "Username is required.", 24 | "PASSWORD_REQUIRED_ERROR": "Password is required.", 25 | "USERNAME": "Username", 26 | "PASSWORD": "Password", 27 | 28 | "ALERT_DANGER_USERNAME_PASSWORD_MISMATCH": "The username and password do not match our records, please try again.", 29 | "ALERT_SUCCESS_LOGOUT_USER_INITIATED":"You have been logged out.", 30 | 31 | "SSP_CONFIG_HEADER":"Student Success Plan Configuration", 32 | "SSP_CONFIG_INSTRUCTIONS":"Use this form to configure the technical details of the integration with Student Success Plan. Most importantly set the threshold that will be used to trigger early alerts.", 33 | "SSP_CONFIG_FORM_KEY_LABEL":"Key", 34 | "SSP_CONFIG_FORM_SECRET_LABEL":"Secret", 35 | "SSP_CONFIG_FORM_URL_LABEL":"Base URL", 36 | "SSP_CONFIG_FORM_RISKRULE_LABEL":"Early Alert Threshold", 37 | "SSP_CONFIG_FORM_URL_HELP":"The base URL of the target SSP instance (e.g., https://ssp.com/)", 38 | "SSP_CONFIG_FORM_RISKRULE_HELP":"Model output records that meet the selected threshold or above will trigger an early alert" 39 | 40 | } -------------------------------------------------------------------------------- /src/main/resources/sample.sql: -------------------------------------------------------------------------------- 1 | -- This script is only used for loading test sample data (not used for normal runs) 2 | -- Script failures will cause the application to fail to start 3 | -- MySQL compatible schema 4 | 5 | -- Add some sample persons 6 | INSERT INTO PERSONAL (ALTERNATIVE_ID,PERCENTILE,SAT_VERBAL,SAT_MATH,ACT_COMPOSITE,AGE,RACE,GENDER,STATUS,EARNED_CREDIT_HOURS,GPA_CUMULATIVE,GPA_SEMESTER,STANDING,PELL_STATUS,CLASS_CODE) VALUES ('AZ_ALT_1',99,600,800,0,40,1,2,1,186,3.1,4,1,1,'SR'); 7 | INSERT INTO PERSONAL (ALTERNATIVE_ID,PERCENTILE,SAT_VERBAL,SAT_MATH,ACT_COMPOSITE,AGE,RACE,GENDER,STATUS,EARNED_CREDIT_HOURS,GPA_CUMULATIVE,GPA_SEMESTER,STANDING,PELL_STATUS,CLASS_CODE) VALUES ('BZ_ALT_1',99,710,800,0,35,1,1,1,150,3.9,4,2,1,'GR'); 8 | 9 | -- Add some sample courses 10 | INSERT INTO COURSE (COURSE_ID,SUBJECT,ENROLLMENT,ONLINE_FLAG) VALUES ('MATH_101_10101_201401', 'MATH', 2, 0); 11 | INSERT INTO COURSE (COURSE_ID,SUBJECT,ENROLLMENT,ONLINE_FLAG) VALUES ('MATH_201_2222_201401', 'MATH', 0, 0); 12 | INSERT INTO COURSE (COURSE_ID,SUBJECT,ENROLLMENT,ONLINE_FLAG) VALUES ('MATH_110_1234_201401', 'MATH', 0, 1); 13 | 14 | -- And then a couple enrollments 15 | -------------------------------------------------------------------------------- /src/main/resources/schema.sql: -------------------------------------------------------------------------------- 1 | -- This schema create script runs on every application load 2 | -- Script failures will cause the application to fail to start 3 | -- MySQL compatible schema 4 | CREATE TABLE IF NOT EXISTS PERSONAL ( 5 | ALTERNATIVE_ID varchar(100) NOT NULL, 6 | PERCENTILE float NOT NULL DEFAULT 0.0, 7 | SAT_VERBAL integer NOT NULL DEFAULT 0, 8 | SAT_MATH integer NOT NULL DEFAULT 0, 9 | ACT_COMPOSITE integer NOT NULL DEFAULT 0, 10 | AGE integer NOT NULL DEFAULT 1, 11 | RACE integer, 12 | GENDER integer, 13 | STATUS integer NOT NULL DEFAULT 1, 14 | EARNED_CREDIT_HOURS integer NOT NULL DEFAULT 0, 15 | GPA_CUMULATIVE float, 16 | GPA_SEMESTER float, 17 | STANDING integer NOT NULL DEFAULT 1, 18 | PELL_STATUS boolean DEFAULT FALSE, 19 | CLASS_CODE varchar(2), 20 | ENROLLMENT_STATUS varchar(100), 21 | PRIMARY KEY (ALTERNATIVE_ID) 22 | ); 23 | 24 | -- COURSE_ID,SUBJECT,ENROLLMENT,ONLINE_FLAG 25 | CREATE TABLE IF NOT EXISTS COURSE ( 26 | COURSE_ID varchar(100) NOT NULL, 27 | SUBJECT varchar(55), 28 | ENROLLMENT integer DEFAULT 0, 29 | ONLINE_FLAG boolean DEFAULT false, 30 | PRIMARY KEY (COURSE_ID) 31 | ); 32 | 33 | -- ALTERNATIVE_ID,COURSE_ID,FINAL_GRADE,WITHDRAWAL_DATE 34 | CREATE TABLE IF NOT EXISTS ENROLLMENT ( 35 | ALTERNATIVE_ID varchar(100) NOT NULL, 36 | COURSE_ID varchar(100) NOT NULL, 37 | FINAL_GRADE varchar(10), 38 | WITHDRAWAL_DATE TIMESTAMP, 39 | PRIMARY KEY (ALTERNATIVE_ID,COURSE_ID), 40 | FOREIGN KEY (ALTERNATIVE_ID) REFERENCES PERSONAL(ALTERNATIVE_ID), 41 | FOREIGN KEY (COURSE_ID) REFERENCES COURSE(COURSE_ID) 42 | ); 43 | 44 | -- ALTERNATIVE_ID,COURSE_ID,GRADABLE_OBJECT,CATEGORY,MAX_POINTS,EARNED_POINTS,WEIGHT,GRADE_DATE 45 | CREATE TABLE IF NOT EXISTS GRADE ( 46 | ALTERNATIVE_ID varchar(100) NOT NULL, 47 | COURSE_ID varchar(100) NOT NULL, 48 | GRADABLE_OBJECT varchar(250) NOT NULL, 49 | CATEGORY varchar(255), 50 | MAX_POINTS float DEFAULT 0.0, 51 | EARNED_POINTS float NOT NULL DEFAULT 0.0, 52 | WEIGHT float, 53 | GRADE_DATE TIMESTAMP, 54 | PRIMARY KEY (ALTERNATIVE_ID,COURSE_ID,GRADABLE_OBJECT), 55 | FOREIGN KEY (ALTERNATIVE_ID) REFERENCES PERSONAL(ALTERNATIVE_ID), 56 | FOREIGN KEY (COURSE_ID) REFERENCES COURSE(COURSE_ID) 57 | ); 58 | 59 | -- ALTERNATIVE_ID,COURSE_ID,EVENT,EVENT_DATE 60 | CREATE TABLE IF NOT EXISTS ACTIVITY ( 61 | ID integer NOT NULL AUTO_INCREMENT, 62 | ALTERNATIVE_ID varchar(100) NOT NULL, 63 | COURSE_ID varchar(100) NOT NULL, 64 | EVENT varchar(255) NOT NULL, 65 | EVENT_DATE TIMESTAMP NOT NULL, 66 | PRIMARY KEY (ID), 67 | FOREIGN KEY (ALTERNATIVE_ID) REFERENCES PERSONAL(ALTERNATIVE_ID), 68 | FOREIGN KEY (COURSE_ID) REFERENCES COURSE(COURSE_ID) 69 | ); 70 | 71 | CREATE TABLE IF NOT EXISTS CONFIGURATION ( 72 | ID integer NOT NULL AUTO_INCREMENT, 73 | SSP_BASE_URL varchar(100) NOT NULL, 74 | SSP_RISK_CONFIDENCE_THRESHOLD float NOT NULL, 75 | SSP_ACTIVE boolean DEFAULT true, 76 | PRIMARY KEY (ID) 77 | ); 78 | -------------------------------------------------------------------------------- /src/test/java/org/apereo/lap/services/OutputHandlerServiceTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services; 16 | 17 | import static org.junit.Assert.assertNotNull; 18 | 19 | import java.util.List; 20 | 21 | import org.apereo.lap.model.Output; 22 | import org.apereo.lap.model.PipelineConfig; 23 | import org.apereo.lap.services.configuration.ConfigurationService; 24 | import org.apereo.lap.services.output.OutputHandlerService; 25 | import org.apereo.lap.services.output.handlers.OutputHandler.OutputResult; 26 | import org.apereo.lap.test.AbstractUnitTest; 27 | import org.junit.Rule; 28 | import org.junit.Test; 29 | import org.junit.rules.ExpectedException; 30 | import org.slf4j.Logger; 31 | import org.slf4j.LoggerFactory; 32 | import org.springframework.beans.factory.annotation.Autowired; 33 | 34 | 35 | public class OutputHandlerServiceTest extends AbstractUnitTest{ 36 | private static final Logger logger = LoggerFactory.getLogger(OutputHandlerServiceTest.class); 37 | 38 | @Autowired 39 | ConfigurationService configuration; 40 | 41 | @Autowired 42 | OutputHandlerService outputHandler; 43 | 44 | @Rule 45 | public ExpectedException exception = ExpectedException.none(); 46 | 47 | @Test 48 | public void testDoOutput() { 49 | assertNotNull(outputHandler); 50 | assertNotNull(configuration); 51 | /* Testing using pipeline config */ 52 | PipelineConfig pipelineConfig = configuration.getPipelineConfig("sample"); 53 | assertNotNull(pipelineConfig); 54 | logger.info("Test Successful in loading 'sample' pipeline using configuration object"); 55 | 56 | List outputs = pipelineConfig.getOutputs(); 57 | for(Output output:outputs){ 58 | OutputResult result = outputHandler.doOutput(output); 59 | logger.info("Output of type:"+output.type+" complete: " + result); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/test/java/org/apereo/lap/services/StorageServiceTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.services; 16 | 17 | import static org.junit.Assert.assertNotNull; 18 | import static org.junit.Assert.assertTrue; 19 | 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | import org.apereo.lap.services.configuration.ConfigurationService; 24 | import org.apereo.lap.services.storage.StorageService; 25 | import org.apereo.lap.test.AbstractUnitTest; 26 | import org.junit.Test; 27 | import org.slf4j.Logger; 28 | import org.slf4j.LoggerFactory; 29 | import org.springframework.beans.factory.annotation.Autowired; 30 | import org.springframework.core.io.ResourceLoader; 31 | 32 | /** 33 | * Integration services test for Storage 34 | */ 35 | public class StorageServiceTest extends AbstractUnitTest{ 36 | private static final Logger logger = LoggerFactory.getLogger(StorageService.class); 37 | @Autowired 38 | ConfigurationService configuration; 39 | 40 | @Autowired 41 | StorageService storage; 42 | 43 | @javax.annotation.Resource 44 | ResourceLoader resourceLoader; 45 | 46 | 47 | @Test 48 | public void testServiceLoad() { 49 | assertNotNull(storage); 50 | assertNotNull(storage.getConfiguration()); 51 | assertNotNull(storage.getTempJdbcTemplate()); 52 | } 53 | 54 | @Test 55 | public void testServiceSQL() { 56 | List> results; 57 | assertNotNull(storage); 58 | 59 | // check for empty tables 60 | results = storage.getTempJdbcTemplate().queryForList("SELECT * FROM PERSONAL"); 61 | assertNotNull(results); 62 | assertTrue(results.isEmpty()); 63 | results = storage.getTempJdbcTemplate().queryForList("SELECT * FROM COURSE"); 64 | assertNotNull(results); 65 | assertTrue(results.isEmpty() ); 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/org/apereo/lap/test/AbstractIntegrationTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.test; 16 | 17 | import org.apereo.lap.LearningAnalyticsProcessor; 18 | import org.apereo.lap.test.group.IntegrationTests; 19 | import org.junit.experimental.categories.Category; 20 | import org.junit.runner.RunWith; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | import org.springframework.boot.test.SpringApplicationConfiguration; 24 | import org.springframework.test.context.ActiveProfiles; 25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 26 | 27 | @ActiveProfiles("test") 28 | @RunWith(SpringJUnit4ClassRunner.class) 29 | @SpringApplicationConfiguration(classes = LearningAnalyticsProcessor.class) 30 | @Category(IntegrationTests.class) 31 | public abstract class AbstractIntegrationTest { 32 | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); 33 | } 34 | -------------------------------------------------------------------------------- /src/test/java/org/apereo/lap/test/AbstractUnitTest.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.test; 16 | 17 | import org.apereo.lap.LearningAnalyticsProcessor; 18 | import org.apereo.lap.test.group.UnitTests; 19 | import org.junit.experimental.categories.Category; 20 | import org.junit.runner.RunWith; 21 | import org.slf4j.Logger; 22 | import org.slf4j.LoggerFactory; 23 | import org.springframework.boot.test.SpringApplicationConfiguration; 24 | import org.springframework.test.context.ActiveProfiles; 25 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 26 | import org.springframework.test.context.web.WebAppConfiguration; 27 | 28 | @ActiveProfiles("test") 29 | @RunWith(SpringJUnit4ClassRunner.class) 30 | @SpringApplicationConfiguration(classes = LearningAnalyticsProcessor.class) 31 | @Category(UnitTests.class) 32 | @WebAppConfiguration 33 | public abstract class AbstractUnitTest { 34 | protected final Logger logger = LoggerFactory.getLogger(this.getClass()); 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apereo/lap/test/MongoUnitTests.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.test; 16 | 17 | import org.apereo.lap.LearningAnalyticsProcessor; 18 | import org.junit.Before; 19 | import org.junit.experimental.categories.Category; 20 | import org.junit.runner.RunWith; 21 | import org.springframework.boot.test.SpringApplicationConfiguration; 22 | import org.springframework.test.context.ActiveProfiles; 23 | import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; 24 | import org.springframework.test.context.web.WebAppConfiguration; 25 | 26 | @ActiveProfiles("mongo-multitenant") 27 | @RunWith(SpringJUnit4ClassRunner.class) 28 | @SpringApplicationConfiguration(classes = LearningAnalyticsProcessor.class) 29 | @Category(MongoUnitTests.class) //Want to be able to remove mongo tests with out affecting other Unit/Integration tests 30 | @WebAppConfiguration 31 | public abstract class MongoUnitTests { 32 | 33 | @Before 34 | public void setup() { 35 | //Keeping with test setup. 36 | //Leave here for future unit tests. 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/test/java/org/apereo/lap/test/group/IntegrationTests.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.test.group; 16 | 17 | public interface IntegrationTests {} 18 | -------------------------------------------------------------------------------- /src/test/java/org/apereo/lap/test/group/MongoUnitTests.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.test.group; 16 | 17 | public interface MongoUnitTests {} 18 | -------------------------------------------------------------------------------- /src/test/java/org/apereo/lap/test/group/UnitTests.java: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Unicon (R) Licensed under the 3 | * Educational Community License, Version 2.0 (the "License"); you may 4 | * not use this file except in compliance with the License. You may 5 | * obtain a copy of the License at 6 | * 7 | * http://www.osedu.org/licenses/ECL-2.0 8 | * 9 | * Unless required by applicable law or agreed to in writing, 10 | * software distributed under the License is distributed on an "AS IS" 11 | * BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express 12 | * or implied. See the License for the specific language governing 13 | * permissions and limitations under the License. 14 | *******************************************************************************/ 15 | package org.apereo.lap.test.group; 16 | 17 | public interface UnitTests {} 18 | --------------------------------------------------------------------------------