├── .bowerrc ├── .gitignore ├── Gruntfile.js ├── Readme.md ├── bower.json ├── package.json ├── pom.xml └── src ├── bin └── crest └── main ├── java └── school │ ├── Application.java │ ├── aop │ └── LoggingAspect.java │ ├── controller │ ├── CourseController.java │ ├── DepartmentController.java │ ├── ImportController.java │ ├── StudentController.java │ ├── StudyBuddyController.java │ ├── SubjectController.java │ └── TeacherController.java │ ├── domain │ ├── Course.java │ ├── Department.java │ ├── Student.java │ ├── StudyBuddy.java │ ├── Subject.java │ └── Teacher.java │ ├── events │ ├── EventPublisher.java │ ├── ModificationEvent.java │ ├── PostDeleteEvent.java │ ├── PostSaveEvent.java │ ├── PreDeleteEvent.java │ └── PreSaveEvent.java │ ├── repository │ ├── CourseRepository.java │ ├── DepartmentRepository.java │ ├── StudentRepository.java │ ├── StudyBuddyRepository.java │ ├── SubjectRepository.java │ └── TeacherRepository.java │ └── service │ ├── ImportService.java │ └── impl │ └── FileBasedImportServiceImpl.java ├── resources ├── application.properties ├── school.cql └── static │ ├── favicon.ico │ ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 │ ├── images │ ├── 032433-250920121-sixth_inner_banner2.ecd87142.jpg │ ├── 120208-070920120-sixthform_048.38c1cbc0.jpg │ ├── 120209-070920121-sixthform_053.e2c484d3.jpg │ ├── chevron-chief-crossbotony-233x300.44beb57a.png │ ├── development_ribbon.f64d6562.png │ ├── glyphicons-halflings-white.9bbc6e96.png │ ├── glyphicons-halflings.180b8ed9.png │ ├── mathematics-dept.c0d2306d.jpg │ ├── science-dept.9310957f.jpg │ ├── student-register.fd2e88c6.jpg │ └── student-registration-apply-now.30cb549b.jpeg │ ├── index.html │ ├── robots.txt │ ├── scripts │ ├── scripts.a5247dcf.js │ └── vendor.b93e3175.js │ └── styles │ ├── main.ab457e5c.css │ └── vendor.96921311.css └── web ├── favicon.ico ├── html ├── class-detail.html ├── classes.html ├── department-detail.html ├── departments.html ├── error.html ├── main.html ├── navbar.html ├── school-detail.html ├── schools.html ├── statistics.html ├── student-detail.html ├── students.html ├── studyBuddies.html ├── studyBuddy-detail.html ├── subject-detail.html ├── subjects.html ├── teacher-detail.html └── teachers.html ├── images ├── 032433-250920121-sixth_inner_banner2.jpg ├── 120208-070920120-sixthform_048.jpg ├── 120209-070920121-sixthform_053.jpg ├── chevron-chief-crossbotony-233x300.png ├── development_ribbon.png ├── engineering-dept.JPG ├── glyphicons-halflings-white.png ├── glyphicons-halflings.png ├── mathematics-dept.jpg ├── science-dept.jpg ├── student-register.jpg └── student-registration-apply-now.jpeg ├── index.html ├── robots.txt ├── scripts ├── app.js ├── entities │ ├── class │ │ ├── class-detail.controller.js │ │ ├── class.controller.js │ │ ├── class.js │ │ └── class.service.js │ ├── department │ │ ├── department-detail.controller.js │ │ ├── department.controller.js │ │ ├── department.js │ │ └── department.service.js │ ├── entity.js │ ├── school │ │ ├── school-detail.controller.js │ │ ├── school.controller.js │ │ ├── school.js │ │ └── school.service.js │ ├── statistics │ │ ├── statistics.controller.js │ │ ├── statistics.js │ │ └── statistics.service.js │ ├── student │ │ ├── student-detail.controller.js │ │ ├── student.controller.js │ │ ├── student.js │ │ └── student.service.js │ ├── studyBuddy │ │ ├── studyBuddy-detail.controller.js │ │ ├── studyBuddy.controller.js │ │ ├── studyBuddy.js │ │ └── studyBuddy.service.js │ ├── subject │ │ ├── subject-detail.controller.js │ │ ├── subject.controller.js │ │ ├── subject.js │ │ └── subject.service.js │ └── teacher │ │ ├── teacher-detail.controller.js │ │ ├── teacher.controller.js │ │ ├── teacher.js │ │ └── teacher.service.js ├── error │ └── error.js ├── main │ ├── main.controller.js │ └── main.js └── navbar.directive.js └── styles └── main.css /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "src/main/web/bower_components" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | node_modules/ 3 | src/main/web/bower_components 4 | deploy/ 5 | .buildpath 6 | .project 7 | .settings 8 | .bin/ 9 | .idea/ 10 | .tmp/ 11 | *.class 12 | *.iml 13 | *.iws 14 | *.ipr 15 | *.db 16 | .DS_Store 17 | .classpath 18 | bin 19 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | // author - Mark Angrish 2 | 'use strict'; 3 | 4 | 5 | module.exports = function (grunt) { 6 | 7 | // Time how long tasks take. Can help when optimizing build times 8 | require('time-grunt')(grunt); 9 | 10 | // Automatically load required Grunt tasks 11 | require('jit-grunt')(grunt, { 12 | useminPrepare: 'grunt-usemin', 13 | ngtemplates: 'grunt-angular-templates', 14 | }); 15 | 16 | // Configurable paths for the application 17 | var appConfig = { 18 | app: require('./bower.json').appPath || 'src/main/web', 19 | dist: 'src/main/resources/static' 20 | }; 21 | 22 | grunt.initConfig({ 23 | // Project settings 24 | yeoman: appConfig, 25 | 26 | // Watches files for changes and runs tasks based on the changed files 27 | watch: { 28 | bower: { 29 | files: ['bower.json'], 30 | tasks: ['wiredep'] 31 | }, 32 | js: { 33 | files: ['<%= yeoman.app %>/scripts/**/*.js'], 34 | tasks: ['newer:jshint:all', 'newer:jscs:all'], 35 | options: { 36 | livereload: '<%= connect.options.livereload %>' 37 | } 38 | }, 39 | styles: { 40 | files: ['<%= yeoman.app %>/styles/{,*/}*.css'], 41 | tasks: ['newer:copy:styles', 'postcss'] 42 | }, 43 | gruntfile: { 44 | files: ['Gruntfile.js'] 45 | }, 46 | livereload: { 47 | options: { 48 | livereload: '<%= connect.options.livereload %>' 49 | }, 50 | files: [ 51 | '<%= yeoman.app %>/**/*.html', 52 | '.tmp/styles/{,*/}*.css', 53 | '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}' 54 | ] 55 | } 56 | }, 57 | 58 | // The actual grunt server settings 59 | connect: { 60 | options: { 61 | port: 9000, 62 | hostname: '0.0.0.0', 63 | open: true, 64 | livereload: 35729 65 | }, 66 | livereload: { 67 | options: { 68 | open: true, 69 | middleware: function (connect) { 70 | return [ 71 | connect.static('.tmp'), 72 | connect().use('/bower_components', connect.static('./src/main/web/bower_components')), 73 | connect().use('/src/main/web/styles', connect.static('./src/main/web/styles')), 74 | connect.static(appConfig.app) 75 | ] 76 | } 77 | } 78 | }, 79 | dist: { 80 | options: { 81 | open: true, 82 | base: '<%= yeoman.dist %>' 83 | } 84 | } 85 | }, 86 | 87 | 88 | // Make sure there are no obvious mistakes 89 | jshint: { 90 | options: { 91 | jshintrc: '.jshintrc', 92 | reporter: require('jshint-stylish') 93 | }, 94 | all: { 95 | src: [ 96 | 'Gruntfile.js', 97 | '<%= yeoman.app %>/scripts/**/*.js' 98 | ] 99 | } 100 | }, 101 | 102 | // Make sure code styles are up to par 103 | jscs: { 104 | options: { 105 | config: '.jscsrc', 106 | verbose: true 107 | }, 108 | all: { 109 | src: [ 110 | 'Gruntfile.js', 111 | '<%= yeoman.app %>/scripts/**/*.js' 112 | ] 113 | } 114 | }, 115 | 116 | // Empties folders to start fresh 117 | clean: { 118 | dist: { 119 | files: [{ 120 | dot: true, 121 | src: [ 122 | '.tmp', 123 | '<%= yeoman.dist %>/{,*/}*', 124 | '!<%= yeoman.dist %>/.git{,*/}*' 125 | ] 126 | }] 127 | }, 128 | server: '.tmp' 129 | }, 130 | 131 | // Add vendor prefixed styles 132 | postcss: { 133 | options: { 134 | processors: [ 135 | require('autoprefixer-core')({browsers: ['last 1 version']}) 136 | ] 137 | }, 138 | server: { 139 | options: { 140 | map: true 141 | }, 142 | files: [{ 143 | expand: true, 144 | cwd: '.tmp/styles/', 145 | src: '{,*/}*.css', 146 | dest: '.tmp/styles/' 147 | }] 148 | }, 149 | dist: { 150 | files: [{ 151 | expand: true, 152 | cwd: '.tmp/styles/', 153 | src: '{,*/}*.css', 154 | dest: '.tmp/styles/' 155 | }] 156 | } 157 | }, 158 | 159 | // Automatically inject Bower components into the app 160 | wiredep: { 161 | app: { 162 | src: ['<%= yeoman.app %>/index.html'], 163 | ignorePath: /\.\.\// 164 | } 165 | }, 166 | 167 | // Renames files for browser caching purposes 168 | filerev: { 169 | dist: { 170 | src: [ 171 | '<%= yeoman.dist %>/scripts/**/*.js', 172 | '<%= yeoman.dist %>/styles/{,*/}*.css', 173 | '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}', 174 | '<%= yeoman.dist %>/styles/fonts/*' 175 | ] 176 | } 177 | }, 178 | 179 | // Reads HTML for usemin blocks to enable smart builds that automatically 180 | // concat, minify and revision files. Creates configurations in memory so 181 | // additional tasks can operate on them 182 | useminPrepare: { 183 | html: '<%= yeoman.app %>/index.html', 184 | options: { 185 | dest: '<%= yeoman.dist %>', 186 | flow: { 187 | html: { 188 | steps: { 189 | js: ['concat', 'uglifyjs'], 190 | css: ['cssmin'] 191 | }, 192 | post: {} 193 | } 194 | } 195 | } 196 | }, 197 | 198 | // Performs rewrites based on filerev and the useminPrepare configuration 199 | usemin: { 200 | html: ['<%= yeoman.dist %>/**/*.html'], 201 | css: ['<%= yeoman.dist %>/styles/{,*/}*.css'], 202 | js: ['<%= yeoman.dist %>/scripts/**/*.js'], 203 | options: { 204 | assetsDirs: [ 205 | '<%= yeoman.dist %>', 206 | '<%= yeoman.dist %>/images', 207 | '<%= yeoman.dist %>/styles' 208 | ], 209 | patterns: { 210 | js: [[/(images\/[^''""]*\.(png|jpg|jpeg|gif|webp|svg))/g, 'Replacing references to images']] 211 | } 212 | } 213 | }, 214 | 215 | imagemin: { 216 | dist: { 217 | files: [{ 218 | expand: true, 219 | cwd: '<%= yeoman.app %>/images', 220 | src: '{,*/}*.{png,jpg,jpeg,gif}', 221 | dest: '<%= yeoman.dist %>/images' 222 | }] 223 | } 224 | }, 225 | 226 | svgmin: { 227 | dist: { 228 | files: [{ 229 | expand: true, 230 | cwd: '<%= yeoman.app %>/images', 231 | src: '{,*/}*.svg', 232 | dest: '<%= yeoman.dist %>/images' 233 | }] 234 | } 235 | }, 236 | 237 | htmlmin: { 238 | dist: { 239 | options: { 240 | collapseWhitespace: true, 241 | conservativeCollapse: true, 242 | collapseBooleanAttributes: true, 243 | removeCommentsFromCDATA: true 244 | }, 245 | files: [{ 246 | expand: true, 247 | cwd: '<%= yeoman.dist %>', 248 | src: ['*.html'], 249 | dest: '<%= yeoman.dist %>' 250 | }] 251 | } 252 | }, 253 | 254 | ngtemplates: { 255 | dist: { 256 | options: { 257 | module: 'registrarApp', 258 | htmlmin: '<%= htmlmin.dist.options %>', 259 | usemin: 'scripts/scripts.js' 260 | }, 261 | cwd: '<%= yeoman.app %>', 262 | src: 'html/**/*.html', 263 | dest: '.tmp/templateCache.js' 264 | } 265 | }, 266 | 267 | // ng-annotate tries to make the code safe for minification automatically 268 | // by using the Angular long form for dependency injection. 269 | ngAnnotate: { 270 | dist: { 271 | files: [{ 272 | expand: true, 273 | cwd: '.tmp/concat/scripts', 274 | src: '*.js', 275 | dest: '.tmp/concat/scripts' 276 | }] 277 | } 278 | }, 279 | 280 | // Copies remaining files to places other tasks can use 281 | copy: { 282 | dist: { 283 | files: [{ 284 | expand: true, 285 | dot: true, 286 | cwd: '<%= yeoman.app %>', 287 | dest: '<%= yeoman.dist %>', 288 | src: [ 289 | '*.{ico,png,txt}', 290 | '*.html', 291 | 'images/{,*/}*.{webp}', 292 | 'styles/fonts/{,*/}*.*' 293 | ] 294 | }, { 295 | expand: true, 296 | cwd: '.tmp/images', 297 | dest: '<%= yeoman.dist %>/images', 298 | src: ['generated/*'] 299 | }, { 300 | expand: true, 301 | cwd: 'src/main/web/bower_components/bootstrap/dist', 302 | src: 'fonts/*', 303 | dest: '<%= yeoman.dist %>' 304 | }] 305 | }, 306 | styles: { 307 | expand: true, 308 | cwd: '<%= yeoman.app %>/styles', 309 | dest: '.tmp/styles/', 310 | src: '{,*/}*.css' 311 | } 312 | }, 313 | 314 | // Run some tasks in parallel to speed up the build process 315 | concurrent: { 316 | server: [ 317 | 'copy:styles' 318 | ], 319 | dist: [ 320 | 'copy:styles', 321 | 'imagemin', 322 | 'svgmin' 323 | ] 324 | }, 325 | }); 326 | 327 | grunt.registerTask('serve', function (target) { 328 | if (target === 'dist') { 329 | return grunt.task.run(['build', 'connect:dist:keepalive']); 330 | } 331 | 332 | grunt.task.run([ 333 | 'clean:server', 334 | 'wiredep', 335 | 'concurrent:server', 336 | 'postcss:server', 337 | 'connect:livereload', 338 | 'watch' 339 | ]); 340 | }); 341 | 342 | grunt.registerTask('server', function (target) { 343 | grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.'); 344 | grunt.task.run([target ? ('serve:' + target) : 'serve']); 345 | }); 346 | 347 | grunt.registerTask('build', [ 348 | 'clean:dist', 349 | 'wiredep', 350 | 'useminPrepare', 351 | 'concurrent:dist', 352 | 'postcss', 353 | 'ngtemplates', 354 | 'concat', 355 | 'ngAnnotate', 356 | 'copy:dist', 357 | 'cssmin', 358 | 'uglify', 359 | 'filerev', 360 | 'usemin', 361 | 'htmlmin' 362 | ]); 363 | 364 | 365 | grunt.registerTask('default', [ 366 | 'newer:jshint', 367 | 'newer:jscs', 368 | 'build' 369 | ]); 370 | }; 371 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | Hilly Fields Technical College 2 | ============================== 3 | 4 | Overview 5 | -------- 6 | 7 | This demo web application shows developers how to quickly get started with [Spring Data Neo4j](https://github.com/spring-projects/spring-data-neo4j) library and the [Neo4j](http://neo4j.org) graph database. For the non Spring version of this application please check out [Neo4j OGM University](https://github.com/neo4j-examples/neo4j-ogm-university). 8 | 9 | Hilly Fields Technical College is a fictitious educational institution. This application allows you to manage its departments, teaching staff, subjects, students and classes. 10 | 11 | This project is built using: 12 | 13 | - Spring Boot 2.0.3 14 | - Spring Data Neo4j 5 15 | - Neo4j OGM 3.1.0 16 | - AngularJS 1.6 17 | - Bootstrap 3.3 18 | 19 | 20 | It leverages combines the power Spring Data and Spring Boot with the Neo4j Object Graph Mapper(OGM) via a RESTful interface with which a web client application like AngularJS or ReactJS may interact. 21 | 22 | 23 | Getting Started 24 | --------------- 25 | 26 | ### Prerequisites 27 | 28 | You will need to following to run this application: 29 | 30 | - [Java 8+](http://www.oracle.com/technetwork/java/javase/downloads/index.html) 31 | - [Maven](https://maven.apache.org/) 32 | 33 | 34 | ### Download the application 35 | 36 | Either [download](https://github.com/neo4j-examples/sdn-university/archive/master.zip) the application or use `git` to clone the application: 37 | 38 | ``` 39 | git clone git@github.com:neo4j-examples/sdn-university.git 40 | cd sdn-university 41 | ``` 42 | 43 | ### Starting the application 44 | 45 | No configuration is required as this application will run with a temporary embedded Neo4j Database by default. See below on how to set this up with a standalone Neo4j Server using bolt or the http drivers. 46 | 47 | You can start the application using maven: 48 | 49 | ``` 50 | mvn spring-boot:run 51 | ``` 52 | 53 | And that's it! Head to to see your application running. 54 | 55 | > **NOTE** 56 | > If you restart your application you may notice changes made in your database disappear. 57 | > That's because if you don't supply a directory to house the database only a temporary data store is set up (and gets destroyed on close). 58 | > If you want the data to persist between restarts then in your favourite editor modify `src/main/resources/application.properties` and add a new line with `spring.data.neo4j.uri=file:///var/tmp/neo4j.db` or wherever you want your database to reside. 59 | 60 | #### Using the binary Bolt driver 61 | 62 | If you'd like to run this application using the fast bolt driver against a standalone Neo4j instance then you will need to do the following. 63 | 64 | 1. Make sure you have a [Neo4j](http://neo4j.org) instance installed and running. 65 | 1. Change the `pom.xml` to comment out the embedded driver and the embedded neo4j instance dependencies and instead uncomment the bolt driver. 66 | 1. You'll need to provide connection credentials for the database to the bolt driver. To do this, set the Neo4j username and password in `src/main/resources/application.properties` 67 | ``` 68 | spring.data.neo4j.uri=bolt://localhost 69 | spring.data.neo4j.username= 70 | spring.data.neo4j.password= 71 | 72 | ``` 73 | 1. You can then start the application using the same maven run command shown above. 74 | 75 | #### Using the HTTP driver 76 | 77 | If you'd like to run this application using the original REST HTTP driver against a standalone Neo4j instance then you will need to do the following. 78 | 79 | 1. Make sure you have a [Neo4j](http://neo4j.org) instance installed and running. 80 | 1. Change the `pom.xml` to comment out the embedded driver and the embedded neo4j instance dependencies and instead uncomment the http driver. 81 | 1. You'll need to provide connection credentials for the database to the bolt driver. To do this, set the Neo4j username and password in `src/main/resources/application.properties` 82 | ``` 83 | spring.data.neo4j.uri=http://localhost:7474 84 | spring.data.neo4j.username= 85 | spring.data.neo4j.password= 86 | 87 | ``` 88 | 1. You can then start the application using the same maven run command shown above. 89 | 90 | ### Loading the initial dataset 91 | 92 | > **WARNING** 93 | > 94 | > By default, the application will use an Neo4j embedded instance of Neo4j. 95 | > If you are running this application with the bolt or http drivers be careful as **IT WILL DESTROY ALL THE DATA IN THAT DATABASE** after hitting the URL below. 96 | > So if you don't want that to happen please back up any existing database first. 97 | 98 | You may notice that there is no data for you to interact with. To fix this, hit the following endpoint from your browser or using `curl`: 99 | 100 | 101 | 102 | This will pre-load the Neo4j database with a handful of departments, a dozen or so subjects and teachers, 103 | and 200 students. You'll probably want to enroll them in classes... 104 | 105 | 106 | ### Stopping the application server 107 | 108 | You can stop the application server at any time by pressing `Ctrl-C` in the console window from where you launched it. 109 | 110 | 111 | Make it better! 112 | --------------- 113 | 114 | If you'd like to contribute to the development of this application you will need to install: 115 | 116 | - [NodeJS](https://nodejs.org/en/) 117 | - [Bower](https://bower.io/) 118 | - [GruntJS](http://gruntjs.com/) 119 | 120 | Once you have followed their instruction on installation you will need to install the project's node and bower dependencies via: 121 | 122 | ``` 123 | git clone git@github.com:neo4j-examples/sdn-university.git 124 | cd sdn-university 125 | npm install && bower install 126 | ``` 127 | 128 | You can then run the front-end angular application simply by using: 129 | 130 | ``` 131 | grunt serve 132 | ``` 133 | 134 | 135 | 136 | If you would like to prepare a releasable version of your front end assets you can run: 137 | 138 | ``` 139 | grunt clean build 140 | ``` 141 | 142 | Your assets will then be available in the `src/main/resources/static` directory. 143 | 144 | You can then run the maven boot run command to see your application served up entirely from Spring Boot! 145 | 146 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sdn4university", 3 | "appPath": "src/main/web", 4 | "moduleName": "registrarApp", 5 | "version": "0.0.1", 6 | "dependencies": { 7 | "bootstrap": "3.3.7", 8 | "jquery": "2.1.1", 9 | "angular": "1.6.1", 10 | "json3": "3.3.2", 11 | "angular-ui-router": "0.4.1", 12 | "angular-resource": "1.6.1", 13 | "angular-sanitize": "1.6.1", 14 | "checklist-model": "0.10.0", 15 | "jsog": "1.0.7" 16 | }, 17 | "overrides": { 18 | "bootstrap": { 19 | "main": [ 20 | "less/bootstrap.less", 21 | "dist/css/bootstrap.css", 22 | "dist/js/bootstrap.js" 23 | ] 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sdn4university", 3 | "version": "0.0.1", 4 | "devDependencies": { 5 | "autoprefixer-core": "^5.2.1", 6 | "connect-modrewrite": "^0.8.2", 7 | "grunt": "0.4.5", 8 | "grunt-angular-templates": "^0.5.7", 9 | "grunt-concurrent": "^1.0.0", 10 | "grunt-connect-rewrite": "^0.2.1", 11 | "grunt-contrib-clean": "^0.6.0", 12 | "grunt-contrib-compress": "^0.14.0", 13 | "grunt-contrib-concat": "^0.5.1", 14 | "grunt-contrib-connect": "^0.10.0", 15 | "grunt-contrib-copy": "^0.8.0", 16 | "grunt-contrib-cssmin": "^0.12.2", 17 | "grunt-contrib-htmlmin": "^0.4.0", 18 | "grunt-contrib-imagemin": "^1.0.0", 19 | "grunt-contrib-jshint": "^0.11.2", 20 | "grunt-contrib-uglify": "^0.9.1", 21 | "grunt-contrib-watch": "^0.6.1", 22 | "grunt-filerev": "^2.3.1", 23 | "grunt-jscs": "^1.8.0", 24 | "grunt-newer": "^1.1.0", 25 | "grunt-ng-annotate": "^0.9.2", 26 | "grunt-postcss": "^0.5.5", 27 | "grunt-svgmin": "^2.0.1", 28 | "grunt-usemin": "^3.0.0", 29 | "grunt-wiredep": "^2.0.0", 30 | "jit-grunt": "^0.9.1", 31 | "jshint-stylish": "^1.0.1", 32 | "time-grunt": "^1.1.1" 33 | }, 34 | "engines": { 35 | "node": ">=4.2.1" 36 | }, 37 | "dependencies": { 38 | "username": "^2.2.2" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.neo4j.examples 8 | sdn-university 9 | 0.4.0 10 | jar 11 | 12 | SDN University 13 | Demo web project for Spring Boot using Spring Data Neo4j 14 | 15 | 16 | org.springframework.boot 17 | spring-boot-starter-parent 18 | 2.0.5.RELEASE 19 | 20 | 21 | 22 | 23 | UTF-8 24 | UTF-8 25 | 26 | 27 | 28 | 29 | 30 | org.springframework.boot 31 | spring-boot-starter-data-neo4j 32 | 33 | 34 | 35 | org.springframework.boot 36 | spring-boot-starter-web 37 | 38 | 39 | 40 | org.springframework.boot 41 | spring-boot-starter-test 42 | test 43 | 44 | 45 | 46 | com.voodoodyne.jackson.jsog 47 | jackson-jsog 48 | 1.1 49 | compile 50 | 51 | 52 | 53 | 54 | org.neo4j 55 | neo4j-ogm-embedded-driver 56 | ${neo4j-ogm.version} 57 | compile 58 | 59 | 60 | 61 | org.neo4j 62 | neo4j 63 | 3.1.0 64 | runtime 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | org.springframework.boot 87 | spring-boot-maven-plugin 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /src/bin/crest: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | URL="localhost:7474" 4 | 5 | function list { 6 | curl -u "neo4j:password" -X GET "$URL/$1/" 7 | echo "" 8 | } 9 | 10 | function create { 11 | curl -H "Content-Type:application/json" -X POST -d $2 "$URL/$1/" 12 | echo "create $URL" 13 | } 14 | 15 | function find { 16 | curl -X GET "$URL/$1/$2/" 17 | echo "" 18 | } 19 | 20 | function delete { 21 | curl -X DELETE "$URL/$1/$2/" 22 | echo "" 23 | } 24 | 25 | function update { 26 | curl -H "Content-Type:application/json" -X PUT -d "$3" "$URL/$1/$2" 27 | echo 28 | } 29 | 30 | function help() { 31 | echo "usage: command {container} [arguments]" 32 | echo "- list {container} - lists the contents of the REST container" 33 | echo "- get {container} {id} - find the resource with id {id} in the container {container}" 34 | echo "- delete {container} {id} - deletes the resource with id {id} from the container {container}" 35 | echo "- create {container} {json} - creates a new resource in the container {container}" 36 | echo "- update {container} {id} {json} - updates the resource with {id} in the container {container}" 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/school/Application.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school; 12 | 13 | import org.springframework.boot.SpringApplication; 14 | import org.springframework.boot.autoconfigure.SpringBootApplication; 15 | import org.springframework.boot.autoconfigure.domain.EntityScan; 16 | import org.springframework.context.annotation.Bean; 17 | import org.springframework.context.event.EventListener; 18 | import school.events.EventPublisher; 19 | import school.events.PostSaveEvent; 20 | import school.events.PreDeleteEvent; 21 | import school.events.PreSaveEvent; 22 | 23 | 24 | @SpringBootApplication 25 | @EntityScan("school.domain") 26 | public class Application { 27 | 28 | public static void main(String[] args) { 29 | SpringApplication.run(Application.class, args); 30 | } 31 | 32 | /** 33 | * Simply defining a Neo4j OGM EventListener will register it 34 | * with the session factory. 35 | */ 36 | @Bean 37 | public EventPublisher eventPublisher() { 38 | return new EventPublisher(); 39 | } 40 | 41 | 42 | @EventListener 43 | public void onPreSaveEvent(PreSaveEvent event) { 44 | Object entity = event.getSource(); 45 | System.out.println("Before save of: " + entity); 46 | } 47 | 48 | @EventListener 49 | public void onPostSaveEvent(PostSaveEvent event) { 50 | Object entity = event.getSource(); 51 | System.out.println("After save of: " + entity); 52 | } 53 | 54 | @EventListener 55 | public void onPreDeleteEvent(PreDeleteEvent event) { 56 | Object entity = event.getSource(); 57 | System.out.println("Before delete of: " + entity); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/school/aop/LoggingAspect.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/java/school/aop/LoggingAspect.java -------------------------------------------------------------------------------- /src/main/java/school/controller/CourseController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | 12 | package school.controller; 13 | 14 | import org.neo4j.ogm.exception.core.NotFoundException; 15 | import org.springframework.beans.factory.annotation.Autowired; 16 | import org.springframework.transaction.annotation.Transactional; 17 | import org.springframework.web.bind.annotation.PathVariable; 18 | import org.springframework.web.bind.annotation.RequestBody; 19 | import org.springframework.web.bind.annotation.RequestMapping; 20 | import org.springframework.web.bind.annotation.RequestMethod; 21 | import org.springframework.web.bind.annotation.RestController; 22 | import school.domain.Course; 23 | import school.repository.CourseRepository; 24 | 25 | @RestController 26 | @RequestMapping(value = "/api/classes") 27 | public class CourseController { 28 | 29 | private CourseRepository courseRepository; 30 | 31 | @Autowired 32 | public CourseController(CourseRepository courseRepository) { 33 | this.courseRepository = courseRepository; 34 | } 35 | 36 | @RequestMapping(method = RequestMethod.GET) 37 | public Iterable readAll() { 38 | return courseRepository.findAll(); 39 | } 40 | 41 | @RequestMapping(method = RequestMethod.POST) 42 | public Course create(@RequestBody Course course) { 43 | return courseRepository.save(course); 44 | } 45 | 46 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 47 | public Course read(@PathVariable Long id) { 48 | return courseRepository.findById(id).orElseThrow(NotFoundException::new); 49 | } 50 | 51 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) 52 | public void delete(@PathVariable Long id) { 53 | courseRepository.deleteById(id); 54 | } 55 | 56 | @Transactional 57 | @RequestMapping(value = "/{id}", method = RequestMethod.PUT) 58 | public Course update(@PathVariable Long id, @RequestBody Course update) { 59 | final Course existing = courseRepository.findById(id).orElseThrow(NotFoundException::new); 60 | existing.updateFrom(update); 61 | return courseRepository.save(existing); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/school/controller/DepartmentController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.controller; 12 | 13 | import org.neo4j.ogm.exception.core.NotFoundException; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.RequestBody; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RequestMethod; 20 | import org.springframework.web.bind.annotation.RestController; 21 | import school.domain.Department; 22 | import school.repository.DepartmentRepository; 23 | 24 | @RestController 25 | @RequestMapping(value = "/api/departments") 26 | public class DepartmentController { 27 | 28 | private DepartmentRepository departmentRepository; 29 | 30 | @Autowired 31 | public DepartmentController(DepartmentRepository departmentRepository) { 32 | this.departmentRepository = departmentRepository; 33 | } 34 | 35 | @RequestMapping(method = RequestMethod.GET) 36 | public Iterable readAll() { 37 | return departmentRepository.findAll(); 38 | } 39 | 40 | @RequestMapping(method = RequestMethod.POST) 41 | public Department create(@RequestBody Department department) { 42 | return departmentRepository.save(department); 43 | } 44 | 45 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 46 | public Department read(@PathVariable Long id) { 47 | return departmentRepository.findById(id).orElseThrow(NotFoundException::new); 48 | } 49 | 50 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) 51 | public void delete(@PathVariable Long id) { 52 | departmentRepository.deleteById(id); 53 | } 54 | 55 | @Transactional 56 | @RequestMapping(value = "/{id}", method = RequestMethod.PUT) 57 | public Department update(@PathVariable Long id, @RequestBody Department update) { 58 | final Department existing = departmentRepository.findById(id).orElseThrow(NotFoundException::new); 59 | existing.updateFrom(update); 60 | return departmentRepository.save(existing); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/school/controller/ImportController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.controller; 12 | 13 | import org.springframework.beans.factory.annotation.Autowired; 14 | import org.springframework.http.HttpStatus; 15 | import org.springframework.http.ResponseEntity; 16 | import org.springframework.transaction.annotation.Transactional; 17 | import org.springframework.web.bind.annotation.RequestMapping; 18 | import org.springframework.web.bind.annotation.RestController; 19 | import school.service.ImportService; 20 | 21 | @RestController 22 | public class ImportController { 23 | 24 | private ImportService service; 25 | 26 | @Autowired 27 | public ImportController(ImportService service) { 28 | this.service = service; 29 | } 30 | 31 | 32 | @Transactional 33 | @RequestMapping("/api/reload") 34 | public ResponseEntity reload() { 35 | 36 | service.clearDatabase(); 37 | service.load(); 38 | 39 | return new ResponseEntity(HttpStatus.CREATED); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/school/controller/StudentController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.controller; 12 | 13 | import org.neo4j.ogm.exception.core.NotFoundException; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.RequestBody; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RequestMethod; 20 | import org.springframework.web.bind.annotation.RestController; 21 | import school.domain.Student; 22 | import school.repository.StudentRepository; 23 | 24 | @RestController 25 | @RequestMapping(value = "/api/students") 26 | public class StudentController { 27 | 28 | private StudentRepository studentRepository; 29 | 30 | @Autowired 31 | public StudentController(StudentRepository studentRepository) { 32 | this.studentRepository = studentRepository; 33 | } 34 | 35 | @RequestMapping(method = RequestMethod.GET) 36 | public Iterable readAll() { 37 | return studentRepository.findAll(); 38 | } 39 | 40 | @RequestMapping(method = RequestMethod.POST) 41 | public Student create(@RequestBody Student student) { 42 | return studentRepository.save(student); 43 | } 44 | 45 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 46 | public Student read(@PathVariable Long id) { 47 | return studentRepository.findById(id).orElseThrow(NotFoundException::new); 48 | } 49 | 50 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) 51 | public void delete(@PathVariable Long id) { 52 | studentRepository.deleteById(id); 53 | } 54 | 55 | @Transactional 56 | @RequestMapping(value = "/{id}", method = RequestMethod.PUT) 57 | public Student update(@PathVariable Long id, @RequestBody Student update) { 58 | final Student existing = studentRepository.findById(id).orElseThrow(NotFoundException::new); 59 | existing.updateFrom(update); 60 | return studentRepository.save(existing); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/school/controller/StudyBuddyController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.controller; 12 | 13 | import org.neo4j.ogm.exception.core.NotFoundException; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.RequestBody; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RequestMethod; 20 | import org.springframework.web.bind.annotation.RestController; 21 | import school.domain.StudyBuddy; 22 | import school.repository.StudyBuddyRepository; 23 | 24 | import java.util.Map; 25 | 26 | 27 | @RestController 28 | @RequestMapping(value = "/api/studyBuddies") 29 | public class StudyBuddyController { 30 | 31 | private StudyBuddyRepository studyBuddyRepository; 32 | 33 | @Autowired 34 | public StudyBuddyController(StudyBuddyRepository studyBuddyRepository) { 35 | this.studyBuddyRepository = studyBuddyRepository; 36 | } 37 | 38 | @RequestMapping(method = RequestMethod.GET) 39 | public Iterable readAll() { 40 | return studyBuddyRepository.findAll(); 41 | } 42 | 43 | @RequestMapping(method = RequestMethod.POST) 44 | public StudyBuddy create(@RequestBody StudyBuddy studyBuddy) { 45 | return studyBuddyRepository.save(studyBuddy); 46 | } 47 | 48 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 49 | public StudyBuddy read(@PathVariable Long id) { 50 | return studyBuddyRepository.findById(id).orElseThrow(NotFoundException::new); 51 | } 52 | 53 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) 54 | public void delete(@PathVariable Long id) { 55 | studyBuddyRepository.deleteById(id); 56 | } 57 | 58 | @Transactional 59 | @RequestMapping(value = "/{id}", method = RequestMethod.PUT) 60 | public StudyBuddy update(@PathVariable Long id, @RequestBody StudyBuddy update) { 61 | final StudyBuddy existing = studyBuddyRepository.findById(id).orElseThrow(NotFoundException::new); 62 | existing.updateFrom(update); 63 | return studyBuddyRepository.save(existing); 64 | } 65 | 66 | @Transactional(readOnly = true) 67 | @RequestMapping("/popular") 68 | public Iterable> popularStudyBuddies() { 69 | return studyBuddyRepository.getStudyBuddiesByPopularity(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/school/controller/SubjectController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.controller; 12 | 13 | import org.neo4j.ogm.exception.core.NotFoundException; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.RequestBody; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RequestMethod; 20 | import org.springframework.web.bind.annotation.RestController; 21 | import school.domain.Subject; 22 | import school.repository.SubjectRepository; 23 | 24 | @RestController 25 | @RequestMapping(value = "/api/subjects") 26 | public class SubjectController { 27 | 28 | private SubjectRepository subjectRepository; 29 | 30 | @Autowired 31 | public SubjectController(SubjectRepository subjectRepository) { 32 | this.subjectRepository = subjectRepository; 33 | } 34 | 35 | @RequestMapping(method = RequestMethod.GET) 36 | public Iterable readAll() { 37 | return subjectRepository.findAll(); 38 | } 39 | 40 | @RequestMapping(method = RequestMethod.POST) 41 | public Subject create(@RequestBody Subject subject) { 42 | return subjectRepository.save(subject); 43 | } 44 | 45 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 46 | public Subject read(@PathVariable Long id) { 47 | return subjectRepository.findById(id).orElseThrow(NotFoundException::new); 48 | } 49 | 50 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) 51 | public void delete(@PathVariable Long id) { 52 | subjectRepository.deleteById(id); 53 | } 54 | 55 | @Transactional 56 | @RequestMapping(value = "/{id}", method = RequestMethod.PUT) 57 | public Subject update(@PathVariable Long id, @RequestBody Subject update) { 58 | final Subject existing = subjectRepository.findById(id).orElseThrow(NotFoundException::new); 59 | existing.updateFrom(update); 60 | return subjectRepository.save(existing); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/school/controller/TeacherController.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.controller; 12 | 13 | import org.neo4j.ogm.exception.core.NotFoundException; 14 | import org.springframework.beans.factory.annotation.Autowired; 15 | import org.springframework.transaction.annotation.Transactional; 16 | import org.springframework.web.bind.annotation.PathVariable; 17 | import org.springframework.web.bind.annotation.RequestBody; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RequestMethod; 20 | import org.springframework.web.bind.annotation.RestController; 21 | import school.domain.Teacher; 22 | import school.repository.TeacherRepository; 23 | 24 | @RestController 25 | @RequestMapping(value = "/api/teachers") 26 | public class TeacherController { 27 | 28 | private TeacherRepository teacherRepository; 29 | 30 | @Autowired 31 | public TeacherController(TeacherRepository teacherRepository) { 32 | this.teacherRepository = teacherRepository; 33 | } 34 | 35 | @RequestMapping(method = RequestMethod.GET) 36 | public Iterable readAll() { 37 | return teacherRepository.findAll(); 38 | } 39 | 40 | @RequestMapping(method = RequestMethod.POST) 41 | public Teacher create(@RequestBody Teacher teacher) { 42 | return teacherRepository.save(teacher); 43 | } 44 | 45 | @RequestMapping(value = "/{id}", method = RequestMethod.GET) 46 | public Teacher read(@PathVariable Long id) { 47 | return teacherRepository.findById(id).orElseThrow(NotFoundException::new); 48 | } 49 | 50 | @RequestMapping(value = "/{id}", method = RequestMethod.DELETE) 51 | public void delete(@PathVariable Long id) { 52 | teacherRepository.deleteById(id); 53 | } 54 | 55 | @Transactional 56 | @RequestMapping(value = "/{id}", method = RequestMethod.PUT) 57 | public Teacher update(@PathVariable Long id, @RequestBody Teacher update) { 58 | final Teacher existing = teacherRepository.findById(id).orElseThrow(NotFoundException::new); 59 | existing.updateFrom(update); 60 | return teacherRepository.save(existing); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/school/domain/Course.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.domain; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIdentityInfo; 14 | import com.voodoodyne.jackson.jsog.JSOGGenerator; 15 | import org.neo4j.ogm.annotation.NodeEntity; 16 | import org.neo4j.ogm.annotation.Relationship; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | /** 22 | * The course object connects a teacher 23 | * with a subject and the pupils who are taught the subject by the teacher 24 | */ 25 | @JsonIdentityInfo(generator = JSOGGenerator.class) 26 | @NodeEntity(label = "Class") 27 | public class Course { 28 | 29 | private Long id; 30 | 31 | private String name; 32 | 33 | @Relationship(type = "SUBJECT_TAUGHT") 34 | private Subject subject; 35 | 36 | @Relationship(type = "TEACHES_CLASS", direction = Relationship.INCOMING) 37 | private Teacher teacher; 38 | 39 | @Relationship(type = "ENROLLED", direction = Relationship.INCOMING) 40 | private Set students = new HashSet<>(); 41 | 42 | public Long getId() { 43 | return id; 44 | } 45 | 46 | public Teacher getTeacher() { 47 | return teacher; 48 | } 49 | 50 | public String getName() { 51 | return name; 52 | } 53 | 54 | public Subject getSubject() { 55 | return subject; 56 | } 57 | 58 | public Set getStudents() { 59 | return students; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return "Course{" + 65 | "id=" + getId() + 66 | ", name='" + name + '\'' + 67 | ", teacher=" + teacher + 68 | ", subject=" + subject + 69 | ", students=" + students.size() + 70 | '}'; 71 | } 72 | 73 | public void updateFrom(Course course) { 74 | this.name = course.name; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/school/domain/Department.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.domain; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIdentityInfo; 14 | import com.voodoodyne.jackson.jsog.JSOGGenerator; 15 | import org.neo4j.ogm.annotation.NodeEntity; 16 | import org.neo4j.ogm.annotation.Relationship; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | @JsonIdentityInfo(generator = JSOGGenerator.class) 22 | @NodeEntity 23 | public class Department { 24 | 25 | private Long id; 26 | 27 | private String name; 28 | 29 | @Relationship(type = "DEPARTMENT_MEMBER") 30 | private Set teachers; 31 | 32 | @Relationship(type = "CURRICULUM") 33 | private Set subjects; 34 | 35 | public Department() { 36 | this.teachers = new HashSet<>(); 37 | this.subjects = new HashSet<>(); 38 | } 39 | 40 | public Department(String name) { 41 | this(); 42 | this.name = name; 43 | } 44 | 45 | public Long getId() { 46 | return id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public Set getTeachers() { 54 | return teachers; 55 | } 56 | 57 | public Set getSubjects() { 58 | return subjects; 59 | } 60 | 61 | @Override 62 | public String toString() { 63 | return "Department{" + 64 | "id=" + getId() + 65 | ", name='" + name + '\'' + 66 | ", teachers=" + teachers.size() + 67 | ", subjects=" + subjects.size() + 68 | '}'; 69 | } 70 | 71 | public void updateFrom(Department department) { 72 | this.name = department.name; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/school/domain/Student.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.domain; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIdentityInfo; 14 | import com.voodoodyne.jackson.jsog.JSOGGenerator; 15 | import org.neo4j.ogm.annotation.NodeEntity; 16 | import org.neo4j.ogm.annotation.Relationship; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | @JsonIdentityInfo(generator = JSOGGenerator.class) 22 | @NodeEntity 23 | public class Student { 24 | 25 | private Long id; 26 | 27 | private String name; 28 | 29 | @Relationship(type = "ENROLLED") 30 | private Set courses; 31 | 32 | @Relationship(type = "BUDDY", direction = Relationship.INCOMING) 33 | private Set studyBuddies; 34 | 35 | public Student() { 36 | this.studyBuddies = new HashSet<>(); 37 | this.courses = new HashSet<>(); 38 | } 39 | 40 | public Student(String name) { 41 | this(); 42 | this.name = name; 43 | } 44 | 45 | public Long getId() { 46 | return id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public Set getStudyBuddies() { 54 | return studyBuddies; 55 | } 56 | 57 | public Set getCourses() { 58 | return courses; 59 | } 60 | 61 | 62 | @Override 63 | public String toString() { 64 | return "Student{" + 65 | "id=" + getId() + 66 | ", name='" + name + '\'' + 67 | ", courses=" + courses.size() + 68 | ", studyBuddies=" + studyBuddies.size() + 69 | '}'; 70 | } 71 | 72 | public void updateFrom(Student student) { 73 | this.name = student.name; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/school/domain/StudyBuddy.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.domain; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIdentityInfo; 14 | import com.voodoodyne.jackson.jsog.JSOGGenerator; 15 | import org.neo4j.ogm.annotation.NodeEntity; 16 | import org.neo4j.ogm.annotation.Relationship; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | @JsonIdentityInfo(generator = JSOGGenerator.class) 22 | @NodeEntity 23 | public class StudyBuddy { 24 | 25 | private Long id; 26 | 27 | @Relationship(type = "BUDDY") 28 | private List buddies; 29 | 30 | private Course course; 31 | 32 | public StudyBuddy() { 33 | buddies = new ArrayList<>(); 34 | } 35 | 36 | public Long getId() { 37 | return id; 38 | } 39 | 40 | public Course getCourse() { 41 | return course; 42 | } 43 | 44 | @Override 45 | public String toString() { 46 | return "StudyBuddy{" + 47 | "buddies= " + buddies.size() + 48 | ", course=" + course + 49 | '}'; 50 | } 51 | 52 | public void updateFrom(StudyBuddy studyBuddy) { 53 | this.course = studyBuddy.course; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /src/main/java/school/domain/Subject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.domain; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIdentityInfo; 14 | import com.voodoodyne.jackson.jsog.JSOGGenerator; 15 | import org.neo4j.ogm.annotation.NodeEntity; 16 | import org.neo4j.ogm.annotation.Relationship; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | @JsonIdentityInfo(generator = JSOGGenerator.class) 22 | @NodeEntity 23 | public class Subject { 24 | 25 | private Long id; 26 | 27 | private String name; 28 | 29 | @Relationship(type = "CURRICULUM", direction = Relationship.INCOMING) 30 | private Department department; 31 | 32 | @Relationship(type = "TAUGHT_BY") 33 | private Set teachers; 34 | 35 | @Relationship(type = "SUBJECT_TAUGHT") 36 | private Set courses; 37 | 38 | public Subject(String name) { 39 | this(); 40 | this.name = name; 41 | } 42 | 43 | public Subject() { 44 | this.teachers = new HashSet<>(); 45 | this.courses = new HashSet<>(); 46 | } 47 | 48 | public Long getId() { 49 | return id; 50 | } 51 | 52 | public Department getDepartment() { 53 | return department; 54 | } 55 | 56 | public String getName() { 57 | return name; 58 | } 59 | 60 | public Set getTeachers() { 61 | return teachers; 62 | } 63 | 64 | @Override 65 | public String toString() { 66 | return "Subject{" + 67 | "id=" + getId() + 68 | ", name='" + name + '\'' + 69 | ", department=" + department + 70 | ", teachers=" + teachers.size() + 71 | '}'; 72 | } 73 | 74 | public void updateFrom(Subject subject) { 75 | this.name = subject.getName(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/school/domain/Teacher.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.domain; 12 | 13 | import com.fasterxml.jackson.annotation.JsonIdentityInfo; 14 | import com.voodoodyne.jackson.jsog.JSOGGenerator; 15 | import org.neo4j.ogm.annotation.NodeEntity; 16 | import org.neo4j.ogm.annotation.Relationship; 17 | 18 | import java.util.HashSet; 19 | import java.util.Set; 20 | 21 | @JsonIdentityInfo(generator = JSOGGenerator.class) 22 | @NodeEntity 23 | public class Teacher { 24 | 25 | private Long id; 26 | 27 | private String name; 28 | 29 | @Relationship(type = "TEACHES_CLASS") 30 | private Set courses; 31 | 32 | @Relationship(type = "DEPARTMENT_MEMBER", direction = Relationship.INCOMING) 33 | private Department department; 34 | 35 | @Relationship(type = "TAUGHT_BY", direction = Relationship.INCOMING) 36 | private Set subjects; 37 | 38 | public Teacher(String name) { 39 | this(); 40 | this.name = name; 41 | } 42 | 43 | public Teacher() { 44 | this.courses = new HashSet<>(); 45 | this.subjects = new HashSet<>(); 46 | } 47 | 48 | public Long getId() { 49 | return id; 50 | } 51 | 52 | public String getName() { 53 | return name; 54 | } 55 | 56 | public Set getCourses() { 57 | return courses; 58 | } 59 | 60 | public Department getDepartment() { 61 | return department; 62 | } 63 | 64 | public Set getSubjects() { 65 | return subjects; 66 | } 67 | 68 | @Override 69 | public String toString() { 70 | return "Teacher{" + 71 | "id=" + getId() + 72 | ", name='" + name + '\'' + 73 | ", classRegisters=" + courses.size() + 74 | ", department=" + department + 75 | ", subjects=" + subjects.size() + 76 | '}'; 77 | } 78 | 79 | public void updateFrom(Teacher teacher) { 80 | this.name = teacher.name; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/school/events/EventPublisher.java: -------------------------------------------------------------------------------- 1 | package school.events; 2 | 3 | import org.neo4j.ogm.session.event.Event; 4 | import org.neo4j.ogm.session.event.EventListenerAdapter; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.context.ApplicationEventPublisher; 7 | import org.springframework.stereotype.Component; 8 | 9 | @Component 10 | public class EventPublisher extends EventListenerAdapter { 11 | 12 | @Autowired 13 | private ApplicationEventPublisher publisher; 14 | 15 | @Override 16 | public void onPreSave(Event event) { 17 | this.publisher.publishEvent(new PreSaveEvent(event)); 18 | } 19 | 20 | @Override 21 | public void onPostSave(Event event) { 22 | this.publisher.publishEvent(new PostSaveEvent(event)); 23 | } 24 | 25 | @Override 26 | public void onPreDelete(Event event) { 27 | this.publisher.publishEvent(new PreDeleteEvent(event)); 28 | } 29 | 30 | @Override 31 | public void onPostDelete(Event event) { 32 | this.publisher.publishEvent(new PostDeleteEvent(event)); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/school/events/ModificationEvent.java: -------------------------------------------------------------------------------- 1 | package school.events; 2 | 3 | import org.neo4j.ogm.session.event.Event; 4 | 5 | /** 6 | * Created by markangrish on 02/11/2016. 7 | */ 8 | public class ModificationEvent { 9 | 10 | private Event source; 11 | 12 | public ModificationEvent(Event source) { 13 | this.source = source; 14 | } 15 | 16 | public Event getSource() { 17 | return source; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/school/events/PostDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package school.events; 2 | 3 | import org.neo4j.ogm.session.event.Event; 4 | 5 | public class PostDeleteEvent extends ModificationEvent { 6 | 7 | public PostDeleteEvent(Event event) { 8 | super(event); 9 | } 10 | } 11 | 12 | -------------------------------------------------------------------------------- /src/main/java/school/events/PostSaveEvent.java: -------------------------------------------------------------------------------- 1 | package school.events; 2 | 3 | import org.neo4j.ogm.session.event.Event; 4 | 5 | public class PostSaveEvent extends ModificationEvent { 6 | 7 | public PostSaveEvent(Event event) { 8 | super(event); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/school/events/PreDeleteEvent.java: -------------------------------------------------------------------------------- 1 | package school.events; 2 | 3 | import org.neo4j.ogm.session.event.Event; 4 | 5 | public class PreDeleteEvent extends ModificationEvent { 6 | 7 | public PreDeleteEvent(Event event) { 8 | super(event); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/school/events/PreSaveEvent.java: -------------------------------------------------------------------------------- 1 | package school.events; 2 | 3 | import org.neo4j.ogm.session.event.Event; 4 | 5 | public class PreSaveEvent extends ModificationEvent { 6 | 7 | public PreSaveEvent(Event event) { 8 | super(event); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/java/school/repository/CourseRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.repository; 12 | 13 | import org.springframework.data.repository.CrudRepository; 14 | import school.domain.Course; 15 | 16 | public interface CourseRepository extends CrudRepository { 17 | 18 | } 19 | 20 | -------------------------------------------------------------------------------- /src/main/java/school/repository/DepartmentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.repository; 12 | 13 | import org.springframework.data.repository.CrudRepository; 14 | import school.domain.Department; 15 | 16 | public interface DepartmentRepository extends CrudRepository { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/school/repository/StudentRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.repository; 12 | 13 | import org.springframework.data.repository.CrudRepository; 14 | import school.domain.Student; 15 | 16 | public interface StudentRepository extends CrudRepository { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/school/repository/StudyBuddyRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.repository; 12 | 13 | import org.springframework.data.neo4j.annotation.Query; 14 | import org.springframework.data.repository.CrudRepository; 15 | import school.domain.StudyBuddy; 16 | 17 | import java.util.Map; 18 | 19 | public interface StudyBuddyRepository extends CrudRepository { 20 | 21 | @Query("MATCH(s:StudyBuddy)<-[:BUDDY]-(p:Student) RETURN p, count(s) AS buddies ORDER BY buddies DESC") 22 | Iterable> getStudyBuddiesByPopularity(); 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/school/repository/SubjectRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.repository; 12 | 13 | import org.springframework.data.repository.CrudRepository; 14 | import school.domain.Subject; 15 | 16 | public interface SubjectRepository extends CrudRepository { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/school/repository/TeacherRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.repository; 12 | 13 | import org.springframework.data.repository.CrudRepository; 14 | import school.domain.Teacher; 15 | 16 | public interface TeacherRepository extends CrudRepository { 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/school/service/ImportService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright [2011-2016] "Neo Technology" 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 9 | * 10 | */ 11 | package school.service; 12 | 13 | public interface ImportService { 14 | 15 | void clearDatabase(); 16 | 17 | void load(); 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/school/service/impl/FileBasedImportServiceImpl.java: -------------------------------------------------------------------------------- 1 | package school.service.impl; 2 | 3 | import org.neo4j.ogm.session.Session; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | import org.springframework.stereotype.Service; 6 | import org.springframework.transaction.annotation.Transactional; 7 | import school.service.ImportService; 8 | 9 | import java.io.BufferedReader; 10 | import java.io.InputStreamReader; 11 | import java.util.Collections; 12 | 13 | /** 14 | * Created by markangrish on 18/01/2017. 15 | */ 16 | @Service 17 | public class FileBasedImportServiceImpl implements ImportService { 18 | 19 | private Session session; 20 | 21 | @Autowired 22 | public FileBasedImportServiceImpl(Session session) { 23 | this.session = session; 24 | } 25 | 26 | @Transactional 27 | public void clearDatabase() { 28 | session.purgeDatabase(); 29 | } 30 | 31 | @Transactional 32 | public void load() { 33 | StringBuilder sb = new StringBuilder(); 34 | BufferedReader reader = new BufferedReader(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream("school.cql"))); 35 | String line; 36 | try { 37 | while ((line = reader.readLine()) != null) { 38 | sb.append(line); 39 | sb.append(" "); 40 | } 41 | } catch (Exception e) { 42 | throw new RuntimeException(e); 43 | } 44 | String cqlFile = sb.toString(); 45 | session.query(cqlFile, Collections.EMPTY_MAP); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | # Add your SDN configuration settings here. 2 | #spring.data.neo4j.uri=bolt://localhost 3 | #spring.data.neo4j.username=neo4j 4 | #spring.data.neo4j.password=admin 5 | 6 | logging.level.org.neo4j.ogm=debug 7 | logging.level.org.springframework.data.neo4j=debug 8 | -------------------------------------------------------------------------------- /src/main/resources/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/favicon.ico -------------------------------------------------------------------------------- /src/main/resources/static/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/main/resources/static/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/main/resources/static/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/main/resources/static/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/main/resources/static/images/032433-250920121-sixth_inner_banner2.ecd87142.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/032433-250920121-sixth_inner_banner2.ecd87142.jpg -------------------------------------------------------------------------------- /src/main/resources/static/images/120208-070920120-sixthform_048.38c1cbc0.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/120208-070920120-sixthform_048.38c1cbc0.jpg -------------------------------------------------------------------------------- /src/main/resources/static/images/120209-070920121-sixthform_053.e2c484d3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/120209-070920121-sixthform_053.e2c484d3.jpg -------------------------------------------------------------------------------- /src/main/resources/static/images/chevron-chief-crossbotony-233x300.44beb57a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/chevron-chief-crossbotony-233x300.44beb57a.png -------------------------------------------------------------------------------- /src/main/resources/static/images/development_ribbon.f64d6562.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/development_ribbon.f64d6562.png -------------------------------------------------------------------------------- /src/main/resources/static/images/glyphicons-halflings-white.9bbc6e96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/glyphicons-halflings-white.9bbc6e96.png -------------------------------------------------------------------------------- /src/main/resources/static/images/glyphicons-halflings.180b8ed9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/glyphicons-halflings.180b8ed9.png -------------------------------------------------------------------------------- /src/main/resources/static/images/mathematics-dept.c0d2306d.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/mathematics-dept.c0d2306d.jpg -------------------------------------------------------------------------------- /src/main/resources/static/images/science-dept.9310957f.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/science-dept.9310957f.jpg -------------------------------------------------------------------------------- /src/main/resources/static/images/student-register.fd2e88c6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/student-register.fd2e88c6.jpg -------------------------------------------------------------------------------- /src/main/resources/static/images/student-registration-apply-now.30cb549b.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/resources/static/images/student-registration-apply-now.30cb549b.jpeg -------------------------------------------------------------------------------- /src/main/resources/static/index.html: -------------------------------------------------------------------------------- 1 | Student Registration and Curriculum Management

© 2016 Neo Technology, Inc; Graph Aware Ltd.

-------------------------------------------------------------------------------- /src/main/resources/static/robots.txt: -------------------------------------------------------------------------------- 1 | # robotstxt.org/ 2 | 3 | User-agent: * 4 | -------------------------------------------------------------------------------- /src/main/resources/static/styles/main.ab457e5c.css: -------------------------------------------------------------------------------- 1 | html{position:relative;min-height:100%}body{margin-bottom:60px;background:#fafafa;color:#333;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif}.footer{position:absolute;bottom:0;width:100%;height:60px;background-color:#f5f5f5}body>.container{padding:60px 15px 0}.container .text-muted{margin:20px 0}.footer>.container{padding-right:15px;padding-left:15px}code{font-size:80%} -------------------------------------------------------------------------------- /src/main/web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/favicon.ico -------------------------------------------------------------------------------- /src/main/web/html/class-detail.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Class {{class.id}}:{{class.name}}

4 |
5 |
10 | 11 |
12 | 15 | 16 | 19 | 20 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 53 | 54 | 55 | 56 | 69 | 70 | 71 | 81 | 82 | 83 |
FieldValue
Name
Subject 39 |
40 | 41 |
42 | 43 | 49 | 50 |
51 |
52 |
Teacher 57 |
58 |
59 | 65 |
66 |
67 |
68 |
Students Enrolled 72 |
73 |
74 |
75 | 76 |
77 |
78 |
79 | 80 |
84 |
85 |
86 | 87 | 114 | 115 |
116 | -------------------------------------------------------------------------------- /src/main/web/html/classes.html: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 |
8 | 9 |
10 | 13 |
14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 27 | 28 | 29 | 30 | 31 |
#Name
{{class.id}}{{class.name}}
32 |
33 |
34 | 35 | 85 | 86 | -------------------------------------------------------------------------------- /src/main/web/html/department-detail.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Department {{department.id}}:{{department.name}}

4 |
5 |
10 | 11 |
12 | 15 | 16 | 19 | 20 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 54 | 55 | 56 | 57 |
FieldValue
Name
Subjects 43 | 53 |
58 | 59 |
60 |
61 | 62 | 89 | 90 |
91 | -------------------------------------------------------------------------------- /src/main/web/html/departments.html: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 |
8 | 9 |
10 | 13 |
14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
#Name
{{department.id}}{{department.name}}
31 |
32 |
33 | 34 | 66 | 67 | 92 | -------------------------------------------------------------------------------- /src/main/web/html/error.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 5 |
6 |
7 |

Error Page!

8 | 9 |
10 |
{{errorMessage}} 11 |
12 |
13 |
14 |
15 |
16 | -------------------------------------------------------------------------------- /src/main/web/html/main.html: -------------------------------------------------------------------------------- 1 |
2 |
3 | 4 |
5 |

Hilly Fields Technical College

6 |

Timendi Causa Est Nesciri

7 |
8 |
9 |

Student Registration and Curriculum Management

10 |
11 | -------------------------------------------------------------------------------- /src/main/web/html/navbar.html: -------------------------------------------------------------------------------- 1 | 2 | 64 | -------------------------------------------------------------------------------- /src/main/web/html/school-detail.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

School {{school.id}}

4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 17 | 20 | 21 | 22 |
FieldValue
15 | Name 16 | 18 | 19 |
23 |
24 | 25 | 30 |
31 | -------------------------------------------------------------------------------- /src/main/web/html/schools.html: -------------------------------------------------------------------------------- 1 |

School

2 | 3 | 6 | 46 | 47 | 71 | 72 |
73 | Find  74 |
75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 |
{{school.name}}
83 | -------------------------------------------------------------------------------- /src/main/web/html/statistics.html: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 |
8 | 9 |
10 |
11 | 12 |
13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 24 | 25 | 26 | 27 | 28 |
Student# Study Buddies
{{result.p.name}}{{result.buddies}}
29 |
30 |
31 | 32 | -------------------------------------------------------------------------------- /src/main/web/html/student-detail.html: -------------------------------------------------------------------------------- 1 |
2 |

Student {{student.id}}:{{student.name}}

3 |
4 |
9 | 10 |
11 | 14 | 15 | 18 | 19 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 36 | 37 | 38 | 39 | 40 | 50 | 51 | 52 | 53 |
FieldValue
Name
Enrolled classes 41 |
42 |
43 |
44 | 46 |
47 |
48 |
49 |
54 |
55 |
56 | 57 | 84 | 85 |
86 | -------------------------------------------------------------------------------- /src/main/web/html/students.html: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 |
8 | 9 |
10 | 13 |
14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
#Name
{{student.id}}{{student.name}}
31 |
32 |
33 | 34 | 66 | -------------------------------------------------------------------------------- /src/main/web/html/studyBuddies.html: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 |
8 | 9 |
10 | 13 |
14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
#Student 1Student 2Course
{{studyBuddy.id}}{{studyBuddy.buddyOne.name}}{{studyBuddy.buddyTwo.name}}{{studyBuddy.course.name}}
35 |
36 |
37 | 38 | 89 | 90 | 114 | -------------------------------------------------------------------------------- /src/main/web/html/studyBuddy-detail.html: -------------------------------------------------------------------------------- 1 |
2 |

StudyBuddy {{studyBuddy.id}}

3 | 4 |
5 |
10 | 11 |
12 | 15 | 16 | 19 | 20 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | 44 | 45 | 46 | 47 | 60 | 61 | 62 | 63 | 79 | 80 | 81 |
Student One 32 |
33 |
34 | 41 |
42 |
43 |
Student Two 48 |
49 |
50 | 57 |
58 |
59 |
Class 64 |
65 | 66 |
67 | 68 | 75 | 76 |
77 |
78 |
82 |
83 |
84 | 85 | 115 | 116 |
117 | -------------------------------------------------------------------------------- /src/main/web/html/subject-detail.html: -------------------------------------------------------------------------------- 1 |
2 |

Subject {{subject.id}}:{{subject.name}}

3 |
4 |
9 | 10 |
11 | 14 | 15 | 18 | 19 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 53 | 54 | 55 | 65 | 66 | 67 |
FieldValue
Name
Teachers 56 |
57 |
58 |
59 | 61 |
62 |
63 |
64 |
68 | 69 |
70 |
71 | 72 | 99 | 100 |
101 | -------------------------------------------------------------------------------- /src/main/web/html/subjects.html: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 |
8 | 9 |
10 | 13 |
14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
#Name
{{subject.id}}{{subject.name}}
31 |
32 |
33 | 34 | 35 | 66 | 67 | 91 | -------------------------------------------------------------------------------- /src/main/web/html/teacher-detail.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Teacher {{teacher.id}}:{{teacher.name}}

4 |
5 |
10 | 11 |
12 | 15 | 16 | 19 | 20 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 43 | 53 | 54 | 55 | 58 | 68 | 69 | 70 |
FieldValue
Name
41 | Specialist subjects 42 | 44 |
45 |
46 |
47 | 49 |
50 |
51 |
52 |
56 | Classes taught 57 | 59 |
60 |
61 |
62 | 64 |
65 |
66 |
67 |
71 |
72 |
73 | 74 | 101 | 102 |
103 | -------------------------------------------------------------------------------- /src/main/web/html/teachers.html: -------------------------------------------------------------------------------- 1 | 5 | 6 |
7 |
8 | 9 |
10 | 13 |
14 | 15 |
16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
#Name
{{teacher.id}}{{teacher.name}}
31 |
32 |
33 | 34 | 35 | 69 | 70 | 71 | 95 | -------------------------------------------------------------------------------- /src/main/web/images/032433-250920121-sixth_inner_banner2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/032433-250920121-sixth_inner_banner2.jpg -------------------------------------------------------------------------------- /src/main/web/images/120208-070920120-sixthform_048.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/120208-070920120-sixthform_048.jpg -------------------------------------------------------------------------------- /src/main/web/images/120209-070920121-sixthform_053.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/120209-070920121-sixthform_053.jpg -------------------------------------------------------------------------------- /src/main/web/images/chevron-chief-crossbotony-233x300.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/chevron-chief-crossbotony-233x300.png -------------------------------------------------------------------------------- /src/main/web/images/development_ribbon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/development_ribbon.png -------------------------------------------------------------------------------- /src/main/web/images/engineering-dept.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/engineering-dept.JPG -------------------------------------------------------------------------------- /src/main/web/images/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /src/main/web/images/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/glyphicons-halflings.png -------------------------------------------------------------------------------- /src/main/web/images/mathematics-dept.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/mathematics-dept.jpg -------------------------------------------------------------------------------- /src/main/web/images/science-dept.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/science-dept.jpg -------------------------------------------------------------------------------- /src/main/web/images/student-register.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/student-register.jpg -------------------------------------------------------------------------------- /src/main/web/images/student-registration-apply-now.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/neo4j-examples/sdn-university/1a452e9aa27cd1ec4e489ba00b7b2ae63c07ef82/src/main/web/images/student-registration-apply-now.jpeg -------------------------------------------------------------------------------- /src/main/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | Student Registration and Curriculum Management 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 |
30 |
31 | 34 |
35 |
36 |
37 |
38 |
39 | 40 |
41 |
42 |

© 2016 Neo Technology, Inc; Graph Aware Ltd.

43 |
44 |
45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /src/main/web/robots.txt: -------------------------------------------------------------------------------- 1 | # robotstxt.org/ 2 | 3 | User-agent: * 4 | -------------------------------------------------------------------------------- /src/main/web/scripts/app.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp', ['ngResource', 'ui.router']) 4 | 5 | .run(function ($rootScope, $location, $http, $state) { 6 | $rootScope.$on('$stateChangeStart', function (event, toState, toStateParams) { 7 | $rootScope.toState = toState; 8 | $rootScope.toStateParams = toStateParams; 9 | 10 | }); 11 | 12 | $rootScope.$on('$stateChangeSuccess', function (event, toState, toParams, fromState, fromParams) { 13 | $rootScope.previousStateName = fromState.name; 14 | $rootScope.previousStateParams = fromParams; 15 | }); 16 | 17 | $rootScope.back = function () { 18 | // If previous state is 'activate' or do not exist go to 'home' 19 | if ($rootScope.previousStateName === 'activate' || $state.get($rootScope.previousStateName) === null) { 20 | $state.go('home'); 21 | } else { 22 | $state.go($rootScope.previousStateName, $rootScope.previousStateParams); 23 | } 24 | }; 25 | }) 26 | 27 | .config(function ($stateProvider, $urlRouterProvider, $httpProvider) { 28 | //enable CSRF 29 | 30 | $urlRouterProvider.otherwise('/'); 31 | $stateProvider.state('site', { 32 | 'abstract': true, 33 | views: { 34 | 'navbar@': { 35 | templateUrl: 'html/navbar.html' 36 | } 37 | } 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/class/class-detail.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('ClassDetailController', function ($scope, $stateParams, Class) { 5 | $scope.class = {}; 6 | 7 | $scope.load = function (id) { 8 | Class.get({id: id}, function(result) { 9 | $scope.class = result; 10 | $scope.class.enrolledStudents = extractEnrolledStudents(result); 11 | }); 12 | }; 13 | 14 | $scope.load($stateParams.id); 15 | 16 | function extractEnrolledStudents(theClass) { 17 | var students = new Array(); 18 | jQuery.each(theClass.enrollments, function(index,value) { 19 | students.push(value.student.id); 20 | }); 21 | return students; 22 | } 23 | }); 24 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/class/class.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('ClassController', function ($scope, $state, Class) { 5 | $scope.classes = []; 6 | $scope.loadAll = function() { 7 | Class.query(function(result) { 8 | $scope.classes = result; 9 | }); 10 | }; 11 | $scope.loadAll(); 12 | 13 | $scope.objectifySubject = function() { 14 | console.log("objectified subject"); 15 | $scope.class.subject = angular.fromJson($scope.class.subject); 16 | }; 17 | 18 | $scope.objectifyTeacher = function() { 19 | console.log("objectified teacher"); 20 | // maybe JSOG? 21 | $scope.class.teacher = angular.fromJson($scope.class.teacher); 22 | }; 23 | 24 | 25 | $scope.create = function () { 26 | 27 | console.log("saving class"); 28 | //$scope.truncate($scope.class, 2); 29 | console.log($scope.class); 30 | 31 | Class.save($scope.class, 32 | function () { 33 | $('#saveClassModal').modal('hide'); 34 | $scope.loadAll(); 35 | }); 36 | }; 37 | 38 | $scope.update = function (id) { 39 | $scope.class = Class.get({id: id}); 40 | 41 | $('#saveClassModal').modal('show'); 42 | }; 43 | 44 | $scope.delete = function (id) { 45 | $scope.class = Class.get({id: id}); 46 | 47 | $('#deleteClassConfirmation').modal('show'); 48 | }; 49 | 50 | $scope.confirmDelete = function (id) { 51 | Class.delete({id: id}, 52 | function () { 53 | var popup = $('#deleteClassConfirmation'); 54 | popup.on('hidden.bs.modal', function(e) { 55 | $state.transitionTo('class'); 56 | }); 57 | $scope.clear(); 58 | popup.modal('hide'); 59 | }); 60 | }; 61 | 62 | $scope.clear = function () { 63 | $scope.class = {}; 64 | }; 65 | }); 66 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/class/class.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('class', { 7 | parent: 'entity', 8 | url: '/classes', 9 | views: { 10 | 'content@': { 11 | templateUrl: 'html/classes.html', 12 | controller: 'ClassController' 13 | } 14 | } 15 | }) 16 | .state('classDetail', { 17 | parent: 'entity', 18 | url: '/classes/:id', 19 | views: { 20 | 'content@': { 21 | templateUrl: 'html/class-detail.html', 22 | controller: 'ClassDetailController' 23 | } 24 | } 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/class/class.service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .factory('Class', function ($resource) { 5 | 6 | var url = 'api/classes/:id'; 7 | 8 | return $resource(url, {}, { 9 | 'query': { 10 | method: 'GET', isArray: true, 11 | transformResponse: function (data) { 12 | return JSOG.parse(data); 13 | } 14 | }, 15 | 'remove': {method: 'DELETE'}, 16 | 'delete': {method: 'DELETE'}, 17 | 'post': {method: 'POST'}, 18 | 'get': { 19 | method: 'GET', 20 | transformResponse: function (data) { 21 | return JSOG.parse(data); 22 | } 23 | } 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/department/department-detail.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('DepartmentDetailController', function ($scope, $stateParams, Department) { 5 | $scope.department = {}; 6 | $scope.load = function (id) { 7 | Department.get({id: id}, function(result) { 8 | $scope.department = result; 9 | }); 10 | }; 11 | $scope.load($stateParams.id); 12 | }); 13 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/department/department.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('DepartmentController', function ($scope, $state, Department) { 5 | 6 | $scope.departments = []; 7 | 8 | $scope.loadAll = function() { 9 | Department.query(function(result) { 10 | $scope.departments = result; 11 | console.log($scope.departments); 12 | }); 13 | }; 14 | 15 | $scope.loadAll(); 16 | 17 | // method is called when user asks to save object 18 | $scope.create = function () { 19 | // don't re-persist existing relationships 20 | 21 | console.log("saving department"); 22 | //$scope.truncate($scope.department, 2); 23 | console.log($scope.department); 24 | 25 | Department.save($scope.department, 26 | function () { 27 | $('#saveDepartmentModal').modal('hide'); 28 | $scope.loadAll(); 29 | }); 30 | }; 31 | 32 | // method is called when used asks to edit 33 | $scope.update = function (id) { 34 | $scope.department = Department.get({id: id}); 35 | $('#saveDepartmentModal').modal('show'); 36 | }; 37 | 38 | // method is called when user asks to delete 39 | $scope.delete = function (id) { 40 | $scope.department = Department.get({id: id}); 41 | $('#deleteDepartmentConfirmation').modal('show'); 42 | }; 43 | 44 | $scope.confirmDelete = function (id) { 45 | Department.delete({id: id}, 46 | function () { 47 | var popup = $('#deleteDepartmentConfirmation'); 48 | popup.on('hidden.bs.modal', function(e) { 49 | $scope.loadAll(); 50 | $state.go('department'); 51 | }); 52 | $scope.clear(); 53 | popup.modal('hide'); 54 | }); 55 | }; 56 | 57 | $scope.clear = function () { 58 | $scope.department = {}; 59 | }; 60 | }); 61 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/department/department.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('department', { 7 | parent: 'entity', 8 | url: '/departments', 9 | views: { 10 | 'content@': { 11 | templateUrl: 'html/departments.html', 12 | controller: 'DepartmentController' 13 | } 14 | } 15 | }) 16 | .state('departmentDetail', { 17 | parent: 'entity', 18 | url: '/departments/:id', 19 | views: { 20 | 'content@': { 21 | templateUrl: 'html/department-detail.html', 22 | controller: 'DepartmentDetailController' 23 | } 24 | } 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/department/department.service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .factory('Department', function ($resource) { 5 | 6 | var url = 'api/departments/:id'; 7 | 8 | // should be done on server side 9 | var truncate = function (obj, depth) { 10 | for (var property in obj) { 11 | if (property == 'id' || property == 'name') { 12 | continue; 13 | } 14 | if (depth == 0) { 15 | var p = obj[property]; 16 | if (p && p.constructor === Array) { 17 | obj[property] = []; 18 | } else { 19 | obj[property] = null; 20 | } 21 | } else { 22 | truncate(obj[property], depth - 1); 23 | } 24 | } 25 | }; 26 | 27 | return $resource(url, {}, { 28 | 'query': { 29 | method: 'GET', isArray: true, 30 | transformResponse: function (data) { 31 | var obj = JSOG.parse(data); 32 | for (var i = 0; i < obj.length; i++) { 33 | truncate(obj[i], 0); 34 | } 35 | return obj; 36 | } 37 | }, 38 | 'remove': {method: 'DELETE'}, 39 | 'delete': {method: 'DELETE'}, 40 | 'post': {method: 'POST'}, 41 | 'get': { 42 | method: 'GET', 43 | transformResponse: function (data) { 44 | var obj = JSOG.parse(data); 45 | truncate(obj, 2); 46 | return obj; 47 | } 48 | } 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/entity.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('entity', { 7 | abstract: true, 8 | parent: 'site' 9 | }); 10 | }); 11 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/school/school-detail.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('SchoolDetailController', function ($scope, $stateParams, School) { 5 | $scope.school = {}; 6 | $scope.load = function (id) { 7 | School.get({id: id}, function(result) { 8 | $scope.school = result; 9 | }); 10 | }; 11 | $scope.load($stateParams.id); 12 | }); 13 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/school/school.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('SchoolController', function ($scope, School) { 5 | $scope.schools = []; 6 | $scope.loadAll = function() { 7 | School.query(function(result) { 8 | $scope.schools = result; 9 | }); 10 | }; 11 | $scope.loadAll(); 12 | 13 | $scope.create = function () { 14 | 15 | console.log("saving school"); 16 | //$scope.truncate($scope.school); 17 | console.log($scope.school); 18 | 19 | School.save($scope.school, 20 | function () { 21 | $('#saveSchoolModal').modal('hide'); 22 | $scope.loadAll(); 23 | }); 24 | }; 25 | 26 | $scope.update = function (id) { 27 | $scope.school = School.get({id: id}); 28 | $('#saveSchoolModal').modal('show'); 29 | }; 30 | 31 | $scope.delete = function (id) { 32 | $scope.school = School.get({id: id}); 33 | $('#deleteSchoolConfirmation').modal('show'); 34 | }; 35 | 36 | $scope.confirmDelete = function (id) { 37 | School.delete({id: id}, 38 | function () { 39 | $scope.loadAll(); 40 | $('#deleteSchoolConfirmation').modal('hide'); 41 | $scope.clear(); 42 | }); 43 | }; 44 | 45 | $scope.clear = function () { 46 | $scope.school = {}; 47 | }; 48 | }); 49 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/school/school.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('school', { 7 | parent: 'entity', 8 | url: '/school', 9 | views: { 10 | 'content@': { 11 | templateUrl: 'html/schools.html', 12 | controller: 'SchoolController' 13 | } 14 | } 15 | }) 16 | .state('schoolDetail', { 17 | parent: 'entity', 18 | url: '/school/:id', 19 | views: { 20 | 'content@': { 21 | templateUrl: 'html/school-detail.html', 22 | controller: 'SchoolDetailController' 23 | } 24 | } 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/school/school.service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .factory('School', function ($resource) { 5 | 6 | var url = 'api/shools/:id'; 7 | 8 | // should be done on server side 9 | var truncate = function (obj, depth) { 10 | for (var property in obj) { 11 | if (property == 'id' || property == 'name') { 12 | continue; 13 | } 14 | if (depth == 0) { 15 | var p = obj[property]; 16 | if (p && p.constructor === Array) { 17 | obj[property] = []; 18 | } else { 19 | obj[property] = null; 20 | } 21 | } else { 22 | truncate(obj[property], depth - 1); 23 | } 24 | } 25 | }; 26 | 27 | return $resource(url, {}, { 28 | 'query': { 29 | method: 'GET', isArray: true, 30 | transformResponse: function (data) { 31 | var obj = JSOG.parse(data); 32 | for (var i = 0; i < obj.length; i++) { 33 | truncate(obj[i], 0); 34 | } 35 | return obj; 36 | } 37 | }, 38 | 'remove': {method: 'DELETE'}, 39 | 'delete': {method: 'DELETE'}, 40 | 'post': {method: 'POST'}, 41 | 'get': { 42 | method: 'GET', 43 | transformResponse: function (data) { 44 | var obj = JSOG.parse(data); 45 | truncate(obj, 2); 46 | return obj; 47 | } 48 | } 49 | }); 50 | }); 51 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/statistics/statistics.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('StatisticsController', function ($scope, $state, Statistics) { 5 | $scope.results = []; 6 | $scope.loadAll = function() { 7 | Statistics.query(function(result) { 8 | $scope.results = result; 9 | }); 10 | }; 11 | $scope.loadAll(); 12 | 13 | }); 14 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/statistics/statistics.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('statistics', { 7 | parent: 'entity', 8 | url: '/popular', 9 | views: { 10 | 'content@': { 11 | templateUrl: 'html/statistics.html', 12 | controller: 'StatisticsController' 13 | } 14 | } 15 | }) 16 | }); 17 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/statistics/statistics.service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .factory('Statistics', function ($resource) { 5 | 6 | var url = 'api/studyBuddies/popular'; 7 | 8 | return $resource(url, {}, { 9 | 'query': { 10 | method: 'GET', isArray: true, 11 | transformResponse: function (data) { 12 | return JSOG.parse(data); 13 | } 14 | } 15 | }); 16 | }); 17 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/student/student-detail.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('StudentDetailController', function ($scope, $stateParams, Student) { 5 | $scope.student = {}; 6 | $scope.load = function (id) { 7 | Student.get({id: id}, function(result) { 8 | $scope.student = result; 9 | $scope.student.enrolledClasses = extractEnrolledClasses(result); 10 | }); 11 | }; 12 | $scope.load($stateParams.id); 13 | 14 | function extractEnrolledClasses(student) { 15 | var classes= new Array(); 16 | jQuery.each(student.enrollments, function(index,value) { 17 | classes.push(value.course.id); 18 | }); 19 | return classes; 20 | } 21 | }); 22 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/student/student.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('StudentController', function ($scope, $state, Student) { 5 | $scope.students = []; 6 | 7 | $scope.loadAll = function() { 8 | Student.query(function(result) { 9 | $scope.students = result; 10 | }); 11 | }; 12 | $scope.loadAll(); 13 | 14 | $scope.create = function () { 15 | 16 | console.log("saving student"); 17 | //$scope.truncate($scope.student,2); 18 | console.log($scope.student); 19 | 20 | Student.save($scope.student, 21 | function () { 22 | $('#saveStudentModal').modal('hide'); 23 | $scope.loadAll(); 24 | }); 25 | }; 26 | 27 | $scope.update = function (id) { 28 | $scope.student = Student.get({id: id}); 29 | $('#saveStudentModal').modal('show'); 30 | }; 31 | 32 | $scope.delete = function (id) { 33 | $scope.student = Student.get({id: id}); 34 | $('#deleteStudentConfirmation').modal('show'); 35 | }; 36 | 37 | $scope.confirmDelete = function (id) { 38 | Student.delete({id: id}, 39 | function () { 40 | var popup = $('#deleteStudentConfirmation'); 41 | popup.on('hidden.bs.modal', function(e) { 42 | $scope.loadAll(); 43 | $state.transitionTo('student'); 44 | }); 45 | $scope.clear(); 46 | popup.modal('hide'); 47 | }); 48 | }; 49 | 50 | $scope.clear = function () { 51 | $scope.student = {}; 52 | }; 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/student/student.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('student', { 7 | parent: 'entity', 8 | url: '/students', 9 | views: { 10 | 'content@': { 11 | templateUrl: 'html/students.html', 12 | controller: 'StudentController' 13 | } 14 | } 15 | }) 16 | .state('studentDetail', { 17 | parent: 'entity', 18 | url: '/students/:id', 19 | views: { 20 | 'content@': { 21 | templateUrl: 'html/student-detail.html', 22 | controller: 'StudentDetailController' 23 | } 24 | } 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/student/student.service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .factory('Student', function ($resource) { 5 | 6 | var url = 'api/students/:id'; 7 | 8 | return $resource(url, {}, { 9 | 'query': { 10 | method: 'GET', isArray: true, 11 | transformResponse: function (data) { 12 | return JSOG.parse(data); 13 | } 14 | }, 15 | 'remove': {method: 'DELETE'}, 16 | 'delete': {method: 'DELETE'}, 17 | 'post': {method: 'POST'}, 18 | 'get': { 19 | method: 'GET', 20 | transformResponse: function (data) { 21 | return JSOG.parse(data); 22 | } 23 | } 24 | }); 25 | }); 26 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/studyBuddy/studyBuddy-detail.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('StudyBuddyDetailController', function ($scope, $stateParams, StudyBuddy) { 5 | $scope.studyBuddy = {}; 6 | $scope.load = function (id) { 7 | StudyBuddy.get({id: id}, function(result) { 8 | $scope.studyBuddy = result; 9 | }); 10 | }; 11 | $scope.load($stateParams.id); 12 | }); 13 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/studyBuddy/studyBuddy.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module( 'registrarApp' ) 4 | .controller( 'StudyBuddyController', function ( $scope, $state, StudyBuddy ) 5 | { 6 | $scope.studyBuddies = []; 7 | 8 | $scope.loadAll = function () 9 | { 10 | StudyBuddy.query( function ( result ) 11 | { 12 | $scope.studyBuddies = result; 13 | } ); 14 | }; 15 | $scope.loadAll(); 16 | 17 | $scope.create = function () 18 | { 19 | 20 | console.log( "saving StudyBuddy" ); 21 | //$scope.truncate($scope.StudyBuddy); 22 | console.log( $scope.studyBuddy ); 23 | 24 | StudyBuddy.save( $scope.studyBuddy, 25 | function () 26 | { 27 | $( '#saveStudyBuddyModal' ).modal( 'hide' ); 28 | $scope.loadAll(); 29 | } ); 30 | }; 31 | 32 | $scope.update = function ( id ) 33 | { 34 | $scope.studyBuddy = StudyBuddy.get( {id: id} ); 35 | $( '#saveStudyBuddyModal' ).modal( 'show' ); 36 | }; 37 | 38 | $scope.delete = function ( id ) 39 | { 40 | $scope.studyBuddy = StudyBuddy.get( {id: id} ); 41 | $( '#deleteStudyBuddyConfirmation' ).modal( 'show' ); 42 | }; 43 | 44 | $scope.confirmDelete = function ( id ) 45 | { 46 | StudyBuddy.delete( {id: id}, 47 | function () 48 | { 49 | var popup = $( '#deleteStudyBuddyConfirmation' ); 50 | popup.on( 'hidden.bs.modal', function ( e ) 51 | { 52 | $scope.loadAll(); 53 | $state.transitionTo( 'StudyBuddy' ); 54 | } ); 55 | $scope.clear(); 56 | popup.modal( 'hide' ); 57 | } ); 58 | }; 59 | 60 | $scope.clear = function () 61 | { 62 | $scope.studyBuddy = {}; 63 | }; 64 | 65 | $scope.objectifyBuddyOne = function () 66 | { 67 | console.log( "objectified buddy one" ); 68 | $scope.studyBuddy.buddyOne = angular.fromJson( $scope.studyBuddy.buddyOne ); 69 | }; 70 | 71 | $scope.objectifyBuddyTwo = function () 72 | { 73 | console.log( "objectified buddy two" ); 74 | $scope.studyBuddy.buddyTwo = angular.fromJson( $scope.studyBuddy.buddyTwo ); 75 | }; 76 | 77 | $scope.objectifyCourse = function () 78 | { 79 | console.log( "objectified course" ); 80 | $scope.studyBuddy.course = angular.fromJson( $scope.studyBuddy.course ); 81 | }; 82 | } ); 83 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/studyBuddy/studyBuddy.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('studyBuddy', { 7 | parent: 'entity', 8 | url: '/studyBuddies', 9 | views: { 10 | 'content@': { 11 | templateUrl: 'html/studyBuddies.html', 12 | controller: 'StudyBuddyController' 13 | } 14 | } 15 | }) 16 | .state('studyBuddyDetail', { 17 | parent: 'entity', 18 | url: '/studyBuddies/:id', 19 | views: { 20 | 'content@': { 21 | templateUrl: 'html/studyBuddy-detail.html', 22 | controller: 'StudyBuddyDetailController' 23 | } 24 | } 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/studyBuddy/studyBuddy.service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .factory('StudyBuddy', function ($resource) { 5 | 6 | var url = 'api/studyBuddies/:id'; 7 | 8 | // should be done on server side 9 | var truncate = function (obj, depth) { 10 | for (var property in obj) { 11 | if (property == 'id' || property == 'name') { 12 | continue; 13 | } 14 | if (depth == 0) { 15 | var p = obj[property]; 16 | if (p && p.constructor === Array) { 17 | obj[property] = []; 18 | } else { 19 | obj[property] = null; 20 | } 21 | } else { 22 | truncate(obj[property], depth - 1); 23 | } 24 | } 25 | }; 26 | 27 | 28 | var prune = function (obj, depth) { 29 | for (var property in obj) { 30 | if (property == 'id' || property == 'name') { 31 | continue; 32 | } 33 | if (depth == 0) { 34 | delete obj[property]; 35 | } else { 36 | prune(obj[property], depth - 1); 37 | } 38 | } 39 | }; 40 | 41 | return $resource(url, {}, { 42 | 'query': { 43 | method: 'GET', isArray: true, 44 | transformResponse: function (data) { 45 | var obj = JSOG.parse(data); 46 | for (var i = 0; i < obj.length; i++) { 47 | truncate(obj[i], 0); 48 | } 49 | return obj; 50 | } 51 | }, 52 | 'remove': {method: 'DELETE'}, 53 | 'delete': {method: 'DELETE'}, 54 | 'post': {method: 'POST'}, 55 | 'get': { 56 | method: 'GET', 57 | transformResponse: function (data) { 58 | var obj = JSOG.parse(data); 59 | truncate(obj, 2); 60 | return obj; 61 | } 62 | } 63 | }); 64 | }); 65 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/subject/subject-detail.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('SubjectDetailController', function ($scope, $stateParams, Subject) { 5 | $scope.subject = {}; 6 | $scope.load = function (id) { 7 | Subject.get({id: id}, function(result) { 8 | $scope.subject = result; 9 | }); 10 | }; 11 | $scope.load($stateParams.id); 12 | }); 13 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/subject/subject.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('SubjectController', function ($scope, $state, Subject) { 5 | $scope.subjects = []; 6 | 7 | $scope.loadAll = function() { 8 | Subject.query(function(result) { 9 | $scope.subjects = result; 10 | }); 11 | }; 12 | $scope.loadAll(); 13 | 14 | $scope.create = function () { 15 | 16 | console.log("saving subject"); 17 | //$scope.truncate($scope.subject); 18 | console.log($scope.subject); 19 | 20 | Subject.save($scope.subject, 21 | function () { 22 | $('#saveSubjectModal').modal('hide'); 23 | $scope.loadAll(); 24 | }); 25 | }; 26 | 27 | $scope.update = function (id) { 28 | $scope.subject = Subject.get({id: id}); 29 | $('#saveSubjectModal').modal('show'); 30 | }; 31 | 32 | $scope.delete = function (id) { 33 | $scope.subject = Subject.get({id: id}); 34 | $('#deleteSubjectConfirmation').modal('show'); 35 | }; 36 | 37 | $scope.confirmDelete = function (id) { 38 | Subject.delete({id: id}, 39 | function () { 40 | var popup = $('#deleteSubjectConfirmation'); 41 | popup.on('hidden.bs.modal', function(e) { 42 | $scope.loadAll(); 43 | $state.transitionTo('subject'); 44 | }); 45 | $scope.clear(); 46 | popup.modal('hide'); 47 | }); 48 | }; 49 | 50 | $scope.clear = function () { 51 | $scope.subject = {}; 52 | }; 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/subject/subject.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('subject', { 7 | parent: 'entity', 8 | url: '/subjects', 9 | data: { 10 | roles: ['ROLE_USER'] 11 | }, 12 | views: { 13 | 'content@': { 14 | templateUrl: 'html/subjects.html', 15 | controller: 'SubjectController' 16 | } 17 | } 18 | }) 19 | .state('subjectDetail', { 20 | parent: 'entity', 21 | url: '/subjects/:id', 22 | data: { 23 | roles: ['ROLE_USER'] 24 | }, 25 | views: { 26 | 'content@': { 27 | templateUrl: 'html/subject-detail.html', 28 | controller: 'SubjectDetailController' 29 | } 30 | } 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/subject/subject.service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .factory('Subject', function ($resource) { 5 | 6 | var url = 'api/subjects/:id'; 7 | 8 | // should be done on server side 9 | var truncate = function (obj, depth) { 10 | for (var property in obj) { 11 | if (property == 'id' || property == 'name') { 12 | continue; 13 | } 14 | if (depth == 0) { 15 | var p = obj[property]; 16 | if (p && p.constructor === Array) { 17 | obj[property] = []; 18 | } else { 19 | obj[property] = null; 20 | } 21 | } else { 22 | truncate(obj[property], depth - 1); 23 | } 24 | } 25 | }; 26 | 27 | 28 | var prune = function (obj, depth) { 29 | for (var property in obj) { 30 | if (property == 'id' || property == 'name') { 31 | continue; 32 | } 33 | if (depth == 0) { 34 | delete obj[property]; 35 | } else { 36 | prune(obj[property], depth - 1); 37 | } 38 | } 39 | }; 40 | 41 | return $resource(url, {}, { 42 | 'query': { 43 | method: 'GET', isArray: true, 44 | transformResponse: function (data) { 45 | var obj = JSOG.parse(data); 46 | for (var i = 0; i < obj.length; i++) { 47 | truncate(obj[i], 0); 48 | } 49 | return obj; 50 | } 51 | }, 52 | 'remove': {method: 'DELETE'}, 53 | 'delete': {method: 'DELETE'}, 54 | 'post': {method: 'POST'}, 55 | 'get': { 56 | method: 'GET', 57 | transformResponse: function (data) { 58 | var obj = JSOG.parse(data); 59 | truncate(obj, 2); 60 | return obj; 61 | } 62 | } 63 | }); 64 | }); 65 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/teacher/teacher-detail.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('TeacherDetailController', function ($scope, $stateParams, Teacher) { 5 | $scope.teacher = {}; 6 | $scope.load = function (id) { 7 | Teacher.get({id: id}, function(result) { 8 | console.log(result); 9 | $scope.teacher = result; 10 | }); 11 | }; 12 | $scope.load($stateParams.id); 13 | }); 14 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/teacher/teacher.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('TeacherController', function ($scope, $state, Teacher) { 5 | $scope.teachers = []; 6 | $scope.loadAll = function() { 7 | Teacher.query(function(result) { 8 | $scope.teachers = result; 9 | }); 10 | }; 11 | $scope.loadAll(); 12 | 13 | $scope.create = function () { 14 | console.log("saving teacher"); 15 | //$scope.truncate($scope.teacher, 2); 16 | console.log($scope.teacher); 17 | Teacher.save($scope.teacher, 18 | function () { 19 | $('#saveTeacherModal').modal('hide'); 20 | $scope.loadAll(); 21 | }); 22 | }; 23 | 24 | $scope.update = function (id) { 25 | $scope.teacher = Teacher.get({id: id}); 26 | $('#saveTeacherModal').modal('show'); 27 | }; 28 | 29 | $scope.delete = function (id) { 30 | $scope.teacher = Teacher.get({id: id}); 31 | $('#deleteTeacherConfirmation').modal('show'); 32 | }; 33 | 34 | $scope.confirmDelete = function (id) { 35 | Teacher.delete({id: id}, 36 | function () { 37 | var popup = $('#deleteTeacherConfirmation'); 38 | popup.on('hidden.bs.modal', function(e) { 39 | $scope.loadAll(); 40 | $state.transitionTo('teacher'); 41 | }); 42 | $scope.clear(); 43 | popup.modal('hide'); 44 | }); 45 | }; 46 | 47 | $scope.clear = function () { 48 | $scope.teacher = {}; 49 | }; 50 | 51 | // $scope.tableParams = new ngTableParams({ 52 | // page: 1, // show first page 53 | // count: 10, // count per page 54 | // sorting: { 55 | // name: 'asc' // initial sorting 56 | // } 57 | // }, { 58 | // total: $scope.teachers.length, // length of data 59 | // getData: function($defer, params) { 60 | // // use build-in angular filter 61 | // var orderedData = params.sorting() ? 62 | // $filter('orderBy')(data, params.orderBy()) : 63 | // data; 64 | // 65 | // $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count())); 66 | // } 67 | // }); 68 | 69 | 70 | 71 | }); 72 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/teacher/teacher.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('teacher', { 7 | parent: 'entity', 8 | url: '/teachers', 9 | data: { 10 | roles: ['ROLE_USER'] 11 | }, 12 | views: { 13 | 'content@': { 14 | templateUrl: 'html/teachers.html', 15 | controller: 'TeacherController' 16 | } 17 | } 18 | }) 19 | .state('teacherDetail', { 20 | parent: 'entity', 21 | url: '/teachers/:id', 22 | data: { 23 | roles: ['ROLE_USER'] 24 | }, 25 | views: { 26 | 'content@': { 27 | templateUrl: 'html/teacher-detail.html', 28 | controller: 'TeacherDetailController' 29 | } 30 | } 31 | }); 32 | }); 33 | -------------------------------------------------------------------------------- /src/main/web/scripts/entities/teacher/teacher.service.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .factory('Teacher', function ($resource) { 5 | 6 | var url = 'api/teachers/:id'; 7 | 8 | // should be done on server side 9 | var truncate = function (obj, depth) { 10 | for (var property in obj) { 11 | if (property == 'id' || property == 'name') { 12 | continue; 13 | } 14 | if (depth == 0) { 15 | var p = obj[property]; 16 | if (p && p.constructor === Array) { 17 | obj[property] = []; 18 | } else { 19 | obj[property] = null; 20 | } 21 | } else { 22 | truncate(obj[property], depth - 1); 23 | } 24 | } 25 | }; 26 | 27 | return $resource(url, {}, { 28 | 'query': { 29 | method: 'GET', isArray: true, 30 | transformResponse: function (data) { 31 | var obj = JSOG.parse(data); 32 | for (var i = 0; i < obj.length; i++) { 33 | truncate(obj[i], 0); 34 | } 35 | return obj; 36 | } 37 | }, 38 | 'remove': {method: 'DELETE'}, 39 | 'delete': {method: 'DELETE'}, 40 | 'post': {method: 'POST'}, 41 | 'get': { 42 | method: 'GET', 43 | transformResponse: function (data) { 44 | var obj = JSOG.parse(data); 45 | truncate(obj, 2); 46 | return obj; 47 | } 48 | } 49 | }); 50 | }); 51 | 52 | -------------------------------------------------------------------------------- /src/main/web/scripts/error/error.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('error', { 7 | parent: 'site', 8 | url: '/error', 9 | views: { 10 | 'content@': { 11 | templateUrl: 'html/error.html' 12 | } 13 | } 14 | }); 15 | }); 16 | -------------------------------------------------------------------------------- /src/main/web/scripts/main/main.controller.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .controller('MainController', function ($scope) { 5 | 6 | }); 7 | -------------------------------------------------------------------------------- /src/main/web/scripts/main/main.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .config(function ($stateProvider) { 5 | $stateProvider 6 | .state('home', { 7 | parent: 'site', 8 | url: '/', 9 | data: { 10 | roles: [] 11 | }, 12 | views: { 13 | 'content@': { 14 | templateUrl: 'html/main.html', 15 | controller: 'MainController' 16 | } 17 | } 18 | }); 19 | }); 20 | -------------------------------------------------------------------------------- /src/main/web/scripts/navbar.directive.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | angular.module('registrarApp') 4 | .directive('activeLink', function(location) { 5 | return { 6 | restrict: 'A', 7 | link: function (scope, element, attrs) { 8 | var clazz = attrs.activeLink; 9 | var path = attrs.href; 10 | path = path.substring(1); //hack because path does bot return including hashbang 11 | scope.location = location; 12 | scope.$watch('location.path()', function(newPath) { 13 | if (path === newPath) { 14 | element.addClass(clazz); 15 | } else { 16 | element.removeClass(clazz); 17 | } 18 | }); 19 | } 20 | }; 21 | }); 22 | -------------------------------------------------------------------------------- /src/main/web/styles/main.css: -------------------------------------------------------------------------------- 1 | /* Sticky footer styles 2 | -------------------------------------------------- */ 3 | html { 4 | position: relative; 5 | min-height: 100%; 6 | } 7 | body { 8 | /* Margin bottom by footer height */ 9 | margin-bottom: 60px; 10 | background: #fafafa; 11 | color: #333; 12 | font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; 13 | } 14 | .footer { 15 | position: absolute; 16 | bottom: 0; 17 | width: 100%; 18 | /* Set the fixed height of the footer here */ 19 | height: 60px; 20 | background-color: #f5f5f5; 21 | } 22 | 23 | 24 | /* Custom page CSS 25 | -------------------------------------------------- */ 26 | /* Not required for template or sticky footer method. */ 27 | 28 | body > .container { 29 | padding: 60px 15px 0; 30 | } 31 | .container .text-muted { 32 | margin: 20px 0; 33 | } 34 | 35 | .footer > .container { 36 | padding-right: 15px; 37 | padding-left: 15px; 38 | } 39 | 40 | code { 41 | font-size: 80%; 42 | } 43 | --------------------------------------------------------------------------------