001/** 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018 019package org.apache.oozie.coord.input.logic; 020 021import org.apache.commons.lang.StringUtils; 022import org.apache.oozie.coord.CoordELFunctions; 023 024public class CoordInputLogicEvaluatorResult { 025 026 private STATUS status; 027 private String dataSets; 028 029 public static enum STATUS { 030 TRUE, FALSE, PHASE_TWO_EVALUATION, TIMED_WAITING 031 } 032 033 public CoordInputLogicEvaluatorResult() { 034 } 035 036 public CoordInputLogicEvaluatorResult(STATUS status, String dataSets) { 037 this.status = status; 038 this.dataSets = dataSets; 039 } 040 041 public CoordInputLogicEvaluatorResult(STATUS status) { 042 this.status = status; 043 } 044 045 public String getDataSets() { 046 return dataSets; 047 } 048 049 public void setDataSets(String dataSets) { 050 this.dataSets = dataSets; 051 } 052 053 public void appendDataSets(String inputDataSets) { 054 if (StringUtils.isEmpty(inputDataSets)) { 055 return; 056 } 057 if (StringUtils.isEmpty(this.dataSets)) { 058 this.dataSets = inputDataSets; 059 } 060 else { 061 this.dataSets = this.dataSets + CoordELFunctions.DIR_SEPARATOR + inputDataSets; 062 } 063 } 064 065 public void setStatus(STATUS status) { 066 this.status = status; 067 } 068 069 public STATUS getStatus() { 070 return status; 071 } 072 073 public boolean isTrue() { 074 if (status == null) { 075 return false; 076 } 077 switch (status) { 078 case TIMED_WAITING: 079 case PHASE_TWO_EVALUATION: 080 case TRUE: 081 return true; 082 default: 083 return false; 084 } 085 086 } 087 088 public boolean isWaiting() { 089 if (status == null) { 090 return false; 091 } 092 return status.equals(STATUS.TIMED_WAITING); 093 094 } 095 096 public boolean isPhaseTwoEvaluation() { 097 if (status == null) { 098 return false; 099 } 100 return status.equals(STATUS.PHASE_TWO_EVALUATION); 101 102 } 103 104}