Skip to content

Commit

Permalink
Angular update, Spring update, Neo4j 5
Browse files Browse the repository at this point in the history
  • Loading branch information
dahoat committed May 2, 2023
1 parent df9a63f commit 41f325b
Show file tree
Hide file tree
Showing 16 changed files with 3,759 additions and 655 deletions.
4,270 changes: 3,665 additions & 605 deletions frontend/package-lock.json

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,37 @@
"private": true,
"dependencies": {
"@angular/animations": "^15.2.8",
"@angular/cdk": "^14.2.7",
"@angular/cdk": "^15.2.8",
"@angular/common": "^15.2.8",
"@angular/compiler": "^15.2.8",
"@angular/core": "^15.2.8",
"@angular/forms": "^15.2.8",
"@angular/material": "^14.2.7",
"@angular/material": "^15.2.8",
"@angular/platform-browser": "^15.2.8",
"@angular/platform-browser-dynamic": "^15.2.8",
"@angular/router": "^15.2.8",
"ngx-highlightjs": "^4.1.3",
"rxjs": "~6.6.0",
"ngx-highlightjs": "^8.0.0",
"rxjs": "~7.8.1",
"tslib": "^2.0.0",
"zone.js": "~0.11.3"
"zone.js": "~0.13.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^15.2.7",
"@angular/cli": "^15.2.7",
"@angular/compiler-cli": "^15.2.8",
"@types/jasmine": "~3.6.0",
"@types/node": "^12.11.1",
"@types/jasmine": "~4.3.1",
"@types/node": "^18.16.3",
"codelyzer": "^6.0.0",
"jasmine-core": "~3.8.0",
"jasmine-spec-reporter": "~5.0.0",
"karma": "~6.3.19",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "^1.7.0",
"jasmine-core": "~4.6.0",
"jasmine-spec-reporter": "~7.0.0",
"karma": "~6.4.2",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "^2.0.0",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"ts-node": "~10.9.1",
"eslint": "^8.39.0",
"typescript": "~4.9.5"
}
}
}
31 changes: 19 additions & 12 deletions frontend/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<h2>Basic building blocks</h2>

<div class="lecture-part">
Two parenthesis denote a node in cypher
Two parenthesis denote a node in Cypher
<app-snippset query="()" copy="false"></app-snippset>
</div>

Expand All @@ -21,12 +21,12 @@ <h2>Basic building blocks</h2>

<div class="lecture-part">
Nodes and edges are connected by dashes and less/greater signs
<app-snippset query="-- -> <-" copy="false"></app-snippset>
<app-snippset query="-- --> <--" copy="false"></app-snippset>
</div>

<div class="lecture-part">
Nodes and edges can have multiple labels which are each started by a colon. <br />
The case is not mandatory but significant.
The case is only a convention but significant.
<app-snippset copy="false" query=":Label1 :Label1:Label2 :LABEL_FOR_AN_EDGE"></app-snippset>
</div>

Expand Down Expand Up @@ -87,7 +87,7 @@ <h2>Creating our First Entries</h2>
<div class="lecture-part">
After Alex graduated, the nodes is eventually removed, so we try this query:
<app-snippset query="MATCH (s:Student{name: 'Alex'}) DELETE s"></app-snippset>
Which won't execute because as Neo4J says <em>Cannot delete node<0>, because it still has relationships. To delete this node, you must first delete its relationships.</em>
Which won't execute because as Neo4j says <em>Cannot delete node<0>, because it still has relationships. To delete this node, you must first delete its relationships.</em>
Instead, we exlicilty need to state that we want also the relationships removed by
<app-snippset query="MATCH (s:Student{name: 'Alex'}) DETACH DELETE s"></app-snippset>
</div>
Expand All @@ -99,7 +99,7 @@ <h2>Creating our First Entries</h2>
<app-snippset query="MERGE (s:Student{name: 'Kim'}) WITH s MERGE (l:Lecture{topic: 'GraphDBs'}) WITH s, l MERGE (s)-[:LISTENS]->(l) RETURN *"></app-snippset>
ATTENTION: If we used
<app-snippset query="MERGE (s:Student{name: 'Kim'})-[:LISTENS]->(l:Lecture{topic: 'GraphDBs'}) RETURN *"></app-snippset>
We would have got another lecture about graph databases because Neo4J would be looking for a lecture with an incoming <b>LISTENS</b> edge attaching a student named Kim.
We would have got another lecture about graph databases because Neo4j would be looking for a lecture with an incoming <b>LISTENS</b> edge attaching a student named Kim.
Actually if you use the second query, change the name and execute it, you would end up with another new lecture with only one student.
</div>

Expand Down Expand Up @@ -148,12 +148,12 @@ <h2>Simple MATCH queries</h2>
In this example we combine the previous two queries by specifying two patterns.
<app-snippset query="MATCH (p:Pokemon), (t:Type) RETURN p, t LIMIT 25"></app-snippset>
We now limit the number of results again to 25.
This query is a very bad example (and Neo4J Browser warns about this one), because we are actually building the Cartesian product of the two sets of results.
According to Neo4J Browser, the number of records would be 16164. <br />
This query is a very bad example (and Neo4j Browser warns about this one), because we are actually building the Cartesian product of the two sets of results.
According to Neo4j Browser, the number of records would be 16164. <br />
A better query is to ask for a Pokemon and its adjacent type:
<app-snippset query="MATCH (p:Pokemon)-[:HAS_TYPE]-(t:Type) RETURN p, t LIMIT 25"></app-snippset>
Here, the label <b>HAS_TYPE</b> is the label of an edge connecting a Pokemon with its type.
And because we both of the variables returned, we can replace <b>p, t</b> with an asterisk.
And because both of the variables are returned, we can replace <b>p, t</b> with an asterisk.
<app-snippset query="MATCH (p:Pokemon)-[:HAS_TYPE]-(t:Type) RETURN * LIMIT 25"></app-snippset>
</div>

Expand Down Expand Up @@ -184,6 +184,13 @@ <h2>Filtering with Properties</h2>
We can also filter for an internal id
<app-snippset copy="false" query="MATCH (n) WHERE id(n) = 42 RETURN n"></app-snippset>
Please note that the id is not really predictable and this query might not yield a meaningful result.
Furthermore, as of Neo4j version 5, using <a href="https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-id" target="_blank">id()</a>
is deprecated in favor of <a href="https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-elementid" target="_blank">elementId()</a>.
</div>

<div class="lecture-part">
This query shows us the results for both functions on the same node.
<app-snippset query="MATCH (n) RETURN id(n), elementId(n) LIMIT 10"></app-snippset>
</div>

<div class="lecture-part">
Expand Down Expand Up @@ -215,7 +222,7 @@ <h2>Filtering with Paths</h2>
<app-snippset query="MATCH (p:Pokemon) WHERE NOT (p)-[:EVOLVES_TO]->() RETURN p LIMIT 25"></app-snippset>
The <b>()</b> here stands for an arbitrary node we do not restrict in any way and also do not store in a variable. <br />
Please note that we used <b>-[]-></b> which is a directed edge instead of the <b>-[]-</b> we used earlier.
All edges in Neo4J are directed and we can care about the direction or not.
All edges in Neo4j are directed and we can care about the direction or not.
</div>

<div class="lecture-part">
Expand Down Expand Up @@ -266,16 +273,16 @@ <h2>Path finding</h2>
</div>

<div class="lecture-part">
Neo4J also offers some interesting functions like <b>shortestPath()</b> which finds the shortest instance of an path in an (according to the documentation) efficient way.
Neo4J Browser advices to use an upper limit here to avoid long execution times
Neo4j also offers some interesting functions like <b>shortestPath()</b> which finds the shortest instance of an path in an (according to the documentation) efficient way.
Neo4j advices to use an upper limit here to avoid long execution times
<app-snippset query="MATCH p=shortestPath((start:City{name:'Snowpoint City'})-[:ROUTE*..10]-(end:City{name:'Hearthome City'})) RETURN length(p), p"></app-snippset>
</div>



</div>

<mat-expansion-panel>
<mat-expansion-panel class="no-print">
<mat-expansion-panel-header>
<mat-panel-title>
Sources
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MatDividerModule} from '@angular/material/divider';
import { BrowserComponent } from './components/browser/browser.component';
import { DatabaseControlComponent } from './components/database-control/database-control.component';
import {MatButtonModule} from '@angular/material/button';
import {HttpClientModule} from '@angular/common/http';
import { SnippetComponent } from './components/snippset/snippet.component';
import {HIGHLIGHT_OPTIONS, HighlightModule} from 'ngx-highlightjs';
import {ClipboardModule} from '@angular/cdk/clipboard';
import {MatButtonModule} from '@angular/material/button';

@NgModule({
declarations: [
Expand Down
10 changes: 10 additions & 0 deletions frontend/src/app/components/snippset/snippet.component.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
.snippet {
margin-bottom: 10px;
}

pre {
white-space: normal; /* css-3 */
}

@media print {
button {
display: none;
}
}
8 changes: 8 additions & 0 deletions frontend/src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,11 @@ html, body {
body {
margin: 0;
}

@media print
{
.no-print, .no-print *
{
display: none !important;
}
}
24 changes: 14 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,19 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.4</version>
<version>3.0.6</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>at.jku.faw</groupId>
<artifactId>neo4jdemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.2.0</version>
<name>Neo4J Demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<java.version>17</java.version>
<neo4j.version>5.7.0</neo4j.version>
<neo4j-browser.version>5.6.0</neo4j-browser.version>
<neo4j-ogm.version>4.0.5</neo4j-ogm.version>
</properties>
<dependencies>
<dependency>
Expand All @@ -35,31 +38,32 @@
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>4.4.6</version>
<version>${neo4j.version}</version>
</dependency>


<dependency>
<groupId>org.neo4j.client</groupId>
<artifactId>neo4j-browser</artifactId>
<version>4.4.5</version>
<version>${neo4j-browser.version}</version>
</dependency>

<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-core</artifactId>
<version>3.2.32</version>
<version>${neo4j-ogm.version}</version>
</dependency>

<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-bolt-driver</artifactId>
<version>3.2.32</version>
<version>${neo4j-ogm.version}</version>
</dependency>

<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.6</version>
<version>5.7.1</version>
</dependency>


Expand Down Expand Up @@ -88,8 +92,8 @@
<goal>install-node-and-npm</goal>
</goals>
<configuration>
<nodeVersion>v16.13.0</nodeVersion>
<npmVersion>8.5.5</npmVersion>
<nodeVersion>v18.10.0</nodeVersion>
<npmVersion>9.6.5</npmVersion>
</configuration>
</execution>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Pokemon {
@Relationship(value = "HAS_TYPE")
private Set<TypeRelation> type;

@Relationship(value = "EVOLVES_TO", direction = Relationship.INCOMING)
@Relationship(value = "EVOLVES_TO", direction = Relationship.Direction.INCOMING)
private Pokemon evolvesTo;

public Long getId() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package at.jku.faw.neo4jdemo.repository;

import at.jku.faw.neo4jdemo.model.neo4j.Type;
import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/at/jku/faw/neo4jdemo/runner/Neo4JRunner.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package at.jku.faw.neo4jdemo.runner;

import jakarta.annotation.PreDestroy;
import org.neo4j.configuration.connectors.BoltConnector;
import org.neo4j.configuration.connectors.HttpConnector;
import org.neo4j.dbms.api.DatabaseManagementService;
import org.neo4j.dbms.api.DatabaseManagementServiceBuilder;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.server.modules.Neo4jBrowserModule;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import javax.annotation.PreDestroy;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
Expand Down
1 change: 0 additions & 1 deletion src/main/resources/static/241.js

This file was deleted.

19 changes: 17 additions & 2 deletions src/main/resources/static/3rdpartylicenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MIT
MIT
The MIT License

Copyright (c) 2022 Google LLC.
Copyright (c) 2023 Google LLC.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -36,7 +36,7 @@ MIT
MIT
The MIT License

Copyright (c) 2022 Google LLC.
Copyright (c) 2023 Google LLC.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -302,6 +302,21 @@ Apache-2.0



tslib
0BSD
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.

zone.js
MIT
The MIT License
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/static/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/resources/static/polyfills.js

Large diffs are not rendered by default.

Loading

0 comments on commit 41f325b

Please sign in to comment.