Skip to content

Commit

Permalink
update the generated code
Browse files Browse the repository at this point in the history
* allow the children for DTYPE and OTPE to appear in natural order
rather
than grouping

* put in a title

* add UCD
  • Loading branch information
pahjbo committed May 24, 2024
1 parent 38e43e9 commit 7229554
Showing 1 changed file with 28 additions and 21 deletions.
49 changes: 28 additions & 21 deletions net.ivoa.vodsl/src/net/ivoa/vodsl/generator/VodslGenerator.xtend
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import org.eclipse.xtext.naming.IQualifiedNameConverter
import net.ivoa.vodsl.vodsl.SubSet
import net.ivoa.vodsl.vodsl.NaturalKey
import net.ivoa.vodsl.vodsl.SemanticConcept
import net.ivoa.vodsl.vodsl.Role

/**
* Generates code from your model files on save.
Expand Down Expand Up @@ -68,11 +69,11 @@ class VodslGenerator extends AbstractGenerator {
<vo-dml:model xmlns:vo-dml="http://www.ivoa.net/xml/VODML/v1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.ivoa.net/xml/VODML/v1 https://www.ivoa.net/xml/VODML/vo-dml-v1.xsd"
vodmlVersion="1.1"> <!-- file generated from VODSL - needs validatate against v1.1 of schema -->
vodmlVersion="1.1"> <!-- file generated from VODSL - needs validatation against v1.1 of schema -->
<name>«e.model.name»</name>
<description>«e.model.description»</description>
<uri/>
<title></title>
<title>«e.model.titular»</title>
«FOR a:e.model.authors»
<author>«a»</author>
«ENDFOR»
Expand Down Expand Up @@ -108,6 +109,18 @@ class VodslGenerator extends AbstractGenerator {
}


}

def vodml(Role e)
{
switch e {

Composition : (e as Composition).vodml
Reference : (e as Reference).vodml
Attribute: (e as Attribute).vodml
default: "unknown type " + e.class
}

}

def preamble(ReferableElement e) '''
Expand Down Expand Up @@ -155,15 +168,9 @@ class VodslGenerator extends AbstractGenerator {
«FOR f: e.subsets»
«f.vodml»
«ENDFOR»
«FOR f: e.content.filter(Attribute)»
«(f as Attribute).vodml»
«FOR f: e.content»
«f.vodml»
«ENDFOR»
«FOR f: e.content.filter(Composition
«(f as Composition).vodml»
«ENDFOR»
«FOR f: e.content.filter(Reference
«(f as Reference).vodml»
«ENDFOR»
</objectType>
'''
def vodml (Attribute e)'''
Expand All @@ -173,12 +180,15 @@ class VodslGenerator extends AbstractGenerator {
«(e.type as ReferableElement).ref»
</datatype>
«vodml(e.multiplicity
«IF e.semanticConcept !== null»
«IF e.semanticConcept !== null»
«e.semanticConcept.vodml»
«ENDIF»
«IF e.key !== null»
«ENDIF»
«IF e.ucd !== null»
<UCD>«e.ucd»</UCD>
«ENDIF»
«IF e.key !== null»
«e.key.vodml»
«ENDIF»
«ENDIF»
</attribute>
'''

Expand Down Expand Up @@ -244,12 +254,9 @@ class VodslGenerator extends AbstractGenerator {
«FOR f: e.subsets»
«f.vodml»
«ENDFOR»
«FOR f: e.content.filter(Attribute
«(f as Attribute).vodml»
«ENDFOR»
«FOR f: e.content.filter(Reference
«(f as Reference).vodml»
«ENDFOR»
«FOR f: e.content»
«f.vodml»
«ENDFOR»
</dataType>
'''

Expand Down Expand Up @@ -305,7 +312,7 @@ class VodslGenerator extends AbstractGenerator {


def vodml (PrimitiveType e)'''
<primitiveType>
<primitiveType «IF e.abstract» abstract="true"«ENDIF»>
«e.preamble»
«IF e.superType !== null»
<extends>
Expand Down

0 comments on commit 7229554

Please sign in to comment.