i was able to add an edge in DSE graph using the native api from java.
but when i try to add the edge using the fluent api in java, it doesnt work.
i went through the documentation for fluent api and there was nothing to show how to add an edge. When i try to add the edge in java it gives a run time error telling Edge cannot be added
is there any way to add an edge using the fluent api from java
want to use the fluent api since it is more readable from the java code
Sample Code:
lets say there is a vertex called user. another vertex called movie. i want an edge between user and movie. this is what i am trying in java. i am able to add the vertex (the code shows adding only one vertex ) and it worked fine. not really sure about the edge part , when i try to add the edge i get the run time error
GraphTraversal<Vertex,Vertex> traversal = g.addV("user").property("name",
"abcd");
GraphStatement graphStatement = DseGraph.statementFromTraversal(traversal);
GraphResultSet grs = dseSession.executeGraph(graphStatement);
Vertex user1 = g.V().has("user","name","abcd").next();
g.V().has("movie","name","movie1").next().addEdge("ratedBy",user1)
It will not work quite that way. As soon as you do this (i.e. call next()):
g.V().has("movie","name","movie1").next().addEdge("ratedBy",user1)
you are no longer using the Traversal API. Everything after that is the Graph API and the Graph API is not supported for remote execution. To be more clear, calling next() emits a Vertex which is not part of the Traversal API. Looking at the javadocs might yield more clarity on the distinction there. The Graph API is for providers (those who implement the TinkerPop interfaces) and are here. The Traversal API is for users and it internally utilizes the Graph API to execute Gremlin against different graph implementations. The Traversal API largely consists of the GraphTraversal and GraphTraversalSource classes shown here.
You should simply execute a single traversal to construct the edge:
g.addV('user').property('name','abcd').as('user').
V().has('movie','name','movie1').
addE('ratedBy').to('user')
Related
I am learning three.js. I have created simple 3D models using hardcoded parameters. My next step is to load the values from a database that I created in MSSQL Server. The x, y and z parameters are stored in a table named dimensions. My question is can I connect three.js with REST API (developed in SpringBoot or Node.js) that API will fetch the data from my DB and pass it to my three.js project which will render the object at runtime.
You aren't really dependent on three.js for that. You can create your API in Spring or Node, then in your client code (three.js), you can use something like fetch or ajax to actually call that API. Once you get a response, you can simply call functions that set appropriate values.
I need to get navigation properties data.
Does anybody know how to use navigation properties using SAP Cloud SDK?
I created a VDM by SAP Cloud SDK VDM Generator.
The source OData is V2 and on S/4 HANA, which is generated by CDS View.
What I want to execute is like following.
HTTP Method: GET
Path: <host, domain, port and path>/(parameter='test')/Set?&fileter=filed eq 'hoge'
You can either fetch the data directly by expanding the navigation properties in the OData call OR fetch them at a later point in time.
To follow the first approach leverage the select functionality of your service class. Pass in the navigation property that you want to retrieve e.g. MyEntityClass.TO_MY_NAVIGATION_PROPERTY. Check out the Cloud SDK documentation for the details and an example.
You then obtain the data by invoking its dedicated Getter on the result entity of your query e.g. myEntityObject.getMyNavigationPropertyIfPresent(). Or you omit expanding in your original request and use myEntityObject.getMyNavigationPropertyOrFetch(). This will again query the server specifically for the data of the navigation property.
Internal Incidents
Stackoverflow
Thank you for replying.
Let me explain in detail.
I created an OData from CDS View on S/4HANA 1709.
The CDS View is with parameters.
The OData should be called like this.
/(parameter='value')/Set?$filter=field eq 'value'
When I tried to call without navigation property, it occurs an error.
/(parameter='value')
Besides, I need "filter" parameter for navigated entity,
since it gets too many records without filtering.
So I don't want to use the both expansion and 2-step fetch.
As workaround, I developed a function module which retrieves data from CDS view.
I want to include the output of the Neo4j application in my Angular Front-end application. (I shall use Nodejs also for backend if required)Is there such a provision ?
Can you please let me know how to include only the middle portion of graph-diagram out of the entire UI of Neo4j-
When you fetch data from Neo4j HTTP api (Not sure about bolt), you can actually fetch graph relationship data.
Once you get that data, it is just a matter of plugging that into any graph visualization libraries available to create your own.
Here is some information along with some examples of Neo4j Graph Visualization
Am trying to build a server on NodeJS, I want to create a n api the simply takes two points and uses a google api and creates a route, I got lost in web, any recommendation for tutorials is appreciated
What you need here is a Direction API or Direction Service, it can calculate directions (using a variety of methods of transportation) by using the DirectionsService object. This object communicates with the Google Maps API Directions Service which receives direction requests and returns an efficient path. You may either handle these directions results yourself or use the DirectionsRenderer object to render these results.
The Directions service can return multi-part directions using a series of waypoints. Directions are displayed as a polyline drawing the route on a map.
Here are the sample jsfiddle for it.
http://jsfiddle.net/gHK7s/2/ and http://jsfiddle.net/user2314737/u9no8te4/
Now, to connect it with the Node.js that you want, you can check these SO questions on how to do that.
Using Node.js to connect to a REST API
Cannot connect to Google Directions API with Node.js server
For more information, check this Node.js Client for Google Maps Services
EDIT
When i am talking about node and node id i am specifically talking about the Neo4j representation of a node not node as in Node.js
I am building out an application on top of Neo with node using the thingdom wrapper on top of the REST API and i am attempting to add my own custom id property that will be a hash of the id to be used in the URL for example.
What i am currently doing is creating the node and then once the id is returned hashing this and saving it back to the node, so in effect i am calling the REST API twice to create a single node.
This is a long shot but is there a way to get a reliable next id from Neo using the REST API so that i can do this all in one request.
If not does anyone know of a better approach to what i am doing?
The internal id of neo4j nodes is not supposed to be used for external interfaces, as noted in the documentation. That means especially it's not a good idea to try to guess the next id.
It's recommended to use application specific ids to reference nodes, if you use UUIDs (especially uuid type 4) there is only a minimal chance of collisions and you can compute them on node creation, before storing them in the database.
By curiosity, can I ask you why you need to have the Id stored in the Node?
But anyway, it's quite common in Node.js to call a succession of APIs. And you will see that with Neo4j it will be required more than once.
If you don't already use it, I can only suggest you to take a look at Async: https://github.com/caolan/async
And particularly to the "waterfall" method that allows you to call more than one API that use the result of the previous call.