001/*
002 * (C) Copyright 2018 Nuxeo (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Funsho David
018 */
019
020package org.nuxeo.ecm.core.bulk;
021
022import java.io.Serializable;
023import java.time.Instant;
024
025/**
026 * This object holds the current bulk command execution status.
027 * <p/>
028 * This aggregates status and metrics of documentSet creation and action computation.
029 *
030 * @since 10.2
031 */
032public class BulkStatus implements Serializable {
033
034    private static final long serialVersionUID = 1L;
035
036    /**
037     * Possible states of bulk execution.
038     */
039    public enum State {
040        /** The {@link BulkCommand} has been submitted to the system. */
041        SCHEDULED,
042
043        /** System is currently scrolling the database and computing the action. */
044        SCROLLING_RUNNING,
045
046        /** System is currently computing the action (scrolling is finished). */
047        RUNNING,
048
049        /** System has finished to scroll. */
050        COMPLETED
051    }
052
053    protected String id;
054
055    protected BulkCommand command;
056
057    protected State state;
058
059    protected Instant submitTime;
060
061    protected Instant scrollStartTime;
062
063    protected Instant scrollEndTime;
064
065    protected Long processed;
066
067    protected Long count;
068
069    /**
070     * Gets bulk id.
071     *
072     * @return the id
073     */
074    public String getId() {
075        return id;
076    }
077
078    /**
079     * Sets bulk command id.
080     *
081     * @param id the id
082     */
083    public void setId(String id) {
084        this.id = id;
085    }
086
087    /**
088     * Gets bulk command.
089     *
090     * @return the bulk command.
091     */
092    public BulkCommand getCommand() {
093        return command;
094    }
095
096    /**
097     * Sets bulk command.
098     *
099     * @param command the bulk command
100     */
101    public void setCommand(BulkCommand command) {
102        this.command = command;
103    }
104
105    /**
106     * Returns the bulk action state.
107     *
108     * @return the bulk action state
109     */
110    public State getState() {
111        return state;
112    }
113
114    /**
115     * Sets bulk action state.
116     *
117     * @param state the state
118     */
119    public void setState(State state) {
120        this.state = state;
121    }
122
123    /**
124     * Gets bulk action submission time.
125     *
126     * @return the submit time
127     */
128    public Instant getSubmitTime() {
129        return submitTime;
130    }
131
132    /**
133     * Sets bulk submission time.
134     *
135     * @param submitTime the submit time
136     */
137    public void setSubmitTime(Instant submitTime) {
138        this.submitTime = submitTime;
139    }
140
141    /**
142     * Gets bulk action scroll start time.
143     *
144     * @return the scroll start time
145     */
146    public Instant getScrollStartTime() {
147        return scrollStartTime;
148    }
149
150    /**
151     * Sets bulk scroll start time.
152     *
153     * @param scrollStartTime the scroll start time
154     */
155    public void setScrollStartTime(Instant scrollStartTime) {
156        this.scrollStartTime = scrollStartTime;
157    }
158
159    /**
160     * Gets bulk action scroll end time.
161     *
162     * @return the scroll end time
163     */
164    public Instant getScrollEndTime() {
165        return scrollEndTime;
166    }
167
168    /**
169     * Sets bulk scroll end time.
170     *
171     * @param scrollEndTime the scroll end time
172     */
173    public void setScrollEndTime(Instant scrollEndTime) {
174        this.scrollEndTime = scrollEndTime;
175    }
176
177    /**
178     * Gets number of elements processed in this bulk.
179     *
180     * @return the number of processed elements
181     */
182    public Long getProcessed() {
183        return processed;
184    }
185
186    /**
187     * Sets number of elements processed in this bulk.
188     *
189     * @param processed the number of elements
190     */
191    public void setProcessed(Long processed) {
192        this.processed = processed;
193    }
194
195    /**
196     * Gets number of element touched in this bulk.
197     *
198     * @return the number of element
199     */
200    public Long getCount() {
201        return count;
202    }
203
204    /**
205     * Sets number of element touched in this bulk.
206     *
207     * @param count the number of element
208     */
209    public void setCount(Long count) {
210        this.count = count;
211    }
212}