Class 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 of PointOfServiceModel as a CSV file so it can be later imported to Google Business.
    • Constructor Detail

      • ExportPointsOfServiceAction

        public ExportPointsOfServiceAction()
    • Method Detail

      • perform

        public com.hybris.cockpitng.actions.ActionResult<java.lang.Object> perform​(com.hybris.cockpitng.actions.ActionContext<java.util.Map> actionContext)
        Specified by:
        perform in interface com.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
      • createCsvContent

        protected void createCsvContent​(java.lang.StringBuilder stringBuilder,
                                        java.util.List<PointOfServiceModel> pointsOfService)
        Creates a CSV body representing a list of PointOfServiceModels
        Parameters:
        stringBuilder - StringBuilder used to build CSV
        pointsOfService - the PointOfServiceModels to be represented as CSVs
      • buildCsv

        protected void buildCsv​(java.lang.StringBuilder stringBuilder,
                                PointOfServiceModel pointOfService)
        Builds the CSV
        Parameters:
        stringBuilder - StringBuilder used to build CSV
        pointOfService - the PointOfServiceModels to be represented as CSVs
      • validatePointOfServiceMeetsRequirements

        protected boolean validatePointOfServiceMeetsRequirements​(PointOfServiceModel pointOfService)
        Returns true if the PointOfServiceModel contains or references all of the data required to pass minimum requirements for an import to Google My Business
        Parameters:
        pointOfService - the PointOfServiceModel to be validated
        Returns:
        whether or not the PointOfServiceModel meets 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 - the PointOfServiceModel to be validated
        url - 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 a PointOfServiceModel for a given day of the week
        Parameters:
        pointOfService - the PointOfServiceModel for which the opening hours must be represented
        dayOfWeek - the day of the week specified as a Calendar constant
        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 a SpecialOpeningDayModel showing the date as well sa the hours, or an 'x' in the case of being closed.
        Parameters:
        specialOpeningDayModel - SpecialOpeningDayModel for 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:
        canPerform in interface com.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:
        needsConfirmation in interface com.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:
        getConfirmationMessage in interface com.hybris.cockpitng.actions.CockpitAction<java.util.Map,​java.lang.Object>