domain-spec Pub Share

Domain Samples

Make sure your classes include a key attribute, unique. Otherwise, one random key is assigned for you and all sorts of funny and entertaining side effects may occur... if you have a name we will try to use that one.

Defining classes

An empty class:

no inventory registered listAll | new

Note that inside a class definition, you can't have free text, just other constructs.

no inventory registered listAll | new
class TestClass1{

   def: simple
   def: withParms (x, y)
   def: withEmptyBody (x, y)
   msg: simpleMsg
   msg: expandedMsg
   def: simple
   def: withParms (x, y)
   def: withEmptyBody (x, y)
   msg: simpleMsg
   msg: expandedMsg

}

Implementing a message outside the class:

$when:: TestClass1.simpleMsg
   a.b

Subtypes and containers:

no inventory registered listAll | new
no inventory registered listAll | new
class TestContainer [T]
no inventory registered listAll | new
class TestEmptyBody

anno  (  prop3="value"="value")

anno  (  prop1="value"="value",   prop2="value"="value")

no inventory registered listAll | new
class TestAnnotated ANNO(  prop1:String="value"="value",   prop2:String="value"="value",   prop3:String="value"="value")
no inventory registered listAll | new
class TestWithParms (
parm1,
slainvokedid:<>SLA,
list3:Array[TestContainer],
parm1,
slainvokedid:<>SLA,
list3:Array[TestContainer]
)

Simple products and inventory

An inventory contains a list of units:

anno  (  inventory="diesel.db.inmem"="diesel.db...)

listAll | new
class DTInventory (  products:Array[DTProductUnit],   products:Array[DTProductUnit]) ANNO(  inventory:String="diesel.db.inmem"="diesel.db.inmem",   inventory:String="diesel.db.inmem"="diesel.db.inmem")

A unit has a reference to a product specification:

anno  (  inventory="diesel.db.inmem"="diesel.db...)

listAll | new
class DTProductUnit (
key,
qty:Number,
spec:<>DTProductSpec,
key,
qty:Number,
spec:<>DTProductSpec
) ANNO(  inventory:String="diesel.db.inmem"="diesel.db.inmem",   inventory:String="diesel.db.inmem"="diesel.db.inmem")

A specification has a reference to a blog post to show on the website:

anno  (  inventory="diesel.db.inmem"="diesel.db...)

listAll | new
class DTProductSpec <spec,spec> (
key,
sku,
descriptionRef:<>DTBlogPost,
key,
sku,
descriptionRef:<>DTBlogPost
) ANNO(  inventory:String="diesel.db.inmem"="diesel.db.inmem",   inventory:String="diesel.db.inmem"="diesel.db.inmem")

anno  (  inventory="diesel.db.inmem"="diesel.db...)

listAll | new
class DTBlogPost (
key,
content,
key,
content
) ANNO(  inventory:String="diesel.db.inmem"="diesel.db.inmem",   inventory:String="diesel.db.inmem"="diesel.db.inmem")

Simple ordering demo

listAll | new
class DTCart (
key,
customerRef:<>DTCustomer,
items:Array[DTItem],
key,
customerRef:<>DTCustomer,
items:Array[DTItem]
)
listAll | new
class DTItem (
key,
productRef:<>DTProductSpec,
qty:Number,
key,
productRef:<>DTProductSpec,
qty:Number
)
listAll | new
class DTOrder (
key,
customerRef:<>DTCustomer,
items:Array[DTItem],
key,
customerRef:<>DTCustomer,
items:Array[DTItem]
)
listAll | new
class DTCustomer (
key,
name,
address,
key,
name,
address
)


Was this useful?    

By: Razie | 2020-10-16 .. 2024-10-10 | Tags: spec , dsl , DslDomain , private


Viewed 799 times ( | History | Print ) this page.

You need to log in to post a comment!

© Copyright DieselApps, 2012-2024, all rights reserved.