Class FormDataFactory


  • @Component
    public class FormDataFactory
    extends Object
    Public contract to be fulfilled by FormDataAnonymization and FormDataAnalysation classes
    • Constructor Detail

      • FormDataFactory

        public FormDataFactory()
    • Method Detail

      • createAnalyzationPayload

        public Request createAnalyzationPayload​(org.springframework.web.multipart.MultipartFile file,
                                                FormMetaDataRequest payload)
                                         throws IOException
        Returns an Request object created from the provided MultipartFile and String.
        Parameters:
        file - a MultipartFile containing the raw dataset file to be parsed.
        payload - a String containing the raw metadata to be parsed.
        Returns:
        an ARX Request model containing the parsed dataset and metadata.
        Throws:
        IOException - when unable to read the InputStream of the files
      • createAnonymizationPayload

        public Request createAnonymizationPayload​(org.springframework.web.multipart.MultipartFile file,
                                                  FormMetaDataRequest payload,
                                                  org.springframework.web.multipart.MultipartFile[] hierarchies)
                                           throws IOException
        Returns an Request object created from the provided MultipartFile and String.
        Parameters:
        file - a MultipartFile containing the raw dataset file to be parsed.
        payload - a String containing the raw metadata to be parsed.
        hierarchies - a array of MultipartFile containing the raw hierarchy files to be parsed.
        Returns:
        an ARX Request model containing the parsed dataset, metadata and hierarchies.
        Throws:
        IOException - when unable to read the InputStream of the files
      • validateParameters

        private void validateParameters​(org.springframework.web.multipart.MultipartFile file,
                                        FormMetaDataRequest payload)
        Validation method for checking against invalid parameters for data analyzation and anonymization
        Parameters:
        file - a MultipartFile containing the raw dataset file to be parsed.
        payload - a String containing the raw metadata to be parsed.
      • handleInputStream

        private List<String[]> handleInputStream​(org.springframework.web.multipart.MultipartFile file)
                                          throws IOException
        Returns a list of String[] containing the dataset parsed from a MultipartFile.
        Parameters:
        file - a MultipartFile containing the raw dataset file to be parsed.
        Returns:
        the parsed dataset in a list of String[].
        Throws:
        IOException - when unable to read the InputStream of the files
      • buildRequestAnonymizationAttribute

        private List<Attribute> buildRequestAnonymizationAttribute​(List<FormDataAttribute> attributeList,
                                                                   List<List<String[]>> hierarchies)
        Builds a list of Attribute from the list of FormDataAttribute to correctly build the attribute metadata and parse the raw hierarchy files.
        Parameters:
        attributeList - a list of FormDataAttribute to be parsed in order to correctly build the attribute metadata.
        hierarchies - a List containing the parsed hierarchy files. the hierarchy files are in a List of String array
        Returns:
        list of Attribute for anonymization.
      • handleHierarchiesInputStream

        private List<List<String[]>> handleHierarchiesInputStream​(org.springframework.web.multipart.MultipartFile[] hierarchies)
                                                           throws IOException
        Takes an array of MultipartFile containing the raw hierarchy files, and parses through the files and building a list out of them.
        Parameters:
        hierarchies - an array of MultipartFile containing the raw hierarchy files to be parsed.
        Returns:
        a List of parsed hierarchy files in the format of List of String array
        Throws:
        IOException - when unable to read the InputStream of the files