Examples of DownloadTimeCounter


Examples of org.dbpedia.downloader.helper.DownloadTimeCounter

            deleteFiles = Boolean.parseBoolean(Global.options.get("deleteFilesAfterCompletion"));
        //Initialize logger
        logger = Logger.getLogger(Main.class);
        logger.addAppender(new ConsoleAppender(new SimpleLayout()));

        DownloadTimeCounter lastDownload = LastDownloadDateManager.getLastDownloadDate("lastDownloadDate.dat");


        UpdatesIterator iterator = new UpdatesIterator(lastDownload, 3);
        while(iterator.hasNext()){
            DownloadTimeCounter cntr = iterator.next();

            //Since next returns null, if now new updates are available, then we should not go any further,
            //and just wait for mor updates
            if(cntr == null)
                continue;

            //u = new URL("http://dbpedia.aksw.org/updates.live.dbpedia.org/2011/05/22/00/000001.added.nt.gz");
//            String fullFilenameToBeDownloaded = Global.options.get("UpdateServerAddress") + lastDownload.getFormattedFilePath() + ".added.nt.gz";
            //String compressedDownloadedFile = FileDownloader.downloadFile(options.get("UpdateServerAddress") + "2011/05/22/00/000001.added.nt.gz",
            //         options.get("UpdatesDownloadFolder"));

            String addedTriplesFilename = "", deletedTriplesFilename = "";

            addedTriplesFilename = Global.options.get("UpdateServerAddress") + cntr.getFormattedFilePath() +
                                   Global.options.get("addedTriplesFileExtension");

            deletedTriplesFilename = Global.options.get("UpdateServerAddress") + cntr.getFormattedFilePath() +
                                   Global.options.get("removedTriplesFileExtension");

            //Download and decompress the file of deleted triples
            String deletedCompressedDownloadedFile = FileDownloader.downloadFile(deletedTriplesFilename,
                    Global.options.get("UpdatesDownloadFolder"));

            if(deletedCompressedDownloadedFile.compareTo("") != 0){
//                Decompressor.decompressGZipFile(deletedCompressedDownloadedFile, true);
                String decompressedDeletedNTriplesFile = Decompressor.decompressGZipFile(deletedCompressedDownloadedFile, deleteFiles);

                //Delete triples from Virtuoso graph
                SPARULFormulator.deleteFromGraph(decompressedDeletedNTriplesFile, deleteFiles);

                //Reset the number of failed trails, since the file is found and downloaded successfully
                Global.numberOfSuccessiveFailedTrails = 0;
            }

            //Download and decompress the file of added triples
            String addedCompressedDownloadedFile = FileDownloader.downloadFile(addedTriplesFilename,
                    Global.options.get("UpdatesDownloadFolder"));
            if(addedCompressedDownloadedFile.compareTo("") != 0){
                String decompressedAddedNTriplesFile = Decompressor.decompressGZipFile(addedCompressedDownloadedFile, deleteFiles);

                //Insert triples into Virtuoso graph
                SPARULFormulator.insertIntoGraph(decompressedAddedNTriplesFile, deleteFiles);
//                SPARULFormulator.deleteFromGraph(decompressedAddedNTriplesFile, true);

                //Reset the number of failed trails, since the file is found and downloaded successfully
                Global.numberOfSuccessiveFailedTrails = 0;
            }



            //No files with that sequence so that indicates a failed trail, so we increment the counter of unsuccessful queries
            if((addedCompressedDownloadedFile.compareTo("") == 0) && (deletedCompressedDownloadedFile.compareTo("") == 0)){
                Global.numberOfSuccessiveFailedTrails++;
            }
            LastDownloadDateManager.writeLastDownloadDate("lastDownloadDate.dat", cntr.toString());

        }

   }  // end of main
View Full Code Here

Examples of org.dbpedia.downloader.helper.DownloadTimeCounter

     * Initializes UpdatesIterator object
     * @param startingCounter   Counter containing the starting point
     * @param delayInterval Interval to wait in case there is no new items available (in seconds)
     */
    public UpdatesIterator(DownloadTimeCounter startingCounter, int delayInterval){
        counter = new DownloadTimeCounter(startingCounter.year, startingCounter.month, startingCounter.day,
                startingCounter.hour, startingCounter.counter);

        delay = delayInterval * 1000;
    }
View Full Code Here

Examples of org.dbpedia.downloader.helper.DownloadTimeCounter

                int ch;
                strLastPublishDate = "";
                while( (ch = fsLastResponseDateFile.read()) != -1)
                    strLastPublishDate += (char)ch;

                DownloadTimeCounter lastPublishCounter = new DownloadTimeCounter(strLastPublishDate);

                if(counter.compareTo(lastPublishCounter) < 0){
                    //fsLastResponseDateFile.close();
                    return true;
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.