Skip to content

Commit

Permalink
Update readme & review
Browse files Browse the repository at this point in the history
  • Loading branch information
DaJaime committed Apr 22, 2024
1 parent 35189b2 commit 05fb663
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 19 deletions.
15 changes: 8 additions & 7 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Goblin Weaver
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE.txt)

The Weaver is a REST API that takes a Cypher query and desired additional information as input and returns the result of this query on a Neo4j ecosystem dependency graph, enriching it on the fly according to the users needs.
The Weaver is a REST API for querying the Maven Central's dependency graph and enriching it by adding information to it according to the user's needs.

This weaver use the Maven ecosystem dependency graph available here: https://zenodo.org/records/10605656

This graph was created by the Goblin Miner, and can be updated by it: https://github.com/Goblin-Ecosystem/goblinMiner

An example of usage of this tool is available here: https://github.com/Goblin-Ecosystem/mavenDatasetExperiences (on Weaver version 1.0.0).
Expand Down Expand Up @@ -40,10 +41,10 @@ The program will first download the osv.dev dataset and create a folder called "
If you already have downloaded this dataset and you don't want to update it, you can add the "noUpdate" argument on the java -jar command.

Example:
> java -Dneo4jUri="bolt://localhost:7687/" -Dneo4jUser="neo4j" -Dneo4jPassword="Password1" -jar .\target\goblinWeaver-1.0.0.jar
> java -Dneo4jUri="bolt://localhost:7687/" -Dneo4jUser="neo4j" -Dneo4jPassword="Password1" -jar .\target\goblinWeaver-2.0.0.jar

> java -Dneo4jUri="bolt://localhost:7687/" -Dneo4jUser="neo4j" -Dneo4jPassword="Password1" -jar .\target\goblinWeaver-1.0.0.jar noUpdate
> java -Dneo4jUri="bolt://localhost:7687/" -Dneo4jUser="neo4j" -Dneo4jPassword="Password1" -jar .\target\goblinWeaver-2.0.0.jar noUpdate
## Use the API
Pre-designed requests are available, but you can also send your own Cypher requests directly to the API.
Expand All @@ -57,9 +58,9 @@ The Weaver is designed to be extensible, allowing a user to easily add informati
Here's how to add an added value:
1. Go to weaver/addedValue/AddedValueEnum and add the name of your new value.
2. Fill the three methods of this enumeration with your new added value
3. Create a new class that extends weaver/addedValue/AbstractAddedValue.
3.1. If you also want to create an aggregated value of your new added value, create a new class that extends your previous new class and implements the "AggregateValue" interface.
4. Write your internal logic in this new class.
3. Create a new class that extends weaver/addedValue/AbstractAddedValue.
4. (optional) If you also want to create an aggregated value of your new added value, create a new class that extends your previous new class and implements the "AggregateValue" interface.
5. Write your internal logic in this new class.

## Licensing
Copyright 2023 SAP SE or an SAP affiliate company and Neo4j Ecosystem Weaver. Please see our [LICENSE](LICENSE) for copyright and license information.
Copyright 2024 SAP SE or an SAP affiliate company and Neo4j Ecosystem Weaver. Please see our [LICENSE](LICENSE) for copyright and license information.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.cifre.sap.su.goblinWeaver.graphDatabase.GraphDatabaseSingleton;
import com.cifre.sap.su.goblinWeaver.graphEntities.InternGraph;
import com.cifre.sap.su.goblinWeaver.graphEntities.edges.DependencyEdge;
import com.cifre.sap.su.goblinWeaver.graphEntities.nodes.ArtifactNode;
import com.cifre.sap.su.goblinWeaver.graphEntities.nodes.NodeObject;
import com.cifre.sap.su.goblinWeaver.graphEntities.nodes.NodeType;
import com.cifre.sap.su.goblinWeaver.graphEntities.nodes.ReleaseNode;
Expand Down Expand Up @@ -109,15 +108,11 @@ public JSONObject getDirectPossibilitiesWithTransitiveRootedGraph(@RequestBody R
resultGraph.mergeGraph(directAllPossibilities);
// Get Releases dependencies
Map<String, Object> parameters = new HashMap<>();
// TODO pas de cypher ici
String query = "MATCH (r:Release)-[d:dependency]->(a:Artifact)-[e:relationship_AR]->(r2:Release) " +
"WHERE r.id IN $releaseIdList AND d.scope = 'compile' AND r2.version = d.targetVersion " +
"RETURN d,a,e,r2";
Set<String> visitedReleases = new HashSet<>();
Set<String> releasesToTreat = directAllPossibilities.getGraphNodes().stream().filter(n -> n.getType().equals(NodeType.RELEASE)).map(NodeObject::getId).collect(Collectors.toSet());
while (!releasesToTreat.isEmpty()){
parameters.put("releaseIdList",releasesToTreat);
InternGraph queryResult = GraphDatabaseSingleton.getInstance().executeQueryWithParameters(query, parameters);
InternGraph queryResult = GraphDatabaseSingleton.getInstance().executeQueryWithParameters(GraphDatabaseSingleton.getInstance().getQueryDictionary().getDependencyGraphFromReleaseIdListParameter(), parameters);
resultGraph.mergeGraph(queryResult);
visitedReleases.addAll(releasesToTreat);
Set<String> newReleaseToTreat = resultGraph.getGraphNodes().stream().filter(node -> node instanceof ReleaseNode).map(NodeObject::getId).collect(Collectors.toSet());
Expand Down Expand Up @@ -147,15 +142,11 @@ public JSONObject getDirectNewPossibilitiesWithTransitiveRootedGraph(@RequestBod
resultGraph.mergeGraph(directAllPossibilities);
// Get Releases dependencies
Map<String, Object> parameters = new HashMap<>();
// TODO pas de cypher ici
String query = "MATCH (r:Release)-[d:dependency]->(a:Artifact)-[e:relationship_AR]->(r2:Release) " +
"WHERE r.id IN $releaseIdList AND d.scope = 'compile' AND r2.version = d.targetVersion " +
"RETURN d,a,e,r2";
Set<String> visitedReleases = new HashSet<>();
Set<String> releasesToTreat = directAllPossibilities.getGraphNodes().stream().filter(n -> n.getType().equals(NodeType.RELEASE)).map(NodeObject::getId).collect(Collectors.toSet());
while (!releasesToTreat.isEmpty()){
parameters.put("releaseIdList",releasesToTreat);
InternGraph queryResult = GraphDatabaseSingleton.getInstance().executeQueryWithParameters(query, parameters);
InternGraph queryResult = GraphDatabaseSingleton.getInstance().executeQueryWithParameters(GraphDatabaseSingleton.getInstance().getQueryDictionary().getDependencyGraphFromReleaseIdListParameter(), parameters);
resultGraph.mergeGraph(queryResult);
visitedReleases.addAll(releasesToTreat);
Set<String> newReleaseToTreat = resultGraph.getGraphNodes().stream().filter(node -> node instanceof ReleaseNode).map(NodeObject::getId).collect(Collectors.toSet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ public interface QueryDictionary {
String getLinkedArtifactReleasesAndEdgesQuery(String artifactId);
String getReleaseDirectCompileDependenciesEdgeAndArtifact(String artifactId);
String getLastReleaseTimestamp();
String getDependencyGraphFromReleaseIdListParameter();
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,11 @@ public String getLastReleaseTimestamp(){
return "MATCH (r:Release) " +
"RETURN MAX(r.timestamp) AS maxTimestamp";
}

@Override
public String getDependencyGraphFromReleaseIdListParameter(){
return "MATCH (r:Release)-[d:dependency]->(a:Artifact)-[e:relationship_AR]->(r2:Release) " +
"WHERE r.id IN $releaseIdList AND d.scope = 'compile' AND r2.version = d.targetVersion " +
"RETURN d,a,e,r2";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

Expand Down

0 comments on commit 05fb663

Please sign in to comment.