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 AddressService
AddressService.AddressLook, AddressService.AddressType -
Field Summary
Fields inherited from interface 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
ConstructorsConstructorDescriptionAddressServiceImpl(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 populatedAddressDataobject 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.booleanisCasualForm(@Nullable Entity sender, Entity recipient) booleanisPoliteForm(@Nullable Entity sender, Entity recipient) @Nullable EntityresolveAddressAddressAcceptor(@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) voidsetAddressDataProviders(List<AddressDataProvider> dataProviders) voidsetUserSalutation(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:AddressServiceGet a string containing the address for the provided entity- Specified by:
getAddressAsStringin 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:
getAddressAsStringin interfaceAddressService
-
getAddressAsString
public String getAddressAsString(Iterable<Entity> users, AddressService.AddressType type, AddressService.AddressLook look) - Specified by:
getAddressAsStringin 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:AddressServiceReturns the salutation string for a list of users. The user entities must be linked to the same address.- Specified by:
getSalutationin interfaceAddressService- Parameters:
sender- optional sender, used to inspect person-to-person salutation
-
getAddressForUser
Description copied from interface:AddressServiceGet an Address entity for the provided User entity- Specified by:
getAddressForUserin 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:AddressServiceGet 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:
resolveAddressAddressAcceptorin 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:AddressServiceGet a string containing the salutation line for the provided entity- Specified by:
getSalutationin interfaceAddressService- Parameters:
entity- entity containing the salutation information- Returns:
- the salutation string
-
getSalutation
- Specified by:
getSalutationin 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:
getAddressAsStringin interfaceAddressService- Returns:
- the generated address as a String
-
getAddressAsStringForUser
public String getAddressAsStringForUser(Entity entity, AddressService.AddressType addressType, @Nullable @Nullable AddressService.AddressLook look) - Specified by:
getAddressAsStringForUserin 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:
getAddressWithAltUserin interfaceAddressService
-
getAddressDataProvider
- Specified by:
getAddressDataProviderin 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:
retrieveAddressUserin interfaceAddressService
-
setUserSalutation
-
isPoliteForm
- Specified by:
isPoliteFormin interfaceAddressService
-
isCasualForm
- Specified by:
isCasualFormin interfaceAddressService
-
getFullName
- Specified by:
getFullNamein interfaceAddressService
-
getFullName
- Specified by:
getFullNamein interfaceAddressService
-
getFullName
-
getAddressData
public AddressData getAddressData(Entity entity, @Nullable AddressService.AddressType type, @Nullable AddressService.AddressLook look) Gets a populatedAddressDataobject for the given entity, address type and address look.- Specified by:
getAddressDatain interfaceAddressService
-
setAddressDataProviders
-