/**
 * 
 */
package org.springblade.etl.dto;

import java.io.Serializable;

import org.springblade.etl.enums.InstanceStatus;

import lombok.Data;

/**
 * @author wookvn
 *
 */
@Data
public class InstanceStatusCount implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private long waitingCnt;
	
	private long runningCnt;
	
	private long successCnt;
	
	private long failureCnt;
	
	private long canceldCnt;
	
	private long unknownCnt;
	
	public InstanceStatus getInstanceStatus() {
		if(waitingCnt > 0 && runningCnt == 0 && successCnt == 0
				&& failureCnt == 0 && canceldCnt == 0 && unknownCnt == 0) {
			return InstanceStatus.WAITING;
		} else if(runningCnt > 0) {
			return InstanceStatus.RUNNING;
		}
		return InstanceStatus.SUCCESS;
	}
}
