/** 
 * (C) Copyright 2012 Chiral Behaviors, LLC. All Rights Reserved
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 *     
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */
package com.chiralbehaviors.CoRE.location;

import java.math.BigDecimal;
import java.util.Map;
import java.util.UUID;

import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.metamodel.SingularAttribute;

import com.chiralbehaviors.CoRE.Ruleform;
import com.chiralbehaviors.CoRE.agency.Agency;
import com.chiralbehaviors.CoRE.attribute.Attribute;
import com.chiralbehaviors.CoRE.attribute.AttributeValue;
import com.chiralbehaviors.CoRE.attribute.unit.Unit;
import com.chiralbehaviors.CoRE.product.Product;

/**
 * The persistent class for the location_attribute database table.
 * 
 */
@Entity
@Table(name = "location_attribute", schema = "ruleform")
public class LocationAttribute extends AttributeValue<Location> {
    private static final long serialVersionUID = 1L;

    // bi-directional many-to-one association to Agency
    @ManyToOne
    @JoinColumn(name = "agency_value")
    private Agency            agencyValue;

    // bi-directional many-to-one association to Location
    @ManyToOne
    @JoinColumn(name = "location")
    private Location          location;

    // bi-directional many-to-one association to Product
    @ManyToOne
    @JoinColumn(name = "product_value")
    private Product           productValue;

    public LocationAttribute() {
    }

    /**
     * @param updatedBy
     */
    public LocationAttribute(Agency updatedBy) {
        super(updatedBy);
    }

    /**
     * @param attribute
     */
    public LocationAttribute(Attribute attribute) {
        super(attribute);
    }

    /**
     * @param attribute
     * @param updatedBy
     */
    public LocationAttribute(Attribute attribute, Agency updatedBy) {
        super(attribute, updatedBy);
    }

    /**
     * @param attribute
     * @param value
     * @param updatedBy
     */
    public LocationAttribute(Attribute attribute, BigDecimal value,
                             Agency updatedBy) {
        super(attribute, value, updatedBy);
    }

    /**
     * @param attribute
     * @param value
     * @param updatedBy
     */
    public LocationAttribute(Attribute attribute, boolean value,
                             Agency updatedBy) {
        super(attribute, value, updatedBy);
    }

    /**
     * @param attribute
     * @param value
     * @param updatedBy
     */
    public LocationAttribute(Attribute attribute, int value, Agency updatedBy) {
        super(attribute, value, updatedBy);
    }

    /**
     * @param attribute
     * @param value
     * @param updatedBy
     */
    public LocationAttribute(Attribute attribute, String value, Agency updatedBy) {
        super(attribute, value, updatedBy);
    }

    /**
     * @param attribute
     * @param unit
     */
    public LocationAttribute(Attribute attribute, Unit unit) {
        super(attribute, unit);
    }

    /**
     * @param id
     */
    public LocationAttribute(UUID id) {
        super(id);
    }

    public Agency getAgencyValue() {
        return agencyValue;
    }

    public Location getLocation() {
        return location;
    }

    public Product getProductValue() {
        return productValue;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.chiralbehaviors.CoRE.attribute.AttributeValue#getRuleformAttribute()
     */
    @Override
    public SingularAttribute<LocationAttribute, Location> getRuleformAttribute() {
        return LocationAttribute_.location;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.chiralbehaviors.CoRE.attribute.AttributeValue#getRuleformClass()
     */
    @Override
    public Class<Location> getRuleformClass() {
        return Location.class;
    }

    public void setAgencyValue(Agency agency2) {
        agencyValue = agency2;
    }

    public void setEntityValue(Product product) {
        productValue = product;
    }

    public void setLocation(Location location) {
        this.location = location;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.chiralbehaviors.CoRE.Ruleform#traverseForeignKeys(javax.persistence
     * .EntityManager, java.util.Map)
     */
    @Override
    public void traverseForeignKeys(EntityManager em,
                                    Map<Ruleform, Ruleform> knownObjects) {
        if (productValue != null) {
            productValue = (Product) productValue.manageEntity(em, knownObjects);
        }
        if (location != null) {
            location = (Location) location.manageEntity(em, knownObjects);
        }
        if (agencyValue != null) {
            agencyValue = (Agency) agencyValue.manageEntity(em, knownObjects);
        }
        super.traverseForeignKeys(em, knownObjects);

    }
}
@@ -1243,57 +1243,8 @@
 nit;
-%0Aimport com.chiralbehaviors.CoRE.product.Product;
 %0A%0A/*
@@ -1558,416 +1558,105 @@
  to 
-Agency%0A    @ManyToOne%0A    @JoinColumn(name = %22agency_value%22)%0A    private Agency            agencyValue;%0A%0A    // bi-directional many-to-one association to Location%0A    @ManyToOne%0A    @JoinColumn(name = %22location%22)%0A    private Location          location;%0A%0A    // bi-directional many-to-one association to Product%0A    @ManyToOne%0A    @JoinColumn(name = %22product_value%22)%0A    private Product           productValue
+Location%0A    @ManyToOne%0A    @JoinColumn(name = %22location%22)%0A    private Location          location
 ;%0A%0A 
@@ -3330,203 +3330,56 @@
 lic 
-Agency getAgencyValue() %7B%0A        return agencyValue;%0A    %7D%0A%0A    public Location getLocation() %7B%0A        return location;%0A    %7D%0A%0A    public Product getProductValue() %7B%0A        return productValue
+Location getLocation() %7B%0A        return location
 ;%0A  
@@ -3896,184 +3896,8 @@
  %7D%0A%0A
-    public void setAgencyValue(Agency agency2) %7B%0A        agencyValue = agency2;%0A    %7D%0A%0A    public void setEntityValue(Product product) %7B%0A        productValue = product;%0A    %7D%0A%0A
     
@@ -4315,322 +4315,70 @@
 if (
-productValue != null) %7B%0A            productValue = (Product) productValue.manageEntity(em, knownObjects);%0A        %7D%0A        if (location != null) %7B%0A            location = (Location) location.manageEntity(em, knownObjects);%0A        %7D%0A        if (agencyValue != null) %7B%0A            agencyValue = (Agency) agencyValue
+location != null) %7B%0A            location = (Location) location
 .man

Remove foreign key values.