package roart.model;

import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;

import roart.util.TimeUtil;

public class IncDecItem {
    private LocalDate record;
    
    private String market;

    private boolean increase;
    
    private String id;
    
    private String name;
    
    private String description;

    private Double score;

    // not saved
    private Boolean verified;
    
    // not saved
    private String verificationComment;
    
    public LocalDate getRecord() {
        return record;
    }

    public void setRecord(LocalDate record) {
        this.record = record;
    }

    public String getMarket() {
        return market;
    }

    public void setMarket(String market) {
        this.market = market;
    }

    public boolean isIncrease() {
        return increase;
    }

    public void setIncrease(boolean increase) {
        this.increase = increase;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Double getScore() {
        return score;
    }

    public void setScore(Double score) {
        this.score = score;
    }

    public Boolean getVerified() {
        return verified;
    }

    public void setVerified(Boolean verified) {
        this.verified = verified;
    }

    public String getVerificationComment() {
        return verificationComment;
    }

    public void setVerificationComment(String verificationComment) {
        this.verificationComment = verificationComment;
    }

    @Override
    public String toString() {
        return market + " " + record + " " + increase + " " + id + " " + name + " " + score + " " + description + " " + verified + " " + verificationComment; 
    }
    
    public void save() throws Exception {
        IncDec incdec = new IncDec();
        incdec.setDescription(getDescription());
        incdec.setId(getId());
        incdec.setIncrease(isIncrease());
        incdec.setMarket(getMarket());
        incdec.setName(getName());
        incdec.setRecord(TimeUtil.convertDate(getRecord()));
        incdec.setScore(getScore());
        incdec.save();
    }
    
    public static List<IncDecItem> getAll() throws Exception {
        List<IncDec> incdecs = IncDec.getAll();
        List<IncDecItem> incdecItems = new ArrayList<>();
        for (IncDec incdec : incdecs) {
            IncDecItem memoryItem = getIncdecItem(incdec);
            incdecItems.add(memoryItem);
        }
        return incdecItems;
    }

   public static List<IncDecItem> getAll(String market) throws Exception {
        List<IncDec> incdecs = IncDec.getAll(market);
        List<IncDecItem> incdecItems = new ArrayList<>();
        for (IncDec incdec : incdecs) {
            IncDecItem memoryItem = getIncdecItem(incdec);
            incdecItems.add(memoryItem);
        }
        return incdecItems;
    }

    private static IncDecItem getIncdecItem(IncDec incdec) {
        IncDecItem incdecItem = new IncDecItem();
        incdecItem.setDescription(incdec.getDescription());
        incdecItem.setId(incdec.getId());
        incdecItem.setIncrease(incdec.isIncrease());
        incdecItem.setMarket(incdec.getMarket());
        incdecItem.setName(incdec.getName());
        incdecItem.setRecord(TimeUtil.convertDate(incdec.getRecord()));
        incdecItem.setScore(incdec.getScore());
        return incdecItem;
    }

}

@@ -177,32 +177,65 @@
 te record;%0A    %0A
+    private LocalDate date;%0A    %0A
     private Stri
@@ -245,16 +245,16 @@
 market;%0A
-
 %0A    pri
@@ -653,32 +653,168 @@
  record;%0A    %7D%0A%0A
+    public LocalDate getDate() %7B%0A        return date;%0A    %7D%0A%0A    public void setDate(LocalDate date) %7B%0A        this.date = date;%0A    %7D%0A%0A
     public Strin
@@ -2115,16 +2115,29 @@
  + %22 %22 +
+ date + %22 %22 +
  increas
@@ -2330,24 +2330,81 @@
 w IncDec();%0A
+        incdec.setDate(TimeUtil.convertDate(getDate()));%0A
         incd
@@ -3502,24 +3502,24 @@
 c incdec) %7B%0A
-
         IncD
@@ -3552,24 +3552,92 @@
 cDecItem();%0A
+        incdecItem.setDate(TimeUtil.convertDate(incdec.getDate()));%0A
         incd

Add date.