| «IMPORT 'http://www.eclipse.org/2008/dnc'» |
| «IMPORT 'http://www.eclipse.org/2008/oocore'» |
| «IMPORT 'http://www.eclipse.org/emf/2002/Ecore'» |
| |
| «EXTENSION dncUtil» |
| «EXTENSION xpt::StringOperations» |
| |
| «DEFINE Main FOR dnc::Archetype-» |
| «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 not features[dnc::Association]->collect(a | a.upperBound = -1)->isEmpty()-» |
| import javax.persistence.OneToMany;«ENDIF» |
| «IF not features[dnc::Association]->collect(a | a.upperBound = 1)->isEmpty()-» |
| import javax.persistence.OneToOne;«ENDIF» |
| «IF features[dnc::Association]->collect(a | a.opposite.upperBound = -1)->isEmpty()-» |
| import javax.persistence.ManyToOne; |
| import javax.persistence.JoinColumn;«ENDIF» |
| |
| /** |
| * «IF not self.description.oclIsUndefined() and description.length() > 0-»«description-»«ELSE»TODO: Enter description of the class here...«ENDIF» |
| * |
| * @generated |
| */ |
| @Entity |
| @Table(name="«EXPAND toColumnName FOR self.name» |
| public class «name» «EXPAND extends FOR self-»implements java.io.Serializable«EXPAND implements FOR self-» { |
| |
| «EXPAND idAttribute FOR self-» |
| «EXPAND attribute FOREACH features[oocore::Attribute]-» |
| «EXPAND reference FOREACH features[oocore::Reference]-» |
| «EXPAND idGetter FOR self-» |
| «FOREACH features[oocore::StructuralFeature] AS feature-» |
| «EXPAND getter FOR feature-» |
| «EXPAND setter FOR feature-» |
| «ENDFOREACH» |
| |
| «EXPAND method FOREACH features[oocore::Operation]-» |
| «EXPAND additions-» |
| } |
| «ENDDEFINE» |
| |
| «DEFINE extends FOR dnc::Archetype-» |
| «IF not superclasses->isEmpty()»extends «EXPAND superClass FOR self.superclasses->select(c | c.interface = false)->asSequence()->first()-»«ENDIF-» |
| «ENDDEFINE» |
| |
| «DEFINE implements FOR dnc::Archetype-» |
| «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-» |
| «self.fullyQualifiedName()-» |
| «ENDDEFINE» |
| |
| «DEFINE idAttribute FOR dnc::Archetype-» |
| «EXPAND generatedComment FOR self-» |
| @Id |
| @Column(name="«name.toUpper()»_ID") |
| @GeneratedValue(strategy=GenerationType.AUTO) |
| private int «name.toLower()»Id; |
| «ENDDEFINE» |
| |
| «DEFINE attribute FOR oocore::Attribute-» |
| «EXPAND generatedComment FOR self-» |
| «IF name.toLower() != name» |
| @Column(name="«EXPAND toColumnName FOR name-»«ENDIF» «visibility.repr().toLower()» «dataType.name» «name»; |
| «ENDDEFINE» |
| |
| «DEFINE reference FOR dnc::Association-» |
| «IF self.type.isEntity()-» |
| «EXPAND generatedComment FOR self-» |
| «IF self.upperBound = -1» |
| @OneToMany(mappedBy="«self.owner.name.toLower()»Id")«ELSEIF self.upperBound = 1» |
| @OneToOne(targetEntity=«self.opposite.owner.fullyQualifiedName()».class)«ENDIF» |
| private «self.wrapIfCollection()» «name»; |
| «ENDIF» |
| «ENDDEFINE» |
| |
| «DEFINE reference FOR oocore::Reference-» |
| «IF self.generateReference()-» |
| «EXPAND generatedComment FOR self-» |
| @ManyToOne |
| @JoinColumn(name="«self.owner.name.toUpper()»_ID") |
| private «self.wrapIfCollection()» «name»; |
| «ENDIF» |
| «ENDDEFINE» |
| |
| «DEFINE idGetter FOR oocore::Class-» |
| «EXPAND generatedComment FOR self-» |
| public int get«name.firstToUpper()»Id() { |
| return «name.toLower()»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 self-» |
| public «self.dataType.name» get«name.firstToUpper()»() { |
| return «name»; |
| } |
| «ENDDEFINE» |
| |
| «DEFINE setter FOR oocore::Attribute-» |
| «EXPAND generatedComment FOR self-» |
| public void set«name.firstToUpper()»(«self.dataType.name» «name») { |
| this.«name» = «name»; |
| } |
| «ENDDEFINE» |
| |
| «DEFINE getter FOR oocore::Reference-» |
| «IF self.generateReference()-» |
| «EXPAND generatedComment FOR self-» |
| public «self.wrapIfCollection()» get«name.firstToUpper()»() { |
| return «name»; |
| } |
| «ENDIF» |
| «ENDDEFINE» |
| |
| «DEFINE setter FOR oocore::Reference-» |
| «IF self.generateReference()-» |
| «EXPAND generatedComment FOR self-» |
| public void set«name.firstToUpper()»(«self.wrapIfCollection()» «name») { |
| this.«name» = «name»; |
| } |
| «ENDIF» |
| «ENDDEFINE» |
| |
| «DEFINE method FOR oocore::Operation-» |
| «EXPAND generatedComment FOR self-» |
| «visibility.repr().toLower()-» «self.wrapIfCollection()» «name-»(«EXPAND parameter FOREACH parameters SEPARATOR ','») { |
| //TODO: implement method |
| } |
| «ENDDEFINE» |
| |
| «DEFINE parameter FOR oocore::Parameter-» |
| «self.wrapIfCollection()» «name-» |
| «ENDDEFINE» |
| |
| «DEFINE generatedComment FOR oocore::NamedElement-» |
| /** |
| *@generated |
| */ |
| «ENDDEFINE» |
| |
| «DEFINE toColumnName FOR String-» |
| «'C_' + self.toUpper()-»") |
| «ENDDEFINE» |
| |
| «DEFINE additions FOR dnc::Archetype-»«ENDDEFINE» |