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.Date;
026
027import dk.netarkivet.common.exceptions.ArgumentNotValid;
028import dk.netarkivet.common.utils.Named;
029import dk.netarkivet.harvester.datamodel.extendedfield.ExtendableEntity;
030import dk.netarkivet.harvester.datamodel.extendedfield.ExtendedFieldTypes;
031
032/**
033 * Sparse version of PartialHarvest to be used for GUI purposes only. Immutable.
034 *
035 * @see PartialHarvest
036 */
037public class SparsePartialHarvest extends ExtendableEntity implements Named {
038
039    /**
040     * ID of this harvest.
041     */
042    private final Long oid;
043    /**
044     * Name of this harvest.
045     */
046    private final String name;
047    /**
048     * Comments on this harvest.
049     */
050    private final String comments;
051    /**
052     * Number of times this harvest has run.
053     */
054    private final int numEvents;
055    /**
056     * True if harvest is active.
057     */
058    private final boolean active;
059    /**
060     * Current edition of harvest.
061     */
062    private final long edition;
063    /**
064     * Submitted date.
065     */
066    private final Date submissionDate;
067    /**
068     * Schedule for harvest definition.
069     */
070    private final String scheduleName;
071    /**
072     * Next date to run.
073     */
074    private final Date nextDate;
075
076    private String audience;
077
078    /**
079     * The id of the associated harvest channel, or null if the default one is to be used.
080     */
081    private Long channelId;
082
083    /**
084     * Create new instance of SparsePartialHarvest.
085     *
086     * @param oid id of this harvest.
087     * @param name the name of the harvest definition.
088     * @param comments comments.
089     * @param numEvents Number of times this harvest has run.
090     * @param submissionDate The submission date.
091     * @param active Whether this harvest definition is active.
092     * @param edition DAO edition of harvest. used to create this Fullharvest definition.
093     * @param schedule name of schedule for this harvest.
094     * @param nextDate next time this harvest will run (null for never).
095     * @param audience The intended audience
096     * @param channelId the channel id, or null for the default one
097     * @throws ArgumentNotValid if oid, name or comments, or schedule is null, or name or schedule is empty.
098     */
099    public SparsePartialHarvest(Long oid, String name, String comments, int numEvents, Date submissionDate,
100            boolean active, long edition, String schedule, Date nextDate, String audience, Long channelId) {
101        super(null);
102        ArgumentNotValid.checkNotNull(oid, "Long oid");
103        ArgumentNotValid.checkNotNullOrEmpty(name, "name");
104        ArgumentNotValid.checkNotNull(comments, "comments");
105        ArgumentNotValid.checkNotNullOrEmpty(schedule, "schedule");
106        this.oid = oid;
107        this.name = name;
108        this.comments = comments;
109        this.numEvents = numEvents;
110        this.submissionDate = submissionDate;
111        this.active = active;
112        this.edition = edition;
113        this.scheduleName = schedule;
114        this.nextDate = nextDate;
115        this.audience = audience;
116        this.channelId = channelId;
117    }
118
119    /**
120     * Next date this harvest will run (null for never).
121     *
122     * @return Returns the nextDate.
123     */
124    public Date getNextDate() {
125        return nextDate;
126    }
127
128    /**
129     * Whether this definition is active.
130     *
131     * @return Returns whether active.
132     */
133    public boolean isActive() {
134        return active;
135    }
136
137    /**
138     * Get comments for domain.
139     *
140     * @return Returns the comments.
141     */
142    public String getComments() {
143        return comments;
144    }
145
146    /**
147     * Get edition.
148     *
149     * @return Returns the edition.
150     */
151    public long getEdition() {
152        return edition;
153    }
154
155    /**
156     * Get name.
157     *
158     * @return Returns the name.
159     */
160    public String getName() {
161        return name;
162    }
163
164    /**
165     * Number of events this harvest definition has run.
166     *
167     * @return Returns the numEvents.
168     */
169    public int getNumEvents() {
170        return numEvents;
171    }
172
173    /**
174     * Name of schedule for harvest definition.
175     *
176     * @return Returns the scheduleName.
177     */
178    public String getScheduleName() {
179        return scheduleName;
180    }
181
182    /**
183     * Submission date.
184     *
185     * @return Returns the submissionDate.
186     */
187    public Date getSubmissionDate() {
188        return submissionDate;
189    }
190
191    /**
192     * ID of harvest definition.
193     *
194     * @return Returns the harvestdefinition ID
195     */
196    public Long getOid() {
197        return oid;
198    }
199
200    public String getAudience() {
201        return audience;
202    }
203
204    protected Long getChannelId() {
205        return channelId;
206    }
207
208    @Override
209    protected int getExtendedFieldType() {
210        return ExtendedFieldTypes.HARVESTDEFINITION;
211    }
212
213}