-
Notifications
You must be signed in to change notification settings - Fork 0
[2] Crystal‐Map‐Connector
The Crystal-Map-Connector module integrates types of the crystal-map framework (CMTypes) into the DOPE framework. CMTypes represent specialized data types that can be used similarly to the types in the Core Module.
With this connector, any function that operates on Core Module types can also be applied to CMTypes, providing a consistent and extended functionality.
There are two approaches to use the CMTypes in DOPE: creating them manually or using them through Schemas.
You can create different CMTypes (CMField, CMList, CMObject, CMObjectList) by including the crystal-map-api framework:
For Gradle Kotlin DSL (build.gradle.kts):
dependencies {
implementation("com.github.SchwarzIT.crystal-map:crystal-map-api:3.18.0")
}
For Gradle Groovy DSL (build.gradle):
dependencies {
implementation 'com.github.SchwarzIT.crystal-map:crystal-map-api:3.18.0'
}
The objects can then be created like this:
import com.schwarz.crystalapi.schema.CMField
import com.schwarz.crystalapi.schema.CMList
val cmPersonAge = CMField<Number>("age", "person")
val cmPersonHobbies = CMList<String>("hobbies", "person")
Crystal-map also provides a possibility to create schemas, which then contain your defined fields.
The CMTypes can be used exactly the same as the fields in the Core Module.
val result = QueryBuilder()
.select(cmPersonAge, cmPersonHobbies) // These CMTypes were created above
.build()
// result.queryString = "SELECT person.age, person.hobbies"
Combining multiple Clauses using CMTypes can be done in a similar manner as with the Core Module:
val personBucket = UnaliasedBucket("person")
val result = QueryBuilder()
.select(personBucket.asterisk())
.from(personBucket)
.where(cmPersonAge.isGreaterThan(18).and(
"Football".inArray(cmPersonHobbies)
))
.groupBy(cmPersonAge)
.limit(10)
.offset(5)
.build()
// result.queryString = "SELECT person.* FROM person WHERE (person.age > 18 AND 'Football' IN person.hobbies) GROUP BY person.age LIMIT 10 OFFSET 5"