[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2024-01-11 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17805525#comment-17805525
 ] 

ASF GitHub Bot commented on GORA-650:
-

djkevincr commented on PR #218:
URL: https://github.com/apache/gora/pull/218#issuecomment-1886947772

   This work is redundant and superseded by work here. [1] Hence closing the 
ticket.
   [1] https://github.com/apache/gora/pull/291
   




> Add datastore for ArangoDB
> --
>
> Key: GORA-650
> URL: https://issues.apache.org/jira/browse/GORA-650
> Project: Apache Gora
>  Issue Type: New Feature
>Affects Versions: 0.9
>Reporter: Kevin Ratnasekera
>Assignee: Chaminda Neluka
>Priority: Major
>  Labels: gsoc2020
> Fix For: 1.0
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> May be we should consider extending our multimodal datastore support with 
> ArangoDB. [1] 
> [1] https://www.arangodb.com/why-arangodb/multi-model/



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2024-01-11 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17805526#comment-17805526
 ] 

ASF GitHub Bot commented on GORA-650:
-

djkevincr closed pull request #218: [GORA-650] [WIP] Add initial ArangoDB 
datastore
URL: https://github.com/apache/gora/pull/218




> Add datastore for ArangoDB
> --
>
> Key: GORA-650
> URL: https://issues.apache.org/jira/browse/GORA-650
> Project: Apache Gora
>  Issue Type: New Feature
>Affects Versions: 0.9
>Reporter: Kevin Ratnasekera
>Assignee: Chaminda Neluka
>Priority: Major
>  Labels: gsoc2020
> Fix For: 1.0
>
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> May be we should consider extending our multimodal datastore support with 
> ArangoDB. [1] 
> [1] https://www.arangodb.com/why-arangodb/multi-model/



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2023-08-22 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17757729#comment-17757729
 ] 

ASF GitHub Bot commented on GORA-650:
-

chaminda-neluka opened a new pull request, #291:
URL: https://github.com/apache/gora/pull/291

   (no comment)




> Add datastore for ArangoDB
> --
>
> Key: GORA-650
> URL: https://issues.apache.org/jira/browse/GORA-650
> Project: Apache Gora
>  Issue Type: New Feature
>Affects Versions: 0.9
>Reporter: Kevin Ratnasekera
>Priority: Major
>  Labels: gsoc2020
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> May be we should consider extending our multimodal datastore support with 
> ArangoDB. [1] 
> [1] https://www.arangodb.com/why-arangodb/multi-model/



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344740#comment-17344740
 ] 

ASF GitHub Bot commented on GORA-650:
-

kamaci commented on pull request #218:
URL: https://github.com/apache/gora/pull/218#issuecomment-841386840


   Thanks @dinuka-perera!
   
   Please review my comments and resolve the conflict.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add datastore for ArangoDB
> --
>
> Key: GORA-650
> URL: https://issues.apache.org/jira/browse/GORA-650
> Project: Apache Gora
>  Issue Type: New Feature
>Affects Versions: 0.9
>Reporter: Kevin Ratnasekera
>Priority: Major
>  Labels: gsoc2020
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> May be we should consider extending our multimodal datastore support with 
> ArangoDB. [1] 
> [1] https://www.arangodb.com/why-arangodb/multi-model/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344738#comment-17344738
 ] 

ASF GitHub Bot commented on GORA-650:
-

kamaci commented on a change in pull request #218:
URL: https://github.com/apache/gora/pull/218#discussion_r632677448



##
File path: 
gora-arangodb/src/test/java/org/apache/gora/arangodb/ArangoDBTestDriver.java
##
@@ -0,0 +1,85 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gora.arangodb;
+
+import org.apache.gora.GoraTestDriver;
+import org.apache.gora.arangodb.store.ArangoDBStore;
+import org.apache.gora.arangodb.store.ArangoDBStoreParameters;
+import org.apache.gora.persistency.Persistent;
+import org.apache.gora.store.DataStore;
+import org.apache.gora.store.DataStoreFactory;
+import org.apache.gora.util.GoraException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+
+/**
+ * Driver to set up an embedded ArangoDB database instance for Gora
+ * dataStore specific integration tests.
+ */
+public class ArangoDBTestDriver extends GoraTestDriver {
+
+  private static Logger log = 
LoggerFactory.getLogger(ArangoDBTestDriver.class);
+
+  private GenericContainer arangodbContainer;
+
+  public ArangoDBTestDriver(GenericContainer arangodbContainer) {
+super(ArangoDBStore.class);
+this.arangodbContainer = arangodbContainer;
+  }
+
+
+  public ArangoDBTestDriver() {
+super(ArangoDBStore.class);
+  }
+
+  /**
+   * Initialize embedded ArangoDB server instance as per the 
gora-arangodb-mapping.xml
+   * server configuration file.
+   */
+  @Override
+  public void setUpClass() throws Exception {
+log.info("Setting up ArangoDB test driver");
+conf.set(ArangoDBStoreParameters.ARANGO_DB_SERVER_HOST, "localhost");
+conf.set(ArangoDBStoreParameters.ARANGO_DB_SERVER_PORT,
+arangodbContainer.getMappedPort(8529).toString());
+log.info("ArangoDB Embedded Server started successfully.");
+  }
+
+  /**
+   * Terminate embedded ArangoDB server.
+   */
+  @Override
+  public void tearDownClass() throws Exception {
+log.info("ArangoDB Embedded server instance terminated successfully.");
+  }
+
+  @Override
+  public  DataStore createDataStore(Class 
keyClass,
+   Class 
persistentClass) throws GoraException {
+

Review comment:
   Remove extra space




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add datastore for ArangoDB
> --
>
> Key: GORA-650
> URL: https://issues.apache.org/jira/browse/GORA-650
> Project: Apache Gora
>  Issue Type: New Feature
>Affects Versions: 0.9
>Reporter: Kevin Ratnasekera
>Priority: Major
>  Labels: gsoc2020
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> May be we should consider extending our multimodal datastore support with 
> ArangoDB. [1] 
> [1] https://www.arangodb.com/why-arangodb/multi-model/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344737#comment-17344737
 ] 

ASF GitHub Bot commented on GORA-650:
-

kamaci commented on a change in pull request #218:
URL: https://github.com/apache/gora/pull/218#discussion_r632677158



##
File path: 
gora-arangodb/src/main/java/org/apache/gora/arangodb/store/ArangoDBStore.java
##
@@ -0,0 +1,690 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gora.arangodb.store;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+
+import com.arangodb.ArangoDB;
+import com.arangodb.entity.BaseDocument;
+import org.apache.avro.Schema;
+import org.apache.avro.util.Utf8;
+import org.apache.gora.arangodb.query.ArangoDBQuery;
+import org.apache.gora.persistency.impl.BeanFactoryImpl;
+import org.apache.gora.persistency.impl.DirtyListWrapper;
+import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.AvroUtils;
+import org.apache.gora.util.ClassLoadingUtils;
+import org.apache.gora.util.GoraException;
+
+
+/**
+ * {@inheritDoc}
+ * {@link org.apache.gora.arangodb.store.ArangoDBStore} is the primary class
+ * responsible for facilitating GORA CRUD operations on ArangoDB documents.
+ */
+public class ArangoDBStore extends 
DataStoreBase {
+
+  public static final String DEFAULT_MAPPING_FILE = 
"/gora-arangodb-mapping.xml";
+  private ArangoDBStoreParameters arangoDbStoreParams;
+  private ArangoDBMapping arangoDBMapping;
+  private ArangoDB arangoDB;
+
+  /**
+   * {@inheritDoc}
+   * Initialize the ArangoDB dataStore by {@link Properties} parameters.
+   *
+   * @param keyClasskey class type for dataStore.
+   * @param persistentClass persistent class type for dataStore.
+   * @param properties  ArangoDB dataStore properties EG:- ArangoDB client 
credentials.
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+super.initialize(keyClass, persistentClass, properties);
+try {
+  arangoDbStoreParams = ArangoDBStoreParameters.load(properties);
+  arangoDB = new ArangoDB.Builder()
+  .host(arangoDbStoreParams.getServerHost(),
+  Integer.valueOf(arangoDbStoreParams.getServerPort()))
+  .user(arangoDbStoreParams.getUserName())
+  .password(arangoDbStoreParams.getUserPassword())
+  
.maxConnections(Integer.valueOf(arangoDbStoreParams.getConnectionPoolSize()))
+  .build();
+  if (!arangoDB.db(arangoDbStoreParams.getDatabaseName()).exists())
+arangoDB.createDatabase(arangoDbStoreParams.getDatabaseName());
+
+  ArangoDBMappingBuilder builder = new 
ArangoDBMappingBuilder<>(this);
+  arangoDBMapping = 
builder.fromFile(arangoDbStoreParams.getMappingFile()).build();
+  if (!schemaExists()) {
+createSchema();
+  }
+} catch (Exception e) {
+  LOG.error("Error while initializing ArangoDB dataStore: {}",
+  new Object[]{e.getMessage()});
+  throw new RuntimeException(e);
+}
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName(final String mappingSchemaName,
+  final Class persistentClass) {
+return super.getSchemaName(mappingSchemaName, persistentClass);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName() {
+return arangoDBMapping.getDocumentClass();
+  }
+
+  /**
+   * {@inheritDoc}
+   * Create a new class of ArangoDB documents if necessary. Enforce specified 
schema over the document class.
+   */
+  @Override
+  public void 

[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344735#comment-17344735
 ] 

ASF GitHub Bot commented on GORA-650:
-

kamaci commented on a change in pull request #218:
URL: https://github.com/apache/gora/pull/218#discussion_r632676903



##
File path: 
gora-arangodb/src/main/java/org/apache/gora/arangodb/store/ArangoDBStore.java
##
@@ -0,0 +1,690 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gora.arangodb.store;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+
+import com.arangodb.ArangoDB;
+import com.arangodb.entity.BaseDocument;
+import org.apache.avro.Schema;
+import org.apache.avro.util.Utf8;
+import org.apache.gora.arangodb.query.ArangoDBQuery;
+import org.apache.gora.persistency.impl.BeanFactoryImpl;
+import org.apache.gora.persistency.impl.DirtyListWrapper;
+import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.AvroUtils;
+import org.apache.gora.util.ClassLoadingUtils;
+import org.apache.gora.util.GoraException;
+
+
+/**
+ * {@inheritDoc}
+ * {@link org.apache.gora.arangodb.store.ArangoDBStore} is the primary class
+ * responsible for facilitating GORA CRUD operations on ArangoDB documents.
+ */
+public class ArangoDBStore extends 
DataStoreBase {
+
+  public static final String DEFAULT_MAPPING_FILE = 
"/gora-arangodb-mapping.xml";
+  private ArangoDBStoreParameters arangoDbStoreParams;
+  private ArangoDBMapping arangoDBMapping;
+  private ArangoDB arangoDB;
+
+  /**
+   * {@inheritDoc}
+   * Initialize the ArangoDB dataStore by {@link Properties} parameters.
+   *
+   * @param keyClasskey class type for dataStore.
+   * @param persistentClass persistent class type for dataStore.
+   * @param properties  ArangoDB dataStore properties EG:- ArangoDB client 
credentials.
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+super.initialize(keyClass, persistentClass, properties);
+try {
+  arangoDbStoreParams = ArangoDBStoreParameters.load(properties);
+  arangoDB = new ArangoDB.Builder()
+  .host(arangoDbStoreParams.getServerHost(),
+  Integer.valueOf(arangoDbStoreParams.getServerPort()))
+  .user(arangoDbStoreParams.getUserName())
+  .password(arangoDbStoreParams.getUserPassword())
+  
.maxConnections(Integer.valueOf(arangoDbStoreParams.getConnectionPoolSize()))
+  .build();
+  if (!arangoDB.db(arangoDbStoreParams.getDatabaseName()).exists())
+arangoDB.createDatabase(arangoDbStoreParams.getDatabaseName());
+
+  ArangoDBMappingBuilder builder = new 
ArangoDBMappingBuilder<>(this);
+  arangoDBMapping = 
builder.fromFile(arangoDbStoreParams.getMappingFile()).build();
+  if (!schemaExists()) {
+createSchema();
+  }
+} catch (Exception e) {
+  LOG.error("Error while initializing ArangoDB dataStore: {}",
+  new Object[]{e.getMessage()});
+  throw new RuntimeException(e);
+}
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName(final String mappingSchemaName,
+  final Class persistentClass) {
+return super.getSchemaName(mappingSchemaName, persistentClass);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName() {
+return arangoDBMapping.getDocumentClass();
+  }
+
+  /**
+   * {@inheritDoc}
+   * Create a new class of ArangoDB documents if necessary. Enforce specified 
schema over the document class.
+   */
+  @Override
+  public void 

[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344734#comment-17344734
 ] 

ASF GitHub Bot commented on GORA-650:
-

kamaci commented on a change in pull request #218:
URL: https://github.com/apache/gora/pull/218#discussion_r632676232



##
File path: 
gora-arangodb/src/main/java/org/apache/gora/arangodb/store/ArangoDBStore.java
##
@@ -0,0 +1,690 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gora.arangodb.store;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+
+import com.arangodb.ArangoDB;
+import com.arangodb.entity.BaseDocument;
+import org.apache.avro.Schema;
+import org.apache.avro.util.Utf8;
+import org.apache.gora.arangodb.query.ArangoDBQuery;
+import org.apache.gora.persistency.impl.BeanFactoryImpl;
+import org.apache.gora.persistency.impl.DirtyListWrapper;
+import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.AvroUtils;
+import org.apache.gora.util.ClassLoadingUtils;
+import org.apache.gora.util.GoraException;
+
+
+/**
+ * {@inheritDoc}
+ * {@link org.apache.gora.arangodb.store.ArangoDBStore} is the primary class
+ * responsible for facilitating GORA CRUD operations on ArangoDB documents.
+ */
+public class ArangoDBStore extends 
DataStoreBase {
+
+  public static final String DEFAULT_MAPPING_FILE = 
"/gora-arangodb-mapping.xml";
+  private ArangoDBStoreParameters arangoDbStoreParams;
+  private ArangoDBMapping arangoDBMapping;
+  private ArangoDB arangoDB;
+
+  /**
+   * {@inheritDoc}
+   * Initialize the ArangoDB dataStore by {@link Properties} parameters.
+   *
+   * @param keyClasskey class type for dataStore.
+   * @param persistentClass persistent class type for dataStore.
+   * @param properties  ArangoDB dataStore properties EG:- ArangoDB client 
credentials.
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+super.initialize(keyClass, persistentClass, properties);
+try {
+  arangoDbStoreParams = ArangoDBStoreParameters.load(properties);
+  arangoDB = new ArangoDB.Builder()
+  .host(arangoDbStoreParams.getServerHost(),
+  Integer.valueOf(arangoDbStoreParams.getServerPort()))
+  .user(arangoDbStoreParams.getUserName())
+  .password(arangoDbStoreParams.getUserPassword())
+  
.maxConnections(Integer.valueOf(arangoDbStoreParams.getConnectionPoolSize()))
+  .build();
+  if (!arangoDB.db(arangoDbStoreParams.getDatabaseName()).exists())
+arangoDB.createDatabase(arangoDbStoreParams.getDatabaseName());
+
+  ArangoDBMappingBuilder builder = new 
ArangoDBMappingBuilder<>(this);
+  arangoDBMapping = 
builder.fromFile(arangoDbStoreParams.getMappingFile()).build();
+  if (!schemaExists()) {
+createSchema();
+  }
+} catch (Exception e) {
+  LOG.error("Error while initializing ArangoDB dataStore: {}",
+  new Object[]{e.getMessage()});
+  throw new RuntimeException(e);
+}
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName(final String mappingSchemaName,
+  final Class persistentClass) {
+return super.getSchemaName(mappingSchemaName, persistentClass);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName() {
+return arangoDBMapping.getDocumentClass();
+  }
+
+  /**
+   * {@inheritDoc}
+   * Create a new class of ArangoDB documents if necessary. Enforce specified 
schema over the document class.
+   */
+  @Override
+  public void 

[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344733#comment-17344733
 ] 

ASF GitHub Bot commented on GORA-650:
-

kamaci commented on a change in pull request #218:
URL: https://github.com/apache/gora/pull/218#discussion_r632675878



##
File path: 
gora-arangodb/src/main/java/org/apache/gora/arangodb/store/ArangoDBStore.java
##
@@ -0,0 +1,690 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gora.arangodb.store;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+
+import com.arangodb.ArangoDB;
+import com.arangodb.entity.BaseDocument;
+import org.apache.avro.Schema;
+import org.apache.avro.util.Utf8;
+import org.apache.gora.arangodb.query.ArangoDBQuery;
+import org.apache.gora.persistency.impl.BeanFactoryImpl;
+import org.apache.gora.persistency.impl.DirtyListWrapper;
+import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.AvroUtils;
+import org.apache.gora.util.ClassLoadingUtils;
+import org.apache.gora.util.GoraException;
+
+
+/**
+ * {@inheritDoc}
+ * {@link org.apache.gora.arangodb.store.ArangoDBStore} is the primary class
+ * responsible for facilitating GORA CRUD operations on ArangoDB documents.
+ */
+public class ArangoDBStore extends 
DataStoreBase {
+
+  public static final String DEFAULT_MAPPING_FILE = 
"/gora-arangodb-mapping.xml";
+  private ArangoDBStoreParameters arangoDbStoreParams;
+  private ArangoDBMapping arangoDBMapping;
+  private ArangoDB arangoDB;
+
+  /**
+   * {@inheritDoc}
+   * Initialize the ArangoDB dataStore by {@link Properties} parameters.
+   *
+   * @param keyClasskey class type for dataStore.
+   * @param persistentClass persistent class type for dataStore.
+   * @param properties  ArangoDB dataStore properties EG:- ArangoDB client 
credentials.
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+super.initialize(keyClass, persistentClass, properties);
+try {
+  arangoDbStoreParams = ArangoDBStoreParameters.load(properties);
+  arangoDB = new ArangoDB.Builder()
+  .host(arangoDbStoreParams.getServerHost(),
+  Integer.valueOf(arangoDbStoreParams.getServerPort()))
+  .user(arangoDbStoreParams.getUserName())
+  .password(arangoDbStoreParams.getUserPassword())
+  
.maxConnections(Integer.valueOf(arangoDbStoreParams.getConnectionPoolSize()))
+  .build();
+  if (!arangoDB.db(arangoDbStoreParams.getDatabaseName()).exists())
+arangoDB.createDatabase(arangoDbStoreParams.getDatabaseName());
+
+  ArangoDBMappingBuilder builder = new 
ArangoDBMappingBuilder<>(this);
+  arangoDBMapping = 
builder.fromFile(arangoDbStoreParams.getMappingFile()).build();
+  if (!schemaExists()) {
+createSchema();
+  }
+} catch (Exception e) {
+  LOG.error("Error while initializing ArangoDB dataStore: {}",
+  new Object[]{e.getMessage()});
+  throw new RuntimeException(e);
+}
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName(final String mappingSchemaName,
+  final Class persistentClass) {
+return super.getSchemaName(mappingSchemaName, persistentClass);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName() {
+return arangoDBMapping.getDocumentClass();
+  }
+
+  /**
+   * {@inheritDoc}
+   * Create a new class of ArangoDB documents if necessary. Enforce specified 
schema over the document class.
+   */
+  @Override
+  public void 

[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344732#comment-17344732
 ] 

ASF GitHub Bot commented on GORA-650:
-

kamaci commented on a change in pull request #218:
URL: https://github.com/apache/gora/pull/218#discussion_r632675729



##
File path: 
gora-arangodb/src/main/java/org/apache/gora/arangodb/store/ArangoDBStore.java
##
@@ -0,0 +1,690 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gora.arangodb.store;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.Base64;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.List;
+import java.util.ArrayList;
+
+import com.arangodb.ArangoDB;
+import com.arangodb.entity.BaseDocument;
+import org.apache.avro.Schema;
+import org.apache.avro.util.Utf8;
+import org.apache.gora.arangodb.query.ArangoDBQuery;
+import org.apache.gora.persistency.impl.BeanFactoryImpl;
+import org.apache.gora.persistency.impl.DirtyListWrapper;
+import org.apache.gora.persistency.impl.DirtyMapWrapper;
+import org.apache.gora.persistency.impl.PersistentBase;
+import org.apache.gora.query.PartitionQuery;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.query.impl.PartitionQueryImpl;
+import org.apache.gora.store.impl.DataStoreBase;
+import org.apache.gora.util.AvroUtils;
+import org.apache.gora.util.ClassLoadingUtils;
+import org.apache.gora.util.GoraException;
+
+
+/**
+ * {@inheritDoc}
+ * {@link org.apache.gora.arangodb.store.ArangoDBStore} is the primary class
+ * responsible for facilitating GORA CRUD operations on ArangoDB documents.
+ */
+public class ArangoDBStore extends 
DataStoreBase {
+
+  public static final String DEFAULT_MAPPING_FILE = 
"/gora-arangodb-mapping.xml";
+  private ArangoDBStoreParameters arangoDbStoreParams;
+  private ArangoDBMapping arangoDBMapping;
+  private ArangoDB arangoDB;
+
+  /**
+   * {@inheritDoc}
+   * Initialize the ArangoDB dataStore by {@link Properties} parameters.
+   *
+   * @param keyClasskey class type for dataStore.
+   * @param persistentClass persistent class type for dataStore.
+   * @param properties  ArangoDB dataStore properties EG:- ArangoDB client 
credentials.
+   */
+  @Override
+  public void initialize(Class keyClass, Class persistentClass, 
Properties properties) throws GoraException {
+super.initialize(keyClass, persistentClass, properties);
+try {
+  arangoDbStoreParams = ArangoDBStoreParameters.load(properties);
+  arangoDB = new ArangoDB.Builder()
+  .host(arangoDbStoreParams.getServerHost(),
+  Integer.valueOf(arangoDbStoreParams.getServerPort()))
+  .user(arangoDbStoreParams.getUserName())
+  .password(arangoDbStoreParams.getUserPassword())
+  
.maxConnections(Integer.valueOf(arangoDbStoreParams.getConnectionPoolSize()))
+  .build();
+  if (!arangoDB.db(arangoDbStoreParams.getDatabaseName()).exists())
+arangoDB.createDatabase(arangoDbStoreParams.getDatabaseName());
+
+  ArangoDBMappingBuilder builder = new 
ArangoDBMappingBuilder<>(this);
+  arangoDBMapping = 
builder.fromFile(arangoDbStoreParams.getMappingFile()).build();
+  if (!schemaExists()) {
+createSchema();
+  }
+} catch (Exception e) {
+  LOG.error("Error while initializing ArangoDB dataStore: {}",
+  new Object[]{e.getMessage()});
+  throw new RuntimeException(e);
+}
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName(final String mappingSchemaName,
+  final Class persistentClass) {
+return super.getSchemaName(mappingSchemaName, persistentClass);
+  }
+
+  /**
+   * {@inheritDoc}
+   */
+  @Override
+  public String getSchemaName() {
+return arangoDBMapping.getDocumentClass();
+  }
+
+  /**
+   * {@inheritDoc}
+   * Create a new class of ArangoDB documents if necessary. Enforce specified 
schema over the document class.
+   */
+  @Override
+  public void 

[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2021-05-14 Thread ASF GitHub Bot (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17344730#comment-17344730
 ] 

ASF GitHub Bot commented on GORA-650:
-

kamaci commented on a change in pull request #218:
URL: https://github.com/apache/gora/pull/218#discussion_r632675364



##
File path: 
gora-arangodb/src/main/java/org/apache/gora/arangodb/store/ArangoDBMappingBuilder.java
##
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.gora.arangodb.store;
+
+import org.apache.gora.persistency.impl.PersistentBase;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Utility builder for create ArangoDB mapping from gora-arango-mapping.xml.
+ */
+public class ArangoDBMappingBuilder {
+
+  public static final String ATT_NAME = "name";
+  public static final String ATT_TYPE = "type";
+  public static final String TAG_CLASS = "class";
+  public static final String ATT_KEYCLASS = "keyClass";
+  public static final String ATT_DOCUMENT = "document";
+  public static final String TAG_FIELD = "field";
+  public static final String ATT_FIELD = "docfield";
+  public static final Logger log = 
LoggerFactory.getLogger(ArangoDBMappingBuilder.class);
+
+  private final ArangoDBStore dataStore;
+
+  private ArangoDBMapping mapping;
+
+  public ArangoDBMappingBuilder(final ArangoDBStore store) {
+this.dataStore = store;
+this.mapping = new ArangoDBMapping();
+  }
+
+  public ArangoDBMapping build() {
+if (mapping.getDocumentClass() == null)
+  throw new IllegalStateException("Document Class is not specified.");
+return mapping;
+  }
+
+  protected ArangoDBMappingBuilder fromFile(String uri) throws IOException {
+try {
+  SAXBuilder saxBuilder = new SAXBuilder();
+  InputStream is = getClass().getResourceAsStream(uri);
+  if (is == null) {
+String msg = "Unable to load the mapping from classpath resource '" + 
uri
++ "' Re-trying local from local file system location.";
+log.warn(msg);
+is = new FileInputStream(uri);
+  }
+  Document doc = saxBuilder.build(is);
+  Element root = doc.getRootElement();
+  List classElements = root.getChildren(TAG_CLASS);
+  for (Element classElement : classElements) {
+final Class persistentClass = dataStore.getPersistentClass();
+final Class keyClass = dataStore.getKeyClass();
+if (matchesKeyClassWithMapping(keyClass, classElement)
+&& matchesPersistentClassWithMapping(persistentClass, 
classElement)) {
+  loadPersistentClass(classElement, persistentClass);
+  break;
+}
+  }
+} catch (IOException ex) {
+  throw ex;
+} catch (Exception ex) {

Review comment:
   Instead of this catch `Exception` and throw `IOException`.
   
   On the other hand, what is the reason to wrap `Exception` as `IOException`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> Add datastore for ArangoDB
> --
>
> Key: GORA-650
> URL: https://issues.apache.org/jira/browse/GORA-650
> Project: Apache Gora
>  Issue Type: New Feature
>Affects Versions: 0.9
>Reporter: Kevin Ratnasekera
>Priority: Major
>  Labels: gsoc2020
>  Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> May be we should consider extending our multimodal datastore support with 
> ArangoDB. [1] 
> [1] https://www.arangodb.com/why-arangodb/multi-model/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)


[jira] [Commented] (GORA-650) Add datastore for ArangoDB

2020-12-29 Thread Thanoshan MV (Jira)


[ 
https://issues.apache.org/jira/browse/GORA-650?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17256024#comment-17256024
 ] 

Thanoshan MV commented on GORA-650:
---

Hi, I would like to contribute to this project. Please help me get started. 

> Add datastore for ArangoDB
> --
>
> Key: GORA-650
> URL: https://issues.apache.org/jira/browse/GORA-650
> Project: Apache Gora
>  Issue Type: New Feature
>Affects Versions: 0.9
>Reporter: Kevin Ratnasekera
>Priority: Major
>  Labels: gsoc2020
>  Time Spent: 20m
>  Remaining Estimate: 0h
>
> May be we should consider extending our multimodal datastore support with 
> ArangoDB. [1] 
> [1] https://www.arangodb.com/why-arangodb/multi-model/



--
This message was sent by Atlassian Jira
(v8.3.4#803005)