| «IMPORT dnc» |
| «IMPORT oocore» |
| |
| «EXTENSION dncUtil» |
| |
| «DEFINE Main FOR oocore::Package» |
| «EXPAND package FOREACH contents.typeSelect(oocore::Package)» |
| «ENDDEFINE» |
| |
| «DEFINE package FOR oocore::Package-» |
| «EXPAND entity FOREACH contents.typeSelect(dnc::Archetype).select(a | a.isEntity())» |
| «EXPAND package FOREACH contents.typeSelect(oocore::Package)» |
| «ENDDEFINE» |
| |
| «DEFINE entity FOR dnc::Archetype-» |
| «FILE this.fullyQualifiedPath() -» |
| «IF package.isValid()-» |
| package «package.fullyQualifiedName()»; |
| «ENDIF» |
| import javax.persistence.Entity; |
| import javax.persistence.Table; |
| import javax.persistence.Column; |
| import javax.persistence.Id; |
| import javax.persistence.GeneratedValue; |
| import javax.persistence.GenerationType; |
| «IF !features.typeSelect(dnc::Association).collect(a | a.upperBound == -1).isEmpty-» |
| import javax.persistence.OneToMany;«ENDIF» |
| «IF !features.typeSelect(dnc::Association).collect(a | a.upperBound == 1).isEmpty-» |
| import javax.persistence.OneToOne;«ENDIF» |
| «IF features.typeSelect(oocore::Reference).collect(a | a.opposite.metaType == dnc::Association && a.opposite.upperBound == -1).isEmpty-» |
| import javax.persistence.ManyToOne; |
| import javax.persistence.JoinColumn;«ENDIF» |
| |
| /** |
| * «IF description.length > 0-»«description-»«ELSE»TODO: Enter description of the class here...«ENDIF» |
| * |
| * @generated |
| */ |
| @Entity |
| @Table(name="«EXPAND toColumnName FOR name-»") |
| public class «name» «EXPAND extends FOR this-»implements java.io.Serializable«EXPAND implements FOR this-» { |
| |
| «EXPAND idAttribute FOR this-» |
| «EXPAND attribute FOREACH features.typeSelect(oocore::Attribute)-» |
| «EXPAND reference FOREACH features.typeSelect(oocore::Reference)-» |
| «EXPAND idGetter FOR this-» |
| «FOREACH features.typeSelect(oocore::StructuralFeature) AS feature-» |
| «EXPAND getter FOR feature-» |
| «EXPAND setter FOR feature-» |
| «ENDFOREACH» |
| |
| «EXPAND method FOREACH features.typeSelect(oocore::Operation)-» |
| «EXPAND additions-» |
| } |
| «ENDFILE» |
| «ENDDEFINE» |
| |
| «DEFINE extends FOR oocore::Class-» |
| «IF !superclasses.isEmpty»extends «EXPAND superClass FOR superclasses.select(c | c.interface == false).first()-»«ENDIF-» |
| «ENDDEFINE» |
| |
| «DEFINE implements FOR oocore::Class-» |
| «IF superclasses.select(c | c.interface == true).size > 0», «EXPAND superClass FOREACH superclasses.select(c | c.interface == true) SEPARATOR ","-»«ENDIF-» |
| «ENDDEFINE» |
| |
| «DEFINE superClass FOR oocore::Class-» |
| «fullyQualifiedName(this)-» |
| «ENDDEFINE» |
| |
| «DEFINE idAttribute FOR oocore::Class-» |
| «EXPAND generatedComment FOR this-» |
| @Id |
| @Column(name="«name.toUpperCase()-»_ID") |
| @GeneratedValue(strategy=GenerationType.AUTO) |
| private int «name.toLowerCase()-»Id; |
| «ENDDEFINE» |
| |
| «DEFINE attribute FOR oocore::Attribute-» |
| «EXPAND generatedComment FOR this-» |
| «IF name.toLowerCase() != name-» @Column(name="«EXPAND toColumnName FOR name-»")«ENDIF» |
| «visibility.toString().toLowerCase()» «dataType.name» «name-»; |
| «ENDDEFINE» |
| |
| «DEFINE reference FOR dnc::Association-» |
| «IF this.type.isEntity()-» |
| «EXPAND generatedComment FOR this-» |
| «IF this.upperBound == -1-» @OneToMany(mappedBy="«this.owner.name.toLowerCase()»Id")«ELSEIF this.upperBound == 1-» @OneToOne(targetEntity=«this.opposite.owner.fullyQualifiedName()».class)«ENDIF» |
| private «wrapIfCollection(this)» «name-»; |
| «ENDIF» |
| «ENDDEFINE» |
| |
| «DEFINE reference FOR oocore::Reference-» |
| «IF this.generateReference()-» |
| «EXPAND generatedComment FOR this-» |
| @ManyToOne |
| @JoinColumn(name="«this.owner.name.toUpperCase()»_ID") |
| private «wrapIfCollection(this)» «name-»; |
| «ENDIF» |
| «ENDDEFINE» |
| |
| «DEFINE idGetter FOR oocore::Class-» |
| «EXPAND generatedComment FOR this-» |
| public int get«name.toFirstUpper()»Id() { |
| return «name.toLowerCase()»Id; |
| } |
| «ENDDEFINE» |
| |
| «REM»Abstract - do nothing, but here to keep Xpand editor happy«ENDREM» |
| «DEFINE getter FOR oocore::StructuralFeature» |
| «ENDDEFINE» |
| «DEFINE setter FOR oocore::StructuralFeature» |
| «ENDDEFINE» |
| |
| «DEFINE getter FOR oocore::Attribute-» |
| «EXPAND generatedComment FOR this-» |
| public «this.dataType.name» get«name.toFirstUpper()»() { |
| return «name»; |
| } |
| «ENDDEFINE» |
| |
| «DEFINE setter FOR oocore::Attribute-» |
| «EXPAND generatedComment FOR this-» |
| public void set«name.toFirstUpper()»(«this.dataType.name» «name») { |
| this.«name» = «name»; |
| } |
| «ENDDEFINE» |
| |
| «DEFINE getter FOR oocore::Reference-» |
| «IF this.generateReference()-» |
| «EXPAND generatedComment FOR this-» |
| public «wrapIfCollection(this)» get«name.toFirstUpper()»() { |
| return «name»; |
| } |
| «ENDIF» |
| «ENDDEFINE» |
| |
| «DEFINE setter FOR oocore::Reference-» |
| «IF this.generateReference()-» |
| «EXPAND generatedComment FOR this-» |
| public void set«name.toFirstUpper()»(«wrapIfCollection(this)» «name») { |
| this.«name» = «name»; |
| } |
| «ENDIF» |
| «ENDDEFINE» |
| |
| «DEFINE method FOR oocore::Operation-» |
| «EXPAND generatedComment FOR this-» |
| «visibility.toString().toLowerCase()-» «wrapIfCollection(this)» «name-»(«EXPAND parameter FOREACH parameters SEPARATOR ','») { |
| //TODO: implement method |
| } |
| «ENDDEFINE» |
| |
| «DEFINE parameter FOR oocore::Parameter-» |
| «wrapIfCollection(this)» «name-» |
| «ENDDEFINE» |
| |
| «DEFINE generatedComment FOR Object-» |
| /** |
| *@generated |
| */ |
| «ENDDEFINE» |
| |
| «DEFINE toColumnName FOR String-» |
| «FOREACH this.toCharList() AS char ITERATOR i-»«IF i.counter0 == 0-»«char.toUpperCase()-»«ELSE-»«char.asColumnNameChar()-»«ENDIF-»«ENDFOREACH-» |
| «ENDDEFINE» |
| |
| «DEFINE additions FOR dnc::Archetype-»«ENDDEFINE» |