Class SequenceParser


  • public class SequenceParser
    extends Object
    This class contains a set of methods to help parsing Sequence objects between Cognite api representations (json and proto) and typed objects.
    • Constructor Detail

      • SequenceParser

        public SequenceParser()
    • Method Detail

      • parseSequenceMetadata

        public static SequenceMetadata parseSequenceMetadata​(String json)
                                                      throws Exception
        Parses a sequence header json string to SequenceMetadata proto object.
        Parameters:
        json - The json representation of a sequence header
        Returns:
        The sequence header as a typed object
        Throws:
        Exception
      • parseSequenceBody

        public static SequenceBody parseSequenceBody​(String json)
                                              throws Exception
        Parses a sequence body json string to SequenceBody proto object.
        Parameters:
        json - The json representation of a sequence body
        Returns:
        The sequence body as a typed object
        Throws:
        Exception
      • toRequestInsertItem

        public static Map<String,​Object> toRequestInsertItem​(SequenceMetadata element)
        Builds a request insert item object from SequenceMetadata. An insert item object creates a new sequence header data object in the Cognite system.
        Parameters:
        element -
        Returns:
      • toRequestInsertItem

        public static Map<String,​Object> toRequestInsertItem​(SequenceBody element)
                                                            throws Exception
        Builds a request insert item object from SequenceBody. An insert item object creates a set of new rows for a sequence in the Cognite system.
        Parameters:
        element -
        Returns:
        Throws:
        Exception
      • toRequestUpdateItem

        public static Map<String,​Object> toRequestUpdateItem​(SequenceMetadata newElement,
                                                                   SequenceMetadata existingElement)
                                                            throws Exception
        Builds a request update item object from SequenceMetadata. An update item object updates an existing sequence header object with new values for all provided fields. Fields that are not in the update object retain their original value. This method will also perform an update of the column definitions. It does so by comparing the newElement with the existingElement and perform the following actions: - New columns will be created. - Existing columns will keep their data type (string, numeric, etc.) and externalId, but other attributes will be updated. Attributes that are not specified in the newElement object will retain their original value. - Deleted columns will not be touched. I.e. no columns will be deleted from CDF.
        Parameters:
        newElement - The new/updated sequence header/metadata.
        existingElement - The existing sequence header/metadata.
        Returns:
        The update object in "javafied Json" structure.
        Throws:
        Exception
      • toRequestUpdateItem

        public static com.google.common.collect.ImmutableMap<String,​Object> toRequestUpdateItem​(SequenceMetadata element)
        Builds a request update item object from SequenceMetadata. An update item object updates an existing sequence header object with new values for all provided fields. Fields that are not in the update object retain their original value. This method will not take the column definition into account. You need to use the toRequestUpdateItem(SequenceMetadata, SequenceMetadata) method to include column definition upsert.
        Parameters:
        element - The sequence header/metadata to update
        Returns:
        The update object in "javafied Json" structure
      • toRequestReplaceItem

        public static Map<String,​Object> toRequestReplaceItem​(SequenceMetadata newElement,
                                                                    SequenceMetadata existingElement)
                                                             throws Exception
        Builds a request replace item object from SequenceMetadata. A replace item object replaces an existing sequence header object with new values for all provided fields. Fields that are not in the update object are set to null. This method will also perform an update of the column definitions. It does so by comparing the newElement with the existingElement and perform the following actions: - New columns will be created. - Existing columns will keep their data type (string, numeric, etc.) and externalId, but other attributes will be replaced. Attributes that are not specified in the newElement object will be set to null. - Deleted columns will be removed.
        Parameters:
        newElement - The new/updated sequence header/metadata.
        existingElement - The existing sequence header/metadata.
        Returns:
        The replace object in "javafied Json" structure.
        Throws:
        Exception
      • toRequestReplaceItem

        public static Map<String,​Object> toRequestReplaceItem​(SequenceMetadata element)
        Builds a request insert item object from SequenceMetadata. A replace item object replaces an existing sequence header object with new values for all provided fields. Fields that are not in the update object are set to null. This method will not take the column definition into account. You need to use the toRequestReplaceItem(SequenceMetadata, SequenceMetadata) method to include column definition upsert.
        Parameters:
        element -
        Returns:
      • toRequestDeleteRowsItem

        public static Map<String,​Object> toRequestDeleteRowsItem​(SequenceBody element)
        Builds a request delete rows object from SequenceBody. An delete rows object removes a set of rows from a sequence in the Cognite system.
        Parameters:
        element -
        Returns: