Class DataToJsonConverter

  • public class DataToJsonConverter
    extends Object
    Is responsible for converting Openbravo business objects (BaseOBObject to a json representation. This converter supports both converting single BaseOBObject instances and a collection of business objects. Values are converted as follows:
    • Reference values are converted as a JSONObject with only the id and identifier set.
    • Primitive date values are converted to a representation following the xml formatting.
    • Other primitive values are converted by the JSONObject itself.
    • Constructor Detail

      • DataToJsonConverter

        public DataToJsonConverter()
    • Method Detail

      • convertToJsonObjects

        public List<org.codehaus.jettison.json.JSONObject> convertToJsonObjects​(List<Map<String,​Object>> data)
        Convert a list of Maps with key value pairs to a list of JSONObject.
        data - the list of Maps
        the corresponding list of JSONObjects
      • toJsonObjects

        public List<org.codehaus.jettison.json.JSONObject> toJsonObjects​(List<? extends BaseOBObject> bobs)
        Convert a list of BaseOBObject to a list of JSONObject.
        bobs - the list of BaseOBObjects to convert
        the corresponding list of JSONObjects
      • toJsonObject

        public org.codehaus.jettison.json.JSONObject toJsonObject​(BaseOBObject bob,
                                                                  DataResolvingMode dataResolvingMode)
        Convert a single BaseOBObject into a JSONObject.
        bob - the BaseOBObject to convert
        dataResolvingMode - the data resolving mode determines how much information is converted (only the identifying info or everything).
        the converted object
      • setShouldDisplayOrgDate

        public void setShouldDisplayOrgDate​(boolean shouldDisplayOrgDate)
      • convertPrimitiveValue

        protected Object convertPrimitiveValue​(Property property,
                                               Object value)
      • convertPrimitiveValue

        protected Object convertPrimitiveValue​(Object value)
      • getAdditionalProperties

        public List<String> getAdditionalProperties()
      • setAdditionalProperties

        public void setAdditionalProperties​(List<String> additionalProperties)
      • setSelectedProperties

        public void setSelectedProperties​(String selectedPropertiesStr)
      • setDisplayProperty

        public void setDisplayProperty​(String displayPropertyValue)
      • setEntity

        public void setEntity​(Entity entity)