Class DataMappingToString

java.lang.Object
com.priint.pubserver.plugin.PluginControlDefault
com.priint.pubserver.plugins.datamapping.DataMappingToString
All Implemented Interfaces:
com.priint.pubserver.datamapping.DataMappingToStringLocal, com.priint.pubserver.plugin.interfaces.PluginControl

public class DataMappingToString extends com.priint.pubserver.plugin.PluginControlDefault implements com.priint.pubserver.datamapping.DataMappingToStringLocal
  • Constructor Details

    • DataMappingToString

      public DataMappingToString()
  • Method Details

    • bucketLabelToString

      public List<String> bucketLabelToString(List<com.priint.pubserver.plugin.entitydata.Bucket> buckets) throws com.priint.pubserver.exception.PubServerException
      maps the label of the first bucket of a bucket list to string
      Specified by:
      bucketLabelToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      buckets - list of buckets
      Returns:
      label of the first bucket in the buckets list
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstTextToStringOrEmptyString

      public List<String> firstTextToStringOrEmptyString(List<com.priint.pubserver.plugin.entitydata.Text> texts) throws com.priint.pubserver.exception.PubServerException
      maps the first text of a text list to string, at least return empty string
      Parameters:
      texts - list of texts
      Returns:
      text of the first list entry if list empty return empty string
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstTextToString

      public List<String> firstTextToString(List<com.priint.pubserver.plugin.entitydata.Text> texts) throws com.priint.pubserver.exception.PubServerException
      maps the first text of a text list to string
      Specified by:
      firstTextToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      texts - list of texts
      Returns:
      text of the first list entry
      Throws:
      com.priint.pubserver.exception.PubServerException
    • bestLocalizedTextToString

      public List<String> bestLocalizedTextToString(List<com.priint.pubserver.plugin.entitydata.Text> texts, com.priint.pubserver.plugin.entitydata.Context context, String defaultValue) throws com.priint.pubserver.exception.PubServerException
      Maps the text of a text list that best matches the context to string. Returns defaultValue if no matching text found.

      Intention: content system has text like

       [
        {lang: "de", cntry:"",   value: "Viele Grüße"}, 
        {lang: "de", cntry:"AT", value: "Grüezzi"}, 
        {lang: "de", cntry:"CH", value: "Viele Grüsse"}
       ] 
      If called for context {language:"deu", country:"DE"} it should return "Viele Grüße" although there is no "de-DE" in the data.

      In EntityModel set entity context for country to [unused].
      Connector will probably return both texts - at least pubhubdb would do.
      DataMapping will read all texts and check if the correct one is in, otherwise fall back to the generic version, or in the end to a default value.

      In example "de-DE" will not be found. But "de" will be returned.
      If the first entry was not be there, "de-AT" would be returned because it is the first entry matching at least "de".

      Parameters:
      texts - list of texts
      context - Context as search filter (e.g country and language)
      defaultValue - default value to be returned if no data found
      Returns:
      text value of the best matching list entry or defaultValue as string
      Throws:
      com.priint.pubserver.exception.PubServerException
    • textToString

      public List<String> textToString(List<com.priint.pubserver.plugin.entitydata.Text> texts, int nth) throws com.priint.pubserver.exception.PubServerException
      maps the nth text of a text list to string
      Specified by:
      textToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      texts - list of texts
      nth - which list entry to return
      Returns:
      text of the nth list entry
      Throws:
      com.priint.pubserver.exception.PubServerException
    • lastTextToString

      public List<String> lastTextToString(List<com.priint.pubserver.plugin.entitydata.Text> texts) throws com.priint.pubserver.exception.PubServerException
      maps the last text of a text list to string
      Specified by:
      lastTextToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      texts - list of texts
      Returns:
      text of the last list entry
      Throws:
      com.priint.pubserver.exception.PubServerException
    • textsToStrings

      public List<String> textsToStrings(List<com.priint.pubserver.plugin.entitydata.Text> texts) throws com.priint.pubserver.exception.PubServerException
      maps all texts of a text list to a string list
      Specified by:
      textsToStrings in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      texts - list of texts
      Returns:
      string list with all texts
      Throws:
      com.priint.pubserver.exception.PubServerException
    • textListToString

      public List<String> textListToString(List<com.priint.pubserver.plugin.entitydata.Text> inputList, String reqRecords, String delimiter, String prefix, String suffix)
      Returns list of Text converted into delimited string
      Parameters:
      inputList - list of Text to be converted
      reqRecords - requested records from text list
      delimiter - string to be used for result
      prefix - string to be added before the first element
      suffix - string to be added after the last element
      Returns:
      string consisting of prefix, texts with delimiter and suffix as first element of string list
    • textListToStrings

      public List<String> textListToStrings(List<com.priint.pubserver.plugin.entitydata.Text> texts, String range, String delimiter, String prefix, String suffix) throws com.priint.pubserver.exception.PubServerException
      maps all texts of a text list to a string list
      Specified by:
      textListToStrings in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      texts - list of texts
      range - selects which entries from the text list to concatenate
      delimiter - put between the texts
      prefix - put as prefix for first text
      suffix - put as suffix behind last text
      Returns:
      string consisting of prefix, texts with delimiter and suffix as first element of string list
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstTextOfAncestorBucketsToString

      public List<String> firstTextOfAncestorBucketsToString(String sessionId, List<com.priint.pubserver.plugin.entitydata.Bucket> descendants, String entityModelName, String ancestorEntityId, String textIdentifier, int level, com.priint.pubserver.plugin.entitydata.Context context, String searchStr) throws com.priint.pubserver.exception.PubServerException
      goes back n levels in bucket tree and maps the specified text of that ancestor bucket to string. If level > 1 all ancestors must have the same entityId.
      Specified by:
      firstTextOfAncestorBucketsToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      sessionId - SessionId (use tag)
      descendants - List of buckets, only first entry is used
      entityModelName - Name of the Entity Model (use tag)
      ancestorEntityId - EntityId of the ancestors
      textIdentifier - Text entity of bucket to be returned
      level - Number of steps up in bucket tree (begins with 1)
      context - Context as search filter (e.g country and language)
      searchStr - Search string
      Returns:
      specified text of ancestor bucket, with specified level up in bucket tree
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstKeyValueToString

      public List<String> firstKeyValueToString(List<com.priint.pubserver.plugin.entitydata.KeyValue> keyValues, String designator) throws com.priint.pubserver.exception.PubServerException
      Returns designated field(s) of first KeyValue in input list
      Parameters:
      keyValues - List of KeyValues to be converted
      designator - String 'ValueWithoutUnit', 'ValueWithUnit', 'Label', 'Symbol', 'Unit' or 'ParentIdentifier'
      Returns:
      String list with one or no element
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstKeyValueByKeyToString

      public List<String> firstKeyValueByKeyToString(List<com.priint.pubserver.plugin.entitydata.KeyValue> keyValues, String key, String designator) throws com.priint.pubserver.exception.PubServerException
      Returns designated field(s) of first KeyValue with given key in input list
      Parameters:
      keyValues - List of KeyValues to be converted
      key - filter KeyValues by this
      designator - String 'ValueWithoutUnit', 'ValueWithUnit', 'Label', 'Symbol', 'Unit' or 'ParentIdentifier'
      Returns:
      String list with one or no element
      Throws:
      com.priint.pubserver.exception.PubServerException
    • mapKeyValuesToString

      public List<String> mapKeyValuesToString(List<com.priint.pubserver.plugin.entitydata.KeyValue> inputList, String reqRecords, String delimiter, String prefix, String suffix, String designator)
      Returns designated field(s) of requested KeyValues or all KeyValues with given key to a string, with selected delimiter, prefix and suffix
      Parameters:
      inputList - List of KeyValues to be converted
      reqRecords - list of requested records from the keyValue list, delimited by ',' (comma) can contain
      • string 'all' whole list will be returned
      • positive numbers - returns record of the index decremented by one e.g 1 will return index of 0
      • negative numbers - returns element count from the end of the list, e.g -1 will return index of the last element
      • 0 (zero) - returns element, the same result as 1
      delimiter - string to be added between the elements
      prefix - string to be added before the first element
      suffix - string to be added after the last element
      designator - String 'ValueWithoutUnit', 'ValueWithUnit', 'Label', 'Symbol', 'Unit' or 'ParentIdentifier'
      Returns:
      String list with one or no element
    • mapKeyValuesByKeyToString

      public List<String> mapKeyValuesByKeyToString(List<com.priint.pubserver.plugin.entitydata.KeyValue> inputList, String reqRecords, String key, String delimiter, String prefix, String suffix, String designator)
      Returns designated field(s) of requested KeyValues or all KeyValues to a string, with selected delimiter, prefix and suffix
      Parameters:
      inputList - List of KeyValues to be converted
      reqRecords - list of requested records from the keyValue list, delimited by ',' (comma) can contain
      • string 'all' whole list will be returned
      • positive numbers - returns record of the index decremented by one e.g 1 will return index of 0
      • negative numbers - returns element count from the end of the list, e.g -1 will return index of the last element
      • 0 (zero) - returns element, the same result as 1
      key - filter KeyValues by this
      delimiter - string to be added between the elements
      prefix - string to be added before the first element
      suffix - string to be added after the last element
      designator - String 'ValueWithoutUnit', 'ValueWithUnit', 'Label', 'Symbol', 'Unit' or 'ParentIdentifier'
      Returns:
      String list with one or no element
    • keyValuesToStrings

      public List<String> keyValuesToStrings(List<com.priint.pubserver.plugin.entitydata.KeyValue> keyValues) throws com.priint.pubserver.exception.PubServerException
      maps all values of a key value list to a string list
      Specified by:
      keyValuesToStrings in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      keyValues - result set of the query
      Returns:
      a string list of the values of all given key values
      Throws:
      com.priint.pubserver.exception.PubServerException
    • valuesByKeyToStrings

      public List<String> valuesByKeyToStrings(List<com.priint.pubserver.plugin.entitydata.KeyValue> keyValues, String key) throws com.priint.pubserver.exception.PubServerException
      maps all values associated to the given key to a string list
      Specified by:
      valuesByKeyToStrings in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      keyValues - result set of the query
      key - filter keeping only key values with given key
      Returns:
      a string list of the values of the filtered key values
      Throws:
      com.priint.pubserver.exception.PubServerException
    • mediaAssetListToFileUrl

      public List<String> mediaAssetListToFileUrl(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets, String record, String type, String media) throws com.priint.pubserver.exception.PubServerException
      gets the URL of the first media object from the first media asset
      Specified by:
      mediaAssetListToFileUrl in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      mediaAssets - the result set of the query
      record - select which record of the set shall be returned
      type - type of the media object to be returned
      media - media of the media object to be returned
      Returns:
      list of string with one element, the url
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstMediaAssetToFileUrl

      public List<String> firstMediaAssetToFileUrl(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets, String type, String media) throws com.priint.pubserver.exception.PubServerException
      gets the URL of the first media object from the first media asset
      Parameters:
      mediaAssets - the result set of the query
      type - type of the media object to be returned
      media - media of the media object to be returned
      Returns:
      list of string, the first element is the url
      Throws:
      com.priint.pubserver.exception.PubServerException
    • lastMediaAssetToFileUrl

      public List<String> lastMediaAssetToFileUrl(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets, String type, String media) throws com.priint.pubserver.exception.PubServerException
      gets the URL of the last media object from the last media asset
      Parameters:
      mediaAssets - the result set of the query
      type - type of the media object to be returned
      media - media of the media object to be returned
      Returns:
      list of string, the first element is the URL
      Throws:
      com.priint.pubserver.exception.PubServerException
    • mediaAssetListToFilePath

      public List<String> mediaAssetListToFilePath(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets, String record, String type, String media) throws com.priint.pubserver.exception.PubServerException
      gets the path of the first media object from the first media asset
      Specified by:
      mediaAssetListToFilePath in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      mediaAssets - the result set of the query
      record - select which record of the media asset list shall be returned
      type - type of the media object to be returned
      media - media of the media object to be returned
      Returns:
      list of string with one element, the path
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstMediaAssetToFilePath

      public List<String> firstMediaAssetToFilePath(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets, String type, String media) throws com.priint.pubserver.exception.PubServerException
      Gets the path of the first media object from the first media asset.

      If no path separator character is found in input path and filename will be concatenated using system default (i.e. backslash on windows)

      Parameters:
      mediaAssets - the result set of the query
      type - type of the media object to be returned
      media - media of the media object to be returned
      Returns:
      list of string with one element, the path
      Throws:
      com.priint.pubserver.exception.PubServerException
    • lastMediaAssetToFilePath

      public List<String> lastMediaAssetToFilePath(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets, String type, String media) throws com.priint.pubserver.exception.PubServerException
      gets the path of the last media object from the last media asset
      Parameters:
      mediaAssets - the result set of the query
      type - type of the media object to be returned
      media - media of the media object to be returned
      Returns:
      list of string with one element, the path
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstMediaAssetTextToString

      public List<String> firstMediaAssetTextToString(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets)
      Get the first text of the first media asset
      Parameters:
      mediaAssets - the result set of the query
      Returns:
      list of string with one element, the text or an empty string, if no text is found
    • firstMediaAssetToFilePath

      public List<String> firstMediaAssetToFilePath(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets) throws com.priint.pubserver.exception.PubServerException
      Specified by:
      firstMediaAssetToFilePath in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstMediaAssetToFileUrl

      public List<String> firstMediaAssetToFileUrl(List<com.priint.pubserver.plugin.entitydata.MediaAsset> arg0) throws com.priint.pubserver.exception.PubServerException
      Specified by:
      firstMediaAssetToFileUrl in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Throws:
      com.priint.pubserver.exception.PubServerException
    • lastMediaAssetToFilePath

      public List<String> lastMediaAssetToFilePath(List<com.priint.pubserver.plugin.entitydata.MediaAsset> arg0) throws com.priint.pubserver.exception.PubServerException
      Specified by:
      lastMediaAssetToFilePath in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Throws:
      com.priint.pubserver.exception.PubServerException
    • lastMediaAssetToFileUrl

      public List<String> lastMediaAssetToFileUrl(List<com.priint.pubserver.plugin.entitydata.MediaAsset> arg0) throws com.priint.pubserver.exception.PubServerException
      Specified by:
      lastMediaAssetToFileUrl in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Throws:
      com.priint.pubserver.exception.PubServerException
    • firstPriceToString

      public List<String> firstPriceToString(List<com.priint.pubserver.plugin.entitydata.Price> prices, String designator) throws com.priint.pubserver.exception.PubServerException
      maps the first price of a price list to string
      Parameters:
      prices - list of prices
      designator - Either Price (default), PriceAndCurrency, Label, Currency, PriceUnit, PackagingUnit or QuantityOfPackagingUnit
      Returns:
      text of the first list entry
      Throws:
      com.priint.pubserver.exception.PubServerException
    • nthPriceToString

      public List<String> nthPriceToString(List<com.priint.pubserver.plugin.entitydata.Price> prices, String designator, int nth) throws com.priint.pubserver.exception.PubServerException
      The nth price as string: map the field(s) selected by designator of the nth price to a string
      Specified by:
      nthPriceToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      prices - result of the query, <Entity.ResultList>
      designator - Either Price (default), PriceAndCurrency, Label, Currency, PriceUnit, PackagingUnit or QuantityOfPackagingUnit
      nth - the nth entry of the price list, should be >0
      Returns:
      string list with no (if input list is empty or too short) or one element
      Throws:
      com.priint.pubserver.exception.PubServerException
    • priceListToString

      public List<String> priceListToString(List<com.priint.pubserver.plugin.entitydata.Price> inputList, String reqRecords, String delimiter, String prefix, String suffix, String designator)
      Returns list of Price converted into delimited string
      Parameters:
      inputList - List of Prices to be converted
      reqRecords - string containing a list of requested records from the pricelist delimited by ',' (comma).

      Can contain

      • string 'all' whole list will be returned
      • positive numbers - returns record of the index decremented by one e.g 1 will return index of 0
      • negative numbers - returns element count from the end of the list, e.g -1 will return index of the last element
      • 0 (zero) - returns element, the same result as 1
      delimiter - string used for result delimitation
      prefix - string to be added before the first element
      suffix - string to be added after the last element
      designator - Price (default), PriceAndCurrency, Label, Currency, PriceUnit, PackagingUnit, QuantityOfPackagingUnit
      Returns:
      delimited string of requested records
    • bucketPropertyToString

      public List<String> bucketPropertyToString(List<com.priint.pubserver.plugin.entitydata.Bucket> buckets, String propertyName) throws com.priint.pubserver.exception.PubServerException

      Gets an arbitrary property from a bucket

      Specified by:
      bucketPropertyToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      buckets - result from data query
      propertyName - name of the property
      Returns:
      list of the requested properties
      Throws:
      com.priint.pubserver.exception.PubServerException
    • cordPropertyToString

      public List<String> cordPropertyToString(List<com.priint.pubserver.plugin.entitydata.Cord> cords, String propertyName) throws com.priint.pubserver.exception.PubServerException

      Gets an arbitrary property from a cord

      Specified by:
      cordPropertyToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      cords - result from data query
      propertyName - name of the property
      Returns:
      list of the requested properties
      Throws:
      com.priint.pubserver.exception.PubServerException
    • keyValuePropertyToString

      public List<String> keyValuePropertyToString(List<com.priint.pubserver.plugin.entitydata.KeyValue> keyValues, String propertyName) throws com.priint.pubserver.exception.PubServerException

      Gets an arbitrary property from a keyValue

      Specified by:
      keyValuePropertyToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      keyValues - result from data query
      propertyName - name of the property
      Returns:
      list of the requested properties
      Throws:
      com.priint.pubserver.exception.PubServerException
    • mediaAssetPropertyToString

      public List<String> mediaAssetPropertyToString(List<com.priint.pubserver.plugin.entitydata.MediaAsset> mediaAssets, String propertyName) throws com.priint.pubserver.exception.PubServerException

      Gets an arbitrary property from a mediaAsset

      Specified by:
      mediaAssetPropertyToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      mediaAssets - result from data query
      propertyName - name of the property
      Returns:
      list of the requested properties
      Throws:
      com.priint.pubserver.exception.PubServerException
    • planningPropertyToString

      public List<String> planningPropertyToString(List<com.priint.pubserver.plugin.entitydata.Planning> plannings, String propertyName) throws com.priint.pubserver.exception.PubServerException

      Gets an arbitrary property from a planning

      Specified by:
      planningPropertyToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      plannings - result from data query
      propertyName - name of the property
      Returns:
      list of the requested properties
      Throws:
      com.priint.pubserver.exception.PubServerException
    • pricePropertyToString

      public List<String> pricePropertyToString(List<com.priint.pubserver.plugin.entitydata.Price> prices, String propertyName) throws com.priint.pubserver.exception.PubServerException

      Gets an arbitrary property from a price

      Specified by:
      pricePropertyToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      prices - result from data query
      propertyName - name of the property
      Returns:
      list of the requested properties
      Throws:
      com.priint.pubserver.exception.PubServerException
    • textPropertyToString

      public List<String> textPropertyToString(List<com.priint.pubserver.plugin.entitydata.Text> texts, String propertyName) throws com.priint.pubserver.exception.PubServerException

      Gets an arbitrary property from a text

      Specified by:
      textPropertyToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      texts - result from data query
      propertyName - name of the property
      Returns:
      list of the requested properties
      Throws:
      com.priint.pubserver.exception.PubServerException
    • tableDataPropertyToString

      public List<String> tableDataPropertyToString(List<com.priint.pubserver.plugin.entitydata.TableData> tableDatas, String propertyName) throws com.priint.pubserver.exception.PubServerException

      Gets an arbitrary property from a tableData

      Specified by:
      tableDataPropertyToString in interface com.priint.pubserver.datamapping.DataMappingToStringLocal
      Parameters:
      tableDatas - result from data query
      propertyName - name of the property
      Returns:
      list of the requested properties
      Throws:
      com.priint.pubserver.exception.PubServerException
    • uniqueKeyIdentifiers

      public List<String> uniqueKeyIdentifiers(List<com.priint.pubserver.plugin.entitydata.KeyValue> keyValues) throws com.priint.pubserver.exception.PubServerException
      Throws:
      com.priint.pubserver.exception.PubServerException