Class Vcf2HtmlWorker

    • Constructor Detail

      • Vcf2HtmlWorker

        public Vcf2HtmlWorker()
    • Method Detail

      • convertVcf2Html

        protected List<Stream> convertVcf2Html​(Stream vcfStream,
                                               String vcardResourceUri,
                                               boolean skipPhotos)
                                        throws IOException
        This function convert a vcf stream to a list of html streams.
        Parameters:
        vcfStream - the vcf data
        vcardResourceUri - the velocity config base folder
        skipPhotos - whether to skip converting images since they might lead to problem during the html conversion.
        Returns:
        list of converted html streams
        Throws:
        IOException - if an io error happened
      • convertWithEncoding

        protected void convertWithEncoding​(Stream vcfStream,
                                           org.apache.velocity.Template template,
                                           com.levigo.jadice.document.io.SeekableInputStream inputStreamBeforeCutting,
                                           Charset charset,
                                           List<Stream> conversionResultStreamsList,
                                           boolean skipPhotos)
                                    throws IOException
        Converts a vcf stream with a specific encoding to html.
        Parameters:
        vcfStream - the vcf that shall be converted to html
        template - the templating used for creating the html
        inputStreamBeforeCutting - the input stream before it is cut into a single vcf stream (vcfs can be combined).
        charset - the charset used for reading and writing the conversion files
        conversionResultStreamsList - the list of conversion results. Since there might be multiple vcfs merge into one.
        skipPhotos - whether to skip converting images since they might lead to problem during the html conversion.
        Throws:
        IOException - if an i/o error occurs
      • preventUTF16Conversion

        protected void preventUTF16Conversion​(com.levigo.jadice.document.io.SeekableInputStream inputStreamBeforeCutting)
      • createVelocityContext

        protected org.apache.velocity.VelocityContext createVelocityContext​(Stream vcfStream,
                                                                            Charset charset,
                                                                            boolean skipPhotos)
                                                                     throws IOException
        This function builds the context that can be used within the velocity template. E.g. it initialises variable that can be used for the templating.
        Parameters:
        vcfStream - the vcf stream that shall be converted
        Returns:
        the velocity context that can be used inside templates
        Throws:
        IOException - if an io error happens
      • writeHtmlStream

        protected BundledStream writeHtmlStream​(Stream vcfStream,
                                                org.apache.velocity.Template template,
                                                org.apache.velocity.VelocityContext context,
                                                Charset charset)
        This method performs the html templating via velocity.
        Parameters:
        vcfStream - the vcf stream
        template - the template that has been chosen for creating the html
        context - the velocity context that contains the variable information
        Returns:
        the resulting bundled html stream
      • cutVcfInputStream

        protected List<InputStream> cutVcfInputStream​(com.levigo.jadice.document.io.SeekableInputStream inputStreamBeforeCutting,
                                                      Charset charset)
                                               throws IOException
        Since vcf streams can be concatenated into one vcf file with the delimiters BEGIN:VCARD and END:VCARD in between we have to split up such concatenated vcf streams into multiple vcf streams that only contain one vcf data set.
        Parameters:
        inputStreamBeforeCutting - the vcf input stream before cutting the stream into it's parts
        Returns:
        a list of input streams that represent the different vcf parts which only contain one vcf data set
        Throws:
        IOException - if an io error happens
      • injectContextMapIntoVelocityContext

        protected void injectContextMapIntoVelocityContext​(org.apache.velocity.VelocityContext context,
                                                           Map<String,​Object> contextMap)
        This method injects the variables from the contextMap into the actual velocity context object.
        Parameters:
        context - velocity context
        contextMap - the context variable map
      • injectCustomInfoIntoVelocityContext

        protected void injectCustomInfoIntoVelocityContext​(org.apache.velocity.VelocityContext context,
                                                           ezvcard.VCard vCard)
        This method injects custom field information into the velocity context.
        Parameters:
        vCard - the vCard object as it has been parsed
        context - the velocity context
      • buildVcfConfigPath

        protected String buildVcfConfigPath()
        Resolve the config folder path.
        Returns:
        the config folder path.
      • determineBeginNeedle

        protected String determineBeginNeedle​(String groupedVCF)
        Determine the vcf begin needle label. Since some vcf files might write the needle differently this is needed to determine the right needle. e.g. the needle could be BEGIN:vCard vs BEGIN:VCARD
        Parameters:
        groupedVCF - the grouped vcf file that shall be split
        Returns:
        the begin needle with which we can split the concatinated vcf file.
      • getVcfConfigPath

        public String getVcfConfigPath()