Skip to content

Commit c839316

Browse files
Merge pull request #7 from henrietteharmse/enumerations
Update docs and minor refactor
2 parents 81e2ca4 + 0d83b4f commit c839316

File tree

4 files changed

+39
-18
lines changed

4 files changed

+39
-18
lines changed

README.md

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ employer and an employer has 1 or more employees.
2727
![Employer Example](./docs/SimpleEmployerExample.png)
2828

2929
### TSV representation
30-
Classes and attributes are created using 2 separate TSV files. First create
30+
UML class diagram information can be specified using TSV files. First create
3131
the TSV file for your classes. It has the following format:
3232

3333

@@ -41,17 +41,38 @@ Here we only specify the name for each class, hence the reason we used the **Nam
4141
`Employee` and `Employer` both extend the `Person` class, we add `Person` to **ParentNames** column. Multiple parents are
4242
separated by `|`. Curie refer to compact URI based on the [W3C CURIE syntax](https://www.w3.org/TR/2010/NOTE-curie-20101216/).
4343

44+
If you want to make use of enumerations, specify them next. The format is as follows:
45+
46+
| Curie | Name | Definition |
47+
|--------------------|-----------------|-----------------------------------|
48+
| emp:SalarySchedule | PaymentSchedule | Defines the frequency of payments |
49+
50+
Again you can specify a curie and/or a name to refer to your enumeration. In this case we assume there
51+
is a difference between the purl and the label of this concept. Definition allows you to describe this
52+
enumeration.
53+
54+
The values that an enumeration exists of, are specified in a different TSV with the following format:
55+
56+
| Enumeration | Curie | Name | Definition |
57+
|----------------------|--------------|------|--------------------------------------------------------|
58+
| emp:SalarySchedule | emp:Daily | | Employee gets paid at the end of each day |
59+
| PaymentSchedule | Weekly | | Employee gets paid at the end of each week on a Friday |
60+
| emp:SalarySchedule | emp:Monthly | | Employee gets paid at the last day of the month |
61+
62+
** Enumeration ** refers the name or curie of an enumeration. Each value of an enumeration can have a curie and/or a name
63+
and a definition.
64+
4465
To specify attributes we use the following format.
4566

46-
| ClassName | Curie | Name | ClassOrPrimitive | MinMultiplicity | MaxMultiplicity | Definition |
47-
|------------|-------|-------------|------------------|-----------------|-----------------|------------|
48-
| Person | | name | xsd:string | | | |
49-
| Person | | surname | xsd:string | | | |
50-
| Person | | dateOfBirth | xsd:dateTime | | | |
51-
| Employee | | employedBy | Employer | 1 | 1 | |
52-
| Employer | | employes | Employee | 1 | * | |
67+
| Class | Curie | Name | ClassOrPrimitive | MinMultiplicity | MaxMultiplicity | Definition |
68+
|----------|-------|-------------|------------------|-----------------|-----------------|------------|
69+
| Person | | name | xsd:string | | | |
70+
| Person | | surname | xsd:string | | | |
71+
| Person | | dateOfBirth | xsd:dateTime | | | |
72+
| Employee | | employedBy | Employer | 1 | 1 | |
73+
| Employer | | employes | Employee | 1 | * | |
5374

54-
**ClassName** refers to the classname for which we are defining the attributes. Attributes can also be defined using curies,
75+
**Class** refers to the class for which we are defining the attributes. Attributes can also be defined using curies,
5576
but we again only used names for now. The type of an attribute can be a primitive or a class. Currenlty XML primitive data
5677
types used in [Protege Desktop](https://protege.stanford.edu/) as data types are supported. When no multiplicity is given,
5778
[1..1] is assumed. `*` is to refer to infinite as per usual.

src/main/scala/org/uml2semantics/reader/TSVReader.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ enum ClassesHeader:
1313
case Name, Curie, Definition, ParentNames
1414

1515
enum ClassAttributesHeader:
16-
case ClassName, Curie, Name, ClassOrPrimitiveType, MinMultiplicity, MaxMultiplicity, Definition
16+
case Class, Curie, Name, ClassEnumOrPrimitiveType, MinMultiplicity, MaxMultiplicity, Definition
1717

1818
enum EnumerationsHeader:
1919
case Name, Curie, Definition
2020

2121
enum EnumerationValuesHeader:
22-
case EnumerationName, Name, Curie, Definition
22+
case Enumeration, Name, Curie, Definition
2323

2424
def parseClasses(maybeTsvFile: Option[File], ontologyPrefix: PrefixNamespace): UMLClasses =
2525
import ClassesHeader.*
@@ -78,11 +78,11 @@ def parseAttributes(maybeTsvFile: Option[File], ontologyPrefix: PrefixNamespace)
7878
reader.allWithHeaders().foreach(m => {
7979
logger.trace(s"m = $m")
8080

81-
val classNamedElement = UMLClassIdentity.findClassNamedElement(m(ClassAttributesHeader.ClassName.toString))
82-
val enumerationNamedElement = UMLEnumerationIdentity.findEnumerationNamedElement(m(ClassAttributesHeader.ClassName.toString))
81+
val classNamedElement = UMLClassIdentity.findClassNamedElement(m(ClassAttributesHeader.Class.toString))
82+
val enumerationNamedElement = UMLEnumerationIdentity.findEnumerationNamedElement(m(ClassAttributesHeader.Class.toString))
8383
logger.trace(s"classNamedElement = $classNamedElement")
8484
if classNamedElement.isDefined || enumerationNamedElement.isDefined then
85-
logger.trace(s"mClassOrPrimitiveType.toString = {${m(ClassOrPrimitiveType.toString)}}")
85+
logger.trace(s"mClassOrPrimitiveType.toString = {${m(ClassEnumOrPrimitiveType.toString)}}")
8686
val curieOption: Option[Curie] = if m(Curie.toString).contains(":") then
8787
Some(org.uml2semantics.model.Curie(m(Curie.toString)))
8888
else
@@ -93,7 +93,7 @@ def parseAttributes(maybeTsvFile: Option[File], ontologyPrefix: PrefixNamespace)
9393
UMLClassAttributeCurie(curieOption),
9494
ontologyPrefix
9595
),
96-
UMLClassAttributeType(m(ClassOrPrimitiveType.toString)),
96+
UMLClassAttributeType(m(ClassEnumOrPrimitiveType.toString)),
9797
UMLMultiplicity(UMLCardinality(m(MinMultiplicity.toString)), UMLCardinality(m(MaxMultiplicity.toString))),
9898
UMLClassAttributeDefinition(m(Definition.toString))
9999
)
@@ -160,7 +160,7 @@ def parseEnumerationValues(maybeTsvFile: Option[File], ontologyPrefix: PrefixNam
160160
logger.trace(s"m = $m")
161161

162162
val enumerationIdentityOption = UMLEnumerationIdentity.findEnumerationNamedElement(
163-
m(EnumerationValuesHeader.EnumerationName.toString))
163+
m(EnumerationValuesHeader.Enumeration.toString))
164164
logger.trace(s"--------------- enumerationIdentityOption = $enumerationIdentityOption")
165165
if enumerationIdentityOption.isDefined then
166166
val enumerationIdentity = enumerationIdentityOption.get

src/test/resources/Employer - Attributes.tsv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ClassName Curie Name ClassOrPrimitiveType MinMultiplicity MaxMultiplicity Definition
1+
Class Curie Name ClassEnumOrPrimitiveType MinMultiplicity MaxMultiplicity Definition
22
Person name xsd:string
33
Person surname xsd:string
44
Person dateOfBirth xsd:dateTime
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
EnumerationName Curie Name Definition
1+
Enumeration Curie Name Definition
22
emp:SalarySchedule emp:Daily Employee gets paid at the end of each day
33
PaymentSchedule Weekly Employee gets paid at the end of each week on a Friday
44
emp:SalarySchedule emp:Monthly Employee gets paid at the last day of the month

0 commit comments

Comments
 (0)