package edu.northwestern.bioinformatics.studycalendar.web.template;

import sun.jvm.hotspot.debugger.LongHashMap;

import java.util.Map;
import java.util.List;

import edu.northwestern.bioinformatics.studycalendar.domain.DomainObject;
import edu.northwestern.bioinformatics.studycalendar.domain.Epoch;
import edu.northwestern.bioinformatics.studycalendar.domain.Arm;

/**
 * @author Rhett Sutphin
 */
public class DeleteCommand extends ModalEditCommand {

    ////// MODES

    protected Mode epochMode() {
        return new DeleteEpoch();
    }

    protected Mode armMode() {
        return new DeleteArm();
    }

    private abstract class DeleteMode<T extends DomainObject> implements Mode {
        public final void performEdit() {
            if (getCollection().size() < 2) return;
            getCollection().remove(getObject());
        }

        protected abstract List<T> getCollection();

        protected abstract T getObject();
    }

    private class DeleteEpoch extends DeleteMode<Epoch> {
        public String getRelativeViewName() {
            return "deleteEpoch";
        }

        public Map<String, Object> getModel() {
            return null;
        }

        protected Epoch getObject() {
            return getEpoch();
        }

        protected List<Epoch> getCollection() {
            return getEpoch().getPlannedCalendar().getEpochs();
        }
    }

    private class DeleteArm extends DeleteMode<Arm> {
        public String getRelativeViewName() {
            return "deleteArm";
        }

        public Map<String, Object> getModel() {
             return null;
        }

        protected Arm getObject() {
            return getArm();
        }

        protected List<Arm> getCollection() {
            return getArm().getEpoch().getArms();
        }
    }
}

@@ -73,93 +73,66 @@
 ort 
-sun.jvm.hotspot.debugger.LongHashMap;%0A%0Aimport java.util.Map;%0Aimport java.util.List
+edu.northwestern.bioinformatics.studycalendar.domain.Arm
 ;%0A
-%0A
 impo
@@ -272,71 +272,52 @@
 ch;%0A
+%0A
 import 
-edu.northwestern.bioinformatics.studycalendar.domain.Arm
+java.util.List;%0Aimport java.util.Map
 ;%0A%0A/
@@ -791,32 +791,116 @@
 ());%0A        %7D%0A%0A
+        public Map%3CString, Object%3E getModel() %7B%0A            return null;%0A        %7D%0A%0A
         protecte
@@ -1138,92 +1138,8 @@
  %7D%0A%0A
-        public Map%3CString, Object%3E getModel() %7B%0A            return null;%0A        %7D%0A%0A
     
@@ -1435,32 +1435,32 @@
 iveViewName() %7B%0A
+
             retu
@@ -1490,93 +1490,8 @@
  %7D%0A%0A
-        public Map%3CString, Object%3E getModel() %7B%0A             return null;%0A        %7D%0A%0A
     

Remove bogus automatic import statement