package seedu.tache.storage;

import java.util.ArrayList;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;

import seedu.tache.commons.exceptions.IllegalValueException;
import seedu.tache.model.tag.Tag;
import seedu.tache.model.tag.UniqueTagList;
import seedu.tache.model.task.Name;
import seedu.tache.model.task.ReadOnlyTask;
import seedu.tache.model.task.Task;

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

    @XmlElement(required = true)
    private String name;

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

    /**
     * Constructs an XmlAdaptedTask.
     * This is the no-arg constructor that is required by JAXB.
     */
    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().fullName;
        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 UniqueTagList tags = new UniqueTagList(taskTags);
        return new Task(name, tags);
    }
}

@@ -73,16 +73,43 @@
 il.List;
+%0Aimport java.util.Optional;
 %0A%0Aimport
@@ -283,24 +283,64 @@
 queTagList;%0A
+import seedu.tache.model.task.DateTime;%0A
 import seedu
@@ -442,16 +442,66 @@
 sk.Task;
+%0Aimport seedu.tache.model.task.Task.RecurInterval;
 %0A%0A/**%0A *
@@ -629,16 +629,444 @@
 g name;%0A
+    %0A    @XmlElement(required = false)%0A    private String startDateTime;%0A    %0A    @XmlElement(required = false)%0A    private String endDateTime;%0A    %0A    @XmlElement(required = false)%0A    private boolean isActive;%0A    %0A    @XmlElement(required = false)%0A    private boolean isTimed;%0A    %0A    @XmlElement(required = false)%0A    private boolean isRecurring;%0A%0A    @XmlElement(required = false)%0A    private RecurInterval interval;%0A    
 %0A    @Xm
@@ -1541,24 +1541,329 @@
 ).fullName;%0A
+        startDateTime = source.getStartDateTime().toString();%0A        endDateTime = source.getEndDateTime().toString();%0A        isActive = source.getActiveStatus();%0A        isTimed = source.getTimedStatus();%0A        isRecurring = source.getRecurringStatus();%0A        interval = source.getRecurInterval();%0A
         tagg
@@ -2463,16 +2463,780 @@
 .name);%0A
+        final Optional%3CDateTime%3E startDateTime;%0A        if(this.startDateTime != null && !(this.startDateTime.equals(%22Optional.empty%22))) %7B%0A            startDateTime = Optional.of(new DateTime(this.startDateTime));%0A        %7D else %7B%0A            startDateTime = Optional.empty();%0A        %7D%0A        final Optional%3CDateTime%3E endDateTime;%0A        if(this.endDateTime != null && !(this.endDateTime.equals(%22Optional.empty%22))) %7B%0A            endDateTime = Optional.of(new DateTime(this.endDateTime));%0A        %7D else %7B%0A            endDateTime = Optional.empty();%0A        %7D%0A        final boolean isActive = this.isActive;%0A        final boolean isTimed = this.isTimed;%0A        final boolean isRecurring = this.isRecurring;%0A        final RecurInterval interval = this.interval;%0A
         
@@ -3321,20 +3321,90 @@
 k(name, 
-tags
+startDateTime, endDateTime, tags, isTimed, isActive, isRecurring, interval
 );%0A    %7D

Fix storage xml to store other attributes