diff --git a/README.md b/README.md index 58960a8..1458ec0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ OrientDB Scala DSL **It's a Scala DSL for OrientDb...** [](https://travis-ci.org/acme-software/orientdb-scala-dsl) - +[](https://raw.githubusercontent.com/acme-software/orientdb-scala-dsl/master/LICENSE) + + *Disclaimer:* *Neiher this code, documentation nor any part of this repository is officially connected/related to @@ -69,24 +71,58 @@ g.getVertexType("Person").dsl withProperty "age" -> INTEGER ```scala // things needed from java driver import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory -import com.orientechnologies.orient.core.metadata.schema.OType._ - -// java converters for collections -import scala.collection.JavaConverters._ // scala dsl import import ch.acmesoftware.orientDbScalaDsl._ -val g = new OrientGraphFactory("memory:orientDbScalaDslTest").getNoTx +val g = new OrientGraphFactory("memory:orientDbScalaDslTest").getTx // add vertex g.dsl addVertex "Person" withProperty "name" -> "Frank" g.dsl addVertex "Customer" withProperty "name" -> "ACME" and "active" -> true +g.dsl addVertex "Customer" withProperty "name" -> Some("ACME") and "active" -> None // only "name" is persisted +g.dsl addVertex "Customer" withProperty "name" -> null // ugly, but no exception - don't work with null in Scala ;) + +// find & filter +g.dsl findVertices "City" single() +g.dsl findVertices "City" filter "name" -> "Zurich" filter "zip" -> 8000 single() // Option[VertexDsl] +g.dsl findVertices "City" filter "name" -> "Zurich" list() // Iterable[VertexDsl] +g.dsl findVertices "City" filter "name" -> "Zurich" list() take 3 // Iterable[VertexDsl] (first 3) // edit existing -val existing = g.getVerticesOfClass("Customer").asScala.last -existing.dsl withProperty "name" -> "ACME Software Solutions" and "year" -> 2017 +val existing = g.dsl findVertices "Customer" single() +existing foreach(_ withProperty "name" -> "ACME Software Solutions" and "year" -> 2017) + +// get property +val name: Option[String] = existing.flatMap(v => v.property[String]("name")) + +// get mandatory property (nullable) - only use this with schema +val name2: String = existing.map(v => v.mandatoryProperty[String]("name")).orNull +``` + +### Edge Type + +TBD + +### Edge + +```scala +// things needed from java driver +import com.tinkerpop.blueprints.impls.orient.OrientGraphFactory + +// scala dsl import +import ch.acmesoftware.orientDbScalaDsl._ + +val g = new OrientGraphFactory("memory:orientDbScalaDslTest").getTx + +val company = g.dsl addVertex "Company" +val employee = g.dsl addVertex "Employee" + +// create edge: Employee --(WorksFor)--> Company +val e1 = g.dsl addEdge "WorksFor" -> (employee -> company) +// add properties... +e1 withProperty "sinde" -> 2011 and "position" -> "Manager" ``` Get Involved diff --git a/bin/prepare-release.sh b/bin/prepare-release.sh new file mode 100755 index 0000000..dd94815 --- /dev/null +++ b/bin/prepare-release.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# pre release tasks +sbt +test +doc + +# sync documentation +rm -rf docs/api +mkdir -p docs/api/2.11 +mkdir -p docs/api/2.12 +cp -R target/scala-2.11/api/* docs/api/2.11 +cp -R target/scala-2.12/api/* docs/api/2.12 diff --git a/build.sbt b/build.sbt index 9dd81bc..6a30991 100644 --- a/build.sbt +++ b/build.sbt @@ -20,9 +20,9 @@ scalacOptions in Compile ++= Seq( "-Xlint" ) -scalacOptions ++= Seq( - "-J-Xms256M", - "-J-Xmx1G" +javaOptions in Test ++= Seq( + "-Xms256M", + "-Xmx1G" ) libraryDependencies ++= Dependencies.db ++ Dependencies.testing diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..921f072 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,8 @@ +OrinteDn Scala DSL - Documentation +================================= + +API Doc +------- + +**[Scala 2.11](api/2.11/index.html)** +**[Scala 2.12](api/2.12/index.html)** diff --git a/docs/api/2.11/ch/acmesoftware/orientDbScalaDsl/EdgeDsl.html b/docs/api/2.11/ch/acmesoftware/orientDbScalaDsl/EdgeDsl.html new file mode 100644 index 0000000..6f58d2c --- /dev/null +++ b/docs/api/2.11/ch/acmesoftware/orientDbScalaDsl/EdgeDsl.html @@ -0,0 +1,595 @@ + + +
+
+
+
+ The original Java instance to wrap
+
+
+
+
+
+
+
+
+
+
+
+ Alias for VertexDsl.withProperty
Alias for VertexDsl.withProperty
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Gets a mandatory property of a vertex
Gets a mandatory property of a vertex
Returns a property if it exists or not. This method can be used to retrieve properties baked in the schema, so
+ it must be present. The result is not wrapped in an Option[T], so if the property does not exist on the database
+ result will be null.
existing.dsl.mandatoryProperty[String]("name") // String
Property type
The filed name of the property
+
+
+
+
+
+
+
+
+
+
+
+ Gets a property of a vertex
Gets a property of a vertex
existing.dsl.property[String]("name") // Option[String]
Property type
The filed name of the property
+
+
+
+
+
+
+
+
+ The original Java instance to wrap
The original Java instance to wrap
+
+
+
+
+
+
+
+
+
+
+
+ Adds a property to existing edge
Adds a property to existing edge
existing.dsl withProperty "name" -> "ACME Software Solutions" and "year" -> 2017 +existing.dsl withProperty "name" -> Some("foo") // will be persisted +existing.dsl withProperty "name" -> None // nothing will happen +existing.dsl withProperty "name" -> null // nothing will happen
The property to set
+ ch.acmesoftware.orientDbScalaDsl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ch.acmesoftware.orientDbScalaDsl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Alias for VertexDsl.withProperty
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Gets a mandatory property of a vertex
Gets a mandatory property of a vertex
Returns a property if it exists or not. This method can be used to retrieve properties baked in the schema, so
+ it must be present. The result is not wrapped in an Option[T], so if the property does not exist on the database
+ result will be null.
existing.dsl.mandatoryProperty[String]("name") // String
Property type
The filed name of the property
+
+
+
+
+
+
+
+
+
+
+
+ Gets a property of a vertex
Gets a property of a vertex
existing.dsl.property[String]("name") // Option[String]
Property type
The filed name of the property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Adds a property to existing edge
Adds a property to existing edge
existing.dsl withProperty "name" -> "ACME Software Solutions" and "year" -> 2017 +existing.dsl withProperty "name" -> Some("foo") // will be persisted +existing.dsl withProperty "name" -> None // nothing will happen +existing.dsl withProperty "name" -> null // nothing will happen
The property to set
+ ch.acmesoftware.orientDbScalaDsl.GraphDsl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ DSL extension for the OrientBaseGraph class
See methods for detailed API and examples... +
+
+
+ The original Java instance to wrap
+
+
+
+
+
+
+
+
+
+
+
+ Add an edge to graph
Add an edge to graph
val company = g addVertex "Company" +val employee = g addVertex "Employee" + +// create edge: Employee --(WorksFor)--> Company +val e1 = g.dsl addEdge "WorksFor" -> (employee -> company)
The edge definition which is a nested tuple containing label and (in / out) vertices
The EdgeDsl of the just created edge
+
+
+ Adds a vertex to graph
Adds a vertex to graph
// add vertex +g.dsl addVertex "Person" withProperty "name" -> "Frank" +g.dsl addVertex "Customer" withProperty "name" -> "ACME" and "active" -> true
+
+
+
+
+
+
+
+
+ Commits the transaction
+
+
+
+ Creates a new vertex type (sometimes refered to as "class)
Creates a new vertex type (sometimes refered to as "class)
g.dsl createVertexType "SomeLabel" + +// ...with properties +g.dsl createVertexType "Person" withProperty "name" -> STRING +g.dsl createVertexType "User" withProperty "name" -> STRING and "active" -> BOOLEAN + +// ...and indexes +g.dsl createVertexType "City" withProperty "name" -> STRING and "zip" -> INTEGER unique "name" unique "zip" + +// edit existing vertex type +g.getVertexType("Person").dsl withProperty "age" -> INTEGER
The lable of the vertex type to create
An VertexTypeDsl instance
+
+
+
+
+
+
+
+
+
+
+
+ Creates a by-label filter query
Creates a by-label filter query
// single by label +g.dsl findVertices "City" single + +// single by label and properties +g.dsl findVertices "City" filter "name" -> "Zurich" filter "zip" -> 8000 single + +// list +g.dsl findVertices "City" filter "name" -> "Zurich" filter "zip" -> 8000 list
The label to filter by
A by-label filter query
+
+
+
+
+
+ Retrieves existing vertex type if present
Retrieves existing vertex type if present
g.dsl getVertexType "Existing" // Option[VertexTypeDsl]
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The original Java instance to wrap
+
+
+
+
+
+
+
+
+
+ DSL extension for the Vertex class
See methods for detailed API and examples... +
+
+
+ The original Java instance to wrap
+
+
+
+
+
+
+
+
+
+
+
+ Alias for VertexDsl.withProperty
Alias for VertexDsl.withProperty
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Gets a mandatory property of a vertex
Gets a mandatory property of a vertex
Returns a property if it exists or not. This method can be used to retrieve properties baked in the schema, so
+ it must be present. The result is not wrapped in an Option[T], so if the property does not exist on the database
+ result will be null.
existing.dsl.mandatoryProperty[String]("name") // String
Property type
The filed name of the property
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Gets a property of a vertex
Gets a property of a vertex
existing.dsl.property[String]("name") // Option[String]
Property type
The filed name of the property
+
+
+
+
+
+
+
+
+ The original Java instance to wrap
The original Java instance to wrap
+
+
+
+
+
+
+
+
+
+
+
+ Adds a property to existing edge
Adds a property to existing edge
existing.dsl withProperty "name" -> "ACME Software Solutions" and "year" -> 2017 +existing.dsl withProperty "name" -> Some("foo") // will be persisted +existing.dsl withProperty "name" -> None // nothing will happen +existing.dsl withProperty "name" -> null // nothing will happen
The property to set
+ ch.acmesoftware.orientDbScalaDsl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ch.acmesoftware.orientDbScalaDsl
+
+
+
+ DSL extension for the OrientVertexType class
See methods for detailed API and examples... +
+
+
+ The original Java instance to wrap
+
+
+
+
+
+
+
+
+
+
+
+ Alias for ch.acmesoftware.orientDbScalaDsl.VertexTypeDsl.withProperty
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The original Java instance to wrap
+
+
+
+ Adds unique index to existing vertex type
Adds unique index to existing vertex type
g.getVertexType("Person").dsl unique "name" unique "zip"
The name of the field which should be unique
+
+
+
+
+
+
+
+
+
+
+
+ Adds a property to existing vertex type
Adds a property to existing vertex type
g.getVertexType("Person").dsl withProperty "age" -> INTEGER
The property definition to add
+ ch.acmesoftware.orientDbScalaDsl
+
+
+
+ Wrapper providing VertexDsl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ch.acmesoftware.orientDbScalaDsl
+
+
+
+ Wrapper providing GraphDsl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ch.acmesoftware.orientDbScalaDsl
+
+
+
+ Wrapper providing VertexTypeDsl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ch.acmesoftware.orientDbScalaDsl
+
+
+
+ Wrapper providing VertexDsl
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Main DSL entry point
This package provides a set of implicit classes (wrappers) which can be imported
import ch.acmesoftware.orientDbScalaDsl._The above import statement decorates the OrientDB Java API with a fluid Scala DSL +
+
+
+ DSL extension for the Edge class
DSL extension for the Edge class
See methods for detailed API and examples... +
+
+
+ Wrapper providing VertexDsl
+
+
+
+
+
+
+
+ DSL extension for the OrientBaseGraph class
DSL extension for the OrientBaseGraph class
See methods for detailed API and examples... +
+
+
+ Wrapper providing GraphDsl
+
+
+
+ DSL extension for the Vertex class
DSL extension for the Vertex class
See methods for detailed API and examples... +
+
+
+ DSL extension for the OrientVertexType class
DSL extension for the OrientVertexType class
See methods for detailed API and examples... +
+
+
+ Wrapper providing VertexTypeDsl
+
+
+
+ Wrapper providing VertexDsl
+
+
+
+
+
+
+
+
+
+
+
+ Main DSL entry point
Main DSL entry point
This package provides a set of implicit classes (wrappers) which can be imported
import ch.acmesoftware.orientDbScalaDsl._The above import statement decorates the OrientDB Java API with a fluid Scala DSL +
+
+
+
+
+
+
+
+ | t |
| t |
DSL extension for the
EdgeclassSee methods for detailed API and examples... +