Giter VIP home page Giter VIP logo

sdn-university's Introduction

Hilly Fields Technical College

Overview

This demo web application shows developers how to quickly get started with Spring Data Neo4j library and the Neo4j graph database. For the non Spring version of this application please check out Neo4j OGM University.

Hilly Fields Technical College is a fictitious educational institution. This application allows you to manage its departments, teaching staff, subjects, students and classes.

This project is built using:

  • Spring Boot 2.0.3
  • Spring Data Neo4j 5
  • Neo4j OGM 3.1.0
  • AngularJS 1.6
  • Bootstrap 3.3

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.

Getting Started

Prerequisites

You will need to following to run this application:

Download the application

Either download the application or use git to clone the application:

git clone [email protected]:neo4j-examples/sdn-university.git
cd sdn-university

Starting the application

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.

You can start the application using maven:

mvn spring-boot:run

And that's it! Head to http://localhost:8080 to see your application running.

NOTE If you restart your application you may notice changes made in your database disappear. 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). 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.

Using the binary Bolt driver

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.

  1. Make sure you have a Neo4j instance installed and running.
  2. Change the pom.xml to comment out the embedded driver and the embedded neo4j instance dependencies and instead uncomment the bolt driver.
  3. 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
    spring.data.neo4j.uri=bolt://localhost
    spring.data.neo4j.username=<your username>
    spring.data.neo4j.password=<your password>
    
    
  4. You can then start the application using the same maven run command shown above.

Using the HTTP driver

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.

  1. Make sure you have a Neo4j instance installed and running.
  2. Change the pom.xml to comment out the embedded driver and the embedded neo4j instance dependencies and instead uncomment the http driver.
  3. 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
    spring.data.neo4j.uri=http://localhost:7474
    spring.data.neo4j.username=<your username>
    spring.data.neo4j.password=<your password>
    
    
  4. You can then start the application using the same maven run command shown above.

Loading the initial dataset

WARNING

By default, the application will use an Neo4j embedded instance of Neo4j. 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. So if you don't want that to happen please back up any existing database first.

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:

http://localhost:8080/api/reload

This will pre-load the Neo4j database with a handful of departments, a dozen or so subjects and teachers, and 200 students. You'll probably want to enroll them in classes...

Stopping the application server

You can stop the application server at any time by pressing Ctrl-C in the console window from where you launched it.

Make it better!

If you'd like to contribute to the development of this application you will need to install:

Once you have followed their instruction on installation you will need to install the project's node and bower dependencies via:

git clone [email protected]:neo4j-examples/sdn-university.git
cd sdn-university
npm install  && bower install

You can then run the front-end angular application simply by using:

grunt serve

If you would like to prepare a releasable version of your front end assets you can run:

grunt clean build

Your assets will then be available in the src/main/resources/static directory.

You can then run the maven boot run command to see your application served up entirely from Spring Boot!

sdn-university's People

Contributors

jasperblues avatar luanne avatar mangrish avatar maximatanasov avatar meistermeier avatar michael-simons avatar nmervaillie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdn-university's Issues

Cipher Query and Angular

Im found cipher query in StudyBuddyRepository.java but it fully unused in app.
Can you show me how to use cipher query in SDN4 with Angular? I tried do custom cipher query myself but without success.

sdn4-university and spring-data-rest?

Realizing that Spring Data Neo4j 4 is currently only at a milestone release, is there an incompatibility between Spring Data Neo4j 4.0.0.M1 and Spring Data Rest?

We are exploring making use of Spring Data Neo4j 4 combined with Spring Data Rest for an upcoming project. As part of migrating our proof of concept from Spring Data Neo4j 3.2.2 to Spring Data Neo4j 4.0.0.M1, we’ve hit a snag in that any restful request received by Spring Data Rest that return data result in an exception.

Removing our project as contributing to the issue, we have been able to reproduce the problem by adding Spring Data Rest to the sdn4-univesrity example project. Our steps to produce the issue are:

  1. Checkout sdn4-university from github
  2. Add the following dependency to sdn4-university’s pom.xml:

    org.springframework.boot
    spring-boot-starter-data-rest

3)Start a local instance of Neo4j with an empty database
4) Start sdn4-university by executing a “mvn clean spring-boot:run” from within the proejct
5) Use a browser to execute "http://localhost:8080/schools”. With no data populated, the request succeeds and returns empty results of “{}"
6) Use a browser to execute “http://localhost:8080/api/reload” to load sample data
7) Use a browser to execute "http://localhost:8080/schools” now returns:

{"cause":null,"message":"Cannot create self link for class school.domain.School! No persistent entity found!"}

The behavior has been reproduced against sending query requests for each entity (schools, teachers, departments, etc) and when running against both neo4j-community-2.1.8 and neo4j-enterprise-2.2.1running locally in server mode. No exceptions are logged in either of Neo4j's data/log/console.log or data/log/neo4j.0.0.log files.

After modifying sdn4-university's pom.xml to make use of:

org.springframework.boot spring-boot-starter-data-rest 1.2.3.RELEASE

The following exception are logged on the console for each request (in this case for a department):

12:34:31.165 [http-nio-8080-exec-10] INFO org.neo4j.ogm.session.Neo4jSession - --------- new request ----------
12:34:31.165 [http-nio-8080-exec-10] INFO org.neo4j.ogm.session.Neo4jSession - getOrCreateTransaction() being called on thread: 29
12:34:31.165 [http-nio-8080-exec-10] INFO org.neo4j.ogm.session.Neo4jSession - Session identity: org.neo4j.ogm.session.Neo4jSession@7c5276ab
12:34:31.165 [http-nio-8080-exec-10] INFO org.neo4j.ogm.session.Neo4jSession - There is no existing transaction, creating a transient one
12:34:31.165 [http-nio-8080-exec-10] INFO o.n.o.session.request.DefaultRequest - POST http://localhost:7474/db/data/transaction/commit, request: {"statements":[{"statement":"MATCH p=(n:Department)-[*0..1]-(m) RETURN collect(distinct p)","parameters":{},"resultDataContents":["graph"]}]}
12:34:31.186 [http-nio-8080-exec-10] INFO o.n.o.session.request.DefaultRequest - response is OK, creating response handler
12:34:31.197 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.198 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.198 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.198 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.198 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.198 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.198 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.School onto property of school.domain.Department
12:34:31.198 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.School onto property of school.domain.Department
12:34:31.199 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.School onto property of school.domain.Department
12:34:31.199 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.199 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.199 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.199 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.203 [http-nio-8080-exec-10] WARN o.neo4j.ogm.mapper.GraphEntityMapper - Unable to map iterable of type: class school.domain.Department onto property of school.domain.Subject
12:34:31.207 [http-nio-8080-exec-10] ERROR o.s.d.r.w.AbstractRepositoryRestController - Cannot create self link for class school.domain.Department! No persistent entity found!
java.lang.IllegalArgumentException: Cannot create self link for class school.domain.Department! No persistent entity found!
at org.springframework.data.rest.webmvc.PersistentEntityResourceAssembler.getSelfLinkFor(PersistentEntityResourceAssembler.java:81) ~[spring-data-rest-webmvc-2.1.4.RELEASE.jar:na]
...
...

As can be seen in the output above, it appears the generated cypher query may be in correct:

MATCH p=(n:Department)-[*0..1]-(m) RETURN collect(distinct p)

Executing this in the Neo4j console returns a graph including departments, schools, and subjects.

Is this a sdn4-university, Spring Data Neo4j 4, or Spring Data Rest issue?

Missing School and SchoolController

There are school-related javascript files, but no equivalent SchoolController.java or School.java domain files. Also getting messages like these in the logs:

looking for concrete class to resolve label: School
...
This label is not known in the mapping context. Moving on...
...
No resolving class found!!

spring-data-neo4j-rest pagination and sorting with custom @Query?

Are Spring Data Neo4j Rest’s pagination and sorting capabilities compatible with custom repository queries?

Based on what I am seeing I am unsure if A) the functionality is simply not supported or B) there is an issue with either C) Spring Data Rest or D) Spring Data Rest Neo4j.

Removing our project as contributing to the issue, we have been able to reproduce the problem by adding Spring Data Rest to the sdn4-univesrity example project. Our steps to produce the issue are:

  1. Checkout sdn4-university from github
  2. Add the following dependency to sdn4-university’s pom.xml:

org.springframework.data
spring-data-neo4j-rest
3.4.0.RELEASE

  1. Replace the project's StudentRepository with the version attached to this issue
    4)Start a local instance of Neo4j with an empty database
  2. Start sdn4-university by executing a “mvn clean spring-boot:run -Drun.jvmArguments="-Dusername=[username] -Dpassword=[password]” from within the proejct
  3. Populate the database by using a browser to http://localhost:8080/api/reload
  4. Use a browser to hit "http://localhost:8080/students/search/findStudyBuddyStudents_with_paginiation?studentId=24"

You will encounter the following stacktrace:

...
14:14:54.217 [main] INFO school.Application - Started Application in 6.456 seconds (JVM running for 7.116)
14:15:01.209 [qtp865744496-15] INFO school.Application - Initialising session-scoped Session Bean
14:15:01.209 [qtp865744496-15] INFO o.s.d.n.config.Neo4jConfiguration - Initialising Neo4jSession
14:15:01.630 [qtp865744496-15] INFO o.s.d.n.config.Neo4jConfiguration - Intercepted exception
14:15:01.641 [qtp865744496-15] WARN o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver - Handler execution resulted in exception: Failed to convert from type java.util.LinkedHashSet to type org.springframework.data.domain.Page for value '[Student{id=81, name='Ciara Odom', courses=0, studyBuddies=0}, Student{id=89, name='Graiden Haynes', courses=0, studyBuddies=0}, Student{id=162, name='Vaughan Haynes', courses=0, studyBuddies=0}, Student{id=147, name='Michael Daniels', courses=0, studyBuddies=0}, Student{id=146, name='Darryl Rosario', courses=0, studyBuddies=0}]'; nested exception is org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type java.util.LinkedHashSet to type org.springframework.data.domain.Page

...

The error message indicates the Cypher query is correctly executed (you can see the correct results in the log) but that LinkedHashSet can not be converted to Spring Data's Page object.

A few questions:

  1. Are pagination and sorting such as this supported when using a custom @query? If so, can you please provide a working sample? (I am unable to find one in the documentation).
  2. Assuming this functionality is supported, what can we do to help resolve the issue? Does it lie within Spring Data Rest or Spring Data Neo4j Rest?

sessionFactory returns an issue

Currently the project won't build currently, right now it returns:

Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.neo4j.ogm.session.SessionFactory]: Factory method 'getSessionFactory' threw exception; nested exception is java.lang.StringIndexOutOfBoundsException: String index out of range: 1
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)

package org.springframework.boot.neo4j does not exist

Dear,
I was tying to build this project but maven kept reporting an error " package org.springframework.boot.neo4j does not exist" as you can see from the attachment. I didn't change any pom.xml configuration. May I know how to solve this problem? Thank you very much.

2016-07-24_18-00-35

neo4j embedded instance.

Hello,

Sorry for bothering you, but is the embedded instance of neo4j start automatically by spring boot because when I follow the same steps of this project I get connection refused. Which I think it mean the instance didn't start.

I am using old versions I have check you old commit and it should be fine I think.
I have only one difference

<dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId>
            <version>3.1.0</version>
            <scope>runtime</scope>
        </dependency>  

this dependency is declared as a dependency of another dependency of the spring boot module. Can this be a problem?

https://stackoverflow.com/questions/51331870/embedded-neo4j-with-spring-boot

Thank you.

Getting NPE from Metadata

Hello,

I have tried this app locally and found it is working correctly. But after deploying this app to the Heroku environment I am getting NullPointerException. I have tried api/reload end point to load neo4j school data which has loaded the data into my Graphenedb instance on Heroku correctly. But I am getting the following exception (attached). Any help is appreciated.

Thanks,
Durga

npe-neo4j-ogm.txt

Infrastructure for testing

I have problems with writing integrations tests based on sdn4-university.

Would it be possible to enhance the project with basic tests to show how to access neo4j?

Update to SDN5 ?

After the SF 5.0 SDN5.0 SD2.0 release in Oct 2017, should we update this project too?

Can't enroll students in courses

I can't seem to be able to enroll students in courses from either the student detail view or the course detail view. Upon making selections and saving, the selections are never preserved. I've never seen a checkbox load as checked on these pages, they're always unchecked. (teacher specialties never seem to save either)

Sometimes other fields go missing too when I revisit the course detail view, such as the course teacher or subject.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.