/********************************************************************
 * Copyright © 2004 EDS. All rights reserved
 ********************************************************************/
package gov.va.med.esr.common.builder.entity;

// Java Classes

// Library Classes

// Framework Classes

import gov.va.med.fw.util.builder.Builder;
import gov.va.med.fw.util.builder.BuilderException;

// Common Classes
import gov.va.med.esr.common.model.ee.AgentOrangeExposure;
import gov.va.med.esr.common.model.ee.CampLejeuneVerification;
import gov.va.med.esr.common.model.ee.EnvironmentalContaminationExposure;
import gov.va.med.esr.common.model.ee.RadiationExposure;
import gov.va.med.esr.common.model.ee.SpecialFactor;
import gov.va.med.esr.common.model.lookup.AgentOrangeExposureLocation;
import gov.va.med.esr.common.model.lookup.CampLejeuneChangeSource;
import gov.va.med.esr.common.model.lookup.Indicator;
import gov.va.med.esr.common.model.lookup.RadiationExposureMethod;
import gov.va.med.esr.common.model.lookup.VAFacility;

// Messaging Classess

/**
 * Class that builds the application from a message.
 *
 * @author Carlos Ruiz
 * @version 1.0
 */
public class SpecialFactorBuilder
    extends EntityBuilder
{
    /**
	 * An instance of serialVersionUID
	 */
	private static final long serialVersionUID = -4545674946762592820L;

	/**
     * Default constructor.
     */
    public SpecialFactorBuilder()
    {
        super();
    }

    private boolean shouldKeep(SpecialFactor obj)
    {
        return true;
    }

    private void transfer(SpecialFactor input, SpecialFactorMetaData metaData)
        throws BuilderException
    {

    }

    public static class AgentOrangeExposureBuilder
        extends SpecialFactorBuilder
    {
        /**
		 * An instance of serialVersionUID
		 */
		private static final long serialVersionUID = -8762874255381718044L;
		private Builder locationBuilder;

        public AgentOrangeExposureBuilder()
        {
            super();
        }

        public Builder getLocationBuilder()
        {
            return this.locationBuilder;
        }

        public void setLocationBuilder(Builder locationBuilder)
        {
            this.locationBuilder = locationBuilder;
        }

        public AgentOrangeExposure build(AgentOrangeExposureMetaData metaData)
            throws BuilderException
        {
            AgentOrangeExposure input = metaData.getEntity();
            AgentOrangeExposure output = (input == null)
                ? new AgentOrangeExposure()
                : input;

            this.transfer(output, metaData);

            return this.shouldKeep(output) ? output : null;
        }

        private AgentOrangeExposureLocation buildLocation(
            AgentOrangeExposureLocation input,
            String code) throws BuilderException
        {
            return super.shouldDelete(code)
                ? null
                : (AgentOrangeExposureLocation)super
                    .build(this.locationBuilder, input, code);
        }

        private boolean shouldKeep(AgentOrangeExposure obj)
        {
            return (super.shouldKeep(obj) && (obj.getLocation() != null));
        }

        private void transfer(
            AgentOrangeExposure input,
            AgentOrangeExposureMetaData metaData) throws BuilderException
        {
            super.transfer((SpecialFactor)input, metaData);

            input.setLocation(this.buildLocation(input.getLocation(), metaData
                .getLocation()));

            input.setAgentOrangeExposureIndicator((Indicator) super.build(
                    getIndicatorBuilder(), input.getAgentOrangeExposureIndicator(),
                    metaData.getIndicator()));

        }
    }

    public static class EnvironmentalContaminationExposureBuilder
        extends SpecialFactorBuilder
    {
        /**
		 * An instance of serialVersionUID
		 */
		private static final long serialVersionUID = 7368239751866865342L;

		public EnvironmentalContaminationExposureBuilder()
        {
            super();
        }

        public EnvironmentalContaminationExposure build(
            EnvironmentalContaminationExposureMetaData metaData)
            throws BuilderException
        {
            EnvironmentalContaminationExposure input = metaData.getEntity();
            EnvironmentalContaminationExposure output = (input == null)
                ? new EnvironmentalContaminationExposure()
                : input;

            this.transfer(output, metaData);

            return this.shouldKeep(output) ? output : null;
        }

        private boolean shouldKeep(EnvironmentalContaminationExposure obj)
        {
            return (super.shouldKeep((SpecialFactor)obj));
        }

        private void transfer(
            EnvironmentalContaminationExposure input,
            EnvironmentalContaminationExposureMetaData metaData)
            throws BuilderException
        {
            super.transfer((SpecialFactor)input, metaData);
            input.setEnvironmentalContaminationExposureIndicator((Indicator) super.build(
                    getIndicatorBuilder(), input.getEnvironmentalContaminationExposureIndicator(),
                    metaData.getIndicator()));

        }
    }

    public static class RadiationExposureBuilder
        extends SpecialFactorBuilder
    {
        /**
		 * An instance of serialVersionUID
		 */
		private static final long serialVersionUID = 2245645460230263855L;
		private Builder exposureMethodBuilder;

        public RadiationExposureBuilder()
        {
            super();
        }

        public Builder getExposureMethodBuilder()
        {
            return this.exposureMethodBuilder;
        }

        public void setExposureMethodBuilder(Builder exposureMethodBuilder)
        {
            this.exposureMethodBuilder = exposureMethodBuilder;
        }

        public RadiationExposure build(RadiationExposureMetaData metaData)
            throws BuilderException
        {
            RadiationExposure input = metaData.getEntity();
            RadiationExposure output = (input == null)
                ? new RadiationExposure()
                : input;

            this.transfer(output, metaData);

            return this.shouldKeep(output) ? output : null;
        }

        private RadiationExposureMethod buildExposureMethod(
            RadiationExposureMethod input,
            String code) throws BuilderException
        {
            return (RadiationExposureMethod)super
                .build(this.exposureMethodBuilder, input, code);
        }

        private boolean shouldKeep(RadiationExposure obj)
        {
            return (super.shouldKeep((SpecialFactor)obj) && ((obj.getExposureMethod() != null)));
        }

        private void transfer(
            RadiationExposure input,
            RadiationExposureMetaData metaData) throws BuilderException
        {
            super.transfer((SpecialFactor)input, metaData);

            input.setExposureMethod(this.buildExposureMethod(input
                .getExposureMethod(), metaData.getExposureMethod()));
            input.setRadiationExposureIndicator((Indicator) super.build(
                    getIndicatorBuilder(), input.getRadiationExposureIndicator(),
                    metaData.getIndicator()));

        }
    }



    public static class CampLejeuneVerificationBuilder
    extends SpecialFactorBuilder
  {


	/**
	 * An instance of serialVersionUID
	 */
	private static final long serialVersionUID = -4422769920283725446L;

	private Builder campLejeuneChangeSourceBuilder;

    public CampLejeuneVerificationBuilder()
    {
        super();
    }


    public CampLejeuneVerification build(CampLejeuneVerificationMetaData metaData)
        throws BuilderException
    {
    	CampLejeuneVerification input = metaData.getEntity();
    	CampLejeuneVerification output = (input == null)
            ? new CampLejeuneVerification()
            : input;

        this.transfer(output, metaData);

        return this.shouldKeep(output) ? output : null;
    }



    private boolean shouldKeep(CampLejeuneVerification obj)
    {
        return (super.shouldKeep((SpecialFactor)obj));
    }

    private void transfer(
    		CampLejeuneVerification input,
    		CampLejeuneVerificationMetaData metaData) throws BuilderException
    {
        super.transfer((SpecialFactor)input, metaData);

        input.setSpecialFactorIndicator((Indicator) super.build(
                getIndicatorBuilder(), input.getSpecialFactorIndicator(), metaData.getCLIndicator()));
        input.setRegistrationDate(super.build(input.getRegistrationDate(), metaData.getCLRegDate()));
        input.setChangeSite((VAFacility)super.build(getVaFacilityBuilder(), input.getChangeSite(), metaData.getCLChangeSite()));
        input.setChangeSource((CampLejeuneChangeSource)super.build(getCampLejeuneChangeSourceBuilder(), input.getChangeSource(), metaData.getCLChangeSource()));


    }


	public Builder getCampLejeuneChangeSourceBuilder() {
		return campLejeuneChangeSourceBuilder;
	}


	public void setCampLejeuneChangeSourceBuilder(
			Builder campLejeuneChangeSourceBuilder) {
		this.campLejeuneChangeSourceBuilder = campLejeuneChangeSourceBuilder;
	}



}

}