package tars.storage;

import tars.commons.exceptions.IllegalValueException;
import tars.model.task.*;
import tars.model.tag.Tag;
import tars.model.tag.UniqueTagList;

import javax.xml.bind.annotation.XmlElement;
import java.util.ArrayList;
import java.util.List;

/**
 * JAXB-friendly version of the Task.
 */
public class XmlAdaptedTask {

    @XmlElement(required = true)
    private String name;
    @XmlElement
    private String priority;
    @XmlElement(required = true)
    private DateTime dateTime;
//    @XmlElement(required = true)
//    private String email;
//    @XmlElement(required = true)
//    private String address;

    @XmlElement
    private List<XmlAdaptedTag> tagged = new ArrayList<>();

    /**
     * No-arg constructor for JAXB use.
     */
    public XmlAdaptedTask() {}


    /**
     * Converts a given Task into this class for JAXB use.
     *
     * @param source future changes to this will not affect the created XmlAdaptedTask
     */
    public XmlAdaptedTask(ReadOnlyTask source) {
        name = source.getName().taskName;
        priority = source.getPriority().priorityLevel;
        dateTime = source.getDateTime();
//        email = source.getEmail().value;
//        address = source.getAddress().value;
        tagged = new ArrayList<>();
        for (Tag tag : source.getTags()) {
            tagged.add(new XmlAdaptedTag(tag));
        }
    }

    /**
     * Converts this jaxb-friendly adapted task object into the model's Task object.
     *
     * @throws IllegalValueException if there were any data constraints violated in the adapted task
     */
    public Task toModelType() throws IllegalValueException {
        final List<Tag> taskTags = new ArrayList<>();
        for (XmlAdaptedTag tag : tagged) {
            taskTags.add(tag.toModelType());
        }
        final Name name = new Name(this.name);
        final Priority priority = new Priority(this.priority);
        final DateTime dateTime = new DateTime(this.dateTime.startDateString, this.dateTime.endDateString);
//        final Email email = new Email(this.email);
//        final Address address = new Address(this.address);
        final UniqueTagList tags = new UniqueTagList(taskTags);
        return new Task(name, dateTime, priority, null, tags);
    }
}

@@ -502,18 +502,16 @@
 teTime;%0A
-//
     @Xml
@@ -527,34 +527,32 @@
 equired = true)%0A
-//
     private Stri
@@ -551,88 +551,26 @@
 ate 
-String email;%0A//    @XmlElement(required = true)%0A//    private String addres
+boolean statu
 s;%0A%0A
+%0A
     
@@ -1087,26 +1087,24 @@
 Time();%0A
-//
         
 email = 
@@ -1099,86 +1099,42 @@
     
-email = source.getEmail().value;%0A//        address = source.getAddress().value
+status = source.getStatus().status
 ;%0A  
@@ -1915,18 +1915,16 @@
 tring);%0A
-//
         
@@ -1933,83 +1933,28 @@
 nal 
-Email email = new Email(this.email);%0A//        final Address addres
+Status statu
 s = new 
 Addr
@@ -1953,27 +1953,25 @@
 new 
-Addres
+Statu
 s(this.
-addres
+statu
 s);%0A
@@ -2088,12 +2088,14 @@
 ty, 
-null
+status
 , ta

Update Status storage