Class ResourceElementTypeHelper

    • Method Detail

      • singleFileToJSON

        public static Map<String,​ObjectsingleFileToJSON​(File file,
                                                                String fileType)
        Convert the single file into a JSON object
        Parameters:
        file - the file to convert
        fileType - the type of the file
        Returns:
        The file as JSON
      • singleFileToSAX

        public static void singleFileToSAX​(ContentHandler contentHandler,
                                           String tagName,
                                           File file,
                                           String fileType,
                                           AttributesImpl attributes)
                                    throws SAXException
        Generates SAX events for the given single file
        Parameters:
        contentHandler - the ContentHandler that will receive the SAX events
        tagName - the tag name of the SAX event to generate.
        file - the single file to SAX
        fileType - the type of the file
        attributes - the attributes for the SAX event to generate
        Throws:
        SAXException - if an error occurs during the SAX events generation
      • isResourceDataEmpty

        public static boolean isResourceDataEmpty​(RepositoryData resourceData)
        Checks if the given resource data is empty. A resource data is considered as empty if it has no stream data
        Parameters:
        resourceData - the resource data to check
        Returns:
        true if the resource has is empty, false otherwise
      • readBinaryData

        public static Binary readBinaryData​(RepositoryData binaryData)
        Read the binary from the given repository data
        Parameters:
        binaryData - the repository data containing the binary's data
        Returns:
        the read binary
      • readResourceData

        public static void readResourceData​(RepositoryData resourceData,
                                            Resource resource)
        Read the resource from the given repository data
        Parameters:
        resourceData - the repository data containing the resource's data
        resource - the resource to read
      • emptyResourceData

        public static void emptyResourceData​(ModifiableRepositoryData parentResourceData,
                                             String name,
                                             String nodeType)
        Empties the resource data with the given name. A resource data is considered as empty if it has no stream data
        Parameters:
        parentResourceData - the parent of the resource data to empty
        name - the name of the resource data
        nodeType - the node type of the resource data
      • writeSingleBinaryValue

        public static void writeSingleBinaryValue​(ModifiableRepositoryData parentData,
                                                  String name,
                                                  Binary value)
        Write the resource in the given repository data
        Parameters:
        parentData - the repository data where to write the binary
        name - the name of the element to write
        value - the binary to write
      • writeResourceData

        public static void writeResourceData​(ModifiableRepositoryData resourceData,
                                             Resource value)
        Write the resource in the given repository data
        Parameters:
        resourceData - the repository data where to write the resource's data
        value - the resource to write
      • compareSingleBinaries

        public static Stream<Triple<DataChangeType,​DataChangeTypeDetail,​String>> compareSingleBinaries​(Binary binary1,
                                                                                                                   Binary binary2)
                                                                                                            throws IOException
        Compare the given single binaries and retrieves the changes as a stream of Triples. The Triple contains:
        • the general type of the change (added, modified or removed) as a DataChangeType,
        • some details about this change if possible (after or before for a date, more or less for a number, ...) as a DataChangeTypeDetail
        • The data concerned by this change if not the element itself (or an empty String)
        Parameters:
        binary1 - the 1st single binary
        binary2 - the 2nd single binary
        Returns:
        the changes between the two given single binaries as a stream of Triples. Retrieves an empty stream if there is no change
        Throws:
        IOException - if an error occurs while reading the binaries' data
      • compareSingleRichTexts

        public static Stream<Triple<DataChangeType,​DataChangeTypeDetail,​String>> compareSingleRichTexts​(RichText richText1,
                                                                                                                    RichText richText2)
                                                                                                             throws IOException
        Compare the given single rich texts and retrieves the changes as a stream of Triples. The Triple contains:
        • the general type of the change (added, modified or removed) as a DataChangeType,
        • some details about this change if possible (after or before for a date, more or less for a number, ...) as a DataChangeTypeDetail
        • The data concerned by this change if not the element itself (or an empty String)
        Parameters:
        richText1 - the 1st single rich text
        richText2 - the 2nd single rich text
        Returns:
        the changes between the two given single rich texts as a stream of Triples. Retrieves an empty stream if there is no change
        Throws:
        IOException - if an error occurs while reading the rich texts' data
      • _compareSingleResourcesMetadata

        protected static Stream<Triple<DataChangeType,​DataChangeTypeDetail,​String>> _compareSingleResourcesMetadata​(Resource resource1,
                                                                                                                                Resource resource2)
                                                                                                                         throws IOException
        Compare the metadata of the given single resources and retrieves the changes as a stream of Triples. The Triples contain:
        • the general type of the change (added, modified or removed) as a DataChangeType,
        • some details about this change if possible (after or before for a date, more or less for a number, ...) as a DataChangeTypeDetail
        • The data concerned by this change if not the element itself (or an empty String)
        Parameters:
        resource1 - the 1st single resource
        resource2 - the 2nd single resource
        Returns:
        the changes between the metadata of the two given single resources as a stream of Triples. Retrieves an empty stream if there is no change
        Throws:
        IOException - if an error occurs while reading the resources' data
      • _compareSingleResourcesContent

        protected static Stream<Triple<DataChangeType,​DataChangeTypeDetail,​String>> _compareSingleResourcesContent​(Resource resource1,
                                                                                                                               Resource resource2)
                                                                                                                        throws IOException
        Compare the content of the given single resources and retrieves the changes as a stream of Triple. The Triples contain:
        • the general type of the change (added, modified or removed) as a DataChangeType,
        • some details about this change if possible (after or before for a date, more or less for a number, ...) as a DataChangeTypeDetail
        • The data concerned by this change if not the element itself (or an empty String)
        Parameters:
        resource1 - the 1st single resource
        resource2 - the 2nd single resource
        Returns:
        the changes between the content of the two given single resources as a stream of Triples. Retrieves an empty stream if there is no change
        Throws:
        IOException - if an error occurs while reading the resources' data
      • getStringValue

        public static String getStringValue​(RepositoryData repositoryData,
                                            String name,
                                            String prefix)
        Retrieves the string value from the given repository data
        Parameters:
        repositoryData - the repository data containing the data to retrieve
        name - the name of the data to retrieve
        prefix - the prefix of the data to retrieve
        Returns:
        the string value
      • getStringValues

        public static String[] getStringValues​(RepositoryData repositoryData,
                                               String name,
                                               String prefix)
        Retrieves the string values from the given repository data
        Parameters:
        repositoryData - the repository data containing the data to retrieve
        name - the name of the data to retrieve
        prefix - the prefix of the data to retrieve
        Returns:
        the string values
      • getRepositoryData

        public static <T extends RepositoryData> T getRepositoryData​(T parentData,
                                                                     String dataTypeName,
                                                                     String name,
                                                                     String prefix)
        Retrieves the child repository data from the given repository data
        Type Parameters:
        T - Type of the repository data (modifiable or not)
        Parameters:
        parentData - the repository data containing the data to retrieve
        dataTypeName - the type of the data to retrieve
        name - the name of the data to retrieve
        prefix - the prefix of the data to retrieve
        Returns:
        the child repository data
      • getDateValue

        public static ZonedDateTime getDateValue​(RepositoryData repositoryData,
                                                 String name,
                                                 String prefix)
        Retrieves the date value from the given repository data
        Parameters:
        repositoryData - the repository data containing data to retrieve
        prefix - the prefix of the data to retrieve
        name - the name of the data to retrieve
        Returns:
        the date value