All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evrythng.thng.resource.model.store.jobs.Job Maven / Gradle / Ivy

There is a newer version: 1.33
Show newest version
/*
 * (c) Copyright 2016 EVRYTHNG Ltd London / Zurich
 * www.evrythng.com
 */
package com.evrythng.thng.resource.model.store.jobs;

import com.evrythng.thng.resource.model.core.DurableResourceModel;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public abstract class Job> extends DurableResourceModel {

	private static final long serialVersionUID = 2316724847629568170L;
	public static final String FIELD_STATUS = "status";
	private List history;
	public static final String FIELD_HISTORY = "history";
	private PROGRESS progress;
	public static final String FIELD_PROGRESS = "progress";
	private Long completedAt;
	public static final String FIELD_COMPLETED_AT = "completedAt";
	private Long failedOperationsAmount;
	public static final String FIELD_FAILED_OPERATIONS_AMOUNT = "failedOperationsAmount";
	private TYPE type;
	public static final String FIELD_TYPE = "type";
	private List> options;
	public static final String FIELD_OPTIONS = "options";

	public final TYPE getType() {

		return type;
	}

	public final void setType(final TYPE type) {

		this.type = type;
	}

	public final Status getStatus() {

		return history != null ? history.get(history.size() - 1).getStatus() : null;
	}

	public final List getHistory() {

		return history != null ? new ArrayList<>(history) : null;
	}

	public final void setHistory(final List history) {

		this.history = history != null ? new ArrayList<>(history) : null;
	}

	public final void addHistory(final NewStatus... history) {

		if (this.history == null) {
			this.history = new ArrayList<>();
		}
		this.history.addAll(Arrays.asList(history));
	}

	public final PROGRESS getProgress() {

		return progress;
	}

	public final void setProgress(final PROGRESS progress) {

		this.progress = progress;
	}

	public final Long getCompletedAt() {

		return completedAt;
	}

	public final void setCompletedAt(final Long completedAt) {

		this.completedAt = completedAt;
	}

	public final void setFailedOperationsAmount(final Long failedOperationsAmount) {

		this.failedOperationsAmount = failedOperationsAmount;
	}

	public final Long getFailedOperationsAmount() {

		return failedOperationsAmount;
	}

	public final List> getOptions() {

		return options != null ? new ArrayList<>(options) : null;
	}

	public final void setOptions(final List> options) {

		this.options = options != null ? new ArrayList<>(options) : null;
	}

	public abstract List availableOptionTypes();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy