diff --git a/l2jserver2-common/pom.xml b/l2jserver2-common/pom.xml
index 846a947d8..ae6ab77a7 100644
--- a/l2jserver2-common/pom.xml
+++ b/l2jserver2-common/pom.xml
@@ -124,6 +124,16 @@
jarruntime
+
+ com.orientechnologies
+ orient-commons
+ 1.0rc7
+
+
+ com.orientechnologies
+ orientdb-core
+ 1.0rc7
+ com.h2databaseh2
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/DatabaseService.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/DatabaseService.java
index 427582b7e..102279c0e 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/DatabaseService.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/DatabaseService.java
@@ -16,12 +16,16 @@
*/
package com.l2jserver.service.database;
+import java.io.IOException;
+import java.nio.file.Path;
+
import com.l2jserver.model.Model;
import com.l2jserver.model.id.ID;
import com.l2jserver.service.Service;
import com.l2jserver.service.ServiceConfiguration;
import com.l2jserver.service.configuration.Configuration;
import com.l2jserver.service.core.threading.AsyncFuture;
+import com.mysema.query.sql.RelationalPathBase;
/**
* This service provides access to an database implementation. Each
@@ -101,6 +105,26 @@ public interface DatabaseService extends Service {
int perform();
}
+ /**
+ * Imports an static data file into the database. File must be an CSV file
+ * with the first row as column names.
+ *
+ * @param
+ * the model type
+ * @param
+ * the table type
+ *
+ * @param path
+ * the path
+ * @param entity
+ * the table
+ * @throws IOException
+ * if any error occur while reading or parsing the file
+ */
+ , T extends RelationalPathBase>> void importData(
+ Path path, T entity)
+ throws IOException;
+
/**
* Checks for the cached version of the object
*
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/StaticDatabaseRow.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/StaticDatabaseRow.java
new file mode 100644
index 000000000..635bbe4e2
--- /dev/null
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/StaticDatabaseRow.java
@@ -0,0 +1,59 @@
+/*
+ * This file is part of l2jserver2 .
+ *
+ * l2jserver2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * l2jserver2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with l2jserver2. If not, see .
+ */
+package com.l2jserver.service.database;
+
+import java.util.Map;
+
+import com.l2jserver.service.database.dao.DatabaseRow;
+import com.l2jserver.util.transformer.Transformer;
+import com.l2jserver.util.transformer.TransformerFactory;
+import com.mysema.query.types.Path;
+
+/**
+ * @author Rogiel
+ *
+ */
+public class StaticDatabaseRow implements DatabaseRow {
+ /**
+ * The static data
+ */
+ private final Map data;
+
+ /**
+ * @param data
+ * the data
+ */
+ public StaticDatabaseRow(Map data) {
+ this.data = data;
+ }
+
+ @Override
+ public T get(Path path) {
+ final String value = data.get(path.getMetadata().getExpression()
+ .toString());
+ @SuppressWarnings("unchecked")
+ Transformer transformer = (Transformer) TransformerFactory
+ .getTransfromer(path.getType());
+ return transformer.untransform(path.getType(), value);
+ }
+
+ @Override
+ public boolean isNull(Path path) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+}
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/QueryFactory.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/QueryFactory.java
similarity index 95%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/QueryFactory.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/QueryFactory.java
index 5938627e3..17b16b7a1 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/QueryFactory.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/QueryFactory.java
@@ -14,15 +14,15 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl;
+package com.l2jserver.service.database.ddl;
import java.util.List;
-import com.l2jserver.service.database.sql.ddl.struct.Column;
-import com.l2jserver.service.database.sql.ddl.struct.Column.ColumnType;
-import com.l2jserver.service.database.sql.ddl.struct.ForeignKey;
-import com.l2jserver.service.database.sql.ddl.struct.PrimaryKey;
-import com.l2jserver.service.database.sql.ddl.struct.Table;
+import com.l2jserver.service.database.ddl.struct.Column;
+import com.l2jserver.service.database.ddl.struct.ForeignKey;
+import com.l2jserver.service.database.ddl.struct.PrimaryKey;
+import com.l2jserver.service.database.ddl.struct.Table;
+import com.l2jserver.service.database.ddl.struct.Column.ColumnType;
import com.l2jserver.util.factory.CollectionFactory;
/**
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/QueryTemplate.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/QueryTemplate.java
similarity index 94%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/QueryTemplate.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/QueryTemplate.java
index f494b8019..eded8ea9c 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/QueryTemplate.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/QueryTemplate.java
@@ -14,9 +14,9 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl;
+package com.l2jserver.service.database.ddl;
-import com.l2jserver.service.database.sql.ddl.struct.Column.ColumnType;
+import com.l2jserver.service.database.ddl.struct.Column.ColumnType;
import com.mysema.query.sql.SQLTemplates;
/**
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/TableFactory.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/TableFactory.java
similarity index 91%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/TableFactory.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/TableFactory.java
index e884dd8f2..eec2a74f7 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/TableFactory.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/TableFactory.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl;
+package com.l2jserver.service.database.ddl;
import java.lang.reflect.Field;
import java.sql.Connection;
@@ -27,15 +27,15 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
-import com.l2jserver.service.database.sql.ddl.annotation.ColumnAutoIncrement;
-import com.l2jserver.service.database.sql.ddl.annotation.ColumnDefault;
-import com.l2jserver.service.database.sql.ddl.annotation.ColumnNullable;
-import com.l2jserver.service.database.sql.ddl.annotation.ColumnSize;
-import com.l2jserver.service.database.sql.ddl.struct.Column;
-import com.l2jserver.service.database.sql.ddl.struct.Column.ColumnType;
-import com.l2jserver.service.database.sql.ddl.struct.ForeignKey;
-import com.l2jserver.service.database.sql.ddl.struct.PrimaryKey;
-import com.l2jserver.service.database.sql.ddl.struct.Table;
+import com.l2jserver.service.database.ddl.annotation.ColumnAutoIncrement;
+import com.l2jserver.service.database.ddl.annotation.ColumnDefault;
+import com.l2jserver.service.database.ddl.annotation.ColumnNullable;
+import com.l2jserver.service.database.ddl.annotation.ColumnSize;
+import com.l2jserver.service.database.ddl.struct.Column;
+import com.l2jserver.service.database.ddl.struct.ForeignKey;
+import com.l2jserver.service.database.ddl.struct.PrimaryKey;
+import com.l2jserver.service.database.ddl.struct.Table;
+import com.l2jserver.service.database.ddl.struct.Column.ColumnType;
import com.l2jserver.util.ClassUtils;
import com.l2jserver.util.factory.CollectionFactory;
import com.mysema.query.sql.RelationalPathBase;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnAutoIncrement.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnAutoIncrement.java
similarity index 95%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnAutoIncrement.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnAutoIncrement.java
index 89e709099..de7069bd3 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnAutoIncrement.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnAutoIncrement.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.annotation;
+package com.l2jserver.service.database.ddl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnDefault.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnDefault.java
similarity index 95%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnDefault.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnDefault.java
index 6ed155558..f01385a5d 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnDefault.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnDefault.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.annotation;
+package com.l2jserver.service.database.ddl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnNullable.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnNullable.java
similarity index 95%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnNullable.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnNullable.java
index 4d2bb514e..08df11743 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnNullable.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnNullable.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.annotation;
+package com.l2jserver.service.database.ddl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnSize.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnSize.java
similarity index 95%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnSize.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnSize.java
index 41595b452..579010992 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/annotation/ColumnSize.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/annotation/ColumnSize.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.annotation;
+package com.l2jserver.service.database.ddl.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/Column.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/Column.java
similarity index 98%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/Column.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/Column.java
index c9f72e5ad..404b759f1 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/Column.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/Column.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.struct;
+package com.l2jserver.service.database.ddl.struct;
import java.util.List;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/ForeignKey.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/ForeignKey.java
similarity index 96%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/ForeignKey.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/ForeignKey.java
index 86953e818..cf0244757 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/ForeignKey.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/ForeignKey.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.struct;
+package com.l2jserver.service.database.ddl.struct;
import java.util.Collections;
import java.util.List;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/PrimaryKey.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/PrimaryKey.java
similarity index 95%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/PrimaryKey.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/PrimaryKey.java
index 61f258300..a4ef3e667 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/PrimaryKey.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/PrimaryKey.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.struct;
+package com.l2jserver.service.database.ddl.struct;
/**
* @author Rogiel
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/Table.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/Table.java
similarity index 98%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/Table.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/Table.java
index d878f345b..71f64d7a9 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/struct/Table.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/struct/Table.java
@@ -14,7 +14,7 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.struct;
+package com.l2jserver.service.database.ddl.struct;
import java.util.Collection;
import java.util.Collections;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/DerbyTemplate.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/DerbyTemplate.java
similarity index 94%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/DerbyTemplate.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/DerbyTemplate.java
index 4b3808b66..1a600b2d2 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/DerbyTemplate.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/DerbyTemplate.java
@@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.template;
+package com.l2jserver.service.database.ddl.template;
-import com.l2jserver.service.database.sql.ddl.QueryTemplate;
-import com.l2jserver.service.database.sql.ddl.struct.Column.ColumnType;
+import com.l2jserver.service.database.ddl.QueryTemplate;
+import com.l2jserver.service.database.ddl.struct.Column.ColumnType;
import com.mysema.query.QueryMetadata;
import com.mysema.query.QueryModifiers;
import com.mysema.query.sql.support.SerializationContext;
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/H2Template.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/H2Template.java
similarity index 91%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/H2Template.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/H2Template.java
index 3bd755ac0..f8d10e7aa 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/H2Template.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/H2Template.java
@@ -14,10 +14,10 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.template;
+package com.l2jserver.service.database.ddl.template;
-import com.l2jserver.service.database.sql.ddl.QueryTemplate;
-import com.l2jserver.service.database.sql.ddl.struct.Column.ColumnType;
+import com.l2jserver.service.database.ddl.QueryTemplate;
+import com.l2jserver.service.database.ddl.struct.Column.ColumnType;
import com.mysema.query.types.Ops;
/**
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/MySQLTemplate.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/MySQLTemplate.java
similarity index 95%
rename from l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/MySQLTemplate.java
rename to l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/MySQLTemplate.java
index a28de4f02..d70c9ea39 100644
--- a/l2jserver2-common/src/main/java/com/l2jserver/service/database/sql/ddl/template/MySQLTemplate.java
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/ddl/template/MySQLTemplate.java
@@ -14,12 +14,12 @@
* You should have received a copy of the GNU General Public License
* along with l2jserver2. If not, see .
*/
-package com.l2jserver.service.database.sql.ddl.template;
+package com.l2jserver.service.database.ddl.template;
import java.math.BigDecimal;
-import com.l2jserver.service.database.sql.ddl.QueryTemplate;
-import com.l2jserver.service.database.sql.ddl.struct.Column.ColumnType;
+import com.l2jserver.service.database.ddl.QueryTemplate;
+import com.l2jserver.service.database.ddl.struct.Column.ColumnType;
import com.mysema.query.types.Ops;
/**
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/orientdb/AbstractOrientDBDAO.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/orientdb/AbstractOrientDBDAO.java
new file mode 100644
index 000000000..34322f887
--- /dev/null
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/orientdb/AbstractOrientDBDAO.java
@@ -0,0 +1,51 @@
+/*
+ * This file is part of l2jserver2 .
+ *
+ * l2jserver2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * l2jserver2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with l2jserver2. If not, see .
+ */
+package com.l2jserver.service.database.orientdb;
+
+import com.google.inject.Inject;
+import com.l2jserver.model.Model;
+import com.l2jserver.model.id.ID;
+import com.l2jserver.service.database.AbstractDAO;
+import com.l2jserver.service.database.DatabaseService;
+
+/**
+ * {@link AbstractDAO} for OrientDB DAO implementation
+ *
+ * @author Rogiel
+ *
+ * @param
+ * the object for the DAO
+ * @param
+ * the object ID type
+ */
+public abstract class AbstractOrientDBDAO, I extends ID>>
+ extends AbstractDAO {
+ /**
+ * The JDBC Database Service
+ */
+ protected final AbstractOrientDatabaseService database;
+
+ /**
+ * @param database
+ * the database service
+ */
+ @Inject
+ protected AbstractOrientDBDAO(DatabaseService database) {
+ super(database);
+ this.database = (AbstractOrientDatabaseService) database;
+ }
+}
diff --git a/l2jserver2-common/src/main/java/com/l2jserver/service/database/orientdb/AbstractOrientDatabaseService.java b/l2jserver2-common/src/main/java/com/l2jserver/service/database/orientdb/AbstractOrientDatabaseService.java
new file mode 100644
index 000000000..c3b53ddb0
--- /dev/null
+++ b/l2jserver2-common/src/main/java/com/l2jserver/service/database/orientdb/AbstractOrientDatabaseService.java
@@ -0,0 +1,795 @@
+/*
+ * This file is part of l2jserver2 .
+ *
+ * l2jserver2 is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * l2jserver2 is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with l2jserver2. If not, see .
+ */
+package com.l2jserver.service.database.orientdb;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Iterators;
+import com.google.inject.Inject;
+import com.l2jserver.model.Model;
+import com.l2jserver.model.Model.ObjectDesire;
+import com.l2jserver.model.id.ID;
+import com.l2jserver.model.id.object.allocator.IDAllocator;
+import com.l2jserver.service.AbstractService;
+import com.l2jserver.service.ServiceStartException;
+import com.l2jserver.service.ServiceStopException;
+import com.l2jserver.service.cache.Cache;
+import com.l2jserver.service.cache.CacheService;
+import com.l2jserver.service.configuration.ConfigurationService;
+import com.l2jserver.service.configuration.XMLConfigurationService.ConfigurationXPath;
+import com.l2jserver.service.core.threading.AbstractTask;
+import com.l2jserver.service.core.threading.AsyncFuture;
+import com.l2jserver.service.core.threading.ScheduledAsyncFuture;
+import com.l2jserver.service.core.threading.ThreadService;
+import com.l2jserver.service.database.DAOResolver;
+import com.l2jserver.service.database.DataAccessObject;
+import com.l2jserver.service.database.DatabaseService;
+import com.l2jserver.service.database.dao.DatabaseRow;
+import com.l2jserver.service.database.dao.InsertMapper;
+import com.l2jserver.service.database.dao.SelectMapper;
+import com.l2jserver.service.database.dao.UpdateMapper;
+import com.l2jserver.util.factory.CollectionFactory;
+import com.mysema.query.sql.ForeignKey;
+import com.mysema.query.sql.RelationalPathBase;
+import com.mysema.query.types.Path;
+import com.orientechnologies.orient.core.db.document.ODatabaseDocumentPool;
+import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx;
+import com.orientechnologies.orient.core.metadata.schema.OClass;
+import com.orientechnologies.orient.core.metadata.schema.OClass.INDEX_TYPE;
+import com.orientechnologies.orient.core.metadata.schema.OProperty;
+import com.orientechnologies.orient.core.metadata.schema.OSchema;
+import com.orientechnologies.orient.core.metadata.schema.OType;
+import com.orientechnologies.orient.core.query.nativ.ONativeSynchQuery;
+import com.orientechnologies.orient.core.query.nativ.OQueryContextNative;
+import com.orientechnologies.orient.core.record.impl.ODocument;
+
+/**
+ * This is an implementation of {@link DatabaseService} that provides an layer
+ * to OrientDB Document Database.
+ *
+ *
Internal specification
The {@link Query} object
+ *
+ * If you wish to implement a new {@link DataAccessObject} you should try not
+ * use {@link Query} object directly because it only provides low level access
+ * to the JDBC architecture. Instead, you could use an specialized class, like
+ * {@link InsertQuery}, {@link SelectListQuery} or {@link SelectSingleQuery}. If
+ * you do need low level access, feel free to use the {@link Query} class
+ * directly.
+ *
+ *
The {@link SelectMapper} object
+ *
+ * The {@link SelectMapper} object maps an OrientDB {@link ODocument} into an
+ * Java {@link Object}.
+ *
+ * @author Rogiel
+ */
+public abstract class AbstractOrientDatabaseService extends AbstractService
+ implements DatabaseService {
+ /**
+ * The configuration object
+ */
+ private final OrientDatabaseConfiguration config;
+ /**
+ * The logger
+ */
+ private final Logger log = LoggerFactory
+ .getLogger(AbstractOrientDatabaseService.class);
+
+ /**
+ * The cache service
+ */
+ private final CacheService cacheService;
+ /**
+ * The thread service
+ */
+ private final ThreadService threadService;
+ /**
+ * The {@link DAOResolver} instance
+ */
+ private final DAOResolver daoResolver;
+
+ /**
+ * An cache object
+ */
+ private Cache