diff --git a/TelosysTools/models/InfiniMotion/Eintrittskarte.entity b/TelosysTools/models/InfiniMotion/Eintrittskarte.entity index bdd6af5..dc11601 100644 --- a/TelosysTools/models/InfiniMotion/Eintrittskarte.entity +++ b/TelosysTools/models/InfiniMotion/Eintrittskarte.entity @@ -5,6 +5,8 @@ Eintrittskarte { id: int { @Id @AutoIncremented @ObjectType } ; show: Vorstellung { } ; seat: Sitzplatz { } ; - code: string { @Unique } ; - state: Kartenstatus { } ; + code: string { @Unique @NotNull } ; + reserved: timestamp { @NotNull } ; + booked: timestamp { } ; + cancelled: timestamp {} ; } diff --git a/TelosysTools/models/InfiniMotion/Film.entity b/TelosysTools/models/InfiniMotion/Film.entity index 13d8b4d..ea74dcc 100644 --- a/TelosysTools/models/InfiniMotion/Film.entity +++ b/TelosysTools/models/InfiniMotion/Film.entity @@ -7,6 +7,6 @@ Film { description: string { @NotNull @MaxLen(2000) } ; duration: int { @NotNull } ; image: string { @NotNull } ; - rating: short { } ; + rating: short { @NotNull } ; category: Filmkategorie { } ; } diff --git a/TelosysTools/models/InfiniMotion/Kartenstatus.entity b/TelosysTools/models/InfiniMotion/Kartenstatus.entity deleted file mode 100644 index 62fcb23..0000000 --- a/TelosysTools/models/InfiniMotion/Kartenstatus.entity +++ /dev/null @@ -1,7 +0,0 @@ -// Entity Kartenstatus - -#BaseModel -Kartenstatus { - id: int { @Id @AutoIncremented @ObjectType } ; - name: string { @NotNull @Unique } ; -} \ No newline at end of file diff --git a/TelosysTools/models/InfiniMotion/OmdbMovie.entity b/TelosysTools/models/InfiniMotion/OmdbMovie.entity new file mode 100644 index 0000000..cb0297b --- /dev/null +++ b/TelosysTools/models/InfiniMotion/OmdbMovie.entity @@ -0,0 +1,15 @@ +// Entity OmdbMovie + +#Omdb +OmdbMovie { + imdbID: string {} ; + title: string {} ; + year: string {} ; + rated: string {} ; + released: string {} ; + runtime: string {} ; + genre: string {} ; + plot: string {} ; + poster: string {} ; + imdbRating: string {} ; +} diff --git a/TelosysTools/models/InfiniMotion/OmdbSearch.entity b/TelosysTools/models/InfiniMotion/OmdbSearch.entity new file mode 100644 index 0000000..87c8f5c --- /dev/null +++ b/TelosysTools/models/InfiniMotion/OmdbSearch.entity @@ -0,0 +1,6 @@ +// Entity OmdbSearch + +#Omdb +OmdbSearch { + search: OmdbMovie[] {} ; +} diff --git a/TelosysTools/models/InfiniMotion/Plan.entity b/TelosysTools/models/InfiniMotion/Plan.entity new file mode 100644 index 0000000..3f57663 --- /dev/null +++ b/TelosysTools/models/InfiniMotion/Plan.entity @@ -0,0 +1,11 @@ +// Entity Plan + +#BaseModel +Plan { + id: int { @Id @AutoIncremented @ObjectType } ; + hall: Kinosaal { } ; + movie: Film { } ; + weekday: byte { @NotNull } ; + time: time { @NotNull } ; + first: date { @NotNull } ; +} diff --git a/TelosysTools/telosys-tools.cfg b/TelosysTools/telosys-tools.cfg index b9c5fea..a33236c 100644 --- a/TelosysTools/telosys-tools.cfg +++ b/TelosysTools/telosys-tools.cfg @@ -22,7 +22,7 @@ ENTITY_PKG=de.infinimotion.model.bean ProjectVariable.MAVEN_ARTIFACT_ID=model ProjectVariable.MAVEN_GROUP_ID=de.infinimotion ProjectVariable.PROJECT_NAME=infinimodel -ProjectVariable.PROJECT_VERSION=0.0.67 +ProjectVariable.PROJECT_VERSION=0.0.76 ProjectVariable.REST_SERVER_PORT=3000 ProjectVariable.REST_API_ROOT=/api/v1 ProjectVariable.REST_URL_ROOT=http://localhost:3000 diff --git a/TelosysTools/templates/infinimotion/backend/backend_entity_java.vm b/TelosysTools/templates/infinimotion/backend/backend_entity_java.vm index ff6e23a..9bebacd 100644 --- a/TelosysTools/templates/infinimotion/backend/backend_entity_java.vm +++ b/TelosysTools/templates/infinimotion/backend/backend_entity_java.vm @@ -1,6 +1,6 @@ ## -------------------------------------------------- -#if ( !($entity.hasTag("BaseModel")) ) -#cancel("Not a Base Model") +#if ( !($entity.hasTag("BaseModel") || $entity.hasTag("Omdb")) ) +#cancel("Not a Base or Omdb Model") #end ## -------------------------------------------------- /* @@ -11,6 +11,7 @@ package ${target.javaPackageFromFolder("backend/${SRC}")}; import java.io.Serializable; +import com.fasterxml.jackson.annotation.JsonFormat; #foreach( $import in $java.imports($entity) ) import $import; @@ -29,6 +30,7 @@ import $import; * @author Telosys Tools Generator * */ +@JsonFormat(with = JsonFormat.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) public class ${entity.name} implements Serializable { private static final long serialVersionUID = 1L; diff --git a/TelosysTools/templates/infinimotion/backend/command/create_java.vm b/TelosysTools/templates/infinimotion/backend/command/create_java.vm index 11587c9..577e9e9 100644 --- a/TelosysTools/templates/infinimotion/backend/command/create_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/create_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Create" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/delete_java.vm b/TelosysTools/templates/infinimotion/backend/command/delete_java.vm index 3a1f0ff..d35fe25 100644 --- a/TelosysTools/templates/infinimotion/backend/command/delete_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/delete_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Delete" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/get_java.vm b/TelosysTools/templates/infinimotion/backend/command/get_java.vm index 2a02904..637ee62 100644 --- a/TelosysTools/templates/infinimotion/backend/command/get_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/get_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Get" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/list_java.vm b/TelosysTools/templates/infinimotion/backend/command/list_java.vm index 4a6f873..e6b3dd0 100644 --- a/TelosysTools/templates/infinimotion/backend/command/list_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/list_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "List" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/processor_create_java.vm b/TelosysTools/templates/infinimotion/backend/command/processor_create_java.vm index c24f828..7c6e384 100644 --- a/TelosysTools/templates/infinimotion/backend/command/processor_create_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/processor_create_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Create" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/processor_delete_java.vm b/TelosysTools/templates/infinimotion/backend/command/processor_delete_java.vm index acf04e1..f7cd5e7 100644 --- a/TelosysTools/templates/infinimotion/backend/command/processor_delete_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/processor_delete_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Delete" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/processor_get_java.vm b/TelosysTools/templates/infinimotion/backend/command/processor_get_java.vm index 9156818..1431531 100644 --- a/TelosysTools/templates/infinimotion/backend/command/processor_get_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/processor_get_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Get" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/processor_list_java.vm b/TelosysTools/templates/infinimotion/backend/command/processor_list_java.vm index 2683d59..4b5a490 100644 --- a/TelosysTools/templates/infinimotion/backend/command/processor_list_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/processor_list_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "List" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/processor_update_java.vm b/TelosysTools/templates/infinimotion/backend/command/processor_update_java.vm index 0dd5449..8ef0d43 100644 --- a/TelosysTools/templates/infinimotion/backend/command/processor_update_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/processor_update_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Update" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/response_create_java.vm b/TelosysTools/templates/infinimotion/backend/command/response_create_java.vm index 59bab98..dd67b65 100644 --- a/TelosysTools/templates/infinimotion/backend/command/response_create_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/response_create_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Create" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/response_delete_java.vm b/TelosysTools/templates/infinimotion/backend/command/response_delete_java.vm index 5457d7d..26098f3 100644 --- a/TelosysTools/templates/infinimotion/backend/command/response_delete_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/response_delete_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Delete" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/response_get_java.vm b/TelosysTools/templates/infinimotion/backend/command/response_get_java.vm index a90670c..4cfcf31 100644 --- a/TelosysTools/templates/infinimotion/backend/command/response_get_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/response_get_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Get" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/response_list_java.vm b/TelosysTools/templates/infinimotion/backend/command/response_list_java.vm index fe310c5..69dfd23 100644 --- a/TelosysTools/templates/infinimotion/backend/command/response_list_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/response_list_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "List" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/response_update_java.vm b/TelosysTools/templates/infinimotion/backend/command/response_update_java.vm index f8ba161..b57b05c 100644 --- a/TelosysTools/templates/infinimotion/backend/command/response_update_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/response_update_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Update" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command/update_java.vm b/TelosysTools/templates/infinimotion/backend/command/update_java.vm index 34e0710..d85677e 100644 --- a/TelosysTools/templates/infinimotion/backend/command/update_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command/update_java.vm @@ -1,3 +1,3 @@ #set( $component = "backend" ) #set( $commandType = "Update" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/backend/command_entity_java.vm b/TelosysTools/templates/infinimotion/backend/command_entity_java.vm index 92b05ad..b4c1fdb 100644 --- a/TelosysTools/templates/infinimotion/backend/command_entity_java.vm +++ b/TelosysTools/templates/infinimotion/backend/command_entity_java.vm @@ -1,167 +1,2 @@ -## -------------------------------------------------- -#if ( !($entity.hasTag("Command")) ) -#cancel("Not a Command") -#end -## -------------------------------------------------- -/* - * Java command model class for entity "${entity.name}" - * Created on $now.date ( $now.time ) - * Generated by $generator.name ( version $generator.version ) - */ -package ${target.javaPackageFromFolder("backend/${SRC}")}; - -import java.io.Serializable; - -#foreach( $import in $java.imports($entity) ) -import $import; -#end - -##-------------------------------------------------------------------------------------------------------- -## Data fields = fields not in Primary Key and not in selected Links -#set( $dataFields = $entity.getAttributesByCriteria( $const.NOT_KEY, $const.NOT_IN_SELECTED_LINKS ) ) -##-------------------------------------------------------------------------------------------------------- -## Link fields = fields not in Primary Key and used as FK in selected Links -#set( $linkFields = $entity.getAttributesByCriteria( $const.NOT_KEY, $const.IN_SELECTED_LINKS ) ) -##-------------------------------------------------------------------------------------------------------- -/** - * Command model class for entity "${entity.name}" - * - * @author Telosys Tools Generator - * - */ -public#if( $entity.isAbstract() ) abstract#end class ${entity.name}#if( $entity.hasSuperClass() ) extends $entity.superClass#end implements Serializable { - - private static final long serialVersionUID = 1L; - - //---------------------------------------------------------------------- - // ENTITY PRIMARY KEY - //---------------------------------------------------------------------- -#foreach( $field in $entity.keyAttributes ) - private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} #end; -#end - - //---------------------------------------------------------------------- - // ENTITY DATA FIELDS - //---------------------------------------------------------------------- -#foreach( $field in $dataFields ) - private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} #end; -#end -#foreach( $field in $linkFields ) - // Attribute "$field.name" is a link -#end - - //---------------------------------------------------------------------- - // ENTITY LINKS ( RELATIONSHIP ) - //---------------------------------------------------------------------- -#foreach( $link in $entity.selectedLinks ) - private ${link.formattedFieldType(10)} $link.formattedFieldName(12) ; -#end - - //---------------------------------------------------------------------- - // CONSTRUCTOR(S) - //---------------------------------------------------------------------- - public ${entity.name}() { - super(); - } - - //---------------------------------------------------------------------- - // GETTER & SETTER FOR "KEY FIELD(S)" - //---------------------------------------------------------------------- -#foreach( $attribute in $entity.keyAttributes ) - public void ${attribute.setter}( $attribute.type $attribute.name ) { - this.$attribute.name = $attribute.name ; - } - public $attribute.type ${attribute.getter}() { - return this.$attribute.name; - } - -#end - - //---------------------------------------------------------------------- - // GETTERS & SETTERS FOR "DATA FIELDS" - //---------------------------------------------------------------------- -#foreach( $attribute in $dataFields ) - public void ${attribute.setter}( $attribute.type $attribute.name ) { - this.$attribute.name = $attribute.name ; - } - public $attribute.type ${attribute.getter}() { - return this.$attribute.name; - } - -#end - - //---------------------------------------------------------------------- - // GETTERS & SETTERS FOR LINKS - //---------------------------------------------------------------------- -#foreach( $link in $entity.selectedLinks ) - public void ${link.setter}( ${link.formattedFieldType(0)} ${link.formattedFieldName(0)} ) { - this.${link.formattedFieldName(0)} = ${link.formattedFieldName(0)}; - } - public ${link.formattedFieldType(0)} ${link.getter}() { - return this.${link.formattedFieldName(0)}; - } - -#end - -#if( $entity.isAbstract() ) - static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER - = new com.fasterxml.jackson.databind.ObjectMapper() - .setVisibility(com.fasterxml.jackson.annotation.PropertyAccessor.FIELD, com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY) - .configure(com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS, false) - .findAndRegisterModules(); - - public abstract CommandWrapper serialize() throws java.io.IOException; -#else -#if ( $entity.name != "CommandWrapper" ) - public CommandWrapper serialize() throws java.io.IOException { - CommandWrapper wrapper = new CommandWrapper(); - wrapper.setType(${entity.name}.class.getSimpleName()); - wrapper.setPayload(OBJECT_MAPPER.writeValueAsBytes(this)); - return wrapper; - } - - public static $entity.name deserialize(CommandWrapper wrapper) throws java.io.IOException { - return OBJECT_MAPPER.readValue(wrapper.getPayload(), ${entity.name}.class); - } - - public static boolean isType(CommandWrapper wrapper) { - return wrapper.getType().equals(${entity.name}.class.getSimpleName()); - } -#else - public $entity.name copyIds(CommandWrapper wrapper) { - setTransaction(wrapper.getTransaction()); - setRequest(wrapper.getRequest()); - return this; - } - - public $entity.name generateIds() { - setTransaction(java.util.UUID.randomUUID().toString()); - setRequest(java.util.UUID.randomUUID().toString()); - return this; - } - - public $entity.name tx(CommandWrapper wrapper) { - setTransaction(wrapper.getTransaction()); - setRequest(java.util.UUID.randomUUID().toString()); - return this; - } - - public $entity.name commit() { - setCommit(true); - return this; - } - - public ${entity.name}(CommandWrapper wrapper) { - this(); - copyIds(wrapper); - } -#end -#end - - //---------------------------------------------------------------------- - // toString METHOD - //---------------------------------------------------------------------- -## This function generates a 'toString' method with 4 blanks before each line -## $java.toStringMethod($fn.concatLists($entity.keyAttributes, $dataFields), 4) -$java.toStringMethod($entity, 1) -} +#set( $component = "backend" ) +#parse( "include/command_entity.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/include_command.vm b/TelosysTools/templates/infinimotion/include/command.vm similarity index 100% rename from TelosysTools/templates/infinimotion/include_command.vm rename to TelosysTools/templates/infinimotion/include/command.vm diff --git a/TelosysTools/templates/infinimotion/include/command_entity.vm b/TelosysTools/templates/infinimotion/include/command_entity.vm new file mode 100644 index 0000000..3911d5b --- /dev/null +++ b/TelosysTools/templates/infinimotion/include/command_entity.vm @@ -0,0 +1,186 @@ +## -------------------------------------------------- +#if ( !($entity.hasTag("Command")) ) +#cancel("Not a Command") +#end +## -------------------------------------------------- +/* + * Java command model class for entity "${entity.name}" + * Created on $now.date ( $now.time ) + * Generated by $generator.name ( version $generator.version ) + */ +package ${target.javaPackageFromFolder("${component}/${SRC}")}; + +import java.io.Serializable; + +#foreach( $import in $java.imports($entity) ) +import $import; +#end + +##-------------------------------------------------------------------------------------------------------- +## Data fields = fields not in Primary Key and not in selected Links +#set( $dataFields = $entity.getAttributesByCriteria( $const.NOT_KEY, $const.NOT_IN_SELECTED_LINKS ) ) +##-------------------------------------------------------------------------------------------------------- +## Link fields = fields not in Primary Key and used as FK in selected Links +#set( $linkFields = $entity.getAttributesByCriteria( $const.NOT_KEY, $const.IN_SELECTED_LINKS ) ) +##-------------------------------------------------------------------------------------------------------- +/** + * Command model class for entity "${entity.name}" + * + * @author Telosys Tools Generator + * + */ +public#if( $entity.isAbstract() ) abstract#end class ${entity.name}#if( $entity.hasSuperClass() ) extends $entity.superClass#end implements Serializable { + + private static final long serialVersionUID = 1L; + + //---------------------------------------------------------------------- + // ENTITY PRIMARY KEY + //---------------------------------------------------------------------- +#foreach( $field in $entity.keyAttributes ) + private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} #end; +#end + + //---------------------------------------------------------------------- + // ENTITY DATA FIELDS + //---------------------------------------------------------------------- +#foreach( $field in $dataFields ) + private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} #end; +#end +#foreach( $field in $linkFields ) + // Attribute "$field.name" is a link +#end + + //---------------------------------------------------------------------- + // ENTITY LINKS ( RELATIONSHIP ) + //---------------------------------------------------------------------- +#foreach( $link in $entity.selectedLinks ) + private ${link.formattedFieldType(10)} $link.formattedFieldName(12) ; +#end + + //---------------------------------------------------------------------- + // CONSTRUCTOR(S) + //---------------------------------------------------------------------- + public ${entity.name}() { + super(); + } + + //---------------------------------------------------------------------- + // GETTER & SETTER FOR "KEY FIELD(S)" + //---------------------------------------------------------------------- +#foreach( $attribute in $entity.keyAttributes ) + public void ${attribute.setter}( $attribute.type $attribute.name ) { + this.$attribute.name = $attribute.name ; + } + public $attribute.type ${attribute.getter}() { + return this.$attribute.name; + } + +#end + + //---------------------------------------------------------------------- + // GETTERS & SETTERS FOR "DATA FIELDS" + //---------------------------------------------------------------------- +#foreach( $attribute in $dataFields ) + public void ${attribute.setter}( $attribute.type $attribute.name ) { + this.$attribute.name = $attribute.name ; + } + public $attribute.type ${attribute.getter}() { + return this.$attribute.name; + } + +#end + + //---------------------------------------------------------------------- + // GETTERS & SETTERS FOR LINKS + //---------------------------------------------------------------------- +#foreach( $link in $entity.selectedLinks ) + public void ${link.setter}( ${link.formattedFieldType(0)} ${link.formattedFieldName(0)} ) { + this.${link.formattedFieldName(0)} = ${link.formattedFieldName(0)}; + } + public ${link.formattedFieldType(0)} ${link.getter}() { + return this.${link.formattedFieldName(0)}; + } + +#end + +#if( $entity.isAbstract() ) + static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER + = new com.fasterxml.jackson.databind.ObjectMapper() + .setVisibility(com.fasterxml.jackson.annotation.PropertyAccessor.FIELD, com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY) + .configure(com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS, false) + .findAndRegisterModules(); + + public abstract CommandWrapper serialize() throws java.io.IOException; + +#if ( $component == "persistence" ) + public abstract Command process() throws Exception; +#end +#else +#if ( $entity.name != "CommandWrapper" ) + public CommandWrapper serialize() throws java.io.IOException { + CommandWrapper wrapper = new CommandWrapper(); + wrapper.setType(${entity.name}.class.getSimpleName()); + wrapper.setPayload(OBJECT_MAPPER.writeValueAsBytes(this)); + return wrapper; + } + + public static $entity.name deserialize(CommandWrapper wrapper) throws java.io.IOException { + return OBJECT_MAPPER.readValue(wrapper.getPayload(), ${entity.name}.class); + } + + public static boolean isType(CommandWrapper wrapper) { + return wrapper.getType().equals(${entity.name}.class.getSimpleName()); + } + +#if ( $component == "persistence" ) + @Override + public Command process() throws Exception { + return jakarta.enterprise.inject.spi.CDI.current().select(${entity.name}Processor.class).get().process${entity.name}(this); + } +#end +#else + public $entity.name copyIds(CommandWrapper wrapper) { + setTransaction(wrapper.getTransaction()); + setRequest(wrapper.getRequest()); + return this; + } + + public $entity.name generateIds() { + setTransaction(java.util.UUID.randomUUID().toString()); + setRequest(java.util.UUID.randomUUID().toString()); + return this; + } + + + public $entity.name tx(CommandWrapper wrapper) { + setTransaction(wrapper.getTransaction()); + setRequest(java.util.UUID.randomUUID().toString()); + return this; + } + + public $entity.name commit() { + setCommit(true); + return this; + } + + public ${entity.name}(CommandWrapper wrapper) { + this(); + copyIds(wrapper); + } + +#if ( $component == "persistence" ) + public Command process() throws Exception { + Command command = (Command) Class.forName(getClass().getPackageName() + "." + this.getType()).getMethod("deserialize", getClass()).invoke(null, this); + return command.process(); + } +#end +#end +#end + + //---------------------------------------------------------------------- + // toString METHOD + //---------------------------------------------------------------------- +## This function generates a 'toString' method with 4 blanks before each line +## $java.toStringMethod($fn.concatLists($entity.keyAttributes, $dataFields), 4) +$java.toStringMethod($entity, 1) +} diff --git a/TelosysTools/templates/infinimotion/include_command_processor.vm b/TelosysTools/templates/infinimotion/include/command_processor.vm similarity index 100% rename from TelosysTools/templates/infinimotion/include_command_processor.vm rename to TelosysTools/templates/infinimotion/include/command_processor.vm diff --git a/TelosysTools/templates/infinimotion/include_command_response.vm b/TelosysTools/templates/infinimotion/include/command_response.vm similarity index 100% rename from TelosysTools/templates/infinimotion/include_command_response.vm rename to TelosysTools/templates/infinimotion/include/command_response.vm diff --git a/TelosysTools/templates/infinimotion/persistence/command/create_java.vm b/TelosysTools/templates/infinimotion/persistence/command/create_java.vm index 6efd212..fe45f37 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/create_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/create_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Create" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/delete_java.vm b/TelosysTools/templates/infinimotion/persistence/command/delete_java.vm index cf49f6c..763f4f3 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/delete_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/delete_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Delete" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/get_java.vm b/TelosysTools/templates/infinimotion/persistence/command/get_java.vm index c7ac348..fe7adc3 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/get_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/get_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Get" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/list_java.vm b/TelosysTools/templates/infinimotion/persistence/command/list_java.vm index e25496f..c020e25 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/list_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/list_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "List" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/processor_create_java.vm b/TelosysTools/templates/infinimotion/persistence/command/processor_create_java.vm index 77b3b27..d78c4c6 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/processor_create_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/processor_create_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Create" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/processor_delete_java.vm b/TelosysTools/templates/infinimotion/persistence/command/processor_delete_java.vm index cb67ee5..5e67214 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/processor_delete_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/processor_delete_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Delete" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/processor_get_java.vm b/TelosysTools/templates/infinimotion/persistence/command/processor_get_java.vm index 91985de..f304c2a 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/processor_get_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/processor_get_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Get" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/processor_list_java.vm b/TelosysTools/templates/infinimotion/persistence/command/processor_list_java.vm index 85fd0b5..bada7de 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/processor_list_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/processor_list_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "List" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/processor_update_java.vm b/TelosysTools/templates/infinimotion/persistence/command/processor_update_java.vm index 342f053..d79b8a7 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/processor_update_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/processor_update_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Update" ) -#parse( "include_command_processor.vm" ) \ No newline at end of file +#parse( "include/command_processor.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/response_create_java.vm b/TelosysTools/templates/infinimotion/persistence/command/response_create_java.vm index 12105ab..e3e7f35 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/response_create_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/response_create_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Create" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/response_delete_java.vm b/TelosysTools/templates/infinimotion/persistence/command/response_delete_java.vm index d05d26e..51bd26f 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/response_delete_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/response_delete_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Delete" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/response_get_java.vm b/TelosysTools/templates/infinimotion/persistence/command/response_get_java.vm index 8e9ba33..7c49f3b 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/response_get_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/response_get_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Get" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/response_list_java.vm b/TelosysTools/templates/infinimotion/persistence/command/response_list_java.vm index 37290db..12a9195 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/response_list_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/response_list_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "List" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/response_update_java.vm b/TelosysTools/templates/infinimotion/persistence/command/response_update_java.vm index 0720965..4c79898 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/response_update_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/response_update_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Update" ) -#parse( "include_command_response.vm" ) \ No newline at end of file +#parse( "include/command_response.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command/update_java.vm b/TelosysTools/templates/infinimotion/persistence/command/update_java.vm index d73f88f..6b54ea6 100644 --- a/TelosysTools/templates/infinimotion/persistence/command/update_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command/update_java.vm @@ -1,3 +1,3 @@ #set( $component = "persistence" ) #set( $commandType = "Update" ) -#parse( "include_command.vm" ) \ No newline at end of file +#parse( "include/command.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/command_entity_java.vm b/TelosysTools/templates/infinimotion/persistence/command_entity_java.vm index d33941b..f2f5c2b 100644 --- a/TelosysTools/templates/infinimotion/persistence/command_entity_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command_entity_java.vm @@ -1,180 +1,2 @@ -## -------------------------------------------------- -#if ( !($entity.hasTag("Command")) ) -#cancel("Not a Command") -#end -## -------------------------------------------------- -/* - * Java command model class for entity "${entity.name}" - * Created on $now.date ( $now.time ) - * Generated by $generator.name ( version $generator.version ) - */ -package ${target.javaPackageFromFolder("persistence/${SRC}")}; - -import java.io.Serializable; - -#foreach( $import in $java.imports($entity) ) -import $import; -#end - -##-------------------------------------------------------------------------------------------------------- -## Data fields = fields not in Primary Key and not in selected Links -#set( $dataFields = $entity.getAttributesByCriteria( $const.NOT_KEY, $const.NOT_IN_SELECTED_LINKS ) ) -##-------------------------------------------------------------------------------------------------------- -## Link fields = fields not in Primary Key and used as FK in selected Links -#set( $linkFields = $entity.getAttributesByCriteria( $const.NOT_KEY, $const.IN_SELECTED_LINKS ) ) -##-------------------------------------------------------------------------------------------------------- -/** - * Command model class for entity "${entity.name}" - * - * @author Telosys Tools Generator - * - */ -public#if( $entity.isAbstract() ) abstract#end class ${entity.name}#if( $entity.hasSuperClass() ) extends $entity.superClass#end implements Serializable { - - private static final long serialVersionUID = 1L; - - //---------------------------------------------------------------------- - // ENTITY PRIMARY KEY - //---------------------------------------------------------------------- -#foreach( $field in $entity.keyAttributes ) - private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} #end; -#end - - //---------------------------------------------------------------------- - // ENTITY DATA FIELDS - //---------------------------------------------------------------------- -#foreach( $field in $dataFields ) - private $field.formattedType(10) $field.formattedName(12) #if($field.hasInitialValue())= ${field.initialValue} #end; -#end -#foreach( $field in $linkFields ) - // Attribute "$field.name" is a link -#end - - //---------------------------------------------------------------------- - // ENTITY LINKS ( RELATIONSHIP ) - //---------------------------------------------------------------------- -#foreach( $link in $entity.selectedLinks ) - private ${link.formattedFieldType(10)} $link.formattedFieldName(12) ; -#end - - //---------------------------------------------------------------------- - // CONSTRUCTOR(S) - //---------------------------------------------------------------------- - public ${entity.name}() { - super(); - } - - //---------------------------------------------------------------------- - // GETTER & SETTER FOR "KEY FIELD(S)" - //---------------------------------------------------------------------- -#foreach( $attribute in $entity.keyAttributes ) - public void ${attribute.setter}( $attribute.type $attribute.name ) { - this.$attribute.name = $attribute.name ; - } - public $attribute.type ${attribute.getter}() { - return this.$attribute.name; - } - -#end - - //---------------------------------------------------------------------- - // GETTERS & SETTERS FOR "DATA FIELDS" - //---------------------------------------------------------------------- -#foreach( $attribute in $dataFields ) - public void ${attribute.setter}( $attribute.type $attribute.name ) { - this.$attribute.name = $attribute.name ; - } - public $attribute.type ${attribute.getter}() { - return this.$attribute.name; - } - -#end - - //---------------------------------------------------------------------- - // GETTERS & SETTERS FOR LINKS - //---------------------------------------------------------------------- -#foreach( $link in $entity.selectedLinks ) - public void ${link.setter}( ${link.formattedFieldType(0)} ${link.formattedFieldName(0)} ) { - this.${link.formattedFieldName(0)} = ${link.formattedFieldName(0)}; - } - public ${link.formattedFieldType(0)} ${link.getter}() { - return this.${link.formattedFieldName(0)}; - } - -#end - -#if( $entity.isAbstract() ) - static final com.fasterxml.jackson.databind.ObjectMapper OBJECT_MAPPER - = new com.fasterxml.jackson.databind.ObjectMapper() - .setVisibility(com.fasterxml.jackson.annotation.PropertyAccessor.FIELD, com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.ANY) - .configure(com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS, false) - .findAndRegisterModules(); - - public abstract CommandWrapper serialize() throws java.io.IOException; - - public abstract Command process() throws Exception; -#else -#if ( $entity.name != "CommandWrapper" ) - public CommandWrapper serialize() throws java.io.IOException { - CommandWrapper wrapper = new CommandWrapper(); - wrapper.setType(${entity.name}.class.getSimpleName()); - wrapper.setPayload(OBJECT_MAPPER.writeValueAsBytes(this)); - return wrapper; - } - - public static $entity.name deserialize(CommandWrapper wrapper) throws java.io.IOException { - return OBJECT_MAPPER.readValue(wrapper.getPayload(), ${entity.name}.class); - } - - public static boolean isType(CommandWrapper wrapper) { - return wrapper.getType().equals(${entity.name}.class.getSimpleName()); - } - - @Override - public Command process() throws Exception { - return jakarta.enterprise.inject.spi.CDI.current().select(${entity.name}Processor.class).get().process${entity.name}(this); - } -#else - public $entity.name copyIds(CommandWrapper wrapper) { - setTransaction(wrapper.getTransaction()); - setRequest(wrapper.getRequest()); - return this; - } - - public $entity.name generateIds() { - setTransaction(java.util.UUID.randomUUID().toString()); - setRequest(java.util.UUID.randomUUID().toString()); - return this; - } - - - public $entity.name tx(CommandWrapper wrapper) { - setTransaction(wrapper.getTransaction()); - setRequest(java.util.UUID.randomUUID().toString()); - return this; - } - - public $entity.name commit() { - setCommit(true); - return this; - } - - public ${entity.name}(CommandWrapper wrapper) { - this(); - copyIds(wrapper); - } - - public Command process() throws Exception { - Command command = (Command) Class.forName(getClass().getPackageName() + "." + this.getType()).getMethod("deserialize", getClass()).invoke(null, this); - return command.process(); - } -#end -#end - - //---------------------------------------------------------------------- - // toString METHOD - //---------------------------------------------------------------------- -## This function generates a 'toString' method with 4 blanks before each line -## $java.toStringMethod($fn.concatLists($entity.keyAttributes, $dataFields), 4) -$java.toStringMethod($entity, 1) -} +#set( $component = "persistence" ) +#parse( "include/command_entity.vm" ) \ No newline at end of file diff --git a/TelosysTools/templates/infinimotion/persistence/include/init_var_entity.vm b/TelosysTools/templates/infinimotion/persistence/include/init_var_entity.vm deleted file mode 100644 index b310f7e..0000000 --- a/TelosysTools/templates/infinimotion/persistence/include/init_var_entity.vm +++ /dev/null @@ -1,9 +0,0 @@ -## #set($recordClass = "${entity.name}Record" ) -## #set($recordInstance = $fn.uncapitalize($entity.name) ) -## -#set($jpaEntityClass = "${entity.name}" ) -#set($jpaEntityIdClass = "${entity.name}Id" ) -## -## #set($jpaMapperClass = "${entity.name}RecordMapper" ) -## #set($jpaMapperInstance = "${recordInstance}Mapper" ) -## diff --git a/TelosysTools/templates/infinimotion/persistence/include/java_header.vm b/TelosysTools/templates/infinimotion/persistence/include/java_header.vm deleted file mode 100644 index 313ba99..0000000 --- a/TelosysTools/templates/infinimotion/persistence/include/java_header.vm +++ /dev/null @@ -1,4 +0,0 @@ -/* - * Created on $now.date ( $now.time ) - * Generated by Telosys ( http://www.telosys.org/ ) version $generator.version - */ diff --git a/TelosysTools/templates/infinimotion/persistence/persistence_entity_id_java.vm b/TelosysTools/templates/infinimotion/persistence/persistence_entity_id_java.vm index f71e795..329a8de 100644 --- a/TelosysTools/templates/infinimotion/persistence/persistence_entity_id_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/persistence_entity_id_java.vm @@ -1,6 +1,17 @@ #checkId($entity) -#parse("persistence/include/init_var_entity.vm") -#parse("persistence/include/java_header.vm") +## #set($recordClass = "${entity.name}Record" ) +## #set($recordInstance = $fn.uncapitalize($entity.name) ) +## +#set($jpaEntityClass = "${entity.name}" ) +#set($jpaEntityIdClass = "${entity.name}Id" ) +## +## #set($jpaMapperClass = "${entity.name}RecordMapper" ) +## #set($jpaMapperInstance = "${recordInstance}Mapper" ) +## +/* + * Created on $now.date ( $now.time ) + * Generated by Telosys ( http://www.telosys.org/ ) version $generator.version + */ ##-------------------------------------------------------------------------------------------------------- package ${target.javaPackageFromFolder("persistence/${SRC}")}; diff --git a/TelosysTools/templates/infinimotion/persistence/persistence_entity_java.vm b/TelosysTools/templates/infinimotion/persistence/persistence_entity_java.vm index 53888bb..8891f6f 100644 --- a/TelosysTools/templates/infinimotion/persistence/persistence_entity_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/persistence_entity_java.vm @@ -8,8 +8,19 @@ #end ## -------------------------------------------------- #checkId($entity) -#parse("persistence/include/init_var_entity.vm") -#parse("persistence/include/java_header.vm") +## #set($recordClass = "${entity.name}Record" ) +## #set($recordInstance = $fn.uncapitalize($entity.name) ) +## +#set($jpaEntityClass = "${entity.name}" ) +#set($jpaEntityIdClass = "${entity.name}Id" ) +## +## #set($jpaMapperClass = "${entity.name}RecordMapper" ) +## #set($jpaMapperInstance = "${recordInstance}Mapper" ) +## +/* + * Created on $now.date ( $now.time ) + * Generated by Telosys ( http://www.telosys.org/ ) version $generator.version + */ ##--------------------------------------------------------------------------------------- ## JPA CONFIGURATION ##--------------------------------------------------------------------------------------- @@ -85,8 +96,11 @@ $jpa.linkAnnotations(4, $link, $entity.attributes) ##--- Just @JoinColumn(s) annotation(s) ## $jpa.linkJoinAnnotation(4, $link) ## $jpa.linkJoinAnnotation(4, $link, $entity.attributes) -#if( !($link.optional) ) - @Column(nullable = false) +## Workaround, sonst undefined... +#if( "${link.optional}" == "true" ) + @JoinColumn(nullable = true) +#else + @JoinColumn(nullable = false) #end private ${link.formattedFieldType(10)} $link.fieldName ;