org.nuiton.wikitty.generator
Class WikittyDTOGenerator

java.lang.Object
  extended by org.nuiton.eugene.Template<I>
      extended by org.nuiton.eugene.Transformer<org.nuiton.eugene.models.object.ObjectModel,O>
          extended by org.nuiton.eugene.models.object.ObjectModelTransformer<org.nuiton.eugene.models.object.ObjectModel>
              extended by org.nuiton.eugene.java.ObjectModelTransformerToJava
                  extended by org.nuiton.wikitty.generator.WikittyDTOGenerator
All Implemented Interfaces:
org.nuiton.eugene.TemplateConfiguration, WikittyTagValue

public class WikittyDTOGenerator
extends org.nuiton.eugene.java.ObjectModelTransformerToJava
implements WikittyTagValue

Wikitty DTO générator.

Plexus component:
role:
"org.nuiton.eugene.Template"
role-hint:
"org.nuiton.wikitty.generator.WikittyDTOGenerator"

Field Summary
protected  Map<String,String> attributeToGetterName
          map "Client.name" to "getName()" or any getter to read this attribute those getter names are stored while generating in order to be found later when generating toString()
protected  List<org.nuiton.eugene.models.object.ObjectModelClass> entitiesWithInheritedOperations
           
protected  Map<org.nuiton.eugene.models.object.ObjectModelClass,org.nuiton.eugene.models.object.ObjectModelClass> processedClasses
          map busines entity from source model to generated abstract class
protected  Pattern toStringTagValuePattern
          pattern to parse toString tagValue for the string "abc{foo|bar}defrzeg{uvw|xyz}oeira" will match {foo|bar} and {uvw|xyz} with groups for foo, bar, uvw and xyz
 
Fields inherited from class org.nuiton.eugene.java.ObjectModelTransformerToJava
builder
 
Fields inherited from class org.nuiton.eugene.Transformer
outputModel, outputProperties, outputTemplate, previousTransformer
 
Fields inherited from class org.nuiton.eugene.Template
configuration, excludeTemplates, generatedPackages, model
 
Fields inherited from interface org.nuiton.wikitty.generator.WikittyTagValue
TAG_ALLOWED, TAG_ALLOWED_QUERY, TAG_ALTERNATIVE_NAME, TAG_CHOICE, TAG_CHOICE_QUERY, TAG_CRYPT, TAG_DOCUMENTATION, TAG_INDEXED, TAG_MAX, TAG_MAX_QUERY, TAG_MIN, TAG_MIN_QUERY, TAG_NOT_NULL, TAG_PATTERN, TAG_PRELOAD, TAG_SORT_ORDER, TAG_SUBTYPE, TAG_TO_STRING, TAG_UNIQUE, TAG_VERSION
 
Fields inherited from interface org.nuiton.eugene.TemplateConfiguration
PROP_CLASS_LOADER, PROP_DEFAULT_PACKAGE, PROP_ENCODING, PROP_EXCLUDE_TEMPLATES, PROP_GENERATED_PACKAGES, PROP_LAST_MODIFIED_SOURCE, PROP_OVERWRITE, PROP_VERBOSE, PROP_WRITER_REPORT
 
Constructor Summary
WikittyDTOGenerator()
           
 
Method Summary
protected  void addBusinessEntityMethods(org.nuiton.eugene.models.object.ObjectModelClass entity, org.nuiton.eugene.models.object.ObjectModelClass dtoClass)
           
protected  void addConstructors(org.nuiton.eugene.models.object.ObjectModelClass clazz)
           
protected  String addCopyFromAttributes(org.nuiton.eugene.models.object.ObjectModelClass businessEntity, String methodBody)
          Generate the copyFrom method.
protected  void addInheritedOperations(org.nuiton.eugene.models.object.ObjectModelClass businessEntity, org.nuiton.eugene.models.object.ObjectModelClass abstractClass)
          Add inherited operations to the abstract generated from an entity.
protected  void addMetaExtensionOperations(org.nuiton.eugene.models.object.ObjectModelClass metaExtension, org.nuiton.eugene.models.object.ObjectModelClass abstractClassForThisMetaExtension)
           
protected  void addModelOperations(org.nuiton.eugene.models.object.ObjectModelClass businessEntity, org.nuiton.eugene.models.object.ObjectModelClass dtoClass)
           
protected  void addOperations(org.nuiton.eugene.models.object.ObjectModelClass businessEntity, org.nuiton.eugene.models.object.ObjectModelClass abstractClass)
           
protected  void addSerialVersionUID(org.nuiton.eugene.models.object.ObjectModelClass clazz)
           
protected  void addToString(org.nuiton.eugene.models.object.ObjectModelClass businessEntity, org.nuiton.eugene.models.object.ObjectModelClass abstractClass)
          add a toString method if a toString tagValue is attached to businessEntity, it will be used to generate a toString as this :

given "hello {Person.name|unknow}"

will try to replace first {...} by name field value for extension Person.

protected  String businessEntityToDTOName(org.nuiton.eugene.models.object.ObjectModelClass clazz)
          Method to get the generated class name
protected  String copyFromAttributesOfClass(org.nuiton.eugene.models.object.ObjectModelClass businessEntity, String methodBody)
           
 void transformFromModel(org.nuiton.eugene.models.object.ObjectModel model)
           
 
Methods inherited from class org.nuiton.eugene.java.ObjectModelTransformerToJava
addAnnotation, addAttribute, addAttribute, addAttribute, addAttribute, addBlock, addComment, addConstant, addConstant, addConstantsFromDependency, addConstructor, addConstructor, addException, addException, addI18n, addImport, addImport, addImport, addInnerClassifier, addInterface, addInterface, addLiteral, addOperation, addOperation, addOperation, addParameter, addParameter, addStereotype, addTagValue, addTagValue, cloneAttribute, cloneClass, cloneClassifier, cloneClassifier, cloneEnumeration, cloneInterface, cloneOperation, cloneOperationSignature, cloneStereotypes, cloneTagValues, copyClassifier, createAbstractClass, createClass, createEnumeration, createInterface, debugOutputModel, generateI18nBlock, getConstantName, getConstantPrefix, getConstantPrefix, getFileInClassPath, getJavaBeanMethodName, initConstantPrefixFromModel, initOutputModel, initOutputTemplate, isInClassPath, isInClassPath, setConstantPrefix, setDocumentation, setMaxMultiplicity, setMinMultiplicity, setNavigable, setOperationBody, setSuperClass, setSuperClass
 
Methods inherited from class org.nuiton.eugene.models.object.ObjectModelTransformer
transform, transformFromClass, transformFromClassifier, transformFromElement, transformFromEnumeration, transformFromInterface
 
Methods inherited from class org.nuiton.eugene.Transformer
applyTemplate, getOutputModel, getOutputProperties, getOutputTemplate, init, initPreviousTransformer, transform
 
Methods inherited from class org.nuiton.eugene.Template
getClassLoader, getConfiguration, getEncoding, getExcludeTemplates, getGeneratedPackages, getLastModifiedSource, getModel, getOverwrite, getProperties, getProperty, getProperty, getWriterReport, isOverwrite, isVerbose, setConfiguration, setProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

processedClasses

protected Map<org.nuiton.eugene.models.object.ObjectModelClass,org.nuiton.eugene.models.object.ObjectModelClass> processedClasses
map busines entity from source model to generated abstract class


toStringTagValuePattern

protected Pattern toStringTagValuePattern
pattern to parse toString tagValue for the string "abc{foo|bar}defrzeg{uvw|xyz}oeira" will match {foo|bar} and {uvw|xyz} with groups for foo, bar, uvw and xyz


attributeToGetterName

protected Map<String,String> attributeToGetterName
map "Client.name" to "getName()" or any getter to read this attribute those getter names are stored while generating in order to be found later when generating toString()


entitiesWithInheritedOperations

protected List<org.nuiton.eugene.models.object.ObjectModelClass> entitiesWithInheritedOperations
Constructor Detail

WikittyDTOGenerator

public WikittyDTOGenerator()
Method Detail

transformFromModel

public void transformFromModel(org.nuiton.eugene.models.object.ObjectModel model)
Overrides:
transformFromModel in class org.nuiton.eugene.models.object.ObjectModelTransformer<org.nuiton.eugene.models.object.ObjectModel>

addSerialVersionUID

protected void addSerialVersionUID(org.nuiton.eugene.models.object.ObjectModelClass clazz)

addConstructors

protected void addConstructors(org.nuiton.eugene.models.object.ObjectModelClass clazz)

addOperations

protected void addOperations(org.nuiton.eugene.models.object.ObjectModelClass businessEntity,
                             org.nuiton.eugene.models.object.ObjectModelClass abstractClass)

addInheritedOperations

protected void addInheritedOperations(org.nuiton.eugene.models.object.ObjectModelClass businessEntity,
                                      org.nuiton.eugene.models.object.ObjectModelClass abstractClass)
Add inherited operations to the abstract generated from an entity. Method browse superClasses to copy methods and their bodies. The method deal with imports, cause bodies call the Helper of the classe where the attribute was declared.

If A inherit from B and B inherit from and A, B, C not in the same package we B need to import CHelper and A need to import BHelper. But, since A has C attributes too, it needs CHelper too. So when we will process B, we will save needed imports, A will get them thus import CHelper.

Parameters:
businessEntity -
abstractClass -

addToString

protected void addToString(org.nuiton.eugene.models.object.ObjectModelClass businessEntity,
                           org.nuiton.eugene.models.object.ObjectModelClass abstractClass)
add a toString method if a toString tagValue is attached to businessEntity, it will be used to generate a toString as this :

given "hello {Person.name|unknow}"

will try to replace first {...} by name field value for extension Person. if this information is not available, will do unknow.

Parameters:
businessEntity -
abstractClass -

addMetaExtensionOperations

protected void addMetaExtensionOperations(org.nuiton.eugene.models.object.ObjectModelClass metaExtension,
                                          org.nuiton.eugene.models.object.ObjectModelClass abstractClassForThisMetaExtension)

businessEntityToDTOName

protected String businessEntityToDTOName(org.nuiton.eugene.models.object.ObjectModelClass clazz)
Method to get the generated class name

Parameters:
clazz -
Returns:

addBusinessEntityMethods

protected void addBusinessEntityMethods(org.nuiton.eugene.models.object.ObjectModelClass entity,
                                        org.nuiton.eugene.models.object.ObjectModelClass dtoClass)

addCopyFromAttributes

protected String addCopyFromAttributes(org.nuiton.eugene.models.object.ObjectModelClass businessEntity,
                                       String methodBody)
Generate the copyFrom method. This method set all fields of the class from all the fields of another instance of the same class.

Parameters:
businessEntity -
methodBody -
Returns:

copyFromAttributesOfClass

protected String copyFromAttributesOfClass(org.nuiton.eugene.models.object.ObjectModelClass businessEntity,
                                           String methodBody)

addModelOperations

protected void addModelOperations(org.nuiton.eugene.models.object.ObjectModelClass businessEntity,
                                  org.nuiton.eugene.models.object.ObjectModelClass dtoClass)


Copyright © 2009-2012 CodeLutin. All Rights Reserved.