001/* 002 * #%L 003 * Netarchivesuite - harvester 004 * %% 005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library, 006 * the National Library of France and the Austrian National Library. 007 * %% 008 * This program is free software: you can redistribute it and/or modify 009 * it under the terms of the GNU Lesser General Public License as 010 * published by the Free Software Foundation, either version 2.1 of the 011 * License, or (at your option) any later version. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Lesser Public License for more details. 017 * 018 * You should have received a copy of the GNU General Lesser Public 019 * License along with this program. If not, see 020 * <http://www.gnu.org/licenses/lgpl-2.1.html>. 021 * #L% 022 */ 023package dk.netarkivet.harvester.datamodel; 024 025import java.util.List; 026 027import dk.netarkivet.common.exceptions.ArgumentNotValid; 028import dk.netarkivet.harvester.datamodel.dao.DAOProviderFactory; 029import dk.netarkivet.harvester.datamodel.eav.EAV.AttributeAndType; 030import dk.netarkivet.harvester.datamodel.extendedfield.ExtendableEntity; 031import dk.netarkivet.harvester.datamodel.extendedfield.ExtendedFieldTypes; 032 033/** 034 * Sparse version of FullHarvest to be used for GUI purposes only. Immutable. For GUI purposes only. 035 * 036 * @see FullHarvest 037 */ 038public class SparseFullHarvest extends ExtendableEntity { 039 040 /** ID of this harvest. */ 041 private final Long oid; 042 /** Name of this harvest. */ 043 private final String name; 044 /** Comments on this harvest. */ 045 private final String comments; 046 /** Number of times this harvest has run. */ 047 private final int numEvents; 048 /** True if harvest is active. */ 049 private final boolean active; 050 /** Current edition of harvest. */ 051 private final long edition; 052 /** The maximum number of objects retrieved from each domain during a snapshot harvest. */ 053 private long maxCountObjects; 054 /** The maximum number of bytes retrieved from each domain during a snapshot harvest. */ 055 private long maxBytes; 056 057 /** The maximum number of time available to the harvester for each job generated by this harvestdefinition. */ 058 private long maxJobRunningTime; 059 060 /** The ID for the harvestdefinition, this FullHarvest is based upon. */ 061 private Long previousHarvestDefinitionOid; 062 063 /** The id of the associated harvest channel, or null if the default one is to be used. */ 064 private Long channelId; 065 066 /** Set full harvest EAV attributes and attribute types. */ 067 private List<AttributeAndType> attributesAndTypes; 068 069 /** 070 * Create new instance of SparseFullHarvest. 071 * 072 * @param oid id of this harvest. 073 * @param harvestDefName the name of the harvest definition. 074 * @param comments comments. 075 * @param numEvents Number of times this harvest has run. 076 * @param active Whether this harvest definition is active. 077 * @param edition DAO edition of harvest. 078 * @param maxCountObjects Limit for how many objects can be harvested 079 * @param maxBytes Limit for how many bytes can be harvested 080 * @param maxJobRunningTime Limit on how much time can be used for this job. See {@link #getMaxJobRunningTime()} 081 * @param previousFullHarvest This id of the harvestDefinition used to create this Fullharvest definition. May be 082 * null for none 083 * @param channelId the channel id, or null for the default one 084 * @throws ArgumentNotValid if oid, name or comments is null, or name is empty. 085 */ 086 public SparseFullHarvest(Long oid, String harvestDefName, String comments, int numEvents, boolean active, 087 long edition, long maxCountObjects, long maxBytes, long maxJobRunningTime, Long previousFullHarvest, 088 Long channelId) { 089 super(DAOProviderFactory.getExtendedFieldDAOProvider()); 090 ArgumentNotValid.checkNotNull(oid, "oid"); 091 ArgumentNotValid.checkNotNullOrEmpty(harvestDefName, "harvestDefName"); 092 ArgumentNotValid.checkNotNull(comments, "comments"); 093 094 this.oid = oid; 095 this.name = harvestDefName; 096 this.comments = comments; 097 this.numEvents = numEvents; 098 this.active = active; 099 this.edition = edition; 100 this.maxCountObjects = maxCountObjects; 101 this.maxBytes = maxBytes; 102 this.maxJobRunningTime = maxJobRunningTime; 103 this.previousHarvestDefinitionOid = previousFullHarvest; 104 this.channelId = channelId; 105 } 106 107 /** 108 * Get ID of HarvestDefinition which this is based on, or null for none. 109 * 110 * @return The previous HarvestDefinition, or null for none 111 */ 112 public Long getPreviousHarvestDefinitionOid() { 113 return previousHarvestDefinitionOid; 114 } 115 116 /** 117 * Get the maximum number of objects that this fullharvest will harvest per domain, -1 for no limit. 118 * 119 * @return Total download limit in objects per domain. 120 */ 121 public long getMaxCountObjects() { 122 return maxCountObjects; 123 } 124 125 /** 126 * Get the maximum number of bytes that this fullharvest will harvest per domain, -1 for no limit. 127 * 128 * @return Total download limit in bytes per domain. 129 */ 130 public long getMaxBytes() { 131 return maxBytes; 132 } 133 134 /** 135 * Get the maximum number of time in seconds that each job in this fullharvest will take. 0 for no limit. 136 * 137 * @return the maximum number of time in seconds for each job in this fullharvest. 138 */ 139 public long getMaxJobRunningTime() { 140 return maxJobRunningTime; 141 } 142 143 /** 144 * Name of harvest definition. 145 * 146 * @return Name of harvest definition. 147 */ 148 public String getName() { 149 return name; 150 } 151 152 /** 153 * Comments for harvest definition. 154 * 155 * @return Comments for harvest definition. 156 */ 157 public String getComments() { 158 return comments; 159 } 160 161 /** 162 * Number of times this harvest has run. 163 * 164 * @return Number of times this harvest has run. 165 */ 166 public int getNumEvents() { 167 return numEvents; 168 } 169 170 /** 171 * ID of this harvest. 172 * 173 * @return ID of this harvest. 174 */ 175 public Long getOid() { 176 return oid; 177 } 178 179 /** 180 * Whether harvest is active. 181 * 182 * @return Whether harvest is active. 183 */ 184 public boolean isActive() { 185 return active; 186 } 187 188 /** 189 * DAO edition of harvest definition. 190 * 191 * @return DAO edition of harvest definition. 192 */ 193 public long getEdition() { 194 return edition; 195 } 196 197 protected Long getChannelId() { 198 return channelId; 199 } 200 201 /** 202 * Get full harvest EAV attributes and attribute types. 203 * @return full harvest EAV attributes and attribute types 204 */ 205 public List<AttributeAndType> getAttributesAndTypes() { 206 return attributesAndTypes; 207 } 208 209 /** 210 * Set full harvest EAV attributes and attribute types. 211 * @param attributesAndTypes full harvest EAV attributes and attribute types 212 */ 213 public void setAttributesAndTypes(List<AttributeAndType> attributesAndTypes) { 214 this.attributesAndTypes = attributesAndTypes; 215 } 216 217 @Override 218 protected int getExtendedFieldType() { 219 return ExtendedFieldTypes.HARVESTDEFINITION; 220 } 221 222}