find your data - using graphdb capabilities in xpages applications - ics.ug 2016
Post on 13-Apr-2017
315 Views
Preview:
TRANSCRIPT
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Find your data - using GraphDB capabilities in XPages applications
Oliver Busse, We4IT GmbH
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
About me
• Working for We4IT
–Aveedo® Application Framework
• „Bleeding Yellow“ since R4.5
• IBM Champion for ICS 2015 + 2016
• OpenNTF Member Director
@zeromancer1972@we4it
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Agenda
• What is GraphDB?
• Terminology
• Data Modelling & Implementation
• Example
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
„Graphs“
http://whatis.techtarget.com/definition/graph-database
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Graph DB
A graph database, also called a graph-oriented database, is a type of NoSQL database that uses graph theory to store, map and query relationships.
A graph database is essentially a collection of nodes and edges. Each node represents an entity (such as a person or business) and each edge represents a connection or
relationship between two nodes.
http://whatis.techtarget.com/definition/graph-database
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Some Graph DBs & Frameworks
• Neo4J
• OrientDB
• DEX
• Tinkerpop
• Apache Lucene / Solr
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Who is using Graph DBs?
• Amazon
• …almost every application that offers something like
– „related posts“ (blogs)
– „others also bought this“ (shops)
– collect relations and „likes“
– …
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Graphs – Terminology
• Vertices (Nodes/Elements)
– Properties (Key-Value pairs)
• Edges
– Connections, Relations between Vertices
• ElementStores
– for us: NSF databases
• MetaverseIDs (Domino related only)
– Replica + UNID (hashed)
– internal use only (don‘t care about them)
– sometime refered to as „Coordinate“
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Graph DB – in Domino?
• Vertices and Edges are stored as Documents
• The data container is a NSF
• The ElementStore defines the filepath to the NSF
• An ElementStore can hold different types of Vertices
• Usually you create one ElementStore for each Vertice type
• Graphs are transactional
• Graph are a new part of the OpenNTF Domino API
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Data Modelling & Implementation
• Nodes are defined as Interfaces
• Fields are defined as properties with Getter and Setter
• Methods define how the Node can build Edges to otherVertices
• Methods also return all Edges to a certain Vertice
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Sample: Webshop, Customer Node@TypeValue("Customer")
public interface Customer extends DVertexFrame {
@Property("$$Key")
public String getKey();
@Property("name")
public String getName();
@Property("name")
public void setName(String name);
@AdjacencyUnique(label = "basket")
public Iterable<ProductItem> getProducts();
@AdjacencyUnique(label = "basket")
public ProductItem addProductItem(ProductItem item);
@AdjacencyUnique(label = "basket")
public void removeProductItem(ProductItem item);
}
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Init the Graph
• Define the Element Store(s)
• Add Element Store(s) to the Graph Configuration
• Define the DFramedTransactionalGraph object with the Graph Configuration
• Work with the Graph object
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Init the Graph: code schemaprivate DFramedTransactionalGraph<DGraph> initStores() {
// create element store
DElementStore myStore = new DElementStore();
myStore.setStoreKey(“folder/some.nsf”);
myStore.addType(MyType.class);
// register the stores to the graph
DConfiguration config = new DConfiguration();
DGraph graph = new DGraph(config);
config.addElementStore(myStore);
config.setDefaultElementStore(myStore.getStoreKey());
// init the graph
DFramedGraphFactory factory = new DFramedGraphFactory(config);
DFramedTransactionalGraph<DGraph> fg = (DFramedTransactionalGraph<DGraph>) factory.create(graph);
return fg;
}
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Create an Edge
• Parameterize Object 1
• Get Object 2 by a unique key
• Call one of the „add“ methods of your Node class
• Commit your changes
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Create an Edge: code schema
public void addToBasket(ProductItem item) {
String userName = Factory.getSession(SessionType.CURRENT).getEffectiveUserName();
try {
DFramedTransactionalGraph<DGraph> graph = initStores();
Customer customer = graph.getElement(userName, Customer.class);
customer.addProductItem(item);
graph.commit();
} catch (Throwable e) {
XspOpenLogUtil.logError(e);
}
}
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Let‘s see the demo &some more code
Find your data - using GraphDB capabilities in XPages applications
www.ics.ug #icsug
Resources
• The XPages demo application
– https://bitbucket.org/zeromancer1972/sutol-2015-oda-graph-demo
• A nice glossary
– http://www.intec.co.uk/from-xpages-to-web-app-glossary/
• OpenNTF Domino API
– http://www.openntf.org/main.nsf/project.xsp?r=project/OpenNTF%20Domino%20API
– http://www.openntf.org/main.nsf/project.xsp?r=project/OpenNTF%20Domino%20API%20Demo%20Database
• Xots
– http://www.intec.co.uk/xots-background-and-multithreaded-tasks-the-openntf-domino-api-way-part-one/
– http://www.intec.co.uk/xots-background-and-multithreaded-tasks-the-openntf-domino-api-way-part-two/
– http://www.intec.co.uk/xots-background-and-multithreaded-tasks-the-openntf-domino-api-way-part-three/
• Graphs
– http://de.slideshare.net/ktree19/the-graph-revolution
top related