package edu.northwestern.bioinformatics.studycalendar.xml.writers;

import edu.northwestern.bioinformatics.studycalendar.xml.AbstractStudyCalendarXmlSerializer;
import edu.northwestern.bioinformatics.studycalendar.xml.XsdElement;
import edu.northwestern.bioinformatics.studycalendar.xml.XsdAttribute;
import edu.northwestern.bioinformatics.studycalendar.domain.ActivityProperty;
import org.dom4j.Element;
import org.apache.commons.lang.StringUtils;

/**
 * @author Jalpa Patel
 */
public class ActivityPropertyXmlSerializer  extends AbstractStudyCalendarXmlSerializer<ActivityProperty> {

    @Override
    public Element createElement(ActivityProperty ap) {
        Element apElt = XsdElement.ACTIVITY_PROPERTY.create();
        XsdAttribute.ACTIVITY_PROPERTY_NAMESPACE.addTo(apElt,ap.getNamespace());
        XsdAttribute.ACTIVITY_PROPERTY_NAME.addTo(apElt,ap.getName());
        if(ap.getValue()!=null)
            XsdAttribute.ACTIVITY_PROPERTY_VALUE.addTo(apElt,ap.getValue());
        return apElt;
    }

    @Override
    public ActivityProperty readElement(Element element) {
        ActivityProperty activityProperty = new ActivityProperty();
        activityProperty.setNamespace(XsdAttribute.ACTIVITY_PROPERTY_NAMESPACE.from(element));
        activityProperty.setName(XsdAttribute.ACTIVITY_PROPERTY_NAME.from(element));
        if(XsdAttribute.ACTIVITY_PROPERTY_VALUE.from(element)!=null)
            activityProperty.setValue(XsdAttribute.ACTIVITY_PROPERTY_VALUE.from(element));
        return activityProperty;
    }

    public boolean validateElement(ActivityProperty ap, Element element) {
        boolean valid = true;
        if (element == null && ap == null) {
            return true;
        } else if ((element != null && ap == null) || (ap != null && element == null)) {
            return false;
        } else if (!StringUtils.equals(ap.getNamespace(),XsdAttribute.ACTIVITY_PROPERTY_NAMESPACE.from(element))) {
            valid = false;
        }  else if (!StringUtils.equals(ap.getName(),XsdAttribute.ACTIVITY_PROPERTY_NAME.from(element))) {
            valid = false;
        }  else if (!StringUtils.equals(ap.getValue(),XsdAttribute.ACTIVITY_PROPERTY_VALUE.from(element))) {
            valid = false;
        }
        return valid;
    }

}

@@ -118,46 +118,31 @@
 dar.
-xml.AbstractStudyCalendarXmlSerializer
+domain.ActivityProperty
 ;%0Aim
@@ -196,26 +196,50 @@
 dar.xml.
-XsdElement
+AbstractStudyCalendarXmlSerializer
 ;%0Aimport
@@ -356,39 +356,30 @@
 alendar.
-domain.ActivityProperty
+xml.XsdElement
 ;%0Aimport
@@ -401,52 +401,8 @@
 ent;
-%0Aimport org.apache.commons.lang.StringUtils;
 %0A%0A/*
@@ -1485,749 +1485,6 @@
   %7D%0A
-%0A    public boolean validateElement(ActivityProperty ap, Element element) %7B%0A        boolean valid = true;%0A        if (element == null && ap == null) %7B%0A            return true;%0A        %7D else if ((element != null && ap == null) %7C%7C (ap != null && element == null)) %7B%0A            return false;%0A        %7D else if (!StringUtils.equals(ap.getNamespace(),XsdAttribute.ACTIVITY_PROPERTY_NAMESPACE.from(element))) %7B%0A            valid = false;%0A        %7D  else if (!StringUtils.equals(ap.getName(),XsdAttribute.ACTIVITY_PROPERTY_NAME.from(element))) %7B%0A            valid = false;%0A        %7D  else if (!StringUtils.equals(ap.getValue(),XsdAttribute.ACTIVITY_PROPERTY_VALUE.from(element))) %7B%0A            valid = false;%0A        %7D%0A        return valid;%0A    %7D%0A%0A
 %7D%0A

Remove never-used "validateElement" method. Noticed with #1296.