Class TemplateServiceImpl
java.lang.Object
ch.tocco.nice2.entityoperation.impl.entitytemplate.TemplateServiceImpl
- All Implemented Interfaces:
TemplateService
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.entityoperation.api.entitytemplate.TemplateService
TemplateService.EntityTemplate
-
Constructor Summary
ConstructorDescriptionTemplateServiceImpl
(QueryBuilderFactory queryBuilderFactory, PrincipalService principalService, UriResolver uriResolver, Context context, L10N l10N, FormModel formModel) -
Method Summary
Modifier and TypeMethodDescriptionvoid
applyTemplateValues
(Entity templateEntity, Entity targetEntity, List<String> fieldsToCopy, List<String> relationsToCopy) copy values from a template entity to a target entity in backend.getDefaultTemplateEntity
(String templateEntityName, String entityName) returns the default template as an entitygetDefaultTemplateValues
(String templateEntityName, String entityName, URI localeId, @Nullable String formName) Load values of the default entity template into a mapgetDefaultTemplateValuesUsingCurrentLocale
(String templateEntityName, String entityName, @Nullable String formName) behaves the same way asTemplateService.getDefaultTemplateValues(String, String, URI, String)
but uses the current locale instead of a provided onegetTemplateValues
(URI templateId, URI localeId, @Nullable String formName) Load values of given template using the given localegetTemplateValuesUsingCurrentLocale
(URI templateId, @Nullable String formName) behaves the same way asTemplateService.getTemplateValues(URI, URI, String)
but uses the current locale instead of a provided oneloadTemplatesList
(String templateEntityName, String entityName) creates a list of all templates of the given templateEntityName.void
setAdditionalConditions
(Map<String, String> additionalConditions) void
setEntityTemplateHandlers
(List<EntityTemplateHandler> handlers)
-
Constructor Details
-
TemplateServiceImpl
public TemplateServiceImpl(QueryBuilderFactory queryBuilderFactory, PrincipalService principalService, UriResolver uriResolver, Context context, L10N l10N, FormModel formModel)
-
-
Method Details
-
setAdditionalConditions
-
loadTemplatesList
public List<TemplateService.EntityTemplate> loadTemplatesList(String templateEntityName, String entityName) throws RpcExecutionException Description copied from interface:TemplateService
creates a list of all templates of the given templateEntityName. It will return the template entities without any related module and those with the given entityName.- Specified by:
loadTemplatesList
in interfaceTemplateService
- Parameters:
templateEntityName
- the name of the template entities to loadentityName
- name of the entity which should limit the loaded entities- Returns:
- a list of templates as string arrays.
- Throws:
RpcExecutionException
-
getTemplateValuesUsingCurrentLocale
public Map<String,Object> getTemplateValuesUsingCurrentLocale(URI templateId, @Nullable @Nullable String formName) throws UnresolvableUriException, UriStoreException Description copied from interface:TemplateService
behaves the same way asTemplateService.getTemplateValues(URI, URI, String)
but uses the current locale instead of a provided one- Specified by:
getTemplateValuesUsingCurrentLocale
in interfaceTemplateService
- Throws:
UnresolvableUriException
UriStoreException
-
getTemplateValues
public Map<String,Object> getTemplateValues(URI templateId, URI localeId, @Nullable @Nullable String formName) throws UnresolvableUriException, UriStoreException Description copied from interface:TemplateService
Load values of given template using the given locale- Specified by:
getTemplateValues
in interfaceTemplateService
- Parameters:
templateId
- uri of the templatelocaleId
- uri of the locale- Returns:
- map containing values of the entity
- Throws:
UnresolvableUriException
UriStoreException
-
getDefaultTemplateValuesUsingCurrentLocale
@Nullable public @Nullable Map<String,Object> getDefaultTemplateValuesUsingCurrentLocale(String templateEntityName, String entityName, @Nullable @Nullable String formName) Description copied from interface:TemplateService
behaves the same way asTemplateService.getDefaultTemplateValues(String, String, URI, String)
but uses the current locale instead of a provided one- Specified by:
getDefaultTemplateValuesUsingCurrentLocale
in interfaceTemplateService
-
getDefaultTemplateValues
@Nullable public @Nullable Map<String,Object> getDefaultTemplateValues(String templateEntityName, String entityName, URI localeId, @Nullable @Nullable String formName) throws UnresolvableUriException, UriStoreException Description copied from interface:TemplateService
Load values of the default entity template into a map- Specified by:
getDefaultTemplateValues
in interfaceTemplateService
- Parameters:
templateEntityName
- name of template entity (e.g. Order_template)entityName
- name of the entity where the action is executed (e.g. Registration)localeId
- the locale to use for localized fields- Returns:
- map containing entity values
- Throws:
UnresolvableUriException
UriStoreException
-
getDefaultTemplateEntity
Description copied from interface:TemplateService
returns the default template as an entity- Specified by:
getDefaultTemplateEntity
in interfaceTemplateService
- Parameters:
templateEntityName
- name of the template entityentityName
- name of the entity where the action is executed (e.g. Registration)- Returns:
- optional of the default template
-
applyTemplateValues
public void applyTemplateValues(Entity templateEntity, Entity targetEntity, List<String> fieldsToCopy, List<String> relationsToCopy) Description copied from interface:TemplateService
copy values from a template entity to a target entity in backend. only "non-empty" values are copied. if a field or relation does not exist on either the template or the target, it is ignored.- Specified by:
applyTemplateValues
in interfaceTemplateService
- Parameters:
templateEntity
- the templatetargetEntity
- the target entityfieldsToCopy
- a list of fields that should be copied. This method handles localized fields and copies values for each language separately.relationsToCopy
- a list of relations that should be copied.
-
setEntityTemplateHandlers
@Autowired(required=false) public void setEntityTemplateHandlers(List<EntityTemplateHandler> handlers)
-