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 021public class DocumentIndexReport extends IndexReport { 022 023 private Measurable retrieveObjectTime; 024 private Measurable assembleDocumentTIme; 025 private Measurable storeInDatabaseTime; 026 private final Measurable totalTime; 027 private boolean successfull; 028 private final String id; 029 030 public DocumentIndexReport(String id) { 031 super(); 032 this.id = id; 033 this.totalTime = new Measurable(); 034 this.successfull = true; 035 } 036 037 private static void lazyInit(Measurable obj){ 038 if(obj == null) 039 obj = new Measurable(); 040 } 041 042 public Measurable getRetrieveObjectTime() { 043 lazyInit(retrieveObjectTime); 044 return retrieveObjectTime; 045 } 046 047 public Measurable getAssembleDocumentTIme() { 048 lazyInit(assembleDocumentTIme); 049 return assembleDocumentTIme; 050 } 051 052 public Measurable getStoreInDatabaseTime() { 053 lazyInit(storeInDatabaseTime); 054 return storeInDatabaseTime; 055 } 056 057 public boolean isSuccessfull() { 058 return successfull; 059 } 060 061 public void setSuccessfull(boolean successfull) { 062 this.successfull = successfull; 063 } 064 065 public String getId() { 066 return id; 067 } 068 069 public void start() { 070 totalTime.start(); 071 } 072 073 public void stop() { 074 totalTime.stop(); 075 } 076 077 @Override 078 public long getElapsedTime() { 079 return totalTime.getTime(); 080 } 081 082 @Override 083 public int getNErrors() { 084 if(isSuccessfull()) 085 return 0; 086 return 1; 087 } 088 089 @Override 090 public int getNIndexed() { 091 if(isSuccessfull()) 092 return 1; 093 return 0; 094 } 095 096}