diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..634aef1 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,16 @@ +# Contributing to coding + +If you're reading this, you're awesome! Thank you for helping us make this project great and being a part of the coding community. Here are a few guidelines that will help you along the way. +Code of Conduct + +Steps to contribute: + +1. Fork this repository into your account on Github +2. Clone your forked repository (not our original one) to your hard drive with git clone https://github.com/YOURUSERNAME/universal-graph-client.git +3. Design and develop your changes +4. Add/update unit tests +5. Add/update integration tests +6. Add/update documentation on gh-pages branch +7. Create a pull request for review to request merge + +THANK YOU! diff --git a/README.md b/README.md index 8a70851..56d4abb 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Universal Graph Client -Universal Graph Client contains data persistence API and implementations specific to data persistence in graph databases. It can be called a JDBC for graph databases. The APIs are designed in such a way that they can be easily extended to work with any graph database. Thereby enabling the end developer to work with java APIs over the graph database, hiding the complexities of the underlying database query and it's complexities. Moreover, the language is very human readable kind of, which makes the API flows self explanatory. +Universal Graph Client contains data persistence API and implementations specific to data persistence in graph databases. It can be called a JDBC for graph databases. The APIs are designed in such a way that they can be easily extended to work with any graph database. Thereby enabling the end developer to work with java APIs over the graph database, hiding the complexities of the underlying database query. Moreover, the language is very human-readable kind of, which makes the API flows self-explanatory. This project consists of 3 modules: 1. Universal Graph Client SDK API @@ -7,7 +7,7 @@ This project consists of 3 modules: 3. Graph Client DSE Provider ### Graph Databases -We live in a connected world. There are no isolated pieces of information, but rich, connected domains all around us. Only a database that embraces relationships as a core aspect of its data model is able to store, process, and query connections efficiently. While other databases compute relationships expensively at query time, a graph database stores connections as first class citizens, readily available for any “join-like” navigation operation. Accessing those already persistent connections is an efficient, constant-time operation and allows you to quickly traverse millions of connections per second per core. +We live in a connected world. There are no isolated pieces of information, but rich, connected domains all around us. Only a database that embraces relationships as a core aspect of its data model can store, process, and query connections efficiently. While other databases compute relationships expensively at query time, a graph database stores connections as first-class citizens, readily available for any “join-like” navigation operation. Accessing those already persistent connections is efficient, constant-time operation and allows you to quickly traverse millions of connections per second per core. There are some 30 popular variations of graph databases which are being used worldwide in real applications for everyday data modelling and insights. (Ref: https://en.wikipedia.org/wiki/Graph_database ) These graph databases come under different licenses, have compatibility with different programming languages and work with different query languages (Gremlin, GraphQL and SPARQL to name a few). But, as of today, there is no one single set of APIs and their implementation available, which could plug with any of these graph databases and work with them, irrespective of their underlying graph query language or programming language compatibility. @@ -18,17 +18,17 @@ There are some 30 popular variations of graph databases which are being used wor ### Universal Graph Client SDK API -Universal Graph Client provider the java APIs to work with graph database. It is the equivalent of, for example, a JDBC driver or the DataStax Cassandra Java driver for any persistence service which intends to work with an underlying graph database. It is the primary interface for Java developers to use a persistence service over graph database. +Universal Graph Client provider the java APIs to work with a graph database. It is the equivalent of, for example, a JDBC driver or the DataStax Cassandra Java driver for any persistence service which intends to work with an underlying graph database. It is the primary interface for Java developers to use a persistence service over graph database. -APIs are defined to support creation, selection (including complex select queries), mutation (updation and deletion) of the graph entities. A graph Vertex is referred to as an Entity and a graph Edge is referred to as a Relationship. Properties of Vertices and Edges are referred to as Attributes. And the label of the Relationship is referred to as it's Name. +APIs are defined to support the creation, selection (including complex select queries), mutation (updation and deletion) of the graph entities. A graph Vertex is referred to as an Entity and a graph Edge is referred to as a Relationship. Properties of Vertices and Edges are referred to as Attributes. And the label of the Relationship is referred to as its Name. ## Queries There are three types of queries possible with Universal Graph Client: * _Lookup queries_ are simple lookups of an entity by a key. The key can either be the database ID or a natural key specified by the domain model. Lookup queries can be used to emulate a simple key-value access pattern. -* _Graph queries_ are queries that start at a single entity (found using a lookup query) and then traverse from that entity to other entities via relationships, potentially over multiple steps. At each step, the list of entities can be filtered by a predicate. The set of attributes that is returned in the response is explicitly defined by a projection clause in the query. -* _Mutations_ are changes to entities and/or relationships, and are executed as a batch of operations that is guaranteed to be atomically applied. +* _Graph queries_ are queries that start at a single entity (found using a lookup query) and then traverse from that entity to other entities via relationships, potentially over multiple steps. At each step, the list of entities can be filtered by a predicate. The set of attributes that are returned in the response is explicitly defined by a projection clause in the query. +* _Mutations_ are changes to entities and/or relationships, and are executed as a batch of operations that are guaranteed to be atomically applied. All of the queries above are constructed using Universal Graph Client's query builder API, which is demonstrated in the examples below. @@ -64,7 +64,7 @@ Entity customer123 = persistence.lookup() ### Graph Queries -The following is an example of graph query to find a certain subset of a vendor's customers: +The following is an example of a graph query to find a certain subset of a vendor's customers: ````java Persistence persistence = ... // Injected @@ -105,7 +105,7 @@ persistence.prepareBatchMutation() .execute(); ```` -A mutation is really a batch of operations, so multiple objects can be created at once: +A mutation is a batch of operations, so multiple objects can be created at once: ````java @@ -197,24 +197,24 @@ List customers = ### Universal Graph Client SDK Core Implementation -Partial implementation of the Universal Graph Client API, requiring a persistence provider as specified by the Service-Provider Interface (SPI) contained in the `com.intuit.ugc.impl.core.spi` package. The provider APIs and implemented classes are further used by service specific persistence providers for specific implementation. +Partial implementation of the Universal Graph Client API, requiring a persistence provider as specified by the Service-Provider Interface (SPI) contained in the `com.intuit.ugc.impl.core.spi` package. The provider APIs and implemented classes are further used by service-specific persistence providers for a specific implementation. ### Graph Client DSE Provider -This is a specific provider for DSE Graph. Look at the `com.intuit.ugc.impl.persistence.dse.DSEGraphVisitor` class to understand how the implementation for all the different graph operations are done. Each of the API here is specific to one operation that can be done over the underlying DSE Graph database. Currently, create, select, update and delete operations are supported for both vertices and edges. -If you intend to use the Graph Client DSE Provider in your project, you can first modify it's pom.xml file to include this data stax driver dependency in the pom.xml : +This is a specific provider for DSE Graph. Look at the `com.intuit.ugc.impl.persistence.dse.DSEGraphVisitor` class to understand how the implementation for all the different graph operations is done. Each of the API here is specific to one operation that can be done over the underlying DSE Graph database. Currently, create, select, update and delete operations are supported for both vertices and edges. +If you intend to use the Graph Client DSE Provider in your project, you can first modify its pom.xml file to include this data stax driver dependency in the pom.xml : ```xml - com.datastax.cassandra - dse-driver - 1.1.0 + com.datastax.cassandra + dse-driver + 1.1.0 ``` Thereafter, compile the module and include it in your own project using the following pom.xml dependency : ```xml - - com.intuit.graph.client.impl - graph-client-impl-provider-dse - 1.0-SNAPSHOT + + com.intuit.graph.client.impl + graph-client-impl-provider-dse + 1.0-SNAPSHOT ``` @@ -237,7 +237,7 @@ schema.vertexLabel('Book').ifNotExists().create() schema.vertexLabel('Author').ifNotExists().create() ```` -Now, you are all set to run the tests.Once the tests are run, you can view the graph that got created in the DSE provided UI. To launch the UI and view the graph, follow these steps: +Now, you are all set to run the tests. Once the tests are run, you can view the graph that got created in the DSE provided UI. To launch the UI and view the graph, follow these steps: ````java cd /bin ./start_studio_server (This launches the UI Server) @@ -259,13 +259,13 @@ Universal Graph Client DSE provider is readily embeddable via the following mave ``` -## Quick instructions to setup a graph client provider +## Quick instructions to set up a graph client provider If you intend to use an existing graph client provider like the DSE provider, these are the two steps to set it up: ### Step1 : add the pom dependency of the corresponding provider in your project. For example, below is the pom dependency of the dse-provider: ```xml - com.intuit.graph.client.impl - graph-client-impl-provider-dse + com.intuit.graph.client.impl + graph-client-impl-provider-dse 1.0-SNAPSHOT ``` @@ -273,18 +273,18 @@ If you intend to use an existing graph client provider like the DSE provider, th ### Step2 : Inject the provider in your initializer class, passing it the properties file location from where to load the database properties. Below is a sample code snippet for the same: ````java public class DSETestModule extends AbstractModule { - @Override + @Override protected void configure() { - DSEPersistenceConfigurationProperties instance = new DSEPersistenceConfigurationProperties(); - try { - instance.load("graph_client_dse_test.properties",null); - } - catch (IOException e) { - throw new PersistenceException(e); - } - bind(Persistence.Configuration.class).toInstance(instance); - bind(DSEPersistenceConfiguration.class).toInstance(instance); - } + DSEPersistenceConfigurationProperties instance = new DSEPersistenceConfigurationProperties(); + try { + instance.load("graph_client_dse_test.properties",null); + } + catch (IOException e) { + throw new PersistenceException(e); + } + bind(Persistence.Configuration.class).toInstance(instance); + bind(DSEPersistenceConfiguration.class).toInstance(instance); + } } ```` @@ -293,18 +293,18 @@ public class DSETestModule extends AbstractModule { Add the pom dependency of the graph-client-api into your project ```xml - com.intuit.graph.client - universal-graph-client-api - 0.5-SNAPSHOT + com.intuit.graph.client + universal-graph-client-api + 0.5-SNAPSHOT ``` And add the dependency of graph-client-impl-core also in your project ```xml - com.intuit.graph.client.impl - universal-graph-client-impl-core - 1.0-SNAPSHOT + com.intuit.graph.client.impl + universal-graph-client-impl-core + 1.0-SNAPSHOT ``` @@ -315,31 +315,31 @@ public class DSEPersistenceConfigurationProperties extends Properties implements ```` And then implement the load method to load the graph specific properties from the file or resource in which you have the graph database specific properties. Refer the following code snippet from `DSEPersistenceConfigurationProperties` : ````java - public final void load(String resourceName, ClassLoader classLoader) throws IOException, PersistenceException { - Preconditions.argumentNotNull(resourceName, "resourceName"); - if (isNull(classLoader)) { - classLoader = DSEPersistenceConfigurationProperties.class.getClassLoader(); - } - try { - super.load(classLoader.getResource(resourceName).openStream()); - validateMissingRequiredKeys(); - LOG.info("Successfully loaded DSE provider configuration " + "from resource \"{}\"", resourceName); - } catch (IOException e) { - throw e; - } catch (Exception e) { - throw new PersistenceException("Could not load configuration from resource \"" + resourceName + "\"", e); - } - } + public final void load(String resourceName, ClassLoader classLoader) throws IOException, PersistenceException { + Preconditions.argumentNotNull(resourceName, "resourceName"); + if (isNull(classLoader)) { + classLoader = DSEPersistenceConfigurationProperties.class.getClassLoader(); + } + try { + super.load(classLoader.getResource(resourceName).openStream()); + validateMissingRequiredKeys(); + LOG.info("Successfully loaded DSE provider configuration " + "from resource \"{}\"", resourceName); + } catch (IOException e) { + throw e; + } catch (Exception e) { + throw new PersistenceException("Could not load configuration from resource \"" + resourceName + "\"", e); + } + } ```` ### Step 3 : Create a ConnectionManager Refer the following code snippet from `DSEConnectionManager`. ````java public class DSEConnectionManager { - private DSEPersistenceConfiguration config; - @Inject - public DSEConnectionManager(DSEPersistenceConfiguration config) { - this.config = config; - } + private DSEPersistenceConfiguration config; + @Inject + public DSEConnectionManager(DSEPersistenceConfiguration config) { + this.config = config; + } ```` ### Step 4 : Implement GraphVisitor GraphVisitor contains all the APIs for interacting with graph database. And every provider that deals with a particular kind of graph database should implement the GraphVisitor APIs. Refer to `DSEGraphVisitor`. @@ -351,24 +351,24 @@ A repository provider is injected with the right instance of GraphVisitor during Finally, initialize the library through the client. Refer to `DSETestModule` to understand how the initialization is done. ````java public class DSETestModule extends AbstractModule { - @Override + @Override protected void configure() { - DSEPersistenceConfigurationProperties instance = new DSEPersistenceConfigurationProperties(); - try { - instance.load("graph_client_dse_test.properties",null); - } - catch (IOException e) { - throw new PersistenceException(e); - } - bind(Persistence.Configuration.class).toInstance(instance); - bind(DSEPersistenceConfiguration.class).toInstance(instance); - } + DSEPersistenceConfigurationProperties instance = new DSEPersistenceConfigurationProperties(); + try { + instance.load("graph_client_dse_test.properties",null); + } + catch (IOException e) { + throw new PersistenceException(e); + } + bind(Persistence.Configuration.class).toInstance(instance); + bind(DSEPersistenceConfiguration.class).toInstance(instance); + } } ```` ## Features #### Extensibility -Universal Graph Client APIs can be implemented to develop provider for any kind of graph implementation +Universal Graph Client APIs can be implemented to develop a provider for any kind of graph implementation #### Default support for DSE Graph provider Universal Graph Client already contains the provider for DSE Graph. This provider can be used to perform CRUD operation over a DSE Graph #### High Performance @@ -381,7 +381,7 @@ For integrating specific modules, refer to the corresponding README.md ## Contributions We greatly encourage contributions! You can add new features, report and fix existing bugs, write docs and tutorials, or any of the above. Feel free to open issues and/or send pull requests. -The `master` branch of this repository contains the latest stable release of Universal Graph Client, while snapshots are published to the `develop` branch. In general, pull requests should be submitted against `develop` by forking this repo into your account, developing and testing your changes, and creating pull requests to request merges.See the [Contributing to a Project](https://guides.github.com/activities/contributing-to-open-source/) +The `master` branch of this repository contains the latest stable release of Universal Graph Client, while snapshots are published to the `develop` branch. In general, pull requests should be submitted against `develop` by forking this repo into your account, developing and testing your changes, and creating pull requests to request merges. See the [Contributing to a Project](https://guides.github.com/activities/contributing-to-open-source/) article for more details about how to contribute in general. Steps to contribute: @@ -395,12 +395,4 @@ Steps to contribute: 7. Create a pull request for review to request merge 8. Obtain 2 approval _squirrels_ before your changes can be merged -Thank you for your contribution! - - - - - - - - +Thank you for your contribution! \ No newline at end of file diff --git a/graph-client-impl-provider-dse/pom.xml b/graph-client-impl-provider-dse/pom.xml index a35a953..9c85465 100644 --- a/graph-client-impl-provider-dse/pom.xml +++ b/graph-client-impl-provider-dse/pom.xml @@ -105,6 +105,11 @@ universal-graph-client-impl-core 1.0-SNAPSHOT + + com.datastax.cassandra + dse-driver + 1.1.0 + org.jmockit jmockit diff --git a/graph-client-impl-provider-neptune/pom.xml b/graph-client-impl-provider-neptune/pom.xml new file mode 100644 index 0000000..5bc8b04 --- /dev/null +++ b/graph-client-impl-provider-neptune/pom.xml @@ -0,0 +1,147 @@ + + + + + + com.intuit.graph.client + graph-client-core + 1.0-SNAPSHOT + + + 4.0.0 + com.intuit.graph.client.impl + graph-client-impl-provider-neptune + 1.0-SNAPSHOT + graph-client-impl-provider-neptune + jar + + + + true + + + + + central + Maven Repository Switchboard + default + http://repo1.maven.org/maven2 + + false + + + + intuit-nexus + Intuit Nexus Repo + http://nexus.intuit.net/nexus/content/groups/public + + + idea-nexus-snapshot + IDEA Nexus Snapshot Repo + http://nexus2-idea.intuit.net/nexus/content/repositories/intuit-idea-analytics-snapshots + + always + + + always + + + + idea-nexus + IDEA Nexus Repo + http://nexus2-idea.intuit.net/nexus/content/repositories/intuit-idea-analytics + + + + + + com.intuit.graph.client + universal-graph-client-api + 0.5-SNAPSHOT + + + com.intuit.graph.client.impl + universal-graph-client-impl-core + 1.0-SNAPSHOT + + + org.apache.tinkerpop + gremlin-driver + 3.4.1 + + + org.apache.tinkerpop + gremlin-groovy + 3.4.1 + + + org.slf4j + slf4j-jdk14 + 1.7.25 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${maven.compiler.plugin} + + ${maven.compiler.source} + ${maven.compiler.target} + + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven.surefire.plugin} + + + org.apache.maven.plugins + maven-failsafe-plugin + ${maven.failsafe.plugin} + + + integration-test + + integration-test + + + + verify + + verify + + + + + + org.apache.maven.plugins + maven-release-plugin + ${maven.release.plugin} + + + + + + ctg.central + CTG Cache Repository + http://nexus.intuit.net/nexus/content/groups/public + + + + + + + jdk8-tests + + 1.8 + + + false + + + + diff --git a/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneConnectionManager.java b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneConnectionManager.java new file mode 100644 index 0000000..c23b099 --- /dev/null +++ b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneConnectionManager.java @@ -0,0 +1,16 @@ +package com.intuit.ugc.impl.persistence.neptune; + +import javax.inject.Inject; + +public class NeptuneConnectionManager { + + private NeptunePersistenceConfiguration config; + + @Inject + public NeptuneConnectionManager(NeptunePersistenceConfiguration config) { + this.config = config; + } + + public NeptuneGraphSession getDSEGraphSession() { return new NeptuneGraphSession(config); } + +} diff --git a/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneDSEPersistenceRepositoryProvider.java b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneDSEPersistenceRepositoryProvider.java new file mode 100644 index 0000000..18c1b7f --- /dev/null +++ b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneDSEPersistenceRepositoryProvider.java @@ -0,0 +1,19 @@ +package com.intuit.ugc.impl.persistence.neptune; + +import com.google.inject.Inject; +import com.google.inject.Provider; + +public class NeptuneDSEPersistenceRepositoryProvider implements Provider { + + NeptuneConnectionManager manager; + + @Inject + public NeptuneDSEPersistenceRepositoryProvider(NeptuneConnectionManager manager) { + this.manager = manager; + } + + @Override + public NeptuneGraphVisitor get() { + return new NeptuneGraphVisitor(this.manager); + } +} diff --git a/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphSession.java b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphSession.java new file mode 100644 index 0000000..80db8d6 --- /dev/null +++ b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphSession.java @@ -0,0 +1,47 @@ +package com.intuit.ugc.impl.persistence.neptune; + +import org.apache.tinkerpop.gremlin.driver.Cluster; +import org.apache.tinkerpop.gremlin.driver.remote.DriverRemoteConnection; +import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource; + +public class NeptuneGraphSession { + + private Cluster cluster = null; + private GraphTraversalSource graphSource = null; + + public NeptuneGraphSession(NeptunePersistenceConfiguration config) { init(config); } + + protected void init(NeptunePersistenceConfiguration config) { + Cluster.Builder builder = Cluster.build(); + builder.addContactPoint(config.getHost()); + builder.port(config.getPort()); + builder.enableSsl(true); + builder.keyCertChainFile(config.getKeyFile()); + cluster = builder.create(); + graphSource = new GraphTraversalSource(DriverRemoteConnection.using(cluster)); + } + + /** + * Get DSESession + * + * @return + */ + public GraphTraversalSource getSession() { + return graphSource; + } + + /** + * Close connection + */ + public void closeConnections() throws Exception { + if (graphSource != null) { + graphSource.close(); + graphSource = null; + } + if (cluster != null) { + cluster.close(); + cluster = null; + } + } + +} diff --git a/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphVisitor.java b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphVisitor.java new file mode 100644 index 0000000..d599b34 --- /dev/null +++ b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphVisitor.java @@ -0,0 +1,85 @@ +package com.intuit.ugc.impl.persistence.neptune; + +import com.intuit.ugc.impl.core.VisitOperationResult; +import com.intuit.ugc.impl.core.queryplan.operations.*; +import com.intuit.ugc.impl.core.spi.GraphVisitor; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NeptuneGraphVisitor implements GraphVisitor { + + private static final Logger LOGGER = LoggerFactory.getLogger(NeptuneGraphVisitor.class); + private NeptuneConnectionManager connectionManager; + private VisitOperationResult qResult = null; + private NeptuneGraphSession graphSession = null; + + public NeptuneGraphVisitor(NeptuneConnectionManager connectionManager) { + this.connectionManager = connectionManager; + this.graphSession = connectionManager.getDSEGraphSession(); + } + + @Override + public void visit(CreateEntity operation) { + + } + + @Override + public void visit(CreateRelationship operation) { + + } + + @Override + public void visit(GetBatchEntityByID operation) { + + } + + @Override + public void visit(GetEntityByID operation) { + + } + + @Override + public void visit(GetEntityByProperty operation) { + + } + + @Override + public void visit(GraphTerminalOperation operation) { + + } + + @Override + public void visit(SelectEntities operation) { + + } + + @Override + public void visit(SelectRelationships operation) { + + } + + @Override + public void visit(UpdateEntity operation) { + + } + + @Override + public void visit(UpdateRelationship operation) { + + } + + @Override + public VisitOperationResult getResult() { + return null; + } + + @Override + public void visit(DeleteEntity operation) { + + } + + @Override + public void visit(DeleteRelationship operation) { + + } +} diff --git a/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfiguration.java b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfiguration.java new file mode 100644 index 0000000..6715f5b --- /dev/null +++ b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfiguration.java @@ -0,0 +1,12 @@ +package com.intuit.ugc.impl.persistence.neptune; + +public interface NeptunePersistenceConfiguration { + public String getHost(); + + public int getPort(); + + public String getGraph(); + + public String getKeyFile(); + +} diff --git a/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties.java b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties.java new file mode 100644 index 0000000..a8f8659 --- /dev/null +++ b/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties.java @@ -0,0 +1,101 @@ +package com.intuit.ugc.impl.persistence.neptune; + +import com.intuit.ugc.api.PersistenceException; +import com.toddfast.util.preconditions.Preconditions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.Properties; + +import static java.util.Objects.isNull; + +public class NeptunePersistenceConfigurationProperties extends Properties implements NeptunePersistenceConfiguration { + + private static final Logger LOG = LoggerFactory.getLogger(NeptunePersistenceConfigurationProperties.class); + + public NeptunePersistenceConfigurationProperties() { + super(); + } + + public NeptunePersistenceConfigurationProperties(Properties defaults) { + super(defaults); + } + + public NeptunePersistenceConfigurationProperties(String resourceName) throws IOException, PersistenceException { + this(resourceName, null); + } + + public NeptunePersistenceConfigurationProperties(String resourceName, ClassLoader classLoader) + throws IOException, PersistenceException { + super(); + load(resourceName, classLoader); + } + + public final void load(String resourceName, ClassLoader classLoader) throws IOException, PersistenceException { + Preconditions.argumentNotNull(resourceName, "resourceName"); + if (isNull(classLoader)) { + classLoader = NeptunePersistenceConfigurationProperties.class.getClassLoader(); + } + try { + super.load(classLoader.getResource(resourceName).openStream()); + LOG.info("Successfully loaded DSE provider configuration " + "from resource \"{}\"", resourceName); + } catch (IOException e) { + throw e; + } catch (Exception e) { + throw new PersistenceException("Could not load configuration from resource \"" + resourceName + "\"", e); + } + } + + @Override + public synchronized void load(InputStream inStream) throws IOException { + super.load(inStream); + } + + @Override + public synchronized void load(Reader reader) throws IOException { + super.load(reader); + } + + /** + * Denotes if a Key is required + * + */ + @Retention(RetentionPolicy.RUNTIME) + @Target(ElementType.FIELD) + public static @interface Required { + } + + /** + * The property keys used to back the configuration property methods + * + */ + public static enum Key { + @Required host, @Required port, @Required graph, @Required keyfile + } + + @Override + public String getHost() { + return getProperty(Key.host.toString()); + } + + @Override + public int getPort() { + return Integer.parseInt(getProperty(Key.port.toString())); + } + + @Override + public String getGraph() { + return getProperty(Key.graph.toString()); + } + + @Override + public String getKeyFile() { return getProperty(Key.keyfile.toString()); } + +} diff --git a/graph-client-impl-provider-neptune/src/test/resource/graph-client-neptune_test.properties b/graph-client-impl-provider-neptune/src/test/resource/graph-client-neptune_test.properties new file mode 100644 index 0000000..62f8d80 --- /dev/null +++ b/graph-client-impl-provider-neptune/src/test/resource/graph-client-neptune_test.properties @@ -0,0 +1,4 @@ +host=127.0.0.1 +port=9042 +graph=test +keyfile= \ No newline at end of file diff --git a/graph-client-impl-provider-neptune/target/graph-client-impl-provider-neptune-1.0-SNAPSHOT.jar b/graph-client-impl-provider-neptune/target/graph-client-impl-provider-neptune-1.0-SNAPSHOT.jar new file mode 100644 index 0000000..d615477 Binary files /dev/null and b/graph-client-impl-provider-neptune/target/graph-client-impl-provider-neptune-1.0-SNAPSHOT.jar differ diff --git a/graph-client-impl-provider-neptune/target/maven-archiver/pom.properties b/graph-client-impl-provider-neptune/target/maven-archiver/pom.properties new file mode 100644 index 0000000..c91976f --- /dev/null +++ b/graph-client-impl-provider-neptune/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Mon Oct 21 11:22:13 IST 2019 +version=1.0-SNAPSHOT +groupId=com.intuit.graph.client.impl +artifactId=graph-client-impl-provider-neptune diff --git a/graph-client-impl-provider-neptune/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/graph-client-impl-provider-neptune/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/graph-client-impl-provider-neptune/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/graph-client-impl-provider-neptune/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst new file mode 100644 index 0000000..9ef5a27 --- /dev/null +++ b/graph-client-impl-provider-neptune/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst @@ -0,0 +1,8 @@ +com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfiguration.class +com/intuit/ugc/impl/persistence/neptune/NeptuneConnectionManager.class +com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties.class +com/intuit/ugc/impl/persistence/neptune/NeptuneDSEPersistenceRepositoryProvider.class +com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties$Key.class +com/intuit/ugc/impl/persistence/neptune/NeptuneGraphSession.class +com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties$Required.class +com/intuit/ugc/impl/persistence/neptune/NeptuneGraphVisitor.class diff --git a/graph-client-impl-provider-neptune/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/graph-client-impl-provider-neptune/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..8a76888 --- /dev/null +++ b/graph-client-impl-provider-neptune/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst @@ -0,0 +1,6 @@ +/Users/ajain17/Work/Code/hacktoberfest/universal-graph-client/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties.java +/Users/ajain17/Work/Code/hacktoberfest/universal-graph-client/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphSession.java +/Users/ajain17/Work/Code/hacktoberfest/universal-graph-client/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphVisitor.java +/Users/ajain17/Work/Code/hacktoberfest/universal-graph-client/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneDSEPersistenceRepositoryProvider.java +/Users/ajain17/Work/Code/hacktoberfest/universal-graph-client/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptuneConnectionManager.java +/Users/ajain17/Work/Code/hacktoberfest/universal-graph-client/graph-client-impl-provider-neptune/src/test/java/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfiguration.java diff --git a/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneConnectionManager.class b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneConnectionManager.class new file mode 100644 index 0000000..22dfabb Binary files /dev/null and b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneConnectionManager.class differ diff --git a/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneDSEPersistenceRepositoryProvider.class b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneDSEPersistenceRepositoryProvider.class new file mode 100644 index 0000000..4f56c85 Binary files /dev/null and b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneDSEPersistenceRepositoryProvider.class differ diff --git a/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphSession.class b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphSession.class new file mode 100644 index 0000000..7e8cb10 Binary files /dev/null and b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphSession.class differ diff --git a/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphVisitor.class b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphVisitor.class new file mode 100644 index 0000000..ef5159f Binary files /dev/null and b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptuneGraphVisitor.class differ diff --git a/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfiguration.class b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfiguration.class new file mode 100644 index 0000000..41131d5 Binary files /dev/null and b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfiguration.class differ diff --git a/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties$Key.class b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties$Key.class new file mode 100644 index 0000000..3e944e3 Binary files /dev/null and b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties$Key.class differ diff --git a/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties$Required.class b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties$Required.class new file mode 100644 index 0000000..5c1e317 Binary files /dev/null and b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties$Required.class differ diff --git a/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties.class b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties.class new file mode 100644 index 0000000..5eaec3a Binary files /dev/null and b/graph-client-impl-provider-neptune/target/test-classes/com/intuit/ugc/impl/persistence/neptune/NeptunePersistenceConfigurationProperties.class differ diff --git a/pom.xml b/pom.xml index 514923f..2ded949 100644 --- a/pom.xml +++ b/pom.xml @@ -109,6 +109,7 @@ universal-graph-client-api universal-graph-client-impl-core graph-client-impl-provider-dse + graph-client-impl-provider-neptune