movie importer and show planner
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Create" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Delete" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Get" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "List" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Create" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Delete" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Get" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "List" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Update" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Create" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Delete" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Get" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "List" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Update" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "backend" )
|
||||
#set( $commandType = "Update" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.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" )
|
||||
186
TelosysTools/templates/infinimotion/include/command_entity.vm
Normal file
186
TelosysTools/templates/infinimotion/include/command_entity.vm
Normal file
@@ -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)
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Create" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Delete" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Get" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "List" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Create" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Delete" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Get" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "List" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Update" )
|
||||
#parse( "include_command_processor.vm" )
|
||||
#parse( "include/command_processor.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Create" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Delete" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Get" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "List" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Update" )
|
||||
#parse( "include_command_response.vm" )
|
||||
#parse( "include/command_response.vm" )
|
||||
@@ -1,3 +1,3 @@
|
||||
#set( $component = "persistence" )
|
||||
#set( $commandType = "Update" )
|
||||
#parse( "include_command.vm" )
|
||||
#parse( "include/command.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" )
|
||||
@@ -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" )
|
||||
##
|
||||
@@ -1,4 +0,0 @@
|
||||
/*
|
||||
* Created on $now.date ( $now.time )
|
||||
* Generated by Telosys ( http://www.telosys.org/ ) version $generator.version
|
||||
*/
|
||||
@@ -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}")};
|
||||
|
||||
|
||||
@@ -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 ;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user