diff --git a/TelosysTools/telosys-tools.cfg b/TelosysTools/telosys-tools.cfg index 75a7e4a..221652b 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.38 +ProjectVariable.PROJECT_VERSION=0.0.44 ProjectVariable.REST_SERVER_PORT=3000 ProjectVariable.REST_API_ROOT=/api/v1 ProjectVariable.REST_URL_ROOT=http://localhost:3000 diff --git a/TelosysTools/templates/infinimotion/persistence/command_entity_java.vm b/TelosysTools/templates/infinimotion/persistence/command_entity_java.vm index c275715..19aad86 100644 --- a/TelosysTools/templates/infinimotion/persistence/command_entity_java.vm +++ b/TelosysTools/templates/infinimotion/persistence/command_entity_java.vm @@ -110,6 +110,8 @@ public#if( $entity.isAbstract() ) abstract#end class ${entity.name}#if( $entity. .configure(com.fasterxml.jackson.databind.SerializationFeature.FAIL_ON_EMPTY_BEANS, false); 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 { @@ -126,6 +128,11 @@ public#if( $entity.isAbstract() ) abstract#end class ${entity.name}#if( $entity. 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()); @@ -143,6 +150,11 @@ public#if( $entity.isAbstract() ) abstract#end class ${entity.name}#if( $entity. 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 diff --git a/TelosysTools/templates/infinimotion/persistence/command_processor_java.vm b/TelosysTools/templates/infinimotion/persistence/command_processor_java.vm new file mode 100644 index 0000000..a521c7d --- /dev/null +++ b/TelosysTools/templates/infinimotion/persistence/command_processor_java.vm @@ -0,0 +1,23 @@ +## -------------------------------------------------- +#if ( !($entity.hasTag("Command")) || $entity.isAbstract() ) +#cancel("Not a concrete Command") +#end +## -------------------------------------------------- +/* + * Java command processor interface for entity "${entity.name}" + * Created on $now.date ( $now.time ) + * Generated by $generator.name ( version $generator.version ) + */ +package ${target.javaPackageFromFolder("persistence/${SRC}")}; + +/** + * Command processor interface for entity "${entity.name}" + * + * @author Telosys Tools Generator + * + */ +public interface ${entity.name}Processor { + + Command process${entity.name}($entity.name request) throws Exception; + +} diff --git a/TelosysTools/templates/infinimotion/persistence/pom_xml.vm b/TelosysTools/templates/infinimotion/persistence/pom_xml.vm index cf06d80..322a810 100644 --- a/TelosysTools/templates/infinimotion/persistence/pom_xml.vm +++ b/TelosysTools/templates/infinimotion/persistence/pom_xml.vm @@ -32,6 +32,16 @@ jackson-annotations 2.20 + + jakarta.inject + jakarta.inject-api + 2.0.1 + + + jakarta.enterprise + jakarta.enterprise.cdi-api + 4.1.0 + diff --git a/TelosysTools/templates/infinimotion/templates.cfg b/TelosysTools/templates/infinimotion/templates.cfg index d25a6a7..d96de46 100644 --- a/TelosysTools/templates/infinimotion/templates.cfg +++ b/TelosysTools/templates/infinimotion/templates.cfg @@ -30,4 +30,5 @@ Maven Backend pom.xml ; pom.xml ; backend ### Persistence ### Java Persistence Models ; ${BEANNAME}.java ; persistence/${SRC}/${ROOT_PKG}/persistence ; persistence/persistence_entity_java.vm Java Command Models (P) ; ${BEANNAME}.java ; persistence/${SRC}/${ROOT_PKG}/persistence ; persistence/command_entity_java.vm +Java Command Processors (P) ; ${BEANNAME}Processor.java ; persistence/${SRC}/${ROOT_PKG}/persistence ; persistence/command_processor_java.vm Maven Persistence pom.xml ; pom.xml ; persistence ; persistence/pom_xml.vm ; 1