From 3364af79fd7ef428ba1fc01d0058ffffe795bb90 Mon Sep 17 00:00:00 2001 From: marcgrue Date: Sat, 9 Mar 2019 21:52:57 +0100 Subject: [PATCH] v0.18.1 Re-aligning Meta semantics --- README.md | 4 +- build.sbt | 2 +- core/src/main/scala/molecule/api/core.scala | 7 +- .../main/scala/molecule/api/get/GetList.scala | 2 +- .../molecule/api/getAsync/GetAsyncList.scala | 2 +- core/src/main/scala/molecule/ast/model.scala | 23 +- .../scala/molecule/ast/transactionModel.scala | 10 +- .../main/scala/molecule/boilerplate/in1.scala | 3 +- .../main/scala/molecule/boilerplate/in2.scala | 5 +- .../main/scala/molecule/boilerplate/in3.scala | 5 +- .../main/scala/molecule/boilerplate/out.scala | 5 +- .../expression/AggregateKeywordsSchema.scala | 4 +- .../src/main/scala/molecule/facade/Conn.scala | 12 +- .../scala/molecule/generic/GenericNs.scala | 3 - .../main/scala/molecule/generic/package.scala | 13 -- .../scala/molecule/input/InputMolecule.scala | 4 +- .../molecule/{generic => meta}/Log.scala | 4 +- .../src/main/scala/molecule/meta/MetaNs.scala | 3 + .../{generic => meta}/datom/Datom.scala | 3 +- .../{generic => meta}/datom/Datom_0.scala | 2 +- .../{generic => meta}/datom/Datom_1.scala | 2 +- .../{generic => meta}/datom/Datom_10.scala | 2 +- .../{generic => meta}/datom/Datom_11.scala | 2 +- .../{generic => meta}/datom/Datom_12.scala | 2 +- .../{generic => meta}/datom/Datom_13.scala | 2 +- .../{generic => meta}/datom/Datom_14.scala | 2 +- .../{generic => meta}/datom/Datom_15.scala | 2 +- .../{generic => meta}/datom/Datom_16.scala | 2 +- .../{generic => meta}/datom/Datom_17.scala | 2 +- .../{generic => meta}/datom/Datom_18.scala | 2 +- .../{generic => meta}/datom/Datom_19.scala | 2 +- .../{generic => meta}/datom/Datom_2.scala | 2 +- .../{generic => meta}/datom/Datom_20.scala | 2 +- .../{generic => meta}/datom/Datom_21.scala | 2 +- .../{generic => meta}/datom/Datom_22.scala | 2 +- .../{generic => meta}/datom/Datom_3.scala | 2 +- .../{generic => meta}/datom/Datom_4.scala | 2 +- .../{generic => meta}/datom/Datom_5.scala | 2 +- .../{generic => meta}/datom/Datom_6.scala | 2 +- .../{generic => meta}/datom/Datom_7.scala | 2 +- .../{generic => meta}/datom/Datom_8.scala | 2 +- .../{generic => meta}/datom/Datom_9.scala | 2 +- .../{generic => meta}/datom/package.scala | 8 +- .../{generic => meta}/index/AEVT.scala | 8 +- .../{generic => meta}/index/AVET.scala | 8 +- .../{generic => meta}/index/EAVT.scala | 8 +- .../{generic => meta}/index/VAET.scala | 8 +- .../{generic => meta}/index/package.scala | 4 +- .../main/scala/molecule/meta/package.scala | 13 ++ .../{generic => meta}/schema/Schema.scala | 6 +- .../{generic => meta}/schema/Schema_0.scala | 2 +- .../{generic => meta}/schema/Schema_1.scala | 2 +- .../{generic => meta}/schema/Schema_10.scala | 2 +- .../{generic => meta}/schema/Schema_11.scala | 2 +- .../{generic => meta}/schema/Schema_12.scala | 2 +- .../{generic => meta}/schema/Schema_13.scala | 2 +- .../{generic => meta}/schema/Schema_14.scala | 2 +- .../{generic => meta}/schema/Schema_15.scala | 2 +- .../{generic => meta}/schema/Schema_16.scala | 2 +- .../{generic => meta}/schema/Schema_17.scala | 2 +- .../{generic => meta}/schema/Schema_18.scala | 2 +- .../{generic => meta}/schema/Schema_19.scala | 2 +- .../{generic => meta}/schema/Schema_2.scala | 2 +- .../{generic => meta}/schema/Schema_20.scala | 2 +- .../{generic => meta}/schema/Schema_21.scala | 2 +- .../{generic => meta}/schema/Schema_22.scala | 2 +- .../{generic => meta}/schema/Schema_3.scala | 2 +- .../{generic => meta}/schema/Schema_4.scala | 2 +- .../{generic => meta}/schema/Schema_5.scala | 2 +- .../{generic => meta}/schema/Schema_6.scala | 2 +- .../{generic => meta}/schema/Schema_7.scala | 2 +- .../{generic => meta}/schema/Schema_8.scala | 2 +- .../{generic => meta}/schema/Schema_9.scala | 2 +- .../{generic => meta}/schema/package.scala | 2 +- .../main/scala/molecule/ops/Liftables.scala | 6 +- .../main/scala/molecule/ops/QueryOps.scala | 30 +-- .../src/main/scala/molecule/ops/TreeOps.scala | 8 +- core/src/main/scala/molecule/package.scala | 10 +- .../scala/molecule/transform/Dsl2Model.scala | 218 +++++++++--------- .../molecule/transform/Model2Query.scala | 181 +++++++-------- .../transform/Model2Transaction.scala | 11 +- .../schema/AEVTDefinition.scala | 2 +- .../schema/AVETDefinition.scala | 2 +- .../schema/DatomDefinition.scala | 2 +- .../schema/EAVTDefinition.scala | 2 +- .../schema/LogDefinition.scala | 2 +- .../schema/SchemaDefinition.scala | 2 +- .../schema/VAETDefinition.scala | 2 +- .../scala/molecule/coretests/AdHocTest.scala | 7 +- .../coretests/{generic => meta}/Datom.scala | 52 ++--- .../coretests/{generic => meta}/Index.scala | 4 +- .../coretests/{generic => meta}/LogTest.scala | 2 +- .../{generic => meta}/SchemaTest.scala | 2 +- .../molecule/coretests/time/GetHistory.scala | 4 +- .../mbrainz/schema/MBrainzDefinition.scala | 1 - .../examples/seattle/SeattleQueryTests.scala | 2 +- .../seattle/SeattleTransformationTests.scala | 14 +- 97 files changed, 421 insertions(+), 416 deletions(-) delete mode 100644 core/src/main/scala/molecule/generic/GenericNs.scala delete mode 100644 core/src/main/scala/molecule/generic/package.scala rename core/src/main/scala/molecule/{generic => meta}/Log.scala (99%) create mode 100644 core/src/main/scala/molecule/meta/MetaNs.scala rename core/src/main/scala/molecule/{generic => meta}/datom/Datom.scala (95%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_0.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_1.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_10.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_11.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_12.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_13.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_14.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_15.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_16.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_17.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_18.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_19.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_2.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_20.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_21.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_22.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_3.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_4.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_5.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_6.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_7.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_8.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/Datom_9.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/datom/package.scala (87%) rename core/src/main/scala/molecule/{generic => meta}/index/AEVT.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/index/AVET.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/index/EAVT.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/index/VAET.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/index/package.scala (94%) create mode 100644 core/src/main/scala/molecule/meta/package.scala rename core/src/main/scala/molecule/{generic => meta}/schema/Schema.scala (97%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_0.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_1.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_10.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_11.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_12.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_13.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_14.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_15.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_16.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_17.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_18.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_19.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_2.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_20.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_21.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_22.scala (98%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_3.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_4.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_5.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_6.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_7.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_8.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/Schema_9.scala (99%) rename core/src/main/scala/molecule/{generic => meta}/schema/package.scala (99%) rename coretests/src/main/scala/molecule/coretests/{generic => meta}/schema/AEVTDefinition.scala (73%) rename coretests/src/main/scala/molecule/coretests/{generic => meta}/schema/AVETDefinition.scala (73%) rename coretests/src/main/scala/molecule/coretests/{generic => meta}/schema/DatomDefinition.scala (93%) rename coretests/src/main/scala/molecule/coretests/{generic => meta}/schema/EAVTDefinition.scala (73%) rename coretests/src/main/scala/molecule/coretests/{generic => meta}/schema/LogDefinition.scala (73%) rename coretests/src/main/scala/molecule/coretests/{generic => meta}/schema/SchemaDefinition.scala (97%) rename coretests/src/main/scala/molecule/coretests/{generic => meta}/schema/VAETDefinition.scala (73%) rename coretests/src/test/scala/molecule/coretests/{generic => meta}/Datom.scala (89%) rename coretests/src/test/scala/molecule/coretests/{generic => meta}/Index.scala (99%) rename coretests/src/test/scala/molecule/coretests/{generic => meta}/LogTest.scala (99%) rename coretests/src/test/scala/molecule/coretests/{generic => meta}/SchemaTest.scala (99%) diff --git a/README.md b/README.md index 2792943ce..f74b0979c 100644 --- a/README.md +++ b/README.md @@ -97,13 +97,13 @@ lazy val yourProject = project.in(file("app")) Resolver.sonatypeRepo("releases") ), libraryDependencies ++= Seq( - "org.scalamolecule" %% "molecule" % "0.18.0", + "org.scalamolecule" %% "molecule" % "0.18.1", "com.datomic" % "datomic-free" % "0.9.5697" ), moleculeSchemas := Seq("app") // paths to your schema definition files... ) ``` -Molecule 0.18.0 for Scala 2.12.8 is available at +Molecule 0.18.1 for Scala 2.12.8 is available at [Sonatype](https://oss.sonatype.org/content/repositories/releases/org/scalamolecule/molecule_2.12/). diff --git a/build.sbt b/build.sbt index 0e88b26ce..2113bb460 100644 --- a/build.sbt +++ b/build.sbt @@ -1,7 +1,7 @@ import sbt.compilerPlugin lazy val commonSettings = Defaults.coreDefaultSettings ++ Seq( organization := "org.scalamolecule", - version := "0.18.0", + version := "0.18.1", scalaVersion := "2.12.8", scalacOptions := Seq( "-feature", diff --git a/core/src/main/scala/molecule/api/core.scala b/core/src/main/scala/molecule/api/core.scala index fbb15c00a..51bc9db71 100644 --- a/core/src/main/scala/molecule/api/core.scala +++ b/core/src/main/scala/molecule/api/core.scala @@ -2,10 +2,9 @@ package molecule.api import molecule.expression.{AggregateKeywords, AttrExpressions, LogicImplicits} import molecule.facade.Datomic -import molecule.generic.GenericLog -import molecule.generic.index.{GenericAVET, GenericEAVT, GenericVAET} -import molecule.generic.index.{GenericAEVT, GenericAVET, GenericEAVT, GenericVAET} -import molecule.generic.schema.GenericSchema +import molecule.meta.GenericLog +import molecule.meta.index.{GenericAEVT, GenericAVET, GenericEAVT, GenericVAET} +import molecule.meta.schema.GenericSchema /** Molecule API to be imported into your project to use Molecule. diff --git a/core/src/main/scala/molecule/api/get/GetList.scala b/core/src/main/scala/molecule/api/get/GetList.scala index cc32e6cb9..8a2fa7313 100644 --- a/core/src/main/scala/molecule/api/get/GetList.scala +++ b/core/src/main/scala/molecule/api/get/GetList.scala @@ -770,7 +770,7 @@ trait GetList[Tpl] extends GetArray[Tpl] { self: Molecule[Tpl] => * @group getHistory * @param conn Implicit [[molecule.facade.Conn Conn]] value in scope * @return List[Tpl] where Tpl is a tuple of data matching molecule - * @see [[http://www.scalamolecule.org/manual/time/history/ manual]] for more info on generic attributes. + * @see [[http://www.scalamolecule.org/manual/time/history/ manual]] for more info on meta attributes. * @see Equivalent asynchronous [[molecule.api.getAsync.GetAsyncList.getAsyncHistory(implicit* getAsyncHistory]] method. */ def getHistory(implicit conn: Conn): List[Tpl] = diff --git a/core/src/main/scala/molecule/api/getAsync/GetAsyncList.scala b/core/src/main/scala/molecule/api/getAsync/GetAsyncList.scala index b653c73ae..7f39398ab 100644 --- a/core/src/main/scala/molecule/api/getAsync/GetAsyncList.scala +++ b/core/src/main/scala/molecule/api/getAsync/GetAsyncList.scala @@ -389,7 +389,7 @@ trait GetAsyncList[Tpl] { self: Molecule[Tpl] with GetAsyncArray[Tpl] => * @group getHistory * @param conn Implicit [[molecule.facade.Conn Conn]] value in scope * @return List[Tpl] where Tpl is tuple of data matching molecule - * @see [[http://www.scalamolecule.org/manual/time/history/ manual]] for more info on generic attributes. + * @see [[http://www.scalamolecule.org/manual/time/history/ manual]] for more info on meta attributes. */ def getAsyncHistory(implicit conn: Conn): Future[List[Tpl]] = Future(getHistory(conn)) diff --git a/core/src/main/scala/molecule/ast/model.scala b/core/src/main/scala/molecule/ast/model.scala index 257c928fe..a0fc8f055 100644 --- a/core/src/main/scala/molecule/ast/model.scala +++ b/core/src/main/scala/molecule/ast/model.scala @@ -48,32 +48,33 @@ object model extends Helpers { trait MetaAtom extends Element { val ns : String val attr : String + val tpe : String val value: Value } case class Meta(ns: String, attr: String, - kind: String, + tpe: String, value: Value) extends MetaAtom { - override def toString: String = s"""Meta("$ns", "$attr", "$kind", $value)""" + override def toString: String = s"""Meta("$ns", "$attr", "$tpe", $value)""" } case class Atom(ns: String, attr: String, - tpeS: String, + tpe: String, card: Int, value: Value, enumPrefix: Option[String] = None, - gs: Seq[Generic] = Nil, + gs: Seq[MetaValue] = Nil, keys: Seq[String] = Nil) extends MetaAtom { - override def toString: String = s"""Atom("$ns", "$attr", "$tpeS", $card, $value, ${o(enumPrefix)}, ${seq(gs)}, ${seq(keys)})""" + override def toString: String = s"""Atom("$ns", "$attr", "$tpe", $card, $value, ${o(enumPrefix)}, ${seq(gs)}, ${seq(keys)})""" } case class Bond(ns: String, refAttr: String, refNs: String = "", card: Int, - gs: Seq[Generic] = Nil) extends Element { + gs: Seq[MetaValue] = Nil) extends Element { override def toString: String = s"""Bond("$ns", "$refAttr", "$refNs", $card, ${seq(gs)})""" } @@ -135,14 +136,14 @@ object model extends Helpers { case class MapKeys(keys: Seq[String]) extends Value {override def toString: String = s"MapKeys(${seq(keys)})"} - sealed trait Generic extends Value + sealed trait MetaValue extends Value - case object NoValue extends Generic - case class Id(eid: Any) extends Generic - case class Card(card: Int) extends Generic {override def toString: String = s"Card($card)"} + case object NoValue extends MetaValue + case class Id(eid: Any) extends MetaValue + case class Card(card: Int) extends MetaValue {override def toString: String = s"Card($card)"} - sealed trait Bidirectional extends Generic + sealed trait Bidirectional extends MetaValue case class BiSelfRef(card: Int) extends Bidirectional {override def toString: String = s"BiSelfRef($card)"} case class BiSelfRefAttr(card: Int) extends Bidirectional {override def toString: String = s"BiSelfRefAttr($card)"} diff --git a/core/src/main/scala/molecule/ast/transactionModel.scala b/core/src/main/scala/molecule/ast/transactionModel.scala index 12dafb84f..450e2bcc1 100644 --- a/core/src/main/scala/molecule/ast/transactionModel.scala +++ b/core/src/main/scala/molecule/ast/transactionModel.scala @@ -15,7 +15,7 @@ object transactionModel { val e : Any val a : String val v : Any - val bi : Generic + val meta : MetaValue val oldV: Any = null def value(v: Any): Object = (v match { @@ -33,17 +33,17 @@ object transactionModel { } } - case class Add(e: Any, a: String, v: Any, bi: Generic) extends Statement { + case class Add(e: Any, a: String, v: Any, meta: MetaValue) extends Statement { val action = ":db/add" } // Todo: Implement in updates? // Current Add's let Datomic automatically create a retract datom for each new update. - case class Cas(e: Any, a: String, override val oldV: Any, v: Any, bi: Generic) extends Statement { + case class Cas(e: Any, a: String, override val oldV: Any, v: Any, meta: MetaValue) extends Statement { val action = ":db.fn/cas" } - case class Retract(e: Any, a: String, v: Any, bi: Generic = NoValue) extends Statement { + case class Retract(e: Any, a: String, v: Any, meta: MetaValue = NoValue) extends Statement { val action = ":db/retract" } @@ -51,7 +51,7 @@ object transactionModel { val action = ":db.fn/retractEntity" val a = "" val v = "" - val bi = NoValue + val meta = NoValue } case class Eid(id: Long) diff --git a/core/src/main/scala/molecule/boilerplate/in1.scala b/core/src/main/scala/molecule/boilerplate/in1.scala index e9c8a0317..191520246 100644 --- a/core/src/main/scala/molecule/boilerplate/in1.scala +++ b/core/src/main/scala/molecule/boilerplate/in1.scala @@ -2,8 +2,7 @@ package molecule.boilerplate import molecule.boilerplate.base._ import molecule.composition.CompositeInit_In_1._ import molecule.expression.AggregateKeywords._ -import molecule.generic.datom._ -import molecule.generic.datom._ +import molecule.meta.datom._ import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/boilerplate/in2.scala b/core/src/main/scala/molecule/boilerplate/in2.scala index 297be4939..e0c05e4e1 100644 --- a/core/src/main/scala/molecule/boilerplate/in2.scala +++ b/core/src/main/scala/molecule/boilerplate/in2.scala @@ -1,9 +1,8 @@ package molecule.boilerplate -import molecule.expression.AggregateKeywords._ import molecule.boilerplate.base._ import molecule.composition.CompositeInit_In_2._ -import molecule.generic.datom._ -import molecule.generic.datom._ +import molecule.expression.AggregateKeywords._ +import molecule.meta.datom._ import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/boilerplate/in3.scala b/core/src/main/scala/molecule/boilerplate/in3.scala index 5e6928166..c0ce09c13 100644 --- a/core/src/main/scala/molecule/boilerplate/in3.scala +++ b/core/src/main/scala/molecule/boilerplate/in3.scala @@ -1,9 +1,8 @@ package molecule.boilerplate -import molecule.expression.AggregateKeywords._ import molecule.boilerplate.base._ import molecule.composition.CompositeInit_In_3._ -import molecule.generic.datom._ -import molecule.generic.datom._ +import molecule.expression.AggregateKeywords._ +import molecule.meta.datom._ import scala.language.higherKinds /** Type distribution to groups of functionality for input molecules expecting 3 inputs. */ diff --git a/core/src/main/scala/molecule/boilerplate/out.scala b/core/src/main/scala/molecule/boilerplate/out.scala index 2b43bc459..c294a7f73 100644 --- a/core/src/main/scala/molecule/boilerplate/out.scala +++ b/core/src/main/scala/molecule/boilerplate/out.scala @@ -1,10 +1,9 @@ package molecule.boilerplate -import molecule.expression.AggregateKeywords._ import molecule.boilerplate.base._ import molecule.composition.CompositeInit._ import molecule.composition.Tx._ -import molecule.generic.datom._ -import molecule.generic.datom._ +import molecule.expression.AggregateKeywords._ +import molecule.meta.datom._ import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/expression/AggregateKeywordsSchema.scala b/core/src/main/scala/molecule/expression/AggregateKeywordsSchema.scala index 87b4baac6..443b7f2b8 100644 --- a/core/src/main/scala/molecule/expression/AggregateKeywordsSchema.scala +++ b/core/src/main/scala/molecule/expression/AggregateKeywordsSchema.scala @@ -3,9 +3,9 @@ package molecule.expression import scala.language.higherKinds -/** Count expression on generic attributes. +/** Count expression on meta attributes. *

- * Apply `count` or `countDistinct` keywords to generic attributes. + * Apply `count` or `countDistinct` keywords to meta attributes. * {{{ * Schema.e(count).get.head === 27 // count of all attributes in schema * Schema.a(countDistinct).get.head === 23 // count of all distinct attribute names in schema diff --git a/core/src/main/scala/molecule/facade/Conn.scala b/core/src/main/scala/molecule/facade/Conn.scala index 85fbc87fb..639b4f933 100644 --- a/core/src/main/scala/molecule/facade/Conn.scala +++ b/core/src/main/scala/molecule/facade/Conn.scala @@ -503,7 +503,7 @@ class Conn(val datomicConn: datomic.Connection) extends Helpers { * @return java.util.Collection[java.util.List[AnyRef]] * */ def query(model: Model, query: Query): jCollection[jList[AnyRef]] = model.elements.head match { - case Meta("log" | "eavt" | "aevt" | "avet" | "vaet", _, _, _) => _index(model) + case Meta("Log" | "EAVT" | "AEVT" | "AVET" | "VAET", _, _, _) => _index(model) case _ => _query(model, query) } @@ -535,7 +535,7 @@ class Conn(val datomicConn: datomic.Connection) extends Helpers { // Datoms API providing direct access to indexes private[molecule] def _index(model: Model): jCollection[jList[AnyRef]] = { val (api, index, args) = model.elements.head match { - case Meta("eavt", _, _, value) => + case Meta("EAVT", _, _, value) => ("datoms", datomic.Database.EAVT, value match { case Eq(Seq(e)) => Seq(e.asInstanceOf[Object]) case Eq(Seq(e, a)) => Seq(e.asInstanceOf[Object], a.asInstanceOf[Object]) @@ -544,7 +544,7 @@ class Conn(val datomicConn: datomic.Connection) extends Helpers { case Eq(Seq(e, a, v, t)) => Seq(e.asInstanceOf[Object], a.asInstanceOf[Object], v.asInstanceOf[Object], t.asInstanceOf[Object]) }) - case Meta("aevt", _, _, value) => + case Meta("AEVT", _, _, value) => ("datoms", datomic.Database.AEVT, value match { case Eq(Seq(a)) => Seq(a.asInstanceOf[Object]) case Eq(Seq(a, e)) => Seq(a.asInstanceOf[Object], e.asInstanceOf[Object]) @@ -553,7 +553,7 @@ class Conn(val datomicConn: datomic.Connection) extends Helpers { case Eq(Seq(a, e, v, t)) => Seq(a.asInstanceOf[Object], e.asInstanceOf[Object], v.asInstanceOf[Object], t.asInstanceOf[Object]) }) - case Meta("avet", attr, _, value) => + case Meta("AVET", attr, _, value) => attr match { case "range" => ("indexRange", datomic.Database.AVET, value match { @@ -578,7 +578,7 @@ class Conn(val datomicConn: datomic.Connection) extends Helpers { }) } - case Meta("vaet", attr, _, value) => + case Meta("VAET", attr, _, value) => ("datoms", datomic.Database.VAET, value match { case Eq(Seq(v)) => Seq(v.asInstanceOf[Object]) case Eq(Seq(v, a)) => Seq(v.asInstanceOf[Object], a.asInstanceOf[Object]) @@ -587,7 +587,7 @@ class Conn(val datomicConn: datomic.Connection) extends Helpers { case Eq(Seq(v, a, e, t)) => Seq(v.asInstanceOf[Object], a.asInstanceOf[Object], e.asInstanceOf[Object], t.asInstanceOf[Object]) }) - case Meta("log", _, _, value) => + case Meta("Log", _, _, value) => ("txRange", datomic.Database.VAET, value match { case Eq(Seq(from: Int, until: Int)) => Seq(from.asInstanceOf[Object], until.asInstanceOf[Object]) case Eq(Seq(from: Int, until: Long)) => Seq(from.asInstanceOf[Object], until.asInstanceOf[Object]) diff --git a/core/src/main/scala/molecule/generic/GenericNs.scala b/core/src/main/scala/molecule/generic/GenericNs.scala deleted file mode 100644 index a2a775aa1..000000000 --- a/core/src/main/scala/molecule/generic/GenericNs.scala +++ /dev/null @@ -1,3 +0,0 @@ -package molecule.generic - -private[molecule] trait GenericNs diff --git a/core/src/main/scala/molecule/generic/package.scala b/core/src/main/scala/molecule/generic/package.scala deleted file mode 100644 index 2c4472e2e..000000000 --- a/core/src/main/scala/molecule/generic/package.scala +++ /dev/null @@ -1,13 +0,0 @@ -package molecule - -/** Interfaces to get generic information about data and schema. - * - * - [[generic.datom Datom]] - Generic Datom attributes in molecules - * - [[generic.Log Log]] - Datoms sorted by transaction/time - * - [[generic.index.EAVT EAVT]] - Datoms sorted by Entity-Attribute-Value-Transaction - * - [[generic.index.AVET AVET]] - Datoms sorted by Attribute-Value-Entity-Transaction - * - [[generic.index.AEVT AEVT]] - Datoms sorted by Attribute-Entity-Value-Transaction - * - [[generic.index.VAET VAET]] - "Reverse index" for reverse lookup of ref types - * - [[generic.schema Schema]] - Meta information about the current database schema. - * */ -package object generic diff --git a/core/src/main/scala/molecule/input/InputMolecule.scala b/core/src/main/scala/molecule/input/InputMolecule.scala index ced7a56eb..277b0e18c 100644 --- a/core/src/main/scala/molecule/input/InputMolecule.scala +++ b/core/src/main/scala/molecule/input/InputMolecule.scala @@ -65,7 +65,7 @@ trait InputMolecule extends MoleculeBase { val ns_ = ns + "_" val (attr_, attrK, attrK_) = (attr + "_", attr + "K", attr + "K_") def isTacit_(elements: Seq[Element], tacit0: Option[Boolean]): Option[Boolean] = elements.foldLeft(tacit0) { - case (tacit, Meta(`ns`, `attr`, _, _)) => Some(true) + case (tacit, Meta(_, `attr`, `ns`, _)) => Some(true) case (tacit, Atom(`ns` | `ns_`, `attr_` | `attrK_`, _, _, _, _, _, _)) => Some(true) case (tacit, Atom(`ns_`, `attr` | `attrK`, _, _, _, _, _, _)) => Some(true) case (tacit, Atom(`ns`, `attr` | `attrK`, _, _, _, _, _, _)) => Some(false) @@ -83,7 +83,7 @@ trait InputMolecule extends MoleculeBase { val ns_ = ns + "_" val (attr_, attrK, attrK_) = (attr + "_", attr + "K", attr + "K_") def isTacit_(elements: Seq[Element], cardOpt0: Option[Int]): Option[Int] = elements.foldLeft(cardOpt0) { - case (cardOpt, Meta(`ns`, `attr`, _, _)) => Some(2) + case (cardOpt, Meta(_, `attr`, `ns`, _)) => Some(2) case (cardOpt, Atom(`ns` | `ns_`, `attr` | `attr_` | `attrK` | `attrK_`, _, card, _, _, _, _)) => Some(card) case (cardOpt, Nested(_, elements2)) => isTacit_(elements2, cardOpt) case (cardOpt, Composite(elements2)) => isTacit_(elements2, cardOpt) diff --git a/core/src/main/scala/molecule/generic/Log.scala b/core/src/main/scala/molecule/meta/Log.scala similarity index 99% rename from core/src/main/scala/molecule/generic/Log.scala rename to core/src/main/scala/molecule/meta/Log.scala index d0fdf15e4..36017537c 100644 --- a/core/src/main/scala/molecule/generic/Log.scala +++ b/core/src/main/scala/molecule/meta/Log.scala @@ -1,4 +1,4 @@ -package molecule.generic +package molecule.meta import java.util.Date import molecule.boilerplate.attributes._ @@ -97,7 +97,7 @@ trait GenericLog { * of transaction data. This is to have a transparent unified return type * as all other molecules returning data. Data can always be grouped if needed. */ -trait Log extends GenericNs { +trait Log extends MetaNs { /** Entity id (Long) */ final class e [Ns, In] extends OneLong [Ns, In] with Indexed diff --git a/core/src/main/scala/molecule/meta/MetaNs.scala b/core/src/main/scala/molecule/meta/MetaNs.scala new file mode 100644 index 000000000..c860de4f2 --- /dev/null +++ b/core/src/main/scala/molecule/meta/MetaNs.scala @@ -0,0 +1,3 @@ +package molecule.meta + +private[molecule] trait MetaNs diff --git a/core/src/main/scala/molecule/generic/datom/Datom.scala b/core/src/main/scala/molecule/meta/datom/Datom.scala similarity index 95% rename from core/src/main/scala/molecule/generic/datom/Datom.scala rename to core/src/main/scala/molecule/meta/datom/Datom.scala index 121245dbf..ca7a3ec29 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom.scala @@ -6,10 +6,9 @@ * 2. `sbt compile` in terminal * 3. Refresh and re-compile project in IDE */ -package molecule.generic.datom +package molecule.meta.datom import molecule.boilerplate.attributes._ -import molecule.generic.GenericNs import scala.language.higherKinds /** Base trait with generic attribute trait types shared by all arity interfaces */ diff --git a/core/src/main/scala/molecule/generic/datom/Datom_0.scala b/core/src/main/scala/molecule/meta/datom/Datom_0.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_0.scala rename to core/src/main/scala/molecule/meta/datom/Datom_0.scala index 4cd40131d..1ce29d796 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_0.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_0.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_1.scala b/core/src/main/scala/molecule/meta/datom/Datom_1.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_1.scala rename to core/src/main/scala/molecule/meta/datom/Datom_1.scala index 5c4459ceb..f0b3ee3cd 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_1.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_1.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_10.scala b/core/src/main/scala/molecule/meta/datom/Datom_10.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_10.scala rename to core/src/main/scala/molecule/meta/datom/Datom_10.scala index dce3b9149..935e61d07 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_10.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_10.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_11.scala b/core/src/main/scala/molecule/meta/datom/Datom_11.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_11.scala rename to core/src/main/scala/molecule/meta/datom/Datom_11.scala index 3147fbcf4..80732eb2c 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_11.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_11.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_12.scala b/core/src/main/scala/molecule/meta/datom/Datom_12.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_12.scala rename to core/src/main/scala/molecule/meta/datom/Datom_12.scala index 7a1c167d6..81f6faf16 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_12.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_12.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_13.scala b/core/src/main/scala/molecule/meta/datom/Datom_13.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_13.scala rename to core/src/main/scala/molecule/meta/datom/Datom_13.scala index a058b4b2b..1b5695a12 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_13.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_13.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_14.scala b/core/src/main/scala/molecule/meta/datom/Datom_14.scala similarity index 98% rename from core/src/main/scala/molecule/generic/datom/Datom_14.scala rename to core/src/main/scala/molecule/meta/datom/Datom_14.scala index 071e2dd9e..a78f47a9f 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_14.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_14.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_15.scala b/core/src/main/scala/molecule/meta/datom/Datom_15.scala similarity index 98% rename from core/src/main/scala/molecule/generic/datom/Datom_15.scala rename to core/src/main/scala/molecule/meta/datom/Datom_15.scala index 1f3e933ba..91a26093d 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_15.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_15.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_16.scala b/core/src/main/scala/molecule/meta/datom/Datom_16.scala similarity index 98% rename from core/src/main/scala/molecule/generic/datom/Datom_16.scala rename to core/src/main/scala/molecule/meta/datom/Datom_16.scala index c44f99c60..72c86039f 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_16.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_16.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_17.scala b/core/src/main/scala/molecule/meta/datom/Datom_17.scala similarity index 98% rename from core/src/main/scala/molecule/generic/datom/Datom_17.scala rename to core/src/main/scala/molecule/meta/datom/Datom_17.scala index 6f8ed02f7..1eddaee0e 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_17.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_17.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_18.scala b/core/src/main/scala/molecule/meta/datom/Datom_18.scala similarity index 98% rename from core/src/main/scala/molecule/generic/datom/Datom_18.scala rename to core/src/main/scala/molecule/meta/datom/Datom_18.scala index 858ce1348..9b7a31877 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_18.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_18.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_19.scala b/core/src/main/scala/molecule/meta/datom/Datom_19.scala similarity index 98% rename from core/src/main/scala/molecule/generic/datom/Datom_19.scala rename to core/src/main/scala/molecule/meta/datom/Datom_19.scala index a4c0eefd2..1470c7861 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_19.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_19.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_2.scala b/core/src/main/scala/molecule/meta/datom/Datom_2.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_2.scala rename to core/src/main/scala/molecule/meta/datom/Datom_2.scala index 91610ebd1..2651d8ff5 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_2.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_2.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_20.scala b/core/src/main/scala/molecule/meta/datom/Datom_20.scala similarity index 98% rename from core/src/main/scala/molecule/generic/datom/Datom_20.scala rename to core/src/main/scala/molecule/meta/datom/Datom_20.scala index ef3e96728..f0ff6bbdd 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_20.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_20.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_21.scala b/core/src/main/scala/molecule/meta/datom/Datom_21.scala similarity index 98% rename from core/src/main/scala/molecule/generic/datom/Datom_21.scala rename to core/src/main/scala/molecule/meta/datom/Datom_21.scala index 0b0766cd9..ab34f552d 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_21.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_21.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_22.scala b/core/src/main/scala/molecule/meta/datom/Datom_22.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_22.scala rename to core/src/main/scala/molecule/meta/datom/Datom_22.scala index 409b88ad1..08e00f6ae 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_22.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_22.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_3.scala b/core/src/main/scala/molecule/meta/datom/Datom_3.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_3.scala rename to core/src/main/scala/molecule/meta/datom/Datom_3.scala index 4f0183905..8439bd084 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_3.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_3.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_4.scala b/core/src/main/scala/molecule/meta/datom/Datom_4.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_4.scala rename to core/src/main/scala/molecule/meta/datom/Datom_4.scala index d6c67011d..bcd35102d 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_4.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_4.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_5.scala b/core/src/main/scala/molecule/meta/datom/Datom_5.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_5.scala rename to core/src/main/scala/molecule/meta/datom/Datom_5.scala index 0c2942150..29f0f3b1d 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_5.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_5.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_6.scala b/core/src/main/scala/molecule/meta/datom/Datom_6.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_6.scala rename to core/src/main/scala/molecule/meta/datom/Datom_6.scala index 4f162b48d..fc64f6338 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_6.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_6.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_7.scala b/core/src/main/scala/molecule/meta/datom/Datom_7.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_7.scala rename to core/src/main/scala/molecule/meta/datom/Datom_7.scala index 785d89144..535fa933a 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_7.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_7.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_8.scala b/core/src/main/scala/molecule/meta/datom/Datom_8.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_8.scala rename to core/src/main/scala/molecule/meta/datom/Datom_8.scala index 98e4a2c70..8aa94da6f 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_8.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_8.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/Datom_9.scala b/core/src/main/scala/molecule/meta/datom/Datom_9.scala similarity index 97% rename from core/src/main/scala/molecule/generic/datom/Datom_9.scala rename to core/src/main/scala/molecule/meta/datom/Datom_9.scala index ef94ac40e..84f3d44b4 100644 --- a/core/src/main/scala/molecule/generic/datom/Datom_9.scala +++ b/core/src/main/scala/molecule/meta/datom/Datom_9.scala @@ -1,4 +1,4 @@ -package molecule.generic.datom +package molecule.meta.datom import java.util.Date import scala.language.higherKinds diff --git a/core/src/main/scala/molecule/generic/datom/package.scala b/core/src/main/scala/molecule/meta/datom/package.scala similarity index 87% rename from core/src/main/scala/molecule/generic/datom/package.scala rename to core/src/main/scala/molecule/meta/datom/package.scala index 03434b647..c8cda36e2 100644 --- a/core/src/main/scala/molecule/generic/datom/package.scala +++ b/core/src/main/scala/molecule/meta/datom/package.scala @@ -1,9 +1,9 @@ -package molecule.generic +package molecule.meta -/** Generic Datom attribute interfaces of all arities. +/** Datom meta attribute interfaces of all arities. * - * "Generic attributes" are special pre-defined attributes that can + * "Meta attributes" are special pre-defined attributes that can * be combined with custom attributes in molecules to return * meta data: * {{{ @@ -21,7 +21,7 @@ package molecule.generic * (42, t2, true) // age 42 asserted in transaction t2 * ) * }}} - * Available generic attributes: + * Available meta attributes: * * - '''`e`''' - Entity id (Long) * - '''`a`''' - Full attribute name like ":Person/name" (String) diff --git a/core/src/main/scala/molecule/generic/index/AEVT.scala b/core/src/main/scala/molecule/meta/index/AEVT.scala similarity index 98% rename from core/src/main/scala/molecule/generic/index/AEVT.scala rename to core/src/main/scala/molecule/meta/index/AEVT.scala index eda1f8c0e..d74751ce8 100644 --- a/core/src/main/scala/molecule/generic/index/AEVT.scala +++ b/core/src/main/scala/molecule/meta/index/AEVT.scala @@ -1,11 +1,11 @@ -package molecule.generic.index +package molecule.meta.index import java.util.Date import molecule.boilerplate.attributes._ import molecule.boilerplate.base._ import molecule.boilerplate.dummyTypes._ import molecule.boilerplate.outIndex._ -import molecule.generic.GenericNs +import molecule.meta.MetaNs import scala.language.higherKinds @@ -37,7 +37,7 @@ trait GenericAEVT { * (from [[https://docs.datomic.com/on-prem/indexes.html Datomic documentation]]) * * Access the AEVT Index in Molecule by instantiating an AEVT object with one - * or more arguments and then add generic attributes: + * or more arguments and then add meta attributes: * {{{ * // Create AEVT Index molecule with 1 entity id argument * AEVT(":Person/name").e.v.t.get === List( @@ -70,7 +70,7 @@ trait GenericAEVT { * Please use Datomics API if you need to return the whole database Index:
* `conn.db.datoms(datomic.Database.AEVT)` * */ -trait AEVT extends GenericNs { +trait AEVT extends MetaNs { /** Entity id (Long) */ final class e [Ns, In] extends OneLong [Ns, In] with Indexed diff --git a/core/src/main/scala/molecule/generic/index/AVET.scala b/core/src/main/scala/molecule/meta/index/AVET.scala similarity index 98% rename from core/src/main/scala/molecule/generic/index/AVET.scala rename to core/src/main/scala/molecule/meta/index/AVET.scala index 52e8d5150..2ce2ac13b 100644 --- a/core/src/main/scala/molecule/generic/index/AVET.scala +++ b/core/src/main/scala/molecule/meta/index/AVET.scala @@ -1,11 +1,11 @@ -package molecule.generic.index +package molecule.meta.index import java.util.Date import molecule.boilerplate.attributes._ import molecule.boilerplate.base._ import molecule.boilerplate.dummyTypes._ import molecule.boilerplate.outIndex._ -import molecule.generic.GenericNs +import molecule.meta.MetaNs import scala.language.higherKinds @@ -49,7 +49,7 @@ trait GenericAVET { * (from [[https://docs.datomic.com/on-prem/indexes.html Datomic documentation]]) * * Access the AVET Index in Molecule by instantiating an AVET object with one - * or more arguments and then add generic attributes: + * or more arguments and then add meta attributes: * {{{ * // Create AVET Index molecule with 1 entity id argument * AVET(":Person/age").e.v.t.get === List( @@ -107,7 +107,7 @@ trait GenericAVET { *

* `from` and `until` cannot both be None since Molecule doesn't allow returning all datoms. * */ -trait AVET extends GenericNs { +trait AVET extends MetaNs { /** Entity id (Long) */ final class e [Ns, In] extends OneLong [Ns, In] with Indexed diff --git a/core/src/main/scala/molecule/generic/index/EAVT.scala b/core/src/main/scala/molecule/meta/index/EAVT.scala similarity index 98% rename from core/src/main/scala/molecule/generic/index/EAVT.scala rename to core/src/main/scala/molecule/meta/index/EAVT.scala index 499ffd844..9e33243f0 100644 --- a/core/src/main/scala/molecule/generic/index/EAVT.scala +++ b/core/src/main/scala/molecule/meta/index/EAVT.scala @@ -1,11 +1,11 @@ -package molecule.generic.index +package molecule.meta.index import java.util.Date import molecule.boilerplate.attributes._ import molecule.boilerplate.base._ import molecule.boilerplate.dummyTypes._ import molecule.boilerplate.outIndex._ -import molecule.generic.GenericNs +import molecule.meta.MetaNs import scala.language.higherKinds @@ -40,7 +40,7 @@ trait GenericEAVT { * (from [[https://docs.datomic.com/on-prem/indexes.html Datomic documentation]]) * * Access the EAVT Index in Molecule by instantiating an EAVT object with one - * or more arguments and then add generic attributes: + * or more arguments and then add meta attributes: * {{{ * // Create EAVT Index molecule with 1 entity id argument * EAVT(e1).e.a.v.t.get === List( @@ -74,7 +74,7 @@ trait GenericEAVT { * Please use Datomics API if you need to return the whole database Index:
* `conn.db.datoms(datomic.Database.EAVT)` * */ -trait EAVT extends GenericNs { +trait EAVT extends MetaNs { /** Entity id (Long) */ final class e [Ns, In] extends OneLong [Ns, In] with Indexed diff --git a/core/src/main/scala/molecule/generic/index/VAET.scala b/core/src/main/scala/molecule/meta/index/VAET.scala similarity index 98% rename from core/src/main/scala/molecule/generic/index/VAET.scala rename to core/src/main/scala/molecule/meta/index/VAET.scala index 5f15d35cd..4580d802c 100644 --- a/core/src/main/scala/molecule/generic/index/VAET.scala +++ b/core/src/main/scala/molecule/meta/index/VAET.scala @@ -1,11 +1,11 @@ -package molecule.generic.index +package molecule.meta.index import java.util.Date import molecule.boilerplate.attributes._ import molecule.boilerplate.base._ import molecule.boilerplate.dummyTypes._ import molecule.boilerplate.outIndex._ -import molecule.generic.GenericNs +import molecule.meta.MetaNs import scala.language.higherKinds @@ -37,7 +37,7 @@ trait GenericVAET { * (from [[https://docs.datomic.com/on-prem/indexes.html Datomic documentation]]) * * Access the VAET Index in Molecule by instantiating a VAET object with one - * or more arguments and then add generic attributes: + * or more arguments and then add meta attributes: * {{{ * // Say we have 3 entities pointing to one entity: * Release.e.name.Artists.e.name.get === List( @@ -78,7 +78,7 @@ trait GenericVAET { * Please use Datomics API if you need to return the whole database Index:
* `conn.db.datoms(datomic.Database.VAET)` * */ -trait VAET extends GenericNs { +trait VAET extends MetaNs { /** Entity id (Long) */ final class e [Ns, In] extends OneLong [Ns, In] with Indexed diff --git a/core/src/main/scala/molecule/generic/index/package.scala b/core/src/main/scala/molecule/meta/index/package.scala similarity index 94% rename from core/src/main/scala/molecule/generic/index/package.scala rename to core/src/main/scala/molecule/meta/index/package.scala index e991731e0..23e316ecc 100644 --- a/core/src/main/scala/molecule/generic/index/package.scala +++ b/core/src/main/scala/molecule/meta/index/package.scala @@ -1,4 +1,4 @@ -package molecule.generic +package molecule.meta /** Datomic Index APIs in Molecule. @@ -13,7 +13,7 @@ package molecule.generic * * Create an Index molecule by instantiating an Index object * with one or more arguments in the order of the Index's elements. Datoms are - * returned as tuples of data depending of which generic attributes you add to the + * returned as tuples of data depending of which meta attributes you add to the * Index molecule: * {{{ * // Create EAVT Index molecule with 1 entity id argument diff --git a/core/src/main/scala/molecule/meta/package.scala b/core/src/main/scala/molecule/meta/package.scala new file mode 100644 index 000000000..6bc3f58a5 --- /dev/null +++ b/core/src/main/scala/molecule/meta/package.scala @@ -0,0 +1,13 @@ +package molecule + +/** Interfaces to get meta information about data and schema. + * + * - [[meta.datom Datom]] - Datom attributes in molecules + * - [[meta.Log Log]] - Datoms sorted by transaction/time + * - [[meta.index.EAVT EAVT]] - Datoms sorted by Entity-Attribute-Value-Transaction + * - [[meta.index.AVET AVET]] - Datoms sorted by Attribute-Value-Entity-Transaction + * - [[meta.index.AEVT AEVT]] - Datoms sorted by Attribute-Entity-Value-Transaction + * - [[meta.index.VAET VAET]] - "Reverse index" for reverse lookup of ref types + * - [[meta.schema Schema]] - Meta information about the current database schema. + * */ +package object meta diff --git a/core/src/main/scala/molecule/generic/schema/Schema.scala b/core/src/main/scala/molecule/meta/schema/Schema.scala similarity index 97% rename from core/src/main/scala/molecule/generic/schema/Schema.scala rename to core/src/main/scala/molecule/meta/schema/Schema.scala index 518b836e7..85feda233 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema.scala @@ -1,8 +1,8 @@ -package molecule.generic.schema +package molecule.meta.schema import molecule.boilerplate.attributes._ import molecule.boilerplate.base._ -import molecule.generic.GenericNs +import molecule.meta.MetaNs import scala.language.higherKinds @@ -14,7 +14,7 @@ trait GenericSchema { } /** Base Schema trait with attribute types shared by all arity interfaces. */ -trait Schema extends GenericNs { +trait Schema extends MetaNs { /** Attribute definition entity id. */ final class id [Ns, In] extends OneLong [Ns, In] with Indexed diff --git a/core/src/main/scala/molecule/generic/schema/Schema_0.scala b/core/src/main/scala/molecule/meta/schema/Schema_0.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_0.scala rename to core/src/main/scala/molecule/meta/schema/Schema_0.scala index 2d083a775..4a49d3672 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_0.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_0.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_1.scala b/core/src/main/scala/molecule/meta/schema/Schema_1.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_1.scala rename to core/src/main/scala/molecule/meta/schema/Schema_1.scala index 47f08c44e..b9a136585 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_1.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_1.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_10.scala b/core/src/main/scala/molecule/meta/schema/Schema_10.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_10.scala rename to core/src/main/scala/molecule/meta/schema/Schema_10.scala index b5feaa981..09b59df8e 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_10.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_10.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_11.scala b/core/src/main/scala/molecule/meta/schema/Schema_11.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_11.scala rename to core/src/main/scala/molecule/meta/schema/Schema_11.scala index 92b577ed4..7079a32f7 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_11.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_11.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_12.scala b/core/src/main/scala/molecule/meta/schema/Schema_12.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_12.scala rename to core/src/main/scala/molecule/meta/schema/Schema_12.scala index 8a37e93b2..316248cac 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_12.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_12.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_13.scala b/core/src/main/scala/molecule/meta/schema/Schema_13.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_13.scala rename to core/src/main/scala/molecule/meta/schema/Schema_13.scala index 42860aeba..020de670e 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_13.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_13.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_14.scala b/core/src/main/scala/molecule/meta/schema/Schema_14.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_14.scala rename to core/src/main/scala/molecule/meta/schema/Schema_14.scala index ab27b01d4..87561c7c6 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_14.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_14.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_15.scala b/core/src/main/scala/molecule/meta/schema/Schema_15.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_15.scala rename to core/src/main/scala/molecule/meta/schema/Schema_15.scala index 75f185711..36bd21e67 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_15.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_15.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_16.scala b/core/src/main/scala/molecule/meta/schema/Schema_16.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_16.scala rename to core/src/main/scala/molecule/meta/schema/Schema_16.scala index 08924ab83..ee03a8136 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_16.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_16.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_17.scala b/core/src/main/scala/molecule/meta/schema/Schema_17.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_17.scala rename to core/src/main/scala/molecule/meta/schema/Schema_17.scala index 1a84391ba..a1b747722 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_17.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_17.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_18.scala b/core/src/main/scala/molecule/meta/schema/Schema_18.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_18.scala rename to core/src/main/scala/molecule/meta/schema/Schema_18.scala index b88d5d6ca..b6ccd9a19 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_18.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_18.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_19.scala b/core/src/main/scala/molecule/meta/schema/Schema_19.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_19.scala rename to core/src/main/scala/molecule/meta/schema/Schema_19.scala index c36f840ab..8511b3192 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_19.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_19.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_2.scala b/core/src/main/scala/molecule/meta/schema/Schema_2.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_2.scala rename to core/src/main/scala/molecule/meta/schema/Schema_2.scala index e4773cac9..ea6f03a2c 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_2.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_2.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_20.scala b/core/src/main/scala/molecule/meta/schema/Schema_20.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_20.scala rename to core/src/main/scala/molecule/meta/schema/Schema_20.scala index dda94308d..37b3bed27 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_20.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_20.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_21.scala b/core/src/main/scala/molecule/meta/schema/Schema_21.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_21.scala rename to core/src/main/scala/molecule/meta/schema/Schema_21.scala index 82e35951a..ed7e6d822 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_21.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_21.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_22.scala b/core/src/main/scala/molecule/meta/schema/Schema_22.scala similarity index 98% rename from core/src/main/scala/molecule/generic/schema/Schema_22.scala rename to core/src/main/scala/molecule/meta/schema/Schema_22.scala index e4244baaf..d884bb213 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_22.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_22.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_3.scala b/core/src/main/scala/molecule/meta/schema/Schema_3.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_3.scala rename to core/src/main/scala/molecule/meta/schema/Schema_3.scala index e74db5c42..1cc21b001 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_3.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_3.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_4.scala b/core/src/main/scala/molecule/meta/schema/Schema_4.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_4.scala rename to core/src/main/scala/molecule/meta/schema/Schema_4.scala index 86231fd98..b4e5c9c9b 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_4.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_4.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_5.scala b/core/src/main/scala/molecule/meta/schema/Schema_5.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_5.scala rename to core/src/main/scala/molecule/meta/schema/Schema_5.scala index 760a2da25..7f07ef83d 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_5.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_5.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_6.scala b/core/src/main/scala/molecule/meta/schema/Schema_6.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_6.scala rename to core/src/main/scala/molecule/meta/schema/Schema_6.scala index 6b068625a..bb0326120 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_6.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_6.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_7.scala b/core/src/main/scala/molecule/meta/schema/Schema_7.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_7.scala rename to core/src/main/scala/molecule/meta/schema/Schema_7.scala index f03fdb812..674616ac8 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_7.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_7.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_8.scala b/core/src/main/scala/molecule/meta/schema/Schema_8.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_8.scala rename to core/src/main/scala/molecule/meta/schema/Schema_8.scala index a3f0ad00a..d1e873248 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_8.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_8.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/Schema_9.scala b/core/src/main/scala/molecule/meta/schema/Schema_9.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/Schema_9.scala rename to core/src/main/scala/molecule/meta/schema/Schema_9.scala index 9c214ecec..40f5cba80 100644 --- a/core/src/main/scala/molecule/generic/schema/Schema_9.scala +++ b/core/src/main/scala/molecule/meta/schema/Schema_9.scala @@ -1,4 +1,4 @@ -package molecule.generic.schema +package molecule.meta.schema import java.util.Date import molecule.boilerplate.dummyTypes._ diff --git a/core/src/main/scala/molecule/generic/schema/package.scala b/core/src/main/scala/molecule/meta/schema/package.scala similarity index 99% rename from core/src/main/scala/molecule/generic/schema/package.scala rename to core/src/main/scala/molecule/meta/schema/package.scala index 4468475d5..e9633dc7b 100644 --- a/core/src/main/scala/molecule/generic/schema/package.scala +++ b/core/src/main/scala/molecule/meta/schema/package.scala @@ -1,4 +1,4 @@ -package molecule.generic +package molecule.meta /** Generic Schema attribute interfaces of all arities. diff --git a/core/src/main/scala/molecule/ops/Liftables.scala b/core/src/main/scala/molecule/ops/Liftables.scala index ef611fd07..8a6acb0e9 100644 --- a/core/src/main/scala/molecule/ops/Liftables.scala +++ b/core/src/main/scala/molecule/ops/Liftables.scala @@ -228,7 +228,7 @@ private[molecule] trait Liftables extends MacroHelpers { case BiTargetRefAttr(card, attr) => q"BiTargetRefAttr($card, $attr)" } - implicit val liftGeneric: c.universe.Liftable[Generic] = Liftable[Generic] { + implicit val liftMetaValue: c.universe.Liftable[MetaValue] = Liftable[MetaValue] { case NoValue => q"NoValue" case Id(eid) => q"Id($eid)" case Card(card) => q"Card($card)" @@ -290,10 +290,10 @@ private[molecule] trait Liftables extends MacroHelpers { case MapKeys(keys) => q"MapKeys(Seq(..$keys))" } - implicit val liftAtom : c.universe.Liftable[Atom] = Liftable[Atom] { a => q"Atom(${a.ns}, ${a.attr}, ${a.tpeS}, ${a.card}, ${a.value}, ${a.enumPrefix}, Seq(..${a.gs}), Seq(..${a.keys}))" } + implicit val liftAtom : c.universe.Liftable[Atom] = Liftable[Atom] { a => q"Atom(${a.ns}, ${a.attr}, ${a.tpe}, ${a.card}, ${a.value}, ${a.enumPrefix}, Seq(..${a.gs}), Seq(..${a.keys}))" } implicit val liftBond : c.universe.Liftable[Bond] = Liftable[Bond] { b => q"Bond(${b.ns}, ${b.refAttr}, ${b.refNs}, ${b.card}, Seq(..${b.gs}))" } implicit val liftReBond: c.universe.Liftable[ReBond] = Liftable[ReBond] { r => q"ReBond(${r.backRef}, ${r.refAttr}, ${r.refNs}, ${r.distinct}, ${r.prevVar})" } - implicit val liftMeta : c.universe.Liftable[Meta] = Liftable[Meta] { m => q"Meta(${m.ns}, ${m.attr}, ${m.kind}, ${m.value})" } + implicit val liftMeta : c.universe.Liftable[Meta] = Liftable[Meta] { m => q"Meta(${m.ns}, ${m.attr}, ${m.tpe}, ${m.value})" } implicit val liftGroup : c.universe.Liftable[Nested] = Liftable[Nested] { g0 => val es0: Seq[c.universe.Tree] = g0.elements map { case a: Atom => q"$a" diff --git a/core/src/main/scala/molecule/ops/QueryOps.scala b/core/src/main/scala/molecule/ops/QueryOps.scala index 7e06e37f5..9b66e31b0 100644 --- a/core/src/main/scala/molecule/ops/QueryOps.scala +++ b/core/src/main/scala/molecule/ops/QueryOps.scala @@ -96,7 +96,7 @@ object QueryOps extends Helpers { def nots(e: String, a: Atom, v: String, argss: Seq[Any]): Query = { argss.zipWithIndex.foldLeft(q) { - case (q1, (set: Set[_], i)) if a.tpeS == "java.net.URI" => + case (q1, (set: Set[_], i)) if a.tpe == "java.net.URI" => val notClauses = set.toSeq.zipWithIndex.flatMap { case (uri, j) => val x = Var(v + "_" + (j + 1)) Seq( @@ -105,7 +105,7 @@ object QueryOps extends Helpers { ) } q1.copy(wh = Where(q1.wh.clauses :+ NotJoinClauses(Seq(Var(e)), notClauses))) - case (q1, (set: Set[_], _)) => + case (q1, (set: Set[_], _)) => val notClauses = set.toSeq.map(arg => DataClause(ImplDS, Var(e), KW(a.ns, a.attr), Val(pre(a, arg)), Empty) ) @@ -203,9 +203,9 @@ object QueryOps extends Helpers { q.copy(wh = Where(q.wh.clauses :+ NotClause(Var("id"), KW("db", attr)))) - // Generic Datom attribute/values .......................................... + // Datom attribute/values .......................................... - def genericE(e: String, v: String, v1: String, singleElement: Boolean = false): Query = { + def datomE(e: String, v: String, v1: String, singleElement: Boolean = false): Query = { if (singleElement) { q.where(e, "?", e + "_attr", Var(v), "") .ident(e + "_attr", v1) @@ -232,7 +232,7 @@ object QueryOps extends Helpers { } } - def genericA(e: String, v: String, v1: String): Query = { + def datomA(e: String, v: String, v1: String): Query = { var nss = false q.wh.clauses.reverse.collectFirst { case Funct("str", Seq(Var(`v1`)), _) => @@ -261,7 +261,7 @@ object QueryOps extends Helpers { ) } - def genericV(e: String, v: String, v1: String): Query = { + def datomV(e: String, v: String, v1: String): Query = { q.wh.clauses.reverse.collectFirst { case DataClause(_, Var(e0), KW("db", "ident", _), _, _, _) if e0 == e + "_attr" => q case DataClause(_, _, KW("?", attr, _), _, _, _) if attr == e + "_attr" => q.ident(e + "_attr", v1) @@ -281,7 +281,7 @@ object QueryOps extends Helpers { case (q1, arg) => q1.func(op, Seq(Var(v), Val(arg))) } - def genericTx(e: String, v: String, v1: String): Query = { + def datomTx(e: String, v: String, v1: String): Query = { // Ensure tx value is present val (hasTxV, cls0): (Int, Seq[Clause]) = q.wh.clauses.foldRight(0, Seq.empty[Clause]) { case (cl@DataClause(_, Var(`e`), _, _, NoBinding | Empty | Var("_"), _), (0, acc)) => (1, cl.copy(tx = Var(v + "_tx")) +: acc) @@ -317,25 +317,25 @@ object QueryOps extends Helpers { .func("!=", Seq(Var(v + "_ns"), Val("fressian"))) } - def genericT(e: String, v: String, v1: String): Query = { + def datomT(e: String, v: String, v1: String): Query = { q.wh.clauses.reverse.collectFirst { case DataClause(_, _, _, _, Var(tx), _) if tx == v + "_tx" => q.func("datomic.Peer/toT ^Long", Seq(Var(v + "_tx")), ScalarBinding(Var(v + "_t"))) } getOrElse - q.genericTx(e, v, v1) + q.datomTx(e, v, v1) .func("datomic.Peer/toT ^Long", Seq(Var(v + "_tx")), ScalarBinding(Var(v + "_t"))) } - def genericTxInstant(e: String, v: String, v1: String): Query = { + def datomTxInstant(e: String, v: String, v1: String): Query = { q.wh.clauses.reverse.collectFirst { case DataClause(_, _, _, _, Var(tx), _) if tx == v + "_tx" => q.where(v + "_tx", "db", "txInstant", Var(v + "_txInstant"), "") } getOrElse - q.genericTx(e, v, v1) + q.datomTx(e, v, v1) .where(v + "_tx", "db", "txInstant", Var(v + "_txInstant"), "") } - def genericOp(e: String, v: String, v1: String): Query = { + def datomOp(e: String, v: String, v1: String): Query = { val (ok, cls0): (Int, Seq[Clause]) = q.wh.clauses.foldRight(0, Seq.empty[Clause]) { case (cl@DataClause(_, Var(`e`), _, _, Empty | NoBinding, NoBinding), (0, acc)) => (1, cl.copy(tx = Var("_"), op = Var(v + "_op")) +: acc) case (cl@DataClause(_, Var(`e`), _, _, _, NoBinding), (0, acc)) => (1, cl.copy(op = Var(v + "_op")) +: acc) @@ -392,7 +392,7 @@ object QueryOps extends Helpers { } def compareTo(op: String, a: Atom, v: String, qv: QueryValue, i: Int = 0): Query = - compareTo2(op, a.tpeS, v, qv, i) + compareTo2(op, a.tpe, v, qv, i) def compareTo2(op: String, tpeS: String, v: String, qv: QueryValue, i: Int = 0): Query = { val w = Var(if (i > 0) v + "_" + i else v + 2) @@ -472,7 +472,7 @@ object QueryOps extends Helpers { // extract value .func(".split ^String", Seq(Var(v), Val("@"), Val(2)), ScalarBinding(Var(v + 2))) .func("second", Seq(Var(v + 2)), ScalarBinding(Var(v + 3))) - a.tpeS match { + a.tpe match { case "String" => q1.compareTo(op, a, v + 3, Var(v + "Value"), 1) case "UUID" => q1.compareTo(op, a, v + 3, Var(v + "Value"), 1) case "URI" => q1.compareTo(op, a, v + 3, Var(v + "Value"), 1) @@ -495,7 +495,7 @@ object QueryOps extends Helpers { // extract value .func(".split ^String", Seq(Var(v), Val("@"), Val(2)), ScalarBinding(Var(v + 1))) .func("second", Seq(Var(v + 1)), ScalarBinding(Var(v + 2))) - a.tpeS match { + a.tpe match { case "String" => q1.compareTo(op, a, v + 2, Var(v + "Value"), 1) case "UUID" => q1.compareTo(op, a, v + 2, Var(v + "Value"), 1) case "URI" => q1.compareTo(op, a, v + 2, Var(v + "Value"), 1) diff --git a/core/src/main/scala/molecule/ops/TreeOps.scala b/core/src/main/scala/molecule/ops/TreeOps.scala index 356b8702b..67aae826b 100644 --- a/core/src/main/scala/molecule/ops/TreeOps.scala +++ b/core/src/main/scala/molecule/ops/TreeOps.scala @@ -2,9 +2,7 @@ package molecule.ops import molecule.ast.query._ import molecule.boilerplate.attributes._ import molecule.boilerplate.base.{FirstNS, NS} -import molecule.expression.AttrExpressions.OptionalExpr import molecule.ops.exception.TreeOpsException -import molecule.transform.exception.Dsl2ModelException import scala.language.existentials import scala.reflect.macros.blackbox @@ -36,6 +34,12 @@ private[molecule] trait TreeOps extends Liftables { lazy val enumPrefix : String = at.enumPrefix lazy val enumPrefixOpt: Option[String] = if (isAnyEnum) Some(at.enumPrefix) else None + def ns2: String = tpe_.baseClasses.foldLeft("") { + case ("", s: ClassSymbol) if s.toType =:= typeOf[NS] => "NS" + case ("NS", ns) => ns.name.toString + case (ns, cls) => ns + } + def isNS: Boolean = tpe_ <:< typeOf[NS] def isFirstNS: Boolean = tpe_ <:< typeOf[FirstNS] def owner: String = t.symbol.typeSignature.typeParams.head.name.toString diff --git a/core/src/main/scala/molecule/package.scala b/core/src/main/scala/molecule/package.scala index 47c63c794..6f17c0477 100644 --- a/core/src/main/scala/molecule/package.scala +++ b/core/src/main/scala/molecule/package.scala @@ -43,18 +43,18 @@ import molecule.factory._ * Implicit macro methods `m` to instantiate molecules from custom DSL molecule constructs. * * - * generic - * Interfaces to generic information about datoms and Datomic database. - * - * * input * Input molecules awaiting input. * * - * macro + * macros * Internal macros generating molecule code from custom DSL molecule constructs. * * + * meta + * Interfaces to meta information about datoms and Datomic database. + * + * * ops * Internal operational helpers for transforming DSL to molecule. * diff --git a/core/src/main/scala/molecule/transform/Dsl2Model.scala b/core/src/main/scala/molecule/transform/Dsl2Model.scala index 045067683..0a084b367 100644 --- a/core/src/main/scala/molecule/transform/Dsl2Model.scala +++ b/core/src/main/scala/molecule/transform/Dsl2Model.scala @@ -1,11 +1,10 @@ package molecule.transform import molecule.ast.model._ import molecule.boilerplate.attributes._ -import molecule.generic.{GenericNs, Log} -import molecule.generic.index._ -import molecule.generic.index.{AEVT, AVET, EAVT, VAET} -import molecule.generic.schema.Schema import molecule.macros.{Cast, Json} +import molecule.meta.index.{AEVT, AVET, EAVT, VAET} +import molecule.meta.schema.Schema +import molecule.meta.{Log, MetaNs} import molecule.transform.exception.Dsl2ModelException import scala.language.experimental.macros import scala.reflect.macros.blackbox @@ -15,7 +14,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { val c: blackbox.Context import c.universe._ - val x = DebugMacro("Dsl2Model", 519, 511) + val x = DebugMacro("Dsl2Model", 901, 900) override def abort(msg: String): Nothing = throw new Dsl2ModelException(msg) @@ -32,12 +31,11 @@ private[molecule] trait Dsl2Model extends Cast with Json { List[Int => Tree] ) = { - val mandatoryDatomGenerics = Seq("e", "tx", "t", "txInstant", "op", "a", "v") - val mandatoryGenerics = Seq("e", "tx", "t", "txInstant", "op", "a", "v", "Self") - val tacitGenerics = Seq("e_", "ns_", "a_", "v_", "tx_", "t_", "txInstant_", "op_") - val datomGenerics = Seq("e", "e_", "tx", "t", "txInstant", "op", "tx_", "t_", "txInstant_", "op_", "a", "a_", "v", "v_") - val keywords = Seq("$qmark", "Nil", "None", "count", "countDistinct", "min", "max", "sum", "avg", "unify", "distinct", - "median", "variance", "stddev", "rand", "sample") + val mandatoryDatomMeta = Seq("e", "tx", "t", "txInstant", "op", "a", "v") + val mandatoryMeta = Seq("e", "tx", "t", "txInstant", "op", "a", "v", "Self") + val tacitMeta = Seq("e_", "ns_", "a_", "v_", "tx_", "t_", "txInstant_", "op_") + val datomMeta = Seq("e", "e_", "tx", "t", "txInstant", "op", "tx_", "t_", "txInstant_", "op_", "a", "a_", "v", "v_") + val keywords = Seq("$qmark", "Nil", "None", "count", "countDistinct", "min", "max", "sum", "avg", "unify", "distinct", "median", "variance", "stddev", "rand", "sample") def badFn(fn: TermName) = List("countDistinct", "distinct", "max", "min", "rand", "sample", "avg", "median", "stddev", "sum", "variance").contains(fn.toString()) var isComposite: Boolean = false @@ -60,8 +58,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { var aggrType: String = "" var first: Boolean = true - // Generic namespace - var gns: String = "?" + var metaType: String = "datom" def addSpecific(castLambda: Int => Tree, tpeStr: String): Unit = { if (post) { @@ -173,16 +170,16 @@ private[molecule] trait Dsl2Model extends Cast with Json { def resolve(tree: Tree): Seq[Element] = { if (first) { val p = richTree(tree) - if (p.tpe_ <:< typeOf[GenericNs]) p.tpe_ match { - case t if t <:< typeOf[Schema] => gns = "schema" - case t if t <:< typeOf[EAVT] => gns = "eavt" - case t if t <:< typeOf[AEVT] => gns = "aevt" - case t if t <:< typeOf[AVET] => gns = "avet" - case t if t <:< typeOf[VAET] => gns = "vaet" - case t if t <:< typeOf[Log] => gns = "log" + if (p.tpe_ <:< typeOf[MetaNs]) p.tpe_ match { + case t if t <:< typeOf[Schema] => metaType = "schema" + case t if t <:< typeOf[EAVT] => metaType = "eavt" + case t if t <:< typeOf[AEVT] => metaType = "aevt" + case t if t <:< typeOf[AVET] => metaType = "avet" + case t if t <:< typeOf[VAET] => metaType = "vaet" + case t if t <:< typeOf[Log] => metaType = "log" } first = false - // x(99, p.tpe_, gns) + // x(99, p.tpe_, metaType) } tree match { @@ -251,21 +248,21 @@ private[molecule] trait Dsl2Model extends Cast with Json { } def resolveMandatoryAttrOrRef(tree: Tree, t: richTree, prev: Tree, p: richTree, attrStr: String): Seq[Element] = { - if (gns == "?" && mandatoryGenerics.contains(attrStr)) { + if (metaType == "datom" && mandatoryMeta.contains(attrStr)) { // x(111, attrStr, t.tpeS) - resolveMandatoryGenericAttr(prev, p, attrStr) + resolveMandatoryMetaAttr(t, prev, p, attrStr) - } else if (gns == "schema") { - resolveMandatorySchemaAttr(prev, p, attrStr) + } else if (metaType == "schema") { + resolveMandatorySchemaAttr(t, prev, p, attrStr) - } else if (gns != "?") { // Indexes - // x(120, gns, attrStr) + } else if (metaType != "datom") { // Indexes + // x(120, metaType, attrStr) if (p.isFirstNS) abort("Non-filtered Indexes returning the whole database not allowed in Molecule.\n" + " Please apply one or more arguments to the Index. For full indexes, use Datomic:\n" + - s" `conn.db.datoms(datomic.Database.${gns.toUpperCase})`" + s" `conn.db.datoms(datomic.Database.${metaType.toUpperCase})`" ) - resolveMandatoryGenericAttr(prev, p, attrStr) + resolveMandatoryMetaAttr(t, prev, p, attrStr) } else if (t.isEnum) { // x(131, t.tpeS) @@ -307,8 +304,8 @@ private[molecule] trait Dsl2Model extends Cast with Json { def resolveOptionalAttr(tree: Tree, t: richTree, prev: Tree, p: richTree, attrStr: String): Seq[Element] = { - if (gns == "schema") { - // x(112, gns, attrStr) + if (metaType == "schema") { + // x(112, metaType, attrStr) resolveOptionalSchemaAttr(t, prev, p, attrStr) } else if (t.isEnum$) { @@ -341,11 +338,11 @@ private[molecule] trait Dsl2Model extends Cast with Json { } def resolveTacitAttr(tree: Tree, t: richTree, prev: Tree, p: richTree, attrStr: String): Seq[Element] = { - if (gns == "?" && tacitGenerics.contains(attrStr)) { + if (metaType == "datom" && tacitMeta.contains(attrStr)) { abort(s"Tacit `$attrStr` can only be used with an applied value i.e. `$attrStr()`") - } else if (gns == "schema") { - traverseElement(prev, p, Meta("schema", attrStr, attrStr, NoValue)) + } else if (metaType == "schema") { + traverseElement(prev, p, Meta("Schema", attrStr, "schema", NoValue)) } else if (t.isEnum) { traverseElement(prev, p, Atom(t.ns, t.name, t.tpeS, t.card, EnumVal, Some(t.enumPrefix), bi(tree, t))) @@ -364,41 +361,49 @@ private[molecule] trait Dsl2Model extends Cast with Json { } } - - def resolveMandatoryGenericAttr(prev: Tree, p: richTree, attrStr: String): Seq[Element] = { - def castMeta(tpe: String, g: Generic, value: Value): Seq[Element] = { + def resolveMandatoryMetaAttr(t: richTree, prev: Tree, p: richTree, attrStr: String): Seq[Element] = { + val metaNs = metaType match { + case "schema" => "Schema" + case "eavt" => "EAVT" + case "aevt" => "AEVT" + case "avet" => "AVET" + case "vaet" => "VAET" + case "log" => "Log" + case _ => p.ns2 + } + def castMeta(tpe: String, value: Value): Seq[Element] = { val tpeOrAggrTpe = if (aggrType.nonEmpty) aggrType else tpe addSpecific(castOneAttr(tpeOrAggrTpe), tpeOrAggrTpe) - addJson(jsonOneAttr, tpeOrAggrTpe, gns + "." + attrStr) - traverseElement(prev, p, Meta(gns, attrStr, attrStr, value)) + addJson(jsonOneAttr, tpeOrAggrTpe, metaType + "." + attrStr) + traverseElement(prev, p, Meta(metaNs, attrStr, metaType, value)) } - // x(113, attrStr, gns) + // x(113, attrStr, metaType, p.ns, p.ns2) attrStr match { - case "e" => castMeta("Long", NoValue, EntValue) - case "v" => castMeta("Any", NoValue, NoValue) - case "a" => castMeta("String", NoValue, NoValue) + case "e" => castMeta("Long", EntValue) + case "v" => castMeta("Any", NoValue) + case "a" => castMeta("String", NoValue) case "Self" => traverseElement(prev, p, Self) case tx => if (prev.toString.endsWith("$")) - abort(s"Optional attributes (`${p.name}`) can't be followed by generic transaction attributes (`$attrStr`).") + abort(s"Optional attributes (`${p.name}`) can't be followed by meta transaction attributes (`$attrStr`).") tx match { - case "t" => castMeta("Long", NoValue, NoValue) - case "tx" => castMeta("Long", NoValue, NoValue) - case "txInstant" => castMeta("java.util.Date", NoValue, NoValue) - case "op" => castMeta("Boolean", NoValue, NoValue) + case "t" => castMeta("Long", NoValue) + case "tx" => castMeta("Long", NoValue) + case "txInstant" => castMeta("java.util.Date", NoValue) + case "op" => castMeta("Boolean", NoValue) } } } - def resolveMandatorySchemaAttr(prev: Tree, p: richTree, attrStr: String): Seq[Element] = { + def resolveMandatorySchemaAttr(t: richTree, prev: Tree, p: richTree, attrStr: String): Seq[Element] = { def castMeta(tpe: String): Seq[Element] = { val tpeOrAggrTpe = if (aggrType.nonEmpty) aggrType else tpe addSpecific(castOneAttr(tpeOrAggrTpe), tpeOrAggrTpe) addJson(jsonOneAttr, tpeOrAggrTpe, "schema." + attrStr) - traverseElement(prev, p, Meta("schema", attrStr, attrStr, NoValue)) + traverseElement(prev, p, Meta("Schema", attrStr, "schema", NoValue)) } - // x(122, attrStr, p.ns) + // x(122, attrStr, p.ns, p.ns2) attrStr match { case "id" => castMeta("Long") case "a" => castMeta("String") @@ -429,31 +434,31 @@ private[molecule] trait Dsl2Model extends Cast with Json { case "unique$" => addCast(castEnumOpt, t) addJsonCard(jsonOptOneEnum, jsonOptManyEnum, t) - traverseElement(prev, p, Meta("schema", attrStr, attrStr, NoValue)) + traverseElement(prev, p, Meta("Schema", attrStr, "schema", NoValue)) case optionalSchemaAttr => addCast(castOptionalAttr, t) addJsonCard(jsonOptOneAttr, jsonOptManyAttr, t) - traverseElement(prev, p, Meta("schema", attrStr, attrStr, NoValue)) + traverseElement(prev, p, Meta("Schema", attrStr, "schema", NoValue)) } def resolveApply(tree: Tree, t: richTree, prev: Tree, p: richTree, attrStr: String, vs: Tree): Seq[Element] = { if (t.isFirstNS) { - // x(230, attrStr, gns) + // x(230, attrStr, metaType) tree match { - case q"$prev.$ns.apply($pkg.?)" => traverseElement(prev, p, Meta(gns, "e_", "Long", Eq(Seq(Qm)))) - case q"$prev.$ns.apply($eid)" if t.isBiEdge => traverseElement(prev, p, Meta(gns, "e_", "Long", Eq(Seq(extract(eid))))) - case q"$prev.$ns.apply(..$eids)" if gns != "?" => traverseElement(prev, p, Meta(gns, "args_", "", Eq(resolveValues(q"Seq(..$eids)")))) - case q"$prev.$ns.apply(..$eids)" => traverseElement(prev, p, Meta(gns, "e_", "Long", Eq(resolveValues(q"Seq(..$eids)")))) + case q"$prev.$ns.apply($pkg.?)" => traverseElement(prev, p, Meta(ns.toString(), "e_", metaType, Eq(Seq(Qm)))) + case q"$prev.$ns.apply($eid)" if t.isBiEdge => traverseElement(prev, p, Meta(ns.toString(), "e_", metaType, Eq(Seq(extract(eid))))) + case q"$prev.$ns.apply(..$eids)" if metaType != "datom" => traverseElement(prev, p, Meta(ns.toString(), "args_", metaType, Eq(resolveValues(q"Seq(..$eids)")))) + case q"$prev.$ns.apply(..$eids)" => traverseElement(prev, p, Meta(ns.toString(), "e_", metaType, Eq(resolveValues(q"Seq(..$eids)")))) } - } else if (gns == "?" && datomGenerics.contains(attrStr)) { - resolveApplyGeneric(prev, p, attrStr, vs) + } else if (metaType == "datom" && datomMeta.contains(attrStr)) { + resolveApplyMeta(prev, p, attrStr, vs) - } else if (gns != "?") { - // x(123, gns, attrStr) - gns match { + } else if (metaType != "datom") { + // x(123, metaType, attrStr) + metaType match { case "schema" => resolveApplySchema(t, prev, p, attrStr, vs) case "log" => abort("Log attributes not allowed to have values applied.\n" + @@ -506,26 +511,26 @@ private[molecule] trait Dsl2Model extends Cast with Json { // Aggregate addSpecific(castOneAttr(aggrType), aggrType) addJson(jsonOneAttr, aggrType, "schema." + attrStr) - traverseElement(prev, p, Meta("schema", attrStr, tpe, value)) + traverseElement(prev, p, Meta("Schema", attrStr, "schema", value)) } else { // Clean/comparison addSpecific(castOneAttr(tpe), tpe) addJson(jsonOneAttr, tpe, "schema." + attrStr) - traverseElement(prev, p, Meta("schema", attrStr, tpe, value)) + traverseElement(prev, p, Meta("Schema", attrStr, "schema", value)) } case "tacit" => if (aggrType.isEmpty) { - traverseElement(prev, p, Meta("schema", attrStr, tpe, value)) + traverseElement(prev, p, Meta("Schema", attrStr, "schema", value)) } else { - abort(s"Can only apply `count` to mandatory generic attribute. Please remove underscore from `$attrStr`") + abort(s"Can only apply `count` to mandatory meta attribute. Please remove underscore from `$attrStr`") } case "optional" => if (aggrType.isEmpty) { addCast(castOptionalApplyAttr, t) addJsonCard(jsonOptOneAttr, jsonOptManyAttr, t) - traverseElement(prev, p, Meta("schema", attrStr, tpe, value)) + traverseElement(prev, p, Meta("Schema", attrStr, "schema", value)) } else { - abort(s"Can only apply `count` to mandatory generic attribute. Please remove `$$` from `$attrStr`") + abort(s"Can only apply `count` to mandatory meta attribute. Please remove `$$` from `$attrStr`") } } } @@ -579,40 +584,40 @@ private[molecule] trait Dsl2Model extends Cast with Json { } val element = vs match { case q"scala.collection.immutable.List($pkg.count)" => resolve(Fn("count"), "Int2") - case q"scala.collection.immutable.List($pkg.?)" => abort("Generic input attributes not implemented.") + case q"scala.collection.immutable.List($pkg.?)" => abort("Meta input attributes not implemented.") case q"scala.collection.immutable.List(scala.None)" => resolve(Fn("not")) case q"scala.collection.immutable.List($v)" => resolve(modelValue("apply", null, v)) case q"scala.collection.immutable.List(..$vs)" => resolve(modelValue("apply", null, q"Seq(..$vs)")) - case _ => abort("Unexpected value applied to generic attribute: " + vs) + case _ => abort("Unexpected value applied to meta attribute: " + vs) } // x(220, p.ns, attrStr, vs, element) element } - def resolveApplyGeneric(prev: Tree, p: richTree, attrStr: String, vs: Tree) = { + def resolveApplyMeta(prev: Tree, p: richTree, attrStr: String, vs: Tree) = { def resolve(value: Value, aggrType: String = ""): Seq[Element] = { def casts(mandatory: Boolean, tpe: String): Seq[Element] = { if (prev.toString.endsWith("$")) - abort(s"Optional attributes (`${p.name}`) can't be followed by generic attribute (`$attrStr`).") + abort(s"Optional attributes (`${p.name}`) can't be followed by meta attribute (`$attrStr`).") if (mandatory) { // x(225, "aggrType: " + aggrType) if (aggrType.nonEmpty) { // Aggregate addSpecific(castOneAttr(aggrType), aggrType) addJson(jsonOneAttr, aggrType, p.ns + "." + attrStr) - traverseElement(prev, p, Meta(gns, attrStr, tpe, value)) + traverseElement(prev, p, Meta(p.ns, attrStr, metaType, value)) } else { // Clean/comparison addSpecific(castOneAttr(tpe), tpe) addJson(jsonOneAttr, tpe, p.ns + "." + attrStr) - traverseElement(prev, p, Meta(gns, attrStr, tpe, value)) + traverseElement(prev, p, Meta(p.ns, attrStr, metaType, value)) } } else { // Tacit if (aggrType.isEmpty) { - traverseElement(prev, p, Meta(gns, attrStr, tpe, value)) + traverseElement(prev, p, Meta(p.ns, attrStr, metaType, value)) } else { - abort(s"Can only apply `count` to mandatory generic attribute. Please remove underscore from `$attrStr`") + abort(s"Can only apply `count` to mandatory meta attribute. Please remove underscore from `$attrStr`") } } } @@ -636,11 +641,11 @@ private[molecule] trait Dsl2Model extends Cast with Json { } val element = vs match { case q"scala.collection.immutable.List($pkg.count)" => resolve(Fn("count"), "Int2") - case q"scala.collection.immutable.List($pkg.?)" => abort("Generic input attributes not implemented.") - case q"scala.collection.immutable.List($pkg.$fn)" if badFn(fn) => abort(s"Generic attributes only allowed to aggregate `count`. Found: `$fn`") + case q"scala.collection.immutable.List($pkg.?)" => abort("Meta input attributes not implemented.") + case q"scala.collection.immutable.List($pkg.$fn)" if badFn(fn) => abort(s"Meta attributes only allowed to aggregate `count`. Found: `$fn`") case q"scala.collection.immutable.List($v)" => resolve(modelValue("apply", null, v)) case q"scala.collection.immutable.List(..$vs)" => resolve(modelValue("apply", null, q"Seq(..$vs)")) - case _ => abort("Unexpected value applied to generic attribute: " + vs) + case _ => abort("Unexpected value applied to meta attribute: " + vs) } // x(220, p.ns, attrStr, vs, element) element @@ -659,7 +664,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { case q"$prev.e.apply[..$types]($nested)" if !p.isRef => // x(320, "e") - Seq(Nested(Bond("", "", "", 2), Meta("", "e", "e", EntValue) +: resolve(q"$nested"))) + Seq(Nested(Bond("", "", "", 2), Meta("", "e", "datom", EntValue) +: resolve(q"$nested"))) case q"$prev.e_.apply[..$types]($nested)" if !p.isRef => // x(330, "e_") @@ -711,17 +716,17 @@ private[molecule] trait Dsl2Model extends Cast with Json { if (attrStr.head.isUpper) { // x(91, attrStr, value) if (attrStr == "AVET") - Meta("avet", "range", "range", value) + Meta("AVET", "range", "avet", value) else Atom(t.name, t.name, t.tpeS, t.card, value, t.enumPrefixOpt, bi(tree, t)) - } else if (gns == "?" && datomGenerics.contains(attrStr)) { + } else if (metaType == "datom" && datomMeta.contains(attrStr)) { // x(92, attrStr, values0, value) - resolveOpGeneric(t, attrStr, value) + resolveOpDatom(t, attrStr, value) - } else if (gns != "?") { - // x(93, gns, attrStr) - gns match { + } else if (metaType != "datom") { + // x(93, metaType, attrStr) + metaType match { case "schema" => resolveOpSchema(t, attrStr, value) } } else if (t.isMapAttr) { @@ -749,7 +754,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { def resolveOpSchema(t: richTree, attrStr: String, value: Value) = { def resolve(tpe: String): Meta = { addAttrOrAggr(attrStr, t, tpe) - Meta("schema", attrStr, tpe, value) + Meta("Schema", attrStr, "schema", value) } attrStr match { case "id" | "id_" => resolve("Long") @@ -773,19 +778,19 @@ private[molecule] trait Dsl2Model extends Cast with Json { } } - def resolveOpGeneric(t: richTree, attrStr: String, value: Value) = { + def resolveOpDatom(t: richTree, attrStr: String, value: Value) = { def resolve(tpe: String): Meta = { addAttrOrAggr(attrStr, t, tpe) - Meta(gns, attrStr, tpe, value) + Meta(t.ns, attrStr, metaType, value) } attrStr match { case "e" | "e_" => resolve("Long") case "a" | "a_" => resolve("String") case "v" | "v_" => value match { - case Gt(v) => abort(s"Can't compare generic values being of different types. Found: $attrStr.>($v)") - case Ge(v) => abort(s"Can't compare generic values being of different types. Found: $attrStr.>=($v)") - case Le(v) => abort(s"Can't compare generic values being of different types. Found: $attrStr.<=($v)") - case Lt(v) => abort(s"Can't compare generic values being of different types. Found: $attrStr.<($v)") + case Gt(v) => abort(s"Can't compare meta values being of different types. Found: $attrStr.>($v)") + case Ge(v) => abort(s"Can't compare meta values being of different types. Found: $attrStr.>=($v)") + case Le(v) => abort(s"Can't compare meta values being of different types. Found: $attrStr.<=($v)") + case Lt(v) => abort(s"Can't compare meta values being of different types. Found: $attrStr.<($v)") case _ => resolve("Any") } case "tx" | "tx_" => resolve("Long") @@ -854,7 +859,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { } } - def bi(tree: Tree, t: richTree): Seq[Generic] = if (t.isBidirectional) { + def bi(tree: Tree, t: richTree): Seq[MetaValue] = if (t.isBidirectional) { if (t.isBiSelfRef) { Seq(BiSelfRef(t.refCard)) @@ -898,7 +903,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { throw new Dsl2ModelException("Unexpected Bidirectional: " + t) } } else { - Seq.empty[Generic] + Seq.empty[MetaValue] } def bi2(tree: Tree, t: richTree): Value = bi(tree, t).headOption.getOrElse(NoValue) @@ -1173,7 +1178,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { single(value) case Apply(_, List(Select(_, TermName("$qmark")))) => - // x(2, "?") + // x(2, "datom") Qm case q"Seq(..$values)" => @@ -1272,7 +1277,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { var i: Int = 0 var after: Boolean = false var hasMandatory: Boolean = false - var generics: Seq[String] = Nil + var metas: Seq[String] = Nil var beforeFirstAttr: Boolean = true var isFiltered: Boolean = false var nsAttrs: Map[String, String] = Map.empty[String, String] @@ -1283,7 +1288,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { el match { case e if after => e match { // No non-tx meta attributes after TxMetaData/Nested - case Meta(_, attr, _, _) => txError(s" generic attribute `$attr`") + case Meta(_, attr, _, _) => txError(s" meta attribute `$attr`") case Atom(_, attr, _, _, _, _, _, _) => txError(s" attribute `$attr`") case Bond(_, refAttr, _, _, _) => txError(s" reference `${refAttr.capitalize}`") case _: TxMetaData => // ok @@ -1315,9 +1320,9 @@ private[molecule] trait Dsl2Model extends Cast with Json { case Atom(ns, attr, _, _, _, _, _, _) => if (beforeFirstAttr) { - if (generics.nonEmpty) - abort(s"Can't add first attribute `${a.attr}` after generic attributes (except `e` which is ok to have first). " + - s"Please add generic attributes ${generics.map(g => s"`$g`").mkString(", ")} after `${a.attr}`.") + if (metas.nonEmpty) + abort(s"Can't add first attribute `${a.attr}` after meta attributes (except `e` which is ok to have first). " + + s"Please add meta attributes ${metas.map(g => s"`$g`").mkString(", ")} after `${a.attr}`.") beforeFirstAttr = false } nsAttrs = nsAttrs + ((ns + "/" + clean(attr)) -> attr) @@ -1334,13 +1339,12 @@ private[molecule] trait Dsl2Model extends Cast with Json { hasMandatory = true beforeFirstAttr = false - case m: Meta => { if (m.attr.last != '_') hasMandatory = true - m.ns match { - case "?" if mandatoryDatomGenerics.contains(m.attr) => + m.tpe match { + case "datom" if mandatoryDatomMeta.contains(m.attr) => if (beforeFirstAttr && (m.attr != "e" && m.attr != "e_")) - generics = generics :+ m.attr + metas = metas :+ m.attr m.value match { case NoValue | EntValue | Fn(_, _) => case _ => isFiltered = true @@ -1404,7 +1408,7 @@ private[molecule] trait Dsl2Model extends Cast with Json { // x(802, elements, beforeFirstAttr, isFiltered) if (beforeFirstAttr && !isFiltered) - abort(s"Molecule with only generic attributes and no entity id(s) applied are not allowed " + + abort(s"Molecule with only meta attributes and no entity id(s) applied are not allowed " + s"since it would cause a full scan of the whole database.") // Return checked model diff --git a/core/src/main/scala/molecule/transform/Model2Query.scala b/core/src/main/scala/molecule/transform/Model2Query.scala index 6be3f645b..47523a4eb 100644 --- a/core/src/main/scala/molecule/transform/Model2Query.scala +++ b/core/src/main/scala/molecule/transform/Model2Query.scala @@ -81,6 +81,8 @@ object Model2Query extends Helpers { } } + val datomMeta = Seq("e", "e_", "tx", "t", "txInstant", "op", "tx_", "t_", "txInstant_", "op_", "a", "a_", "v", "v_") + def makeAtom(model: Model, query: Query, atom: Atom, e: String, v: String, w: String, prevNs: String, prevAttr: String, prevRefNs: String) : (Query, String, String, String, String, String) = { val (ns, attr) = (atom.ns, atom.attr) @@ -92,7 +94,7 @@ object Model2Query extends Helpers { case Atom(`prevRefNs`, _, _, _, _, _, _, _) => (resolve(query, v, w, atom), v, w, ns, attr, "") case Atom(`prevAttr`, _, _, _, _, _, _, _) => (resolve(query, v, w, atom), v, w, ns, attr, "") case Atom(`prevNs`, _, _, _, _, _, _, _) => (resolve(query, e, w, atom), e, w, ns, attr, "") - case _ if prevNs == "?" => (resolve(query, e, w, atom), e, w, ns, attr, "") + case _ if datomMeta.contains(prevAttr) => (resolve(query, e, w, atom), e, w, ns, attr, "") case _ => (resolve(query, e, v, atom), e, v, ns, attr, "") } } @@ -143,9 +145,9 @@ object Model2Query extends Helpers { def makeMeta(model: Model, query: Query, meta: Meta, e: String, v: String, w: String, y: String, prevNs: String, prevAttr: String, prevRefNs: String) : (Query, String, String, String, String, String) = if (prevRefNs.nonEmpty) { // Advance variable letters to next namespace - (resolve(query, v, w, meta), v, y, meta.ns, meta.attr, "") + (resolve(query, v, w, meta), v, y, meta.tpe, meta.attr, "") } else { - (resolve(query, e, v, meta), e, v, meta.ns, meta.attr, "") + (resolve(query, e, v, meta), e, v, meta.tpe, meta.attr, "") } def makeTxMetaData(model: Model, query0: Query, txMetaData: TxMetaData, w: String, prevNs: String, prevAttr: String, prevRefNs: String) @@ -164,7 +166,6 @@ object Model2Query extends Helpers { (query0.copy(wh = Where(cls1)), txV) } - // val (q2, e2, v2, prevNs2, prevAttr2, prevRefNs2) = txMetaData.elements.foldLeft((query, "tx", w, prevNs, prevAttr, prevRefNs)) { val (q2, e2, v2, prevNs2, prevAttr2, prevRefNs2) = txMetaData.elements.foldLeft((query, txV, w, prevNs, prevAttr, prevRefNs)) { case ((q1, e1, v1, prevNs1, prevAttr1, prevRefNs1), element) => make(model, q1, element, e1, v1, prevNs1, prevAttr1, prevRefNs1) } @@ -247,60 +248,61 @@ object Model2Query extends Helpers { } - def resolveMeta(q: Query, e: String, meta: Meta, v: String, v1: String, v2: String, v3: String): Query = meta.ns match { + // def resolveMeta(q: Query, e: String, meta: Meta, v: String, v1: String, v2: String, v3: String): Query = meta.ns match { + def resolveMeta(q: Query, e: String, meta: Meta, v: String, v1: String, v2: String, v3: String): Query = meta.tpe match { case "schema" => resolveSchema(q, meta) - case "?" => resolveGeneric(q, e, meta, v, v1, v2, v3) - case _ => q + case "datom" => resolveDatom(q, e, meta, v, v1, v2, v3) + case _ => q // Indexes are handled in Conn directly from Model elements } // Schema .................................................................................... def resolveSchema(q: Query, meta: Meta): Query = meta.attr match { - case "id" => resolveSchemaMandatory(meta, q.schema) - case "a" => resolveSchemaMandatory(meta, q.schemaA) - case "part" => resolveSchemaMandatory(meta, q.schema) - case "nsFull" => resolveSchemaMandatory(meta, q.schema) - case "ns" => resolveSchemaMandatory(meta, q.schema) - case "attr" => resolveSchemaMandatory(meta, q.schemaAttr) - case "tpe" => resolveSchemaMandatory(meta, q.schemaTpe) - case "card" => resolveSchemaMandatory(meta, q.schemaCard) - case "doc" => resolveSchemaMandatory(meta, q.schemaDoc) - case "index" => resolveSchemaMandatory(meta, q.schemaIndex) - case "unique" => resolveSchemaMandatory(meta, q.schemaUnique) - case "fulltext" => resolveSchemaMandatory(meta, q.schemaFulltext) - case "isComponent" => resolveSchemaMandatory(meta, q.schemaIsComponent) - case "noHistory" => resolveSchemaMandatory(meta, q.schemaNoHistory) - case "enum" => resolveSchemaMandatory(meta, q.schemaEnum) - case "t" => resolveSchemaMandatory(meta, q.schemaT) - case "tx" => resolveSchemaMandatory(meta, q.schema) - case "txInstant" => resolveSchemaMandatory(meta, q.schemaTxInstant) - - case "id_" => resolveSchemaTacit(meta, q.schema) - case "a_" => resolveSchemaTacit(meta, q.schemaA) - case "part_" => resolveSchemaTacit(meta, q.schema) - case "nsFull_" => resolveSchemaTacit(meta, q.schema) - case "ns_" => resolveSchemaTacit(meta, q.schema) - case "attr_" => resolveSchemaTacit(meta, q.schemaAttr) - case "tpe_" => resolveSchemaTacit(meta, q.schemaTpe) - case "card_" => resolveSchemaTacit(meta, q.schemaCard) - case "doc_" => resolveSchemaTacit(meta, q.schemaDoc) - case "index_" => resolveSchemaTacit(meta, q.schemaIndex) - case "unique_" => resolveSchemaTacit(meta, q.schemaUnique) - case "fulltext_" => resolveSchemaTacit(meta, q.schemaFulltext) - case "isComponent_" => resolveSchemaTacit(meta, q.schemaIsComponent) - case "noHistory_" => resolveSchemaTacit(meta, q.schemaNoHistory) - case "enum_" => resolveSchemaTacit(meta, q.schemaEnum) - case "t_" => resolveSchemaTacit(meta, q.schemaT) - case "tx_" => resolveSchemaTacit(meta, q.schema) - case "txInstant_" => resolveSchemaTacit(meta, q.schemaTxInstant) + case "id" => resolveSchemaMandatory(meta, q.schema, "Long") + case "a" => resolveSchemaMandatory(meta, q.schemaA, "String") + case "part" => resolveSchemaMandatory(meta, q.schema, "String") + case "nsFull" => resolveSchemaMandatory(meta, q.schema, "String") + case "ns" => resolveSchemaMandatory(meta, q.schema, "String") + case "attr" => resolveSchemaMandatory(meta, q.schemaAttr, "String") + case "tpe" => resolveSchemaMandatory(meta, q.schemaTpe, "String") + case "card" => resolveSchemaMandatory(meta, q.schemaCard, "String") + case "doc" => resolveSchemaMandatory(meta, q.schemaDoc, "String") + case "index" => resolveSchemaMandatory(meta, q.schemaIndex, "Boolean") + case "unique" => resolveSchemaMandatory(meta, q.schemaUnique, "String") + case "fulltext" => resolveSchemaMandatory(meta, q.schemaFulltext, "Boolean") + case "isComponent" => resolveSchemaMandatory(meta, q.schemaIsComponent, "Boolean") + case "noHistory" => resolveSchemaMandatory(meta, q.schemaNoHistory, "Boolean") + case "enum" => resolveSchemaMandatory(meta, q.schemaEnum, "String") + case "t" => resolveSchemaMandatory(meta, q.schemaT, "Long") + case "tx" => resolveSchemaMandatory(meta, q.schema, "Long") + case "txInstant" => resolveSchemaMandatory(meta, q.schemaTxInstant, "java.util.Date") + + case "id_" => resolveSchemaTacit(meta, q.schema, "Long") + case "a_" => resolveSchemaTacit(meta, q.schemaA, "String") + case "part_" => resolveSchemaTacit(meta, q.schema, "String") + case "nsFull_" => resolveSchemaTacit(meta, q.schema, "String") + case "ns_" => resolveSchemaTacit(meta, q.schema, "String") + case "attr_" => resolveSchemaTacit(meta, q.schemaAttr, "String") + case "tpe_" => resolveSchemaTacit(meta, q.schemaTpe, "String") + case "card_" => resolveSchemaTacit(meta, q.schemaCard, "String") + case "doc_" => resolveSchemaTacit(meta, q.schemaDoc, "String") + case "index_" => resolveSchemaTacit(meta, q.schemaIndex, "Boolean") + case "unique_" => resolveSchemaTacit(meta, q.schemaUnique, "String") + case "fulltext_" => resolveSchemaTacit(meta, q.schemaFulltext, "Boolean") + case "isComponent_" => resolveSchemaTacit(meta, q.schemaIsComponent, "Boolean") + case "noHistory_" => resolveSchemaTacit(meta, q.schemaNoHistory, "Boolean") + case "enum_" => resolveSchemaTacit(meta, q.schemaEnum, "String") + case "t_" => resolveSchemaTacit(meta, q.schemaT, "Long") + case "tx_" => resolveSchemaTacit(meta, q.schema, "Long") + case "txInstant_" => resolveSchemaTacit(meta, q.schemaTxInstant, "java.util.Date") case "unique$" => resolveSchemaOptionalUnique(meta, q) case optional => resolveSchemaOptional(meta, q) } - def resolveSchemaMandatory(meta: Meta, q: Query): Query = { - val (v, tpe) = (meta.attr, meta.kind) + def resolveSchemaMandatory(meta: Meta, q: Query, tpe: String): Query = { + val v = meta.attr meta.value match { case NoValue => q.find(v) case Eq(args) => q.find(v).in(args, v) @@ -316,8 +318,8 @@ object Model2Query extends Helpers { } } - def resolveSchemaTacit(meta: Meta, q: Query): Query = { - val (v, tpe) = (meta.attr.init, meta.kind) + def resolveSchemaTacit(meta: Meta, q: Query, tpe: String): Query = { + val v = meta.attr.init meta.value match { case NoValue => q case Eq(args) => q.in(args, v) @@ -358,78 +360,77 @@ object Model2Query extends Helpers { } - // Generic .................................................................................... + // Datom .................................................................................... - def resolveGeneric(q: Query, e: String, meta: Meta, v: String, v1: String, v2: String, v3: String): Query = meta.attr match { + def resolveDatom(q: Query, e: String, meta: Meta, v: String, v1: String, v2: String, v3: String): Query = meta.attr match { case "e" => - val q1 = q.genericE(e, v, v1, _model.elements.size == 1) + val q1 = q.datomE(e, v, v1, _model.elements.size == 1) val w = if (q1.wh.clauses.exists { case DataClause(_, Var(`e`), KW(_, _, refNs), _, _, _) if refNs.nonEmpty => true case _ => false }) v else e - resolveGenericMandatory(q1, e, meta, "", w) - case "tx" => resolveGenericMandatory(q.genericTx(e, v, v1), e, meta, v) - case "t" => resolveGenericMandatory(q.genericT(e, v, v1), e, meta, v) - case "txInstant" => resolveGenericMandatory(q.genericTxInstant(e, v, v1), e, meta, v) - case "op" => resolveGenericMandatory(q.genericOp(e, v, v1), e, meta, v) - case "a" => resolveGenericMandatory(q.genericA(e, v, v1), e, meta, v) + resolveDatomMandatory(q1, e, meta, "Long", "", w) + case "tx" => resolveDatomMandatory(q.datomTx(e, v, v1), e, meta, "Long", v) + case "t" => resolveDatomMandatory(q.datomT(e, v, v1), e, meta, "Long", v) + case "txInstant" => resolveDatomMandatory(q.datomTxInstant(e, v, v1), e, meta, "java.util.Date", v) + case "op" => resolveDatomMandatory(q.datomOp(e, v, v1), e, meta, "Boolean", v) + case "a" => resolveDatomMandatory(q.datomA(e, v, v1), e, meta, "String", v) case "v" => - val q1 = q.genericV(e, v, v1) + val q1 = q.datomV(e, v, v1) val w = if (q1.wh.clauses.exists { case DataClause(_, _, KW(_, attr, _), _, _, _) if attr == e + "_attr" => true case _ => false }) v else v + "_v" - resolveGenericMandatory(q1, e, meta, "", w) + resolveDatomMandatory(q1, e, meta, "Any", "", w) case "e_" => - val q1 = q.genericE(e, v, v1) + val q1 = q.datomE(e, v, v1) val w = if (q1.wh.clauses.exists { case DataClause(_, Var(`e`), KW(_, _, refNs), _, _, _) if refNs.nonEmpty => true case _ => false }) v else e - resolveGenericTacit(q1, e, meta, "", w) - case "tx_" => resolveGenericTacit(q.genericTx(e, v, v1), e, meta, v) - case "t_" => resolveGenericTacit(q.genericT(e, v, v1), e, meta, v) - case "txInstant_" => resolveGenericTacit(q.genericTxInstant(e, v, v1), e, meta, v) - case "op_" => resolveGenericTacit(q.genericOp(e, v, v1), e, meta, v) - case "a_" => resolveGenericTacit(q.genericA(e, v, v1), e, meta, v) + resolveDatomTacit(q1, e, meta, "Long", "", w) + case "tx_" => resolveDatomTacit(q.datomTx(e, v, v1), e, meta, "Long", v) + case "t_" => resolveDatomTacit(q.datomT(e, v, v1), e, meta, "Long", v) + case "txInstant_" => resolveDatomTacit(q.datomTxInstant(e, v, v1), e, meta, "java.util.Date", v) + case "op_" => resolveDatomTacit(q.datomOp(e, v, v1), e, meta, "Boolean", v) + case "a_" => resolveDatomTacit(q.datomA(e, v, v1), e, meta, "String", v) case "v_" => - val q1 = q.genericV(e, v, v1) + val q1 = q.datomV(e, v, v1) val w = if (q1.wh.clauses.exists { case DataClause(_, _, KW(_, attr, _), _, _, _) if attr == e + "_attr" => true case _ => false }) v else v + "_v" - resolveGenericTacit(q1, e, meta, "", w) + resolveDatomTacit(q1, e, meta, "Any", "", w) } - def resolveGenericMandatory(q: Query, e: String, meta: Meta, v0: String, w: String = ""): Query = { + def resolveDatomMandatory(q: Query, e: String, meta: Meta, tpe: String, v0: String, w: String = ""): Query = { val v = if (w.nonEmpty) w else v0 + "_" + meta.attr -// val w = meta.value match { case NoValue | EntValue => q.find(v) case Eq(args) => q.find(v).in(args, v) case Neq(args) => q.find(v).compareToMany2("!=", v, args) - case Gt(arg) => q.find(v).compareTo2(">", meta.kind, v, Val(arg), q.wh.clauses.length) - case Ge(arg) => q.find(v).compareTo2(">=", meta.kind, v, Val(arg), q.wh.clauses.length) - case Lt(arg) => q.find(v).compareTo2("<", meta.kind, v, Val(arg), q.wh.clauses.length) - case Le(arg) => q.find(v).compareTo2("<=", meta.kind, v, Val(arg), q.wh.clauses.length) + case Gt(arg) => q.find(v).compareTo2(">", tpe, v, Val(arg), q.wh.clauses.length) + case Ge(arg) => q.find(v).compareTo2(">=", tpe, v, Val(arg), q.wh.clauses.length) + case Lt(arg) => q.find(v).compareTo2("<", tpe, v, Val(arg), q.wh.clauses.length) + case Le(arg) => q.find(v).compareTo2("<=", tpe, v, Val(arg), q.wh.clauses.length) case Fn("count", _) => q.find("count", Nil, v) case other => abort("Unexpected value: " + other) } } - def resolveGenericTacit(q: Query, e: String, meta: Meta, v0: String, w: String = ""): Query = { + def resolveDatomTacit(q: Query, e: String, meta: Meta, tpe: String, v0: String, w: String = ""): Query = { val v = if (w.nonEmpty) w else v0 + "_" + meta.attr.init // skip underscore at end meta.value match { case NoValue | EntValue => q - case Eq(Seq(Qm)) => q.in(v, meta.ns, meta.attr, e) - case Eq(args) => q.in(args, v) - case Neq(args) => q.compareToMany2("!=", v, args) - case Gt(arg) => q.compareTo2(">", meta.kind, v, Val(arg), q.wh.clauses.length) - case Ge(arg) => q.compareTo2(">=", meta.kind, v, Val(arg), q.wh.clauses.length) - case Lt(arg) => q.compareTo2("<", meta.kind, v, Val(arg), q.wh.clauses.length) - case Le(arg) => q.compareTo2("<=", meta.kind, v, Val(arg), q.wh.clauses.length) - case other => abort("Unexpected value: " + other) + case Eq(Seq(Qm)) => q.in(v, meta.tpe, meta.attr, e) + case Eq(args) => q.in(args, v) + case Neq(args) => q.compareToMany2("!=", v, args) + case Gt(arg) => q.compareTo2(">", tpe, v, Val(arg), q.wh.clauses.length) + case Ge(arg) => q.compareTo2(">=", tpe, v, Val(arg), q.wh.clauses.length) + case Lt(arg) => q.compareTo2("<", tpe, v, Val(arg), q.wh.clauses.length) + case Le(arg) => q.compareTo2("<=", tpe, v, Val(arg), q.wh.clauses.length) + case other => abort("Unexpected value: " + other) } } @@ -704,7 +705,7 @@ object Model2Query extends Helpers { } def resolveEnumMandatory2(q: Query, e: String, a: Atom, v: String, v1: String, v2: String, v3: String, prefix: String): Query = { - val (gs, t) = (a.gs, a.tpeS) + val (gs, t) = (a.gs, a.tpe) a.value match { case Qm => q.findD(v2).enum(e, a, v).in(e, a, Some(prefix), v2) case Neq(Seq(Qm)) => q.findD(v2).enum(e, a, v).compareTo("!=", a, v2, Var(v3), 1).in(e, a, Some(prefix), v3) @@ -734,7 +735,7 @@ object Model2Query extends Helpers { } def resolveEnumMandatory1(q: Query, e: String, a: Atom, v: String, v1: String, v2: String, v3: String, prefix: String): Query = { - val (gs, t) = (a.gs, a.tpeS) + val (gs, t) = (a.gs, a.tpe) a.value match { case Qm => q.find(v2).enum(e, a, v).in(e, a, Some(prefix), v2) case Neq(Seq(Qm)) => q.find(v2).enum(e, a, v).compareTo("!=", a, v2, Var(v3), 1).in(e, a, Some(prefix), v3) @@ -763,7 +764,7 @@ object Model2Query extends Helpers { def resolveAtomOptional2(q: Query, e: String, a0: Atom, v: String): Query = { val a = a0.copy(attr = a0.attr.init) - val (gs, t) = (a.gs, a.tpeS) + val (gs, t) = (a.gs, a.tpe) a.value match { case VarValue => q.pull(e, a) case Fn("not", _) => q.pull(e, a).not(e, a) // None @@ -775,7 +776,7 @@ object Model2Query extends Helpers { } def resolveAtomOptional1(q: Query, e: String, a0: Atom, v: String): Query = { val a = a0.copy(attr = a0.attr.init) - val (gs, t) = (a.gs, a.tpeS) + val (gs, t) = (a.gs, a.tpe) a.value match { case VarValue => q.pull(e, a) case Fn("not", _) => q.pull(e, a).not(e, a) // None @@ -789,7 +790,7 @@ object Model2Query extends Helpers { def resolveAtomTacit(q: Query, e: String, a0: Atom, v: String, v1: String): Query = { val a = a0.copy(attr = a0.attr.init) - val (gs, t) = (a.gs, a.tpeS) + val (gs, t) = (a.gs, a.tpe) a.value match { case Qm => q.where(e, a, v).in(e, a, None, v) case Neq(Seq(Qm)) => q.where(e, a, v).compareTo("!=", a, v, Var(v1)).in(e, a, None, v1) @@ -822,7 +823,7 @@ object Model2Query extends Helpers { } def resolveAtomMandatory2(q: Query, e: String, a: Atom, v: String, v1: String, v2: String): Query = { - val (gs, t) = (a.gs, a.tpeS) + val (gs, t) = (a.gs, a.tpe) a.value match { case Qm => q.findD(v).where(e, a, v).in(e, a, None, v) case Neq(Seq(Qm)) => q.findD(v).where(e, a, v).compareTo("!=", a, v, Var(v1)).in(e, a, None, v1) @@ -857,7 +858,7 @@ object Model2Query extends Helpers { } def resolveAtomMandatory1(q: Query, e: String, a: Atom, v: String, v1: String, v2: String): Query = { - val (gs, t) = (a.gs, a.tpeS) + val (gs, t) = (a.gs, a.tpe) a.value match { case Qm => q.find(v).where(e, a, v).in(e, a, None, v) case Neq(Seq(Qm)) => q.find(v).where(e, a, v).compareTo("!=", a, v, Var(v1)).in(e, a, None, v1) diff --git a/core/src/main/scala/molecule/transform/Model2Transaction.scala b/core/src/main/scala/molecule/transform/Model2Transaction.scala index 0dc11141c..55b3a4a8b 100644 --- a/core/src/main/scala/molecule/transform/Model2Transaction.scala +++ b/core/src/main/scala/molecule/transform/Model2Transaction.scala @@ -29,7 +29,7 @@ case class Model2Transaction(conn: Conn, model: Model) extends Helpers { case ((eSlot1, stmts1), element1) => resolveElement(eSlot1, stmts1, element1) }._2 - def bi(gs: Seq[Generic], card: Int) = gs.collectFirst { + def bi(gs: Seq[MetaValue], card: Int) = gs.collectFirst { case bi: Bidirectional => bi } getOrElse Card(card) @@ -172,7 +172,7 @@ case class Model2Transaction(conn: Conn, model: Model) extends Helpers { a: String, arg: Any, prefix: Option[String], - bi: Generic, + bidirectional: MetaValue, otherEdgeId: Option[AnyRef]): Seq[Statement] = { def p(arg: Any) = if (prefix.isDefined) prefix.get + arg else arg @@ -678,7 +678,7 @@ case class Model2Transaction(conn: Conn, model: Model) extends Helpers { case v => Seq(Add(e, a, p(v), Card(card))) } - val newStmts = bi match { + val newStmts = bidirectional match { case BiSelfRef(card) => biSelf(card) case BiSelfRefAttr(card) => biSelf(card) case BiOtherRef(card, attr) => biOther(card, attr) @@ -690,8 +690,7 @@ case class Model2Transaction(conn: Conn, model: Model) extends Helpers { case BiEdgePropRef(card) => biEdgeProp(card) case BiTargetRef(card, attr) => biTarget(card, attr) case BiTargetRefAttr(card, attr) => biTarget(card, attr) - case Card(card) => - default(card) + case Card(card) => default(card) case other => throw new Model2TransactionException( s"""Unexpected or missing Generic `$other`: |e : $e @@ -713,7 +712,7 @@ case class Model2Transaction(conn: Conn, model: Model) extends Helpers { case ((stmts, txStmts), stmt) => (stmts :+ stmt, txStmts) } - def lastE(stmts: Seq[Statement], attr: String, nestedE: Any, bi: Generic, composite: Any = 'e): Any = { + def lastE(stmts: Seq[Statement], attr: String, nestedE: Any, bi: MetaValue, composite: Any = 'e): Any = { bi match { case BiTargetRef(_, _) => { val lastEdgeNs = attr.split("/").head diff --git a/coretests/src/main/scala/molecule/coretests/generic/schema/AEVTDefinition.scala b/coretests/src/main/scala/molecule/coretests/meta/schema/AEVTDefinition.scala similarity index 73% rename from coretests/src/main/scala/molecule/coretests/generic/schema/AEVTDefinition.scala rename to coretests/src/main/scala/molecule/coretests/meta/schema/AEVTDefinition.scala index 3b5fb20a7..6cffd1cb3 100644 --- a/coretests/src/main/scala/molecule/coretests/generic/schema/AEVTDefinition.scala +++ b/coretests/src/main/scala/molecule/coretests/meta/schema/AEVTDefinition.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic.schema +package molecule.coretests.meta.schema import molecule.schema.definition._ @InOut(0, 8) diff --git a/coretests/src/main/scala/molecule/coretests/generic/schema/AVETDefinition.scala b/coretests/src/main/scala/molecule/coretests/meta/schema/AVETDefinition.scala similarity index 73% rename from coretests/src/main/scala/molecule/coretests/generic/schema/AVETDefinition.scala rename to coretests/src/main/scala/molecule/coretests/meta/schema/AVETDefinition.scala index d31292af8..ce0f19c0c 100644 --- a/coretests/src/main/scala/molecule/coretests/generic/schema/AVETDefinition.scala +++ b/coretests/src/main/scala/molecule/coretests/meta/schema/AVETDefinition.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic.schema +package molecule.coretests.meta.schema import molecule.schema.definition._ @InOut(0, 8) diff --git a/coretests/src/main/scala/molecule/coretests/generic/schema/DatomDefinition.scala b/coretests/src/main/scala/molecule/coretests/meta/schema/DatomDefinition.scala similarity index 93% rename from coretests/src/main/scala/molecule/coretests/generic/schema/DatomDefinition.scala rename to coretests/src/main/scala/molecule/coretests/meta/schema/DatomDefinition.scala index f8dbaf1aa..cc856a1e4 100644 --- a/coretests/src/main/scala/molecule/coretests/generic/schema/DatomDefinition.scala +++ b/coretests/src/main/scala/molecule/coretests/meta/schema/DatomDefinition.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic.schema +package molecule.coretests.meta.schema import molecule.schema.definition._ @InOut(0, 22) diff --git a/coretests/src/main/scala/molecule/coretests/generic/schema/EAVTDefinition.scala b/coretests/src/main/scala/molecule/coretests/meta/schema/EAVTDefinition.scala similarity index 73% rename from coretests/src/main/scala/molecule/coretests/generic/schema/EAVTDefinition.scala rename to coretests/src/main/scala/molecule/coretests/meta/schema/EAVTDefinition.scala index f2ff90a06..c251e24da 100644 --- a/coretests/src/main/scala/molecule/coretests/generic/schema/EAVTDefinition.scala +++ b/coretests/src/main/scala/molecule/coretests/meta/schema/EAVTDefinition.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic.schema +package molecule.coretests.meta.schema import molecule.schema.definition._ @InOut(0, 8) diff --git a/coretests/src/main/scala/molecule/coretests/generic/schema/LogDefinition.scala b/coretests/src/main/scala/molecule/coretests/meta/schema/LogDefinition.scala similarity index 73% rename from coretests/src/main/scala/molecule/coretests/generic/schema/LogDefinition.scala rename to coretests/src/main/scala/molecule/coretests/meta/schema/LogDefinition.scala index 0f9dae1d5..a9c7a8d6b 100644 --- a/coretests/src/main/scala/molecule/coretests/generic/schema/LogDefinition.scala +++ b/coretests/src/main/scala/molecule/coretests/meta/schema/LogDefinition.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic.schema +package molecule.coretests.meta.schema import molecule.schema.definition._ @InOut(0, 8) diff --git a/coretests/src/main/scala/molecule/coretests/generic/schema/SchemaDefinition.scala b/coretests/src/main/scala/molecule/coretests/meta/schema/SchemaDefinition.scala similarity index 97% rename from coretests/src/main/scala/molecule/coretests/generic/schema/SchemaDefinition.scala rename to coretests/src/main/scala/molecule/coretests/meta/schema/SchemaDefinition.scala index 25401f061..1bf61b5df 100644 --- a/coretests/src/main/scala/molecule/coretests/generic/schema/SchemaDefinition.scala +++ b/coretests/src/main/scala/molecule/coretests/meta/schema/SchemaDefinition.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic.schema +package molecule.coretests.meta.schema import molecule.schema.definition._ @InOut(0, 22) diff --git a/coretests/src/main/scala/molecule/coretests/generic/schema/VAETDefinition.scala b/coretests/src/main/scala/molecule/coretests/meta/schema/VAETDefinition.scala similarity index 73% rename from coretests/src/main/scala/molecule/coretests/generic/schema/VAETDefinition.scala rename to coretests/src/main/scala/molecule/coretests/meta/schema/VAETDefinition.scala index 0c8ce08b7..cf6671386 100644 --- a/coretests/src/main/scala/molecule/coretests/generic/schema/VAETDefinition.scala +++ b/coretests/src/main/scala/molecule/coretests/meta/schema/VAETDefinition.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic.schema +package molecule.coretests.meta.schema import molecule.schema.definition._ @InOut(0, 8) diff --git a/coretests/src/test/scala/molecule/coretests/AdHocTest.scala b/coretests/src/test/scala/molecule/coretests/AdHocTest.scala index 921be1f8d..f28731080 100644 --- a/coretests/src/test/scala/molecule/coretests/AdHocTest.scala +++ b/coretests/src/test/scala/molecule/coretests/AdHocTest.scala @@ -1,10 +1,12 @@ package molecule.coretests +import molecule.api.in1_out6.m import molecule.api.in3_out22._ -import molecule.ast.tempDb.History +import molecule.ast.model._ import molecule.coretests.util.CoreSpec -import molecule.coretests.util.dsl.coreTest.{Ns, Ref1} +import molecule.coretests.util.dsl.coreTest._ import molecule.coretests.util.schema.CoreTestSchema +import molecule.transform.Model2Query import molecule.util.Helpers @@ -17,6 +19,7 @@ class AdHocTest extends CoreSpec with Helpers { "adhoc" >> { + ok } diff --git a/coretests/src/test/scala/molecule/coretests/generic/Datom.scala b/coretests/src/test/scala/molecule/coretests/meta/Datom.scala similarity index 89% rename from coretests/src/test/scala/molecule/coretests/generic/Datom.scala rename to coretests/src/test/scala/molecule/coretests/meta/Datom.scala index faaa85ac2..43afcda2e 100644 --- a/coretests/src/test/scala/molecule/coretests/generic/Datom.scala +++ b/coretests/src/test/scala/molecule/coretests/meta/Datom.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic +package molecule.coretests.meta import molecule.api.out10._ import molecule.coretests.util.CoreSpec @@ -8,7 +8,7 @@ import molecule.ops.exception.VerifyModelException import molecule.util.expectCompileError -/** Generic Datom attribute interface +/** Datom meta attribute interface * * - `e` Entity id (Long) * - `a` Full attribute name like ":Person/name" (String) @@ -79,8 +79,8 @@ class Datom extends CoreSpec { "1 entity" >> { - // Several generic attributes can be asserted with a common entity id - // Molecules with an applied entity id and only generic attributes + // Several meta attributes can be asserted with a common entity id + // Molecules with an applied entity id and only meta attributes // matches the Datom values of the entity // Entity `e1` has 2 asserted datoms (and the entity id) @@ -119,7 +119,7 @@ class Datom extends CoreSpec { (e1, ":Ns/str", "b", tx2, true), ) - // Generic attributes can be added in any order + // Meta attributes can be added in any order Ns(e1).v.t.e.op.tx.a.get === List( ("b", 1030, e1, true, tx2, ":Ns/str"), (3, 1031, e1, true, tx3, ":Ns/int") @@ -169,7 +169,7 @@ class Datom extends CoreSpec { Ns.int.txInstant.get.sortBy(_._1).toString === List((3, d3), (5, d5)).toString Ns.int.op.get === List((5, true), (3, true)) - // Generic attributes after attribute with applied value + // Meta attributes after attribute with applied value Ns.int(5).e.get === List((5, e2)) Ns.int(5).a.get === List((5, ":Ns/int")) Ns.int(5).v.get === List((5, 5)) @@ -178,7 +178,7 @@ class Datom extends CoreSpec { Ns.int(5).txInstant.get.toString === List((5, d5)).toString Ns.int(5).op.get === List((5, true)) - // Generic attributes after attribute with applied operation + // Meta attributes after attribute with applied operation Ns.int.<(4).e.get === List((3, e1)) Ns.int.<(4).a.get === List((3, ":Ns/int")) Ns.int.<(4).v.get === List((3, 3)) @@ -187,7 +187,7 @@ class Datom extends CoreSpec { Ns.int.<(4).txInstant.get.toString === List((3, d3)).toString Ns.int.<(4).op.get === List((3, true)) - // Generic attributes after attribute with applied aggregate keyword + // Meta attributes after attribute with applied aggregate keyword Ns.int(max).e.get === List((3, e1), (5, e2)) Ns.int(max).a.get === List((5, ":Ns/int")) Ns.int(max).v.get === List((3, 3), (5, 5)) @@ -198,31 +198,31 @@ class Datom extends CoreSpec { } - "Generic attributes before custom attribute" >> { + "Meta attributes before custom attribute" >> { // Generic entity id attribute before first attribute ok Ns.e.int.t.get === List((e1, 3, t3), (e2, 5, t5)) - // Other generic attributes not allowed before first attribute + // Other meta attributes not allowed before first attribute expectCompileError( "Ns.t.op.int.get", "molecule.transform.exception.Dsl2ModelException: " + - "Can't add first attribute `int` after generic attributes (except `e` which is ok to have first). " + - "Please add generic attributes `t`, `op` after `int`.") + "Can't add first attribute `int` after meta attributes (except `e` which is ok to have first). " + + "Please add meta attributes `t`, `op` after `int`.") - // Add generic attributes after custom attribute instead + // Add meta attributes after custom attribute instead Ns.int.t.op.get === List((5, t5, true), (3, t3, true)) } "Full scan" >> { - // Generic attributes without an entity id applied or custom attributes added would + // Meta attributes without an entity id applied or custom attributes added would // cause a full scan of the whole database and is not allowed expectCompileError( "Ns.e.a.v.t.get", "molecule.transform.exception.Dsl2ModelException: " + - "Molecule with only generic attributes and no entity id(s) applied are not allowed since " + + "Molecule with only meta attributes and no entity id(s) applied are not allowed since " + "it would cause a full scan of the whole database.") // Any filter will prevent a full scan @@ -236,7 +236,7 @@ class Datom extends CoreSpec { expectCompileError( "Ns.e(count).get", "molecule.transform.exception.Dsl2ModelException: " + - "Molecule with only generic attributes and no entity id(s) applied are not allowed since " + + "Molecule with only meta attributes and no entity id(s) applied are not allowed since " + "it would cause a full scan of the whole database.") // If some attribute is also asserted, we can use count @@ -246,7 +246,7 @@ class Datom extends CoreSpec { "Ref" >> { - // Generic attributes after ref id + // Meta attributes after ref id Ns.Ref1.e.get === List(r1) Ns.Ref1.a.get === List(":Ref1/str1") Ns.Ref1.v.get === List("hello") @@ -335,7 +335,7 @@ class Datom extends CoreSpec { expectCompileError( """m(Ns.v.>(3))""", "molecule.transform.exception.Dsl2ModelException: " + - "Can't compare generic values being of different types. Found: v.>(3)") + "Can't compare meta values being of different types. Found: v.>(3)") Ns.tx(tx3).get === List(tx3) Ns.tx(tx3, tx5).get === List(tx3, tx5) @@ -415,11 +415,11 @@ class Datom extends CoreSpec { Ns.int_.op(count).get === List(1) - // Generic attributes only allowed to aggregate `count` + // Meta attributes only allowed to aggregate `count` expectCompileError( """m(Ns.int.t(max))""", "molecule.transform.exception.Dsl2ModelException: " + - "Generic attributes only allowed to aggregate `count`. Found: `max`") + "Meta attributes only allowed to aggregate `count`. Found: `max`") ok } @@ -446,7 +446,7 @@ class Datom extends CoreSpec { expectCompileError( """m(Ns.int.v_.<=(3))""", "molecule.transform.exception.Dsl2ModelException: " + - "Can't compare generic values being of different types. Found: v_.<=(3)") + "Can't compare meta values being of different types. Found: v_.<=(3)") Ns.int.tx_(tx3).get === List(3) Ns.int.tx_(tx3, tx5).get === List(3, 5) @@ -501,7 +501,7 @@ class Datom extends CoreSpec { "Multiple tx attributes" >> { - // Tacit attributes can be followed by generic attributes + // Tacit attributes can be followed by meta attributes Ns(e1).str_.tx.get.head === tx2 Ns(e1).int_.tx.get.head === tx3 @@ -512,19 +512,19 @@ class Datom extends CoreSpec { "Optional tx data not allowed" >> { expectCompileError( """m(Ns.int$.tx.str)""", - "molecule.transform.exception.Dsl2ModelException: Optional attributes (`int$`) can't be followed by generic transaction attributes (`tx`).") + "molecule.transform.exception.Dsl2ModelException: Optional attributes (`int$`) can't be followed by meta transaction attributes (`tx`).") expectCompileError( """m(Ns.int$.t.str)""", - "molecule.transform.exception.Dsl2ModelException: Optional attributes (`int$`) can't be followed by generic transaction attributes (`t`).") + "molecule.transform.exception.Dsl2ModelException: Optional attributes (`int$`) can't be followed by meta transaction attributes (`t`).") expectCompileError( """m(Ns.int$.txInstant.str)""", - "molecule.transform.exception.Dsl2ModelException: Optional attributes (`int$`) can't be followed by generic transaction attributes (`txInstant`).") + "molecule.transform.exception.Dsl2ModelException: Optional attributes (`int$`) can't be followed by meta transaction attributes (`txInstant`).") expectCompileError( """m(Ns.int$.op.str)""", - "molecule.transform.exception.Dsl2ModelException: Optional attributes (`int$`) can't be followed by generic transaction attributes (`op`).") + "molecule.transform.exception.Dsl2ModelException: Optional attributes (`int$`) can't be followed by meta transaction attributes (`op`).") ok } diff --git a/coretests/src/test/scala/molecule/coretests/generic/Index.scala b/coretests/src/test/scala/molecule/coretests/meta/Index.scala similarity index 99% rename from coretests/src/test/scala/molecule/coretests/generic/Index.scala rename to coretests/src/test/scala/molecule/coretests/meta/Index.scala index 1654f4170..4bb405ccd 100644 --- a/coretests/src/test/scala/molecule/coretests/generic/Index.scala +++ b/coretests/src/test/scala/molecule/coretests/meta/Index.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic +package molecule.coretests.meta import molecule.api.out10._ import molecule.api.out5.m @@ -115,7 +115,7 @@ class Index extends CoreSpec { (e1, ":Ns/int", 2, t3) ) - // Freely order generic attributes as you like + // Freely order meta attributes as you like EAVT(e1).t.v.e.a.get === List( (t2, "b", e1, ":Ns/str"), (t3, 2, e1, ":Ns/int") diff --git a/coretests/src/test/scala/molecule/coretests/generic/LogTest.scala b/coretests/src/test/scala/molecule/coretests/meta/LogTest.scala similarity index 99% rename from coretests/src/test/scala/molecule/coretests/generic/LogTest.scala rename to coretests/src/test/scala/molecule/coretests/meta/LogTest.scala index a2ca710b8..ac0543e02 100644 --- a/coretests/src/test/scala/molecule/coretests/generic/LogTest.scala +++ b/coretests/src/test/scala/molecule/coretests/meta/LogTest.scala @@ -1,4 +1,4 @@ -package molecule.coretests.generic +package molecule.coretests.meta import molecule.api.out10._ import molecule.coretests.util.CoreSpec diff --git a/coretests/src/test/scala/molecule/coretests/generic/SchemaTest.scala b/coretests/src/test/scala/molecule/coretests/meta/SchemaTest.scala similarity index 99% rename from coretests/src/test/scala/molecule/coretests/generic/SchemaTest.scala rename to coretests/src/test/scala/molecule/coretests/meta/SchemaTest.scala index 3938f1d0f..cf34af3f3 100644 --- a/coretests/src/test/scala/molecule/coretests/generic/SchemaTest.scala +++ b/coretests/src/test/scala/molecule/coretests/meta/SchemaTest.scala @@ -1,5 +1,5 @@ -package molecule.coretests.generic +package molecule.coretests.meta import molecule.api.out10._ import molecule.coretests.schemaDef.schema.PartitionTestSchema diff --git a/coretests/src/test/scala/molecule/coretests/time/GetHistory.scala b/coretests/src/test/scala/molecule/coretests/time/GetHistory.scala index 822e413d6..1f234c3e7 100644 --- a/coretests/src/test/scala/molecule/coretests/time/GetHistory.scala +++ b/coretests/src/test/scala/molecule/coretests/time/GetHistory.scala @@ -176,7 +176,7 @@ class GetHistory extends Specification { ) // Order of attributes is free. - // All generic attributes always relate to the previous domain attribute (`int` here) + // All meta attributes always relate to the previous domain attribute (`int` here) Ns.str_("x").int.t.op.getHistory.sortBy(t => (t._2, t._3)) === List( (4, t4, true), (4, t5, false), @@ -187,7 +187,7 @@ class GetHistory extends Specification { "Multiple attrs" >> { - // We _can_ combine multiple attrs with generic attributes in a history + // We _can_ combine multiple attrs with meta attributes in a history // query but then two individual attribute history "timelines" of changes // are unified which can become less useful: Ns(e1).str.t.op.int.t.op.getHistory === List( diff --git a/examples/src/main/scala/molecule/examples/mbrainz/schema/MBrainzDefinition.scala b/examples/src/main/scala/molecule/examples/mbrainz/schema/MBrainzDefinition.scala index a95f85aeb..371d17dc7 100644 --- a/examples/src/main/scala/molecule/examples/mbrainz/schema/MBrainzDefinition.scala +++ b/examples/src/main/scala/molecule/examples/mbrainz/schema/MBrainzDefinition.scala @@ -25,7 +25,6 @@ object MBrainzDefinition { val `type` = oneEnum('person, 'group, 'other) val gender = oneEnum('male, 'female, 'other) val country = one[Country] - // val country = one[Medium] } trait Country { diff --git a/examples/src/test/scala/molecule/examples/seattle/SeattleQueryTests.scala b/examples/src/test/scala/molecule/examples/seattle/SeattleQueryTests.scala index 3153ef724..8c16573e8 100644 --- a/examples/src/test/scala/molecule/examples/seattle/SeattleQueryTests.scala +++ b/examples/src/test/scala/molecule/examples/seattle/SeattleQueryTests.scala @@ -1,7 +1,7 @@ package molecule.examples.seattle import molecule.api.in2_out8._ import molecule.examples.seattle.dsl.seattle._ -import molecule.generic._ +import molecule.meta._ import scala.language.reflectiveCalls diff --git a/examples/src/test/scala/molecule/examples/seattle/SeattleTransformationTests.scala b/examples/src/test/scala/molecule/examples/seattle/SeattleTransformationTests.scala index d873aea6e..bee96c92a 100644 --- a/examples/src/test/scala/molecule/examples/seattle/SeattleTransformationTests.scala +++ b/examples/src/test/scala/molecule/examples/seattle/SeattleTransformationTests.scala @@ -1073,7 +1073,7 @@ class SeattleTransformationTests extends SeattleSpec { m(Schema.txInstant) --> Model(List( - Meta("schema", "txInstant", "txInstant", NoValue)) + Meta("Schema", "txInstant", "schema", NoValue)) ) --> Query( Find(List( @@ -1208,7 +1208,7 @@ class SeattleTransformationTests extends SeattleSpec { Community(belltownId).name("belltown 2").url("url 2") ) --> Model(List( - Meta("?", "e_", "Long", Eq(List(17592186045886L))), + Meta("Community", "e_", "datom", Eq(List(17592186045886L))), Atom("Community", "name", "String", 1, Eq(List("belltown 2")), None), Atom("Community", "url", "String", 1, Eq(List("url 2")), None)) ) --> @@ -1226,7 +1226,7 @@ class SeattleTransformationTests extends SeattleSpec { Community(belltownId).category.replace("news" -> "Cool news") ) --> Model(List( - Meta("?", "e_", "Long", Eq(List(17592186045886L))), + Meta("Community", "e_", "datom", Eq(List(17592186045886L))), Atom("Community", "category", "String", 2, ReplaceValue(Seq("news" -> "Cool news")), None)) ) --> """List( @@ -1243,7 +1243,7 @@ class SeattleTransformationTests extends SeattleSpec { ) ) --> Model(List( - Meta("?", "e_", "Long", Eq(List(17592186045886L))), + Meta("Community", "e_", "datom", Eq(List(17592186045886L))), Atom("Community", "category", "String", 2, ReplaceValue(Seq( "Cool news" -> "Super cool news", "events" -> "Super cool events")), None)) @@ -1261,7 +1261,7 @@ class SeattleTransformationTests extends SeattleSpec { Community(belltownId).category.assert("extra category") ) --> Model(List( - Meta("?", "e_", "Long", Eq(List(17592186045886L))), + Meta("Community", "e_", "datom", Eq(List(17592186045886L))), Atom("Community", "category", "String", 2, AssertValue(List("extra category")), None)) ) --> """List( @@ -1274,7 +1274,7 @@ class SeattleTransformationTests extends SeattleSpec { Community(belltownId).category.retract("Super cool events") ) --> Model(List( - Meta("?", "e_", "Long", Eq(List(17592186045886L))), + Meta("Community", "e_", "datom", Eq(List(17592186045886L))), Atom("Community", "category", "String", 2, RetractValue(List("Super cool events")), None)) ) --> """List( @@ -1290,7 +1290,7 @@ class SeattleTransformationTests extends SeattleSpec { Community(belltownId).name("belltown 3").url().category() ) --> Model(List( - Meta("?", "e_", "Long", Eq(List(17592186045886L))), + Meta("Community", "e_", "datom", Eq(List(17592186045886L))), Atom("Community", "name", "String", 1, Eq(List("belltown 3")), None), Atom("Community", "url", "String", 1, Eq(List()), None), Atom("Community", "category", "String", 2, Eq(List()), None))