Class ExportPointsOfServiceAction
- java.lang.Object
-
- de.hybris.platform.warehousingbackoffice.actions.exportpointsofservice.ExportPointsOfServiceAction
-
- All Implemented Interfaces:
com.hybris.cockpitng.actions.CockpitAction<java.util.Map,java.lang.Object>
public class ExportPointsOfServiceAction extends java.lang.Object implements com.hybris.cockpitng.actions.CockpitAction<java.util.Map,java.lang.Object>Action to export a list ofPointOfServiceModelas a CSV file so it can be later imported to Google Business.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCSV_HEADERSprotected static java.lang.StringMODEL_PAGEABLE
-
Constructor Summary
Constructors Constructor Description ExportPointsOfServiceAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbuildCsv(java.lang.StringBuilder stringBuilder, PointOfServiceModel pointOfService)Builds the CSVbooleancanPerform(com.hybris.cockpitng.actions.ActionContext<java.util.Map> ctx)protected java.lang.StringcreateCsv(java.util.List<PointOfServiceModel> pointsOfService)Builds a CSV based upon a list ofPointOfServiceModelsprotected voidcreateCsvContent(java.lang.StringBuilder stringBuilder, java.util.List<PointOfServiceModel> pointsOfService)Creates a CSV body representing a list ofPointOfServiceModelsjava.lang.StringgetConfirmationMessage(com.hybris.cockpitng.actions.ActionContext<java.util.Map> ctx)protected java.lang.StringgetDailySchedule(PointOfServiceModel pointOfService, int dayOfWeek)Generates a formatted 24 hour representation of the opening hours of aPointOfServiceModelfor a given day of the weekprotected SiteBaseUrlResolutionServicegetSiteBaseUrlResolutionService()protected java.lang.StringgetSpecialDaySchedule(SpecialOpeningDayModel specialOpeningDayModel)Provides the opening and closing times for aSpecialOpeningDayModelshowing the date as well sa the hours, or an 'x' in the case of being closed.protected booleanisPointOfServiceMeetsRequirements(PointOfServiceModel pointOfService, java.lang.String url)Checks conditions for which pointOfServiceMeetsRequirements will be falsebooleanneedsConfirmation(com.hybris.cockpitng.actions.ActionContext<java.util.Map> ctx)com.hybris.cockpitng.actions.ActionResult<java.lang.Object>perform(com.hybris.cockpitng.actions.ActionContext<java.util.Map> actionContext)protected java.lang.StringprepareCsvValue(java.lang.String value)Prepares a value to be inserted into a CSVprotected booleanvalidatePointOfServiceMeetsRequirements(PointOfServiceModel pointOfService)Returns true if thePointOfServiceModelcontains or references all of the data required to pass minimum requirements for an import to Google My Businessprotected voidwriteBinaryResponse(java.lang.String csvContent)Writes a CSV file to the browser for download.
-
-
-
Field Detail
-
CSV_HEADERS
protected static final java.lang.String CSV_HEADERS
- See Also:
- Constant Field Values
-
MODEL_PAGEABLE
protected static final java.lang.String MODEL_PAGEABLE
- See Also:
- Constant Field Values
-
-
Method Detail
-
perform
public com.hybris.cockpitng.actions.ActionResult<java.lang.Object> perform(com.hybris.cockpitng.actions.ActionContext<java.util.Map> actionContext)
- Specified by:
performin interfacecom.hybris.cockpitng.actions.CockpitAction<java.util.Map,java.lang.Object>
-
writeBinaryResponse
protected void writeBinaryResponse(java.lang.String csvContent)
Writes a CSV file to the browser for download.- Parameters:
csvContent- a string representation of the contents of the file
-
createCsv
protected java.lang.String createCsv(java.util.List<PointOfServiceModel> pointsOfService)
Builds a CSV based upon a list ofPointOfServiceModels- Parameters:
pointsOfService- list ofPointOfServiceModels- Returns:
- a CSV string representation of the list of
PointOfServiceModels including column headers
-
createCsvContent
protected void createCsvContent(java.lang.StringBuilder stringBuilder, java.util.List<PointOfServiceModel> pointsOfService)Creates a CSV body representing a list ofPointOfServiceModels- Parameters:
stringBuilder-StringBuilderused to build CSVpointsOfService- thePointOfServiceModels to be represented as CSVs
-
buildCsv
protected void buildCsv(java.lang.StringBuilder stringBuilder, PointOfServiceModel pointOfService)Builds the CSV- Parameters:
stringBuilder-StringBuilderused to build CSVpointOfService- thePointOfServiceModels to be represented as CSVs
-
validatePointOfServiceMeetsRequirements
protected boolean validatePointOfServiceMeetsRequirements(PointOfServiceModel pointOfService)
Returns true if thePointOfServiceModelcontains or references all of the data required to pass minimum requirements for an import to Google My Business- Parameters:
pointOfService- thePointOfServiceModelto be validated- Returns:
- whether or not the
PointOfServiceModelmeets the requirements of Google My Business
-
isPointOfServiceMeetsRequirements
protected boolean isPointOfServiceMeetsRequirements(PointOfServiceModel pointOfService, java.lang.String url)
Checks conditions for which pointOfServiceMeetsRequirements will be false- Parameters:
pointOfService- thePointOfServiceModelto be validatedurl- the url of the site- Returns:
- true or false
-
getDailySchedule
protected java.lang.String getDailySchedule(PointOfServiceModel pointOfService, int dayOfWeek)
Generates a formatted 24 hour representation of the opening hours of aPointOfServiceModelfor a given day of the week- Parameters:
pointOfService- thePointOfServiceModelfor which the opening hours must be representeddayOfWeek- the day of the week specified as aCalendarconstant- Returns:
- a formatted 24 hour representation of the opening hours
-
getSpecialDaySchedule
protected java.lang.String getSpecialDaySchedule(SpecialOpeningDayModel specialOpeningDayModel)
Provides the opening and closing times for aSpecialOpeningDayModelshowing the date as well sa the hours, or an 'x' in the case of being closed.- Parameters:
specialOpeningDayModel-SpecialOpeningDayModelfor which to show the date and opening times- Returns:
- String of the format "yyyy-MM-dd: HH:mm-HH:mm" if open or "yyyy-MM-dd: x" if closed
-
prepareCsvValue
protected java.lang.String prepareCsvValue(java.lang.String value)
Prepares a value to be inserted into a CSV- Parameters:
value- the value to be prepared- Returns:
- a CSV-ready value
-
canPerform
public boolean canPerform(com.hybris.cockpitng.actions.ActionContext<java.util.Map> ctx)
- Specified by:
canPerformin interfacecom.hybris.cockpitng.actions.CockpitAction<java.util.Map,java.lang.Object>
-
needsConfirmation
public boolean needsConfirmation(com.hybris.cockpitng.actions.ActionContext<java.util.Map> ctx)
- Specified by:
needsConfirmationin interfacecom.hybris.cockpitng.actions.CockpitAction<java.util.Map,java.lang.Object>
-
getConfirmationMessage
public java.lang.String getConfirmationMessage(com.hybris.cockpitng.actions.ActionContext<java.util.Map> ctx)
- Specified by:
getConfirmationMessagein interfacecom.hybris.cockpitng.actions.CockpitAction<java.util.Map,java.lang.Object>
-
getSiteBaseUrlResolutionService
protected SiteBaseUrlResolutionService getSiteBaseUrlResolutionService()
-
-