Skip to content

Commit

Permalink
feat: added support for applying vocab and decorators to a model
Browse files Browse the repository at this point in the history
Signed-off-by: Muskan Bararia <[email protected]>
  • Loading branch information
Muskan Bararia committed Oct 19, 2023
1 parent f98734a commit 259264f
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/data/decorate-dcs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$class": "org.accordproject.decoratorcommands.DecoratorCommandSet",
"name": "pii",
"version": "1.0.0",
"commands": [
{
"$class": "org.accordproject.decoratorcommands.Command",
"type": "UPSERT",
"target": {
"$class": "org.accordproject.decoratorcommands.CommandTarget",
"property": "ssn"
},
"decorator": {
"$class": "[email protected]",
"name": "PII",
"arguments": [
]
}
},
{
"$class": "org.accordproject.decoratorcommands.Command",
"type": "UPSERT",
"target": {
"$class": "org.accordproject.decoratorcommands.CommandTarget",
"type": "[email protected]"
},
"decorator": {
"$class": "[email protected]",
"name": "Hide",
"arguments": [{
"$class" : "[email protected]",
"value" : "object"
}]
}
}
]
}
6 changes: 6 additions & 0 deletions test/data/decorate-voc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
locale: en-gb
namespace: [email protected]
declarations:
- Driver: A driver of a vehicle
properties:
- favoriteColor: favourite colour
Empty file.
23 changes: 23 additions & 0 deletions test/models/decorate-model-expected-with-dcs.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
namespace [email protected]

abstract concept Person identified by ssn {
o String firstName
o String lastName
@PII()
o String ssn
}

concept Driver extends Person {
o String favoriteColor
}

concept Employee {
@PII()
o String ssn
}

concept Car identified by vin {
o String vin
@Hide("object")
o Person owner
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"$class":"[email protected]","decorators":[],"namespace":"[email protected]","imports":[],"declarations":[{"$class":"[email protected]","name":"Person","isAbstract":true,"properties":[{"$class":"[email protected]","name":"firstName","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":74,"line":5,"column":5,"$class":"[email protected]"},"end":{"offset":98,"line":6,"column":5,"$class":"[email protected]"}},"decorators":[{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"First Name of the Person"}]}]},{"$class":"[email protected]","name":"lastName","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":98,"line":6,"column":5,"$class":"[email protected]"},"end":{"offset":119,"line":7,"column":3,"$class":"[email protected]"}},"decorators":[{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"Last Name of the Person"}]}]},{"$class":"[email protected]","name":"ssn","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":119,"line":7,"column":3,"$class":"[email protected]"},"end":{"offset":133,"line":8,"column":1,"$class":"[email protected]"}},"decorators":[{"$class":"[email protected]","name":"PII","arguments":[]},{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"Ssn of the Person"}]}]}],"location":{"$class":"[email protected]","start":{"offset":24,"line":3,"column":1,"$class":"[email protected]"},"end":{"offset":134,"line":8,"column":2,"$class":"[email protected]"}},"identified":{"$class":"[email protected]","name":"ssn"},"decorators":[{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"Person"}]}]},{"$class":"[email protected]","name":"Driver","isAbstract":false,"properties":[{"$class":"[email protected]","name":"favoriteColor","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":173,"line":11,"column":3,"$class":"[email protected]"},"end":{"offset":197,"line":12,"column":1,"$class":"[email protected]"}},"decorators":[{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"favourite colour"}]}]}],"location":{"$class":"[email protected]","start":{"offset":138,"line":10,"column":1,"$class":"[email protected]"},"end":{"offset":198,"line":12,"column":2,"$class":"[email protected]"}},"superType":{"$class":"[email protected]","name":"Person","namespace":"[email protected]"},"decorators":[{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"A driver of a vehicle"}]}]},{"$class":"[email protected]","name":"Employee","isAbstract":false,"properties":[{"$class":"[email protected]","name":"ssn","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":224,"line":15,"column":3,"$class":"[email protected]"},"end":{"offset":238,"line":16,"column":1,"$class":"[email protected]"}},"decorators":[{"$class":"[email protected]","name":"PII","arguments":[]},{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"Ssn of the Employee"}]}]}],"location":{"$class":"[email protected]","start":{"offset":202,"line":14,"column":1,"$class":"[email protected]"},"end":{"offset":239,"line":16,"column":2,"$class":"[email protected]"}},"decorators":[{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"Employee"}]}]},{"$class":"[email protected]","name":"Car","isAbstract":false,"properties":[{"$class":"[email protected]","name":"vin","isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":281,"line":20,"column":5,"$class":"[email protected]"},"end":{"offset":299,"line":21,"column":5,"$class":"[email protected]"}},"decorators":[{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"Vin of the Car"}]}]},{"$class":"[email protected]","name":"owner","type":{"$class":"[email protected]","name":"Person","namespace":"[email protected]"},"isArray":false,"isOptional":false,"location":{"$class":"[email protected]","start":{"offset":299,"line":21,"column":5,"$class":"[email protected]"},"end":{"offset":315,"line":22,"column":1,"$class":"[email protected]"}},"decorators":[{"$class":"[email protected]","name":"Hide","arguments":[{"$class":"[email protected]","value":"object"}]},{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"Owner of the Car"}]}]}],"location":{"$class":"[email protected]","start":{"offset":243,"line":18,"column":1,"$class":"[email protected]"},"end":{"offset":316,"line":22,"column":2,"$class":"[email protected]"}},"identified":{"$class":"[email protected]","name":"vin"},"decorators":[{"$class":"[email protected]","name":"Term","arguments":[{"$class":"[email protected]","value":"Car"}]}]}]}
31 changes: 31 additions & 0 deletions test/models/decorate-model-expected-with-vocabs-only.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
namespace [email protected]

@Term("Person")
abstract concept Person identified by ssn {
@Term("First Name of the Person")
o String firstName
@Term("Last Name of the Person")
o String lastName
@Term("Ssn of the Person")
o String ssn
}

@Term("A driver of a vehicle")
concept Driver extends Person {
@Term("favourite colour")
o String favoriteColor
}

@Term("Employee")
concept Employee {
@Term("Ssn of the Employee")
o String ssn
}

@Term("Car")
concept Car identified by vin {
@Term("Vin of the Car")
o String vin
@Term("Owner of the Car")
o Person owner
}
22 changes: 22 additions & 0 deletions test/models/decorate-model.cto
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace [email protected]

abstract concept Person identified by ssn
{
o String firstName
o String lastName
o String ssn
}

concept Driver extends Person {
o String favoriteColor
}

concept Employee {
o String ssn
}

concept Car identified by vin
{
o String vin
o Person owner
}

0 comments on commit 259264f

Please sign in to comment.