Skip to content

Commit

Permalink
Merge pull request #25 from schernolyas/version_0.1.3
Browse files Browse the repository at this point in the history
Version 0.1.3
  • Loading branch information
eugene-kamenev authored Jan 11, 2019
2 parents 38f6c43 + c134eb3 commit 486f747
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 18 deletions.
34 changes: 20 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,7 @@ plugins {
}

group 'com.github.eugene-kamenev'
version '0.1.2'

allprojects {
repositories {
jcenter()
}
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'groovy'
}
version '0.1.3'

def file = new File('bintray.gradle')
if (file.exists()) {
Expand All @@ -27,23 +18,29 @@ if (file.exists()) {

apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'maven'
apply plugin: 'maven-publish'

sourceCompatibility = 1.7
sourceCompatibility = 1.8

repositories {
jcenter()
mavenCentral()
mavenLocal()
}

def groovy = '2.4.5'
def orientDb = '2.2.0-beta'
def orientDb = '2.2.37'

dependencies {
compile("org.codehaus.groovy:groovy-all:${groovy}")
compile("com.orientechnologies:orientdb-core:${orientDb}")
compile("com.orientechnologies:orientdb-client:${orientDb}")
compile("com.orientechnologies:orientdb-graphdb:${orientDb}")
testCompile "org.spockframework:spock-core:1.0-groovy-2.4"
compile group: 'asm', name: 'asm-all', version: '3.3.1'
compile "com.tinkerpop.gremlin:gremlin-groovy:2.6.0"

testCompile "org.spockframework:spock-core:1.2-groovy-2.4"
}

task sourcesJar(type: Jar) {
Expand All @@ -64,4 +61,13 @@ artifacts {
archives javadocJar
archives sourcesJar
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.eugene.kamenev.orient
import com.github.eugene.kamenev.orient.document.OrientDocumentHelper
import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal
import com.orientechnologies.orient.core.id.ORecordId
import com.orientechnologies.orient.core.record.impl.ODocument
import groovy.transform.CompileStatic
Expand Down Expand Up @@ -35,6 +37,7 @@ class OrientDSL {
* @return
*/
static <T> T get(Class<T> clazz, String rid) {
OrientDocumentHelper.transformDocument(clazz, (ODocument) new ODocument().getDatabaseIfDefined().getRecord(new ORecordId(rid)))
ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get()
OrientDocumentHelper.transformDocument(clazz, (ODocument) db.getRecord(new ORecordId(rid)))
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package com.github.eugene.kamenev.orient.document

import com.orientechnologies.orient.core.db.ODatabaseDocumentInternal
import com.orientechnologies.orient.core.db.ODatabaseRecordThreadLocal
import com.orientechnologies.orient.core.metadata.schema.OType
import com.orientechnologies.orient.core.record.impl.ODocument
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
Expand All @@ -25,7 +28,8 @@ class OrientDocumentHelper {
*/
static <T> Object executeQuery(Class<T> clazz, String query, boolean singleResult, ... params) {
def orientQuery = new OSQLSynchQuery<ODocument>(query)
List<ODocument> result = (List<ODocument>) new ODocument().getDatabaseIfDefined().command(orientQuery).execute(params)
ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get()
List<ODocument> result = (List<ODocument>) db.command(orientQuery).execute(params)
if (singleResult) {
return transformDocument(clazz, result[0])
}
Expand Down Expand Up @@ -113,7 +117,8 @@ class OrientDocumentHelper {
* @return
*/
static <T> Iterable<T> iterate(Class clazz, String className) {
return new DocumentIterator<T>(new ODocument().databaseIfDefined.browseClass(className), clazz)
ODatabaseDocumentInternal db = ODatabaseRecordThreadLocal.instance().get()
return new DocumentIterator<T>(db.browseClass(className), clazz)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class OrientGraphTransformationTest extends Specification {

def 'test that transformations applied right'() {
given: 'orient graph instance'
def orient = new OrientGraph(db)
def orient = new OrientGraph(db,false)
orient.begin()
and: 'few entities'
def first = new Person(firstName: 'Gomer', lastName: 'Simpson')
Expand Down

0 comments on commit 486f747

Please sign in to comment.