Class AddressServiceImpl
java.lang.Object
ch.tocco.nice2.optional.address.impl.AddressServiceImpl
- All Implemented Interfaces:
AddressService
,SalutationConstants
@Component
public class AddressServiceImpl
extends Object
implements AddressService, SalutationConstants
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.optional.address.api.AddressService
AddressService.AddressLook, AddressService.AddressType
-
Field Summary
Fields inherited from interface ch.tocco.nice2.optional.address.api.SalutationConstants
ACADEMIC_TITLE, DATA_OBJECT, ENTITY_APPLICATION, ENTITY_SALUTATION, ENTITY_USER, FORMAL_SALUTATION_UNIQUE_ID, GENDER, INFORMAL_SALUTATION_UNIQUE_ID, LABEL, NEUTRAL_SALUTATION_UNIQUE_ID, OTHER_TITLE, REL_ACADEMIC_TITLE, REL_ADDRESS_OUTPUT, REL_GENDER, REL_SALUTATION, REL_USER_OUTPUT, SALUTATION, SALUTATION_TITLE_PLACEHOLDER, TEMPLATE, UNIQUE_ID
-
Constructor Summary
ConstructorDescriptionAddressServiceImpl
(GroovyEvaluationService groovyEvaluationService, TemplateEngineFactory templateEngineFactory, QueryBuilderFactory queryBuilderFactory, CommandExecutor executor) -
Method Summary
Modifier and TypeMethodDescriptiongetAddressAsString
(AddressData data, AddressService.AddressLook look, @Nullable AddressService.AddressType type) This method implements all the logic to generate an address from a basic set of fields required for address generation.getAddressAsString
(Entity entity, AddressService.AddressType type, AddressService.AddressLook look) Get a string containing the address for the provided entitygetAddressAsString
(Entity entity, AddressService.AddressType type, AddressService.AddressLook look, String billingAddressAddition) getAddressAsString
(Iterable<Entity> users, AddressService.AddressType type, AddressService.AddressLook look) getAddressAsStringForUser
(Entity entity, AddressService.AddressType addressType, @Nullable AddressService.AddressLook look) getAddressData
(Entity entity, AddressService.AddressType type, AddressService.AddressLook look) Gets a populatedAddressData
object for the given entity, address type and address look.getAddressDataProvider
(String entityName) getAddressForUser
(Entity userEntity, AddressService.AddressType addressType) Get an Address entity for the provided User entitygetAddressWithAltUser
(Entity altAddress, Entity user, AddressService.AddressType addressType, AddressService.AddressLook look, @Nullable String billingAddressAdditionUser, @Nullable String billingAddressAdditionOther) Prepares data for function "getAddressAsString" Usage: In Correspondence, when an alternative correspondenceaddress is set.getFullName
(AddressData data, boolean withTitle) getFullName
(Entity entity) getFullName
(Entity entity, boolean withTitle) getSalutation
(AddressData data) This method implements the logic to generate a salutation line for a given AddressData object.getSalutation
(Entity entity) Get a string containing the salutation line for the provided entitygetSalutation
(Entity entity, @Nullable Entity sender) getSalutation
(Iterable<Entity> users, @Nullable Entity sender) Returns the salutation string for a list of users.boolean
isCasualForm
(@Nullable Entity sender, Entity recipient) boolean
isPoliteForm
(@Nullable Entity sender, Entity recipient) @Nullable Entity
resolveAddressAddressAcceptor
(@Nullable Entity address, AddressService.AddressType addressType) Get the address that is linked as "recipient" of the parameter address using Address_address with the appropriate "Acceptor" for a given AddressType.retrieveAddressUser
(Entity user, @Nullable Entity address) void
setAddressDataProviders
(List<AddressDataProvider> dataProviders) void
setUserSalutation
(AddressData data)
-
Constructor Details
-
AddressServiceImpl
public AddressServiceImpl(GroovyEvaluationService groovyEvaluationService, TemplateEngineFactory templateEngineFactory, QueryBuilderFactory queryBuilderFactory, CommandExecutor executor)
-
-
Method Details
-
getAddressAsString
public String getAddressAsString(Entity entity, AddressService.AddressType type, AddressService.AddressLook look) Description copied from interface:AddressService
Get a string containing the address for the provided entity- Specified by:
getAddressAsString
in interfaceAddressService
- Parameters:
entity
- entity containing the address information to printtype
- type enum - see enum for detailslook
- look enum - see enum for details- Returns:
- the address string
-
getAddressAsString
public String getAddressAsString(Entity entity, AddressService.AddressType type, AddressService.AddressLook look, String billingAddressAddition) - Specified by:
getAddressAsString
in interfaceAddressService
-
getAddressAsString
public String getAddressAsString(Iterable<Entity> users, AddressService.AddressType type, AddressService.AddressLook look) - Specified by:
getAddressAsString
in interfaceAddressService
- Parameters:
users
- multiple `User` entities that are all linked to the same address- Returns:
- an address block, where the fullnames of the persons are concatenated
-
getSalutation
Description copied from interface:AddressService
Returns the salutation string for a list of users. The user entities must be linked to the same address.- Specified by:
getSalutation
in interfaceAddressService
- Parameters:
sender
- optional sender, used to inspect person-to-person salutation
-
getAddressForUser
Description copied from interface:AddressService
Get an Address entity for the provided User entity- Specified by:
getAddressForUser
in interfaceAddressService
- Parameters:
userEntity
- the user entityaddressType
- type enum - see enum for details- Returns:
- an Address entity
-
resolveAddressAddressAcceptor
@Nullable public @Nullable Entity resolveAddressAddressAcceptor(@Nullable @Nullable Entity address, AddressService.AddressType addressType) Description copied from interface:AddressService
Get the address that is linked as "recipient" of the parameter address using Address_address with the appropriate "Acceptor" for a given AddressType. If the input address is null, null is returned.- Specified by:
resolveAddressAddressAcceptor
in interfaceAddressService
- Parameters:
address
- the address to resolveaddressType
- the address type used to select the proper Acceptor- Returns:
- either the input address or the linked address if available.
-
getSalutation
Description copied from interface:AddressService
Get a string containing the salutation line for the provided entity- Specified by:
getSalutation
in interfaceAddressService
- Parameters:
entity
- entity containing the salutation information- Returns:
- the salutation string
-
getSalutation
- Specified by:
getSalutation
in interfaceAddressService
-
getAddressAsString
public String getAddressAsString(AddressData data, AddressService.AddressLook look, @Nullable @Nullable AddressService.AddressType type) This method implements all the logic to generate an address from a basic set of fields required for address generation.- Specified by:
getAddressAsString
in interfaceAddressService
- Returns:
- the generated address as a String
-
getAddressAsStringForUser
public String getAddressAsStringForUser(Entity entity, AddressService.AddressType addressType, @Nullable @Nullable AddressService.AddressLook look) - Specified by:
getAddressAsStringForUser
in interfaceAddressService
-
getAddressWithAltUser
public String getAddressWithAltUser(Entity altAddress, Entity user, AddressService.AddressType addressType, AddressService.AddressLook look, @Nullable @Nullable String billingAddressAdditionUser, @Nullable @Nullable String billingAddressAdditionOther) Prepares data for function "getAddressAsString" Usage: In Correspondence, when an alternative correspondenceaddress is set.- Specified by:
getAddressWithAltUser
in interfaceAddressService
-
getAddressDataProvider
- Specified by:
getAddressDataProvider
in interfaceAddressService
-
getSalutation
This method implements the logic to generate a salutation line for a given AddressData object.
Note: This method could potentially be made public and moved to the interface to enable salutation generation from a "manually" created AddressData object. -
retrieveAddressUser
- Specified by:
retrieveAddressUser
in interfaceAddressService
-
setUserSalutation
-
isPoliteForm
- Specified by:
isPoliteForm
in interfaceAddressService
-
isCasualForm
- Specified by:
isCasualForm
in interfaceAddressService
-
getFullName
- Specified by:
getFullName
in interfaceAddressService
-
getFullName
- Specified by:
getFullName
in interfaceAddressService
-
getFullName
-
getAddressData
public AddressData getAddressData(Entity entity, @Nullable AddressService.AddressType type, @Nullable AddressService.AddressLook look) Gets a populatedAddressData
object for the given entity, address type and address look.- Specified by:
getAddressData
in interfaceAddressService
-
setAddressDataProviders
-