Files
model/TelosysTools/templates/infinimotion/backend/backend_entity_java.vm
2025-10-17 00:37:26 +02:00

108 lines
4.3 KiB
Plaintext

/*
* Java backend 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 ) )
##--------------------------------------------------------------------------------------------------------
/**
* Backend model class for entity "${entity.name}"
*
* @author Telosys Tools Generator
*
*/
public class ${entity.name} 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
//----------------------------------------------------------------------
// 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)
}