001/**
002 * Copyright (C) 2014  Universidade de Aveiro, DETI/IEETA, Bioinformatics Group - http://bioinformatics.ua.pt/
003 *
004 * This file is part of Dicoogle/dicoogle-sdk.
005 *
006 * Dicoogle/dicoogle-sdk is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * Dicoogle/dicoogle-sdk is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with Dicoogle.  If not, see <http://www.gnu.org/licenses/>.
018 */
019package pt.ua.dicoogle.sdk.datastructs;
020
021import java.util.ArrayList;
022import java.util.List;
023
024public class TaskIndexReport extends IndexReport {
025
026        private final List<DocumentIndexReport> successfulReports;
027        private final List<DocumentIndexReport> errorReports;
028        private boolean successful;
029        private final Measurable elapsedTime;
030        
031        public TaskIndexReport() {
032                // TODO Auto-generated constructor stub
033                this.successfulReports = new ArrayList<>();
034                this.errorReports = new ArrayList<>();
035                this.elapsedTime = new Measurable();
036                this.successful = true;
037        }
038        
039        public void addReport(DocumentIndexReport report){
040                if(report.isSuccessfull())
041                        successfulReports.add(report);
042                else
043                        errorReports.add(report);
044        }
045
046        public void start() {
047                elapsedTime.start();
048        }
049
050        public void stop() {
051                elapsedTime.stop();
052        }
053        
054        public void setSuccessful(boolean successful) {
055                this.successful = successful;
056        }
057
058        /* (non-Javadoc)
059         * @see pt.ua.dicoogle.sdk.datastructs.IndexReport#getElapsedTime()
060         */
061        @Override
062        public long getElapsedTime() {
063                return elapsedTime.getTime();
064        }
065        
066        /* (non-Javadoc)
067         * @see pt.ua.dicoogle.sdk.datastructs.IndexReport#getNErrors()
068         */
069        @Override
070        public int getNErrors(){
071                if(!successful)
072                        return -1;
073                return this.errorReports.size();
074        }
075
076        /* (non-Javadoc)
077         * @see pt.ua.dicoogle.sdk.datastructs.IndexReport#getNIndexed()
078         */
079        @Override
080        public int getNIndexed(){
081                if(!successful)
082                        return -1;
083                return this.successfulReports.size();
084        }
085}