X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=auth%2Fauth-batch%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fauth%2Fbatch%2Fapprovalsets%2FPending.java;h=eed6733823899b40617164e915a128b870d74b4d;hb=3d1706fcbe7f95830ff6fd23cf679ee55c6d0595;hp=2e7997b4f456e9bd52cc8b95c960fa1c5446db2d;hpb=d9c0bb04b77f6a637f1fc07b69c90898d672bd34;p=aaf%2Fauthz.git diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/approvalsets/Pending.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/approvalsets/Pending.java index 2e7997b4..eed67338 100644 --- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/approvalsets/Pending.java +++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/approvalsets/Pending.java @@ -28,81 +28,82 @@ import org.onap.aaf.cadi.util.CSV.Writer; import org.onap.aaf.misc.env.util.Chrono; public class Pending { - public static final String REMIND = "remind"; - - int qty; - boolean hasNew; - Date earliest; - - /** - * Use this Constructor when there is no Last Notified Date - */ - public Pending() { - qty = 1; - hasNew = true; - earliest = null; - } + public static final String REMIND = "remind"; + + int qty; + boolean hasNew; + Date earliest; + + /** + * Use this constructor to indicate when last Notified + * @param last_notified + */ + public Pending(Date last_notified) { + qty = 1; + hasNew = last_notified==null; + earliest = last_notified; + } - /** - * Use this constructor to indicate when last Notified - * @param last_notified - */ - public Pending(Date last_notified) { - qty = 1; - hasNew = last_notified==null; - earliest = last_notified; - } + /** + * Create from CSV Row + * @param row + * @throws ParseException + */ + public Pending(List row) throws ParseException { + hasNew = Boolean.parseBoolean(row.get(2)); + String d = row.get(3); + if(d==null || d.isEmpty()) { + earliest = null; + } else { + earliest = Chrono.dateOnlyFmt.parse(d); + } + qty = Integer.parseInt(row.get(4)); + } - /** - * Create from CSV Row - * @param row - * @throws ParseException - */ - public Pending(List row) throws ParseException { - hasNew = Boolean.parseBoolean(row.get(2)); - String d = row.get(3); - if(d==null || d.isEmpty()) { - earliest = null; - } else { - earliest = Chrono.dateOnlyFmt.parse(d); - } - qty = Integer.parseInt(row.get(4)); - } + /** + * Write CSV Row + * @param approveCW + * @param key + */ + public void row(Writer approveCW, String key) { + approveCW.row(REMIND,key,hasNew,Chrono.dateOnlyStamp(earliest),qty); + } - /** - * Write CSV Row - * @param approveCW - * @param key - */ - public void row(Writer approveCW, String key) { - approveCW.row(REMIND,key,hasNew,Chrono.dateOnlyStamp(earliest),qty); - } + public void inc() { + ++qty; + } + + public void inc(Pending value) { + qty+=value.qty; + if(earliest==null) { + earliest = value.earliest; + } else if(value.earliest!=null && value.earliest.before(earliest)) { + earliest = value.earliest; + } + } - public void inc() { - ++qty; - } - - public void inc(Pending value) { - qty+=value.qty; - } + public void earliest(Date lastnotified) { + if(lastnotified==null) { + hasNew=true; + } else if (earliest==null || lastnotified.before(earliest)) { + earliest = lastnotified; + } + } + + public int qty() { + return qty; + } + + public Date earliest() { + return earliest; + } + + public boolean newApprovals() { + return hasNew; + } + + public static Pending create() { + return new Pending((Date)null); + } - public void earliest(Date lastnotified) { - if(lastnotified==null) { - hasNew=true; - } else if (earliest==null || lastnotified.before(earliest)) { - earliest = lastnotified; - } - } - - public int qty() { - return qty; - } - - public Date earliest() { - return earliest; - } - - public boolean newApprovals() { - return hasNew; - } } \ No newline at end of file