I need help in order to update relation at runtime.
I have this use case:
I have created a graph with the following collections:
- A (VertexCollection)
- B (VertexCollection)
- E (EdgeCollection) with relation( A -> B)
at runtme, using Foxx app, I neet to create a new collection (VertexCollection C) and I need to update EdgeCollection with the following relation( A -> [B,C]).
Is there a way to update relation at runtime?
Thanks in advanced,
Peter
You create new collections from Foxx with
var db = require("internal").db;
var C = db._create("C");
An edge collection E can contain edges with in arbitrary vertex collections, you create a new edge in E with:
var edge = E.insert("A/xyz", "C/abc", {"someData":12});
to create an edge from the vertex with _key "xyz" in A to the vertex with _key "abc" in C, say.
Does this answer your question?
In the ArangoDB manual, in section Modify a graph definition during runtime, the following ways for modifying edge definitions at runtime are shown:
Adding a new edge definition to an existing graph:
/* load graph module */
var graph_module = require("org/arangodb/general-graph");
/* load existing graph by name */
var graph = graph_module._graph("myGraph");
/* add a relation for edge collection myEC2, with vertices
between collections myVC1 and myVC3 */
var defs = graph_module._relation("myEC2", ["myVC1"], ["myVC3"]);
/* update the existing graph's definition */
graph._extendEdgeDefinitions(defs);
Modifying an existing edge definition in an existing graph:
/* load graph module */
var graph_module = require("org/arangodb/general-graph");
/* load existing graph by name */
var graph = graph_module._graph("myGraph");
/* update the relation for edge collection myEC2, with vertices
between collections myVC23 and [ myVC42, myVC99 ] */
var defs = graph_module._relation("myEC2", ["myVC23"], ["myVC42", "myVC99"]);
/* update the existing graph's definition */
graph._editEdgeDefinitions(defs);
Related
How to create an instance of a graph extension something like:
MyGraph_Extension graph = PXGraphExtension.CreateInstance<MyGraph_Extension>();
You do not create an instance for an extension graph the same way as the base graph. You use the instance of the base graph and just get your extension graph using GetExtension. Here is an example which is an extension for Sales order entry:
var baseGraph = PXGraph.CreateInstance<SOOrderEntry>();
var extGraph = baseGraph.GetExtension<SOOrderEntryExtension>();
.NET 4.5, C#, Npgsql 3.1.0
I have a query which retrieves a Postgis geometry field - the only way I could see of doing this was:
public class pgRasterChart
{
...
public NpgsqlTypes.PostgisGeometry GEOMETRY;
...
}
...
NpgsqlDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
pgRasterChart chart = new pgRasterChart();
chart.GEOMETRY = (PostgisGeometry) reader.GetValue(21);
...
This functions but I need to get at the coordinates of the GEOMETRY field and I can't find a way of doing that? I want to use the coordinates to display the results on an OpenLayers map.
Any answers most gratefully received. This is my first post so my apologies if the etiquette is clumsy or question unclear.
Providing another answer because the the link above to the documentation for PostGisTypes is now broken.
PostGisGeometry is an abstract base class that does not contain anything more exiting than the SRID. Instead, you want to cast the object obtained by your datareader to the appropriate type (any of the following):
PostGisLineString
PostGisMultiLineString
PostGisMultiPoint
PostGisMultiPolygon
PostGisPoint
PostGisPolygon
These classes have ways of getting to the coordinates.
eg:
...
NpgsqlDataReader reader = command.ExecuteReader();
try
{
while (reader.Read())
{
var geom = (PostgisLineString) reader.GetValue(0);
var firstCoordinate = geom[0]; // Coordinate in linestring at index 0
var X = firstCoordinate.X;
var Y = firstCoordinate.Y;
...
As you can see here
https://github.com/npgsql/npgsql/blob/dev/src/Npgsql.LegacyPostgis/PostgisTypes.cs
PostgisGeometry types are a set of xy pairs.
For example, a linestring is an array of points, a polygon is an array of rings and so on..
You could traverse those structures and get the coordinates.
However, if you just want to display geometries using openlayers, I suggest you to use the wkt format.
You should change your query, selecting st_astext(geometry) instead of geometry, than treat the result as a string and give it back to OpenLayers.
Then use OpenLayers.Geometry.fromWKT to parse the WKT into an OpenLayers.Geometry
I am testing ArangoDb for using the graph features provided by the framework.
I am trying to create a very simple graph like below, similar to the Java driver example provided here, https://github.com/arangodb/arangodb-java-driver/
List<EdgeDefinitionEntity> edgeDefinitions = new ArrayList<EdgeDefinitionEntity>();
EdgeDefinitionEntity edgeDefinition = new EdgeDefinitionEntity();
edgeDefinition.setCollection("myEdgeCollection");
List<String> from = new ArrayList<String>();
from.add("myCollection1");
edgeDefinition.setFrom(from);
List<String> to = new ArrayList<String>();
to.add("myCollection2");
edgeDefinition.setTo(to);
edgeDefinitions.add(edgeDefinition);
GraphEntity graph = arangoDriver.createGraph("myGraph",
edgeDefinitions, null, true);
User myObject1 = new User("Homer", 38);
User myObject2 = new User("Bart", 36);
User myObject3 = new User("Marge", 39);
User myObject4 = new User("Lisa", 40);
DocumentEntity<User> vertexFrom1 = arangoDriver.graphCreateVertex(
"myGraph", "myCollection1", myObject1, true);
DocumentEntity<User> vertexFrom2 = arangoDriver.graphCreateVertex(
"myGraph", "myCollection1", myObject2, true);
DocumentEntity<User> vertexTo1 = arangoDriver.graphCreateVertex(
"myGraph", "myCollection2", myObject3, true);
DocumentEntity<User> vertexTo2 = arangoDriver.graphCreateVertex(
"myGraph", "myCollection2", myObject4, true);
EdgeEntity<?> edge1 = arangoDriver.graphCreateEdge("myGraph",
"myEdgeCollection", null, vertexFrom1.getDocumentHandle(),
vertexTo1.getDocumentHandle(), null, null);
EdgeEntity<?> edge2 = arangoDriver.graphCreateEdge("myGraph",
"myEdgeCollection", null, vertexFrom2.getDocumentHandle(),
vertexTo2.getDocumentHandle(), null, null);
The edge collection seems to have a right mapping,
{"_from":"myCollection1/1544266710","_to":"myCollection2/1544987606"}
{"_from":"myCollection1/1544528854","_to":"myCollection2/1545249750"}
I am trying to visualise this graph in the web interface. Graph visualization is showing some weird behaviour which I do not understand. In the above setup, I expect four nodes in the graph with edges between "Homer" -- "Marge" and "Bart" -- "Lisa" but I see only two nodes and one edge, i.e. Homer -- Marge.
Visulaization view itself sometimes shows that there are no nodes and on revisit to the same page nodes appear.
The graph viewer starts with a random vertex. That means it probably uses a totally different start vertex whenever it's opened.
This is because a graph in the general case can contain many vertices and displaying all of them together is not an option because it may take a long time to render or even crash the browser. Which vertex to put into the center of the display at start is also not really easy to determine because this would require the graph viewer to know which vertex is more important than others or most important to the users. As it doesn't know that, there is the random start vertex selection.
You can select a different start/center vertex by clicking on the filter icon in the top right of the graph viewer. This will bring up a search input field that you can use to select a start vertex by any attribute (e.g. name == Homer if your vertices contain a name attribute).
If such vertex exists, it will be put into the center of the screen, along with all its directly connected vertices. Note that only relationships/edges from the start vertex to its directly connected vertices will be shown. Indirect connections will not be shown in the graph viewer by default. Clicking on any of the vertices displayed will expand (or contract) them and may bring up further relationships.
Again all of this is done because it may not be possible to display the entire graph at start (imagine a graph with a few million nodes). But as your question indicates, the current solution may not be intuitive.
Hi I have an existing database with a table with 30 fields, I want to split the table into many models so I could retrieve/save fields that I need and not every time retrieve/save the whole object from the db. using c#.
I think I should be using Code-First. Could someone provide an example or a tutorial link?
thanks,
You don't need to split table to be able to load a subset of field or persist subset of fields. Both operations are available with the whole table mapped to single entity as well.
For selection you simply have to use projection:
var data = from x in context.HugeEntities
select new { x.Id, x.Name };
You can use either anonymous type in projection or any non-mapped class.
For updates you can simply use:
var data = new HugeEntity { Id = existingId, Name = newName };
context.HugeEntities.Attach(data);
var dataEntry = context.Entry(data);
dataEntry.Property(d => d.Name).IsModified = true; // Only this property will be updated
context.SaveChanges();
Or:
var data = new HugeEntity { Id = existingId };
context.HugeEntities.Attach(data);
data.Name = newName;
context.SaveChanges(); // Now EF detected change of Name property and updated it
Mapping multiple entities to single table must follows very strict rules and it is possible only with table splitting were all entities must be related with one-to-one relation (and there are some problems with more than two entities per split table in code first) or with table-per-hierarchy inheritance. I don't think that you want to use any of them for this case.
I am trying to create a grid using GXT that contains data from multiple JSON sources. I've been able to get the grid working with one source, but can't figure out how to add additional sources to the grid or the ListStore.
// ...
ScriptTagProxy<PagingLoadResult<ModelData>> proxy =
new ScriptTagProxy<PagingLoadResult<ModelData>>(url);
ModelType type = new ModelType();
type.setRoot("root");
type.addField("source");
type.addField("description");
JsonPagingLoadResultReader<PagingLoadResult<ModelData>> reader =
new JsonPagingLoadResultReader<PagingLoadResult<ModelData>>(type);
final PagingLoader<PagingLoadResult<ModelData>> loader =
new BasePagingLoader<PagingLoadResult<ModelData>>(proxy, reader);
ListStore<ModelData> store = new ListStore<ModelData>(loader);
final Grid<ModelData> grid = new Grid<ModelData>(store, cm);
add(grid);
// ...
Is there a way to add additional loaders to a GXT ListStore? Ideas? Thanks in advance.
It looks like one method of populating a grid with multiple remote sources is to use borrow from the article http://code.google.com/webtoolkit/articles/using_gwt_for_json_mashups.html and create a 'mashup' class that populates a ListStore with the results as each response is returned.