templates.service.base.impl.vm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stout-spring-mda Show documentation
Show all versions of stout-spring-mda Show documentation
Contains resources for generating application code that realizes a
Spring-based business object and business service architecture
package ${basePackage}.service.impl;
#foreach( $import in $service.imports )
import $import;
#end
import javax.inject.Inject;
import org.bitbucket.fermenter.stout.authz.Action;
import org.bitbucket.fermenter.stout.messages.AbstractMessageManagerAwareService;
import org.bitbucket.fermenter.stout.messages.MessageManagerAwareService;
import org.bitbucket.fermenter.stout.messages.Message;
import org.bitbucket.fermenter.stout.messages.Messages;
import org.bitbucket.fermenter.stout.messages.MessageManager;
import org.bitbucket.fermenter.stout.messages.ServiceMessages;
import org.bitbucket.fermenter.stout.messages.Severity;
import org.bitbucket.fermenter.stout.service.ValueServiceResponse;
import org.bitbucket.fermenter.stout.service.VoidServiceResponse;
import org.bitbucket.fermenter.stout.page.PageWrapper;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import ${basePackage}.service.rest.${service.name}Service;
/**
* Service implementation class for the ${service.name} service
* @see ${basePackage}.service.rest.${service.name}Service
*
* Generated from: ${templateName}
*/
public abstract class ${service.name}BaseServiceImpl extends AbstractMessageManagerAwareService implements ${service.name}Service {
@Inject
protected Messages messages;
@Inject
private MessageManagerAwareService messageManagerAwareService;
#foreach( $operation in $service.operations )
/**
* {@inheritDoc}
*/
@Transactional(propagation=Propagation.${operation.transactionAttribute})
@Override
#if($operation.return.isPagedResponse())
public ValueServiceResponse> ${operation.uncapitalizedName}(${operation.signature}) {
#elseif($operation.return.isMany())
public ValueServiceResponse> ${operation.uncapitalizedName}(${operation.signature}) {
#elseif($operation.isResponseTypeVoid())
public VoidServiceResponse ${operation.uncapitalizedName}(${operation.signature}) {
#else
public ValueServiceResponse<${operation.return.javaType}> ${operation.uncapitalizedName}(${operation.signature}) {
#end
messageManagerAwareService.initializeMessageManager(messages);
assertAuthorization(PATH + "/${operation.uncapitalizedName}", Action.EXECUTE);
#if( $operation.return.isPagedResponse() )
ValueServiceResponse> response = null;
if(startPage == null || startPage < 0) {
Message requiresStartPage = new Message(ServiceMessages.PAGING_REQUIRES_START_PAGE, Severity.ERROR);
MessageManager.addMessage(requiresStartPage);
}
if(count == null || count < 0) {
Message requiresCount = new Message(ServiceMessages.PAGING_REQUIRES_COUNT, Severity.ERROR);
MessageManager.addMessage(requiresCount);
}
if(!MessageManager.hasErrorMessages()) {
PageWrapper<${operation.return.javaType}> result =
#elseif( $operation.return.isMany() )
Collection<${operation.return.javaType}> result =
#elseif( $operation.isResponseTypeVoid() )
#else
${operation.return.javaType} result =
#end
${operation.uncapitalizedName}Impl(
#foreach( $parameter in $operation.parameters )
${parameter.name} #if( $foreach.hasNext ),#end
#end
);
#if($operation.return.isPagedResponse())
response = new ValueServiceResponse<>(result);
} else {
response = new ValueServiceResponse<>(null);
}
#elseif($operation.return.isMany())
ValueServiceResponse> response = new ValueServiceResponse<>(result);
#elseif( $operation.isResponseTypeVoid() )
VoidServiceResponse response = new VoidServiceResponse();
#else
ValueServiceResponse<${operation.return.javaType}> response = new ValueServiceResponse<>(result);
#end
messageManagerAwareService.addAllMessagesToResponse(response);
return response;
}
/**
* Performs the business function for ${operation.name}.
#if( $operation.parameters.size() > 0 )
#foreach( $parameter in $operation.parameters )
#if( $parameter.documentation )
* @param ${parameter.name} ${parameter.documentation}
#else
* @param ${parameter.name}
#end
#end
#end
#if($operation.return.isPagedResponse())
* @return A page of {@link ${operation.returnManyTypeAsBO}}
#elseif($operation.return.isMany())
* @return A {@link Collection} of {@link ${operation.returnManyTypeAsBO}}
#elseif($operation.isResponseTypeVoid())
* @return A instance of {@link ${operation.returnManyTypeAsBO}}
#end
*/
#if($operation.return.isPagedResponse())
protected abstract PageWrapper<${operation.return.javaType}> ${operation.uncapitalizedName}Impl(${operation.signature});
#elseif($operation.return.isMany())
protected abstract Collection<${operation.return.javaType}> ${operation.uncapitalizedName}Impl(${operation.signature});
#elseif($operation.isResponseTypeVoid())
protected abstract void ${operation.uncapitalizedName}Impl(${operation.signature});
#else
protected abstract ${operation.return.javaType} ${operation.uncapitalizedName}Impl(${operation.signature});
#end
#end
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy