JSON Facade - Wolfgang-Schuetzelhofer/jcypher GitHub Wiki

Previous Next Table of Contents

Domain Access using JSON

To open JCypher's Domain Mapping and Domain Query features for access from other, possibly remote, systems, JSON Facades are provided.
This for example allows to implement a server running JCypher in a way that the server provides RESTful services which accept and / or return JSON encoded data. The server code itself communicates with JCypher using the upper mentioned JSON Facades.
A project JCypher-Server, which utilizes this approach is currently under development.

Note: JSON Facades will provide access to all of JCypher's features concerning Domain Mapping and Domain Query. However that's not the case right now. JSON Facades will grow in functionality over the next couple of releases. In fact, requirements for JSON Facades are currently driven by the previously mentioned project JCypher-Server.

JSONDBFacade

(iot.jcypher.facade.JSONDBFacade) provides information about domains contained in a graph database.

// create a database access
IDBAccess dbAccess = ...

// instantiate a JSONDBFacade
// Note: setPrettyFormat(..) is optional
JSONDBFacade dbFacade = new JSONDBFacade(dbAccess)
   .setPrettyFormat(Format.PRETTY_1);

// query the domains available in the database
String domains = dbFacade.getDomains();

This will return a JSON array containig a list of domain names.
For example:

["PEOPLE-DOMAIN", "SALES-DOMAIN"]

JSONDomainFacade

(iot.jcypher.facade.JSONDomainFacade) provides JSON representations of a domain models.

// create a database access
IDBAccess dbAccess = ...

// create a domain access
// (must be a generic domain access)
IGenericDomainAccess gda = DomainAccessFactory
   .createGenericDomainAccess(dbAccess, "PEOPLE-DOMAIN");

// instantiate a JSONDomainFacade
// Note: setPrettyFormat(..) is optional
JSONDomainFacade domainFacade = new JSONDomainFacade(gda)
   .setPrettyFormat(Format.PRETTY_1);

// retrieve a JSON representation of the domain model
String model = domainFacade.getDomainModel();

This will return a JSON representation of a domain model.
For an example look at this model of the 'PEOPLE-DOMAIN'
The returned string represents a JSON object containing the domain name and a list of domain object types. A domain object type can be either an Interface, an Abstract-Class, a concrete Class, or an Enumeration. Every domain object type is represented by a JSON object in turn, which contains all relevant meta information like: The type's fully qualified name, all fields (with name and type), the supertype, the implemented interface(s)...


Previous Next Table of Contents
⚠️ **GitHub.com Fallback** ⚠️