All Downloads are FREE. Search and download functionalities are using the official Maven repository.

nz.co.senanque.decisiontable.Order Maven / Gradle / Ivy

Go to download

This is a plugin to Madura Objects. It provides a rules/constraint engine to assist with validation, deriving new values from user inputs (eg total of invoices entered on this customer) an manipulating metadata (eg because the amount is above X we make some field readonly). Note that the Java that is using the monitored objects is quite unaware of the rules layer implemented here. That means you can change rules without having to go back to your Java code, and it also means you don't have to wonder if everything implemented the same rules. Anything using that Java object has the rules (unless you turn them all off).

There is a newer version: 3.3.5
Show newest version
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.4 
// See http://java.sun.com/xml/jaxb 
// Any modifications to this file will be lost upon recompilation of the source schema. 
// Generated on: 2016.03.24 at 09:48:53 PM NZDT 
//


package nz.co.senanque.decisiontable;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import nz.co.senanque.validationengine.ListeningArray;
import nz.co.senanque.validationengine.ObjectMetadata;
import nz.co.senanque.validationengine.ValidationObject;
import nz.co.senanque.validationengine.ValidationSession;
import nz.co.senanque.validationengine.ValidationUtils;
import nz.co.senanque.validationengine.annotations.Digits;
import nz.co.senanque.validationengine.annotations.Label;
import nz.co.senanque.validationengine.annotations.Range;
import nz.co.senanque.validationengine.annotations.ReadOnly;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
import org.jvnet.jaxb2_commons.lang.HashCode;
import org.jvnet.jaxb2_commons.lang.HashCodeStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBHashCodeStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBToStringStrategy;
import org.jvnet.jaxb2_commons.lang.ToString;
import org.jvnet.jaxb2_commons.lang.ToStringStrategy;
import org.jvnet.jaxb2_commons.locator.ObjectLocator;
import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
import org.w3._2001.xmlschema.Adapter2;


/**
 * 

Java class for Order complex type. * *

The following schema fragment specifies the expected content contained within this class. * *

 * <complexType name="Order">
 *   <complexContent>
 *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       <sequence>
 *         <element name="id" type="{http://www.w3.org/2001/XMLSchema}long"/>
 *         <element name="parentid" type="{http://www.w3.org/2001/XMLSchema}long"/>
 *         <element name="amount" type="{http://www.w3.org/2001/XMLSchema}double"/>
 *         <element name="date" type="{http://www.w3.org/2001/XMLSchema}date"/>
 *         <element name="customer" type="{http://www.senanque.co.nz/pizzaorder}Customer"/>
 *         <element name="shoppingCartStatus" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         <element name="orderItems" type="{http://www.senanque.co.nz/pizzaorder}OrderItem" maxOccurs="unbounded" minOccurs="0"/>
 *       </sequence>
 *     </restriction>
 *   </complexContent>
 * </complexType>
 * 
* * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "Order", propOrder = { "id", "parentid", "amount", "date", "customer", "shoppingCartStatus", "orderItems" }) @Entity(name = "Order") @Table(name = "ORDER_") @Inheritance(strategy = InheritanceType.JOINED) public class Order implements Serializable, ValidationObject, Equals, HashCode, ToString { protected long id; protected long parentid; protected double amount; @XmlElement(required = true, type = String.class) @XmlJavaTypeAdapter(Adapter2 .class) @XmlSchemaType(name = "date") protected Date date; @XmlElement(required = true) protected Customer customer; @XmlElement(required = true) protected String shoppingCartStatus; protected List orderItems; @XmlTransient protected ValidationSession m_validationSession; @XmlTransient protected ObjectMetadata m_metadata; @XmlTransient public final static String ID = "id"; @XmlTransient public final static String PARENTID = "parentid"; @XmlTransient public final static String AMOUNT = "amount"; @XmlTransient public final static String DATE = "date"; @XmlTransient public final static String CUSTOMER = "customer"; @XmlTransient public final static String SHOPPINGCARTSTATUS = "shoppingCartStatus"; @XmlTransient public final static String ORDERITEMS = "orderItems"; public Order() { ValidationUtils.setDefaults(this); } /** * Gets the value of the id property. * */ @Id @Column(name = "ID", scale = 0) @Range(maxInclusive = "9223372036854775807", minInclusive = "-9223372036854775808") public long getId() { if (m_validationSession!= null) { m_validationSession.clean(this); } return id; } /** * Sets the value of the id property. * */ public void setId(long value) { getMetadata().removeUnknown("id"); if (m_validationSession!= null) { m_validationSession.set(this, "id", value, id); } this.id = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "id", value, id); } } /** * Gets the value of the parentid property. * */ @Basic @Column(name = "PARENTID", precision = 20, scale = 0) @Range(maxInclusive = "9223372036854775807", minInclusive = "-9223372036854775808") public long getParentid() { if (m_validationSession!= null) { m_validationSession.clean(this); } return parentid; } /** * Sets the value of the parentid property. * */ public void setParentid(long value) { getMetadata().removeUnknown("parentid"); if (m_validationSession!= null) { m_validationSession.set(this, "parentid", value, parentid); } this.parentid = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "parentid", value, parentid); } } /** * Gets the value of the amount property. * */ @Label(labelName = "Amount") @Digits(fractionalDigits = "2", integerDigits = "8") @Range(minInclusive = "5", maxInclusive = "999") @ReadOnly @Basic @Column(name = "AMOUNT", precision = 20, scale = 10) public double getAmount() { if (m_validationSession!= null) { m_validationSession.clean(this); } return amount; } /** * Sets the value of the amount property. * */ public void setAmount(double value) { getMetadata().removeUnknown("amount"); if (m_validationSession!= null) { m_validationSession.set(this, "amount", value, amount); } this.amount = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "amount", value, amount); } } /** * Gets the value of the date property. * * @return * possible object is * {@link String } * */ @Label(labelName = "Date") @Basic @Column(name = "DATE_") @Temporal(TemporalType.DATE) public Date getDate() { if (m_validationSession!= null) { m_validationSession.clean(this); } return date; } /** * Sets the value of the date property. * * @param value * allowed object is * {@link String } * */ public void setDate(Date value) { getMetadata().removeUnknown("date"); if (m_validationSession!= null) { m_validationSession.set(this, "date", value, date); } this.date = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "date", value, date); } } /** * Gets the value of the customer property. * * @return * possible object is * {@link Customer } * */ @ManyToOne(targetEntity = Customer.class, cascade = { CascadeType.ALL }) @JoinColumn(name = "CUSTOMER_ORDER__ID") public Customer getCustomer() { if (m_validationSession!= null) { m_validationSession.clean(this); } return customer; } /** * Sets the value of the customer property. * * @param value * allowed object is * {@link Customer } * */ public void setCustomer(Customer value) { getMetadata().removeUnknown("customer"); if (m_validationSession!= null) { m_validationSession.set(this, "customer", value, customer); } this.customer = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "customer", value, customer); } } /** * Gets the value of the shoppingCartStatus property. * * @return * possible object is * {@link String } * */ @ReadOnly @Basic @Column(name = "SHOPPINGCARTSTATUS", length = 255) public String getShoppingCartStatus() { if (m_validationSession!= null) { m_validationSession.clean(this); } return shoppingCartStatus; } /** * Sets the value of the shoppingCartStatus property. * * @param value * allowed object is * {@link String } * */ public void setShoppingCartStatus(String value) { getMetadata().removeUnknown("shoppingCartStatus"); if (m_validationSession!= null) { m_validationSession.set(this, "shoppingCartStatus", value, shoppingCartStatus); } this.shoppingCartStatus = value; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "shoppingCartStatus", value, shoppingCartStatus); } } /** * Gets the value of the orderItems property. * *

* This accessor method returns a reference to the live list, * not a snapshot. Therefore any modification you make to the * returned list will be present inside the JAXB object. * This is why there is not a set method for the orderItems property. * *

* For example, to add a new item, do as follows: *

     *    getOrderItems().add(newItem);
     * 
* * *

* Objects of the following type(s) are allowed in the list * {@link OrderItem } * * */ @OneToMany(targetEntity = OrderItem.class, cascade = { CascadeType.ALL }) @JoinColumn(name = "ORDERITEMS_ORDER__ID") public List getOrderItems() { if (m_validationSession!= null) { m_validationSession.clean(this); } if (orderItems == null) { orderItems = new ListeningArray(); } if (orderItems == null) { orderItems = new ArrayList(); } return this.orderItems; } /** * * */ public void setOrderItems(List orderItems) { getMetadata().removeUnknown("orderItems"); if (m_validationSession!= null) { m_validationSession.set(this, "orderItems", orderItems, orderItems); } this.orderItems = orderItems; if (m_validationSession!= null) { m_validationSession.invokeListeners(this, "orderItems", orderItems, orderItems); } } public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) { if (!(object instanceof Order)) { return false; } if (this == object) { return true; } final Order that = ((Order) object); { long lhsId; lhsId = (true?this.getId(): 0L); long rhsId; rhsId = (true?that.getId(): 0L); if (!strategy.equals(LocatorUtils.property(thisLocator, "id", lhsId), LocatorUtils.property(thatLocator, "id", rhsId), lhsId, rhsId)) { return false; } } { long lhsParentid; lhsParentid = (true?this.getParentid(): 0L); long rhsParentid; rhsParentid = (true?that.getParentid(): 0L); if (!strategy.equals(LocatorUtils.property(thisLocator, "parentid", lhsParentid), LocatorUtils.property(thatLocator, "parentid", rhsParentid), lhsParentid, rhsParentid)) { return false; } } { double lhsAmount; lhsAmount = (true?this.getAmount(): 0.0D); double rhsAmount; rhsAmount = (true?that.getAmount(): 0.0D); if (!strategy.equals(LocatorUtils.property(thisLocator, "amount", lhsAmount), LocatorUtils.property(thatLocator, "amount", rhsAmount), lhsAmount, rhsAmount)) { return false; } } { Date lhsDate; lhsDate = this.getDate(); Date rhsDate; rhsDate = that.getDate(); if (!strategy.equals(LocatorUtils.property(thisLocator, "date", lhsDate), LocatorUtils.property(thatLocator, "date", rhsDate), lhsDate, rhsDate)) { return false; } } { Customer lhsCustomer; lhsCustomer = this.getCustomer(); Customer rhsCustomer; rhsCustomer = that.getCustomer(); if (!strategy.equals(LocatorUtils.property(thisLocator, "customer", lhsCustomer), LocatorUtils.property(thatLocator, "customer", rhsCustomer), lhsCustomer, rhsCustomer)) { return false; } } { String lhsShoppingCartStatus; lhsShoppingCartStatus = this.getShoppingCartStatus(); String rhsShoppingCartStatus; rhsShoppingCartStatus = that.getShoppingCartStatus(); if (!strategy.equals(LocatorUtils.property(thisLocator, "shoppingCartStatus", lhsShoppingCartStatus), LocatorUtils.property(thatLocator, "shoppingCartStatus", rhsShoppingCartStatus), lhsShoppingCartStatus, rhsShoppingCartStatus)) { return false; } } { List lhsOrderItems; lhsOrderItems = (((this.orderItems!= null)&&(!this.orderItems.isEmpty()))?this.getOrderItems():null); List rhsOrderItems; rhsOrderItems = (((that.orderItems!= null)&&(!that.orderItems.isEmpty()))?that.getOrderItems():null); if (!strategy.equals(LocatorUtils.property(thisLocator, "orderItems", lhsOrderItems), LocatorUtils.property(thatLocator, "orderItems", rhsOrderItems), lhsOrderItems, rhsOrderItems)) { return false; } } return true; } public boolean equals(Object object) { final EqualsStrategy strategy = JAXBEqualsStrategy.INSTANCE; return equals(null, null, object, strategy); } public String toString() { final ToStringStrategy strategy = JAXBToStringStrategy.INSTANCE; final StringBuilder buffer = new StringBuilder(); append(null, buffer, strategy); return buffer.toString(); } public StringBuilder append(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { strategy.appendStart(locator, this, buffer); appendFields(locator, buffer, strategy); strategy.appendEnd(locator, this, buffer); return buffer; } public StringBuilder appendFields(ObjectLocator locator, StringBuilder buffer, ToStringStrategy strategy) { { long theId; theId = (true?this.getId(): 0L); strategy.appendField(locator, this, "id", buffer, theId); } { long theParentid; theParentid = (true?this.getParentid(): 0L); strategy.appendField(locator, this, "parentid", buffer, theParentid); } { double theAmount; theAmount = (true?this.getAmount(): 0.0D); strategy.appendField(locator, this, "amount", buffer, theAmount); } { Date theDate; theDate = this.getDate(); strategy.appendField(locator, this, "date", buffer, theDate); } { Customer theCustomer; theCustomer = this.getCustomer(); strategy.appendField(locator, this, "customer", buffer, theCustomer); } { String theShoppingCartStatus; theShoppingCartStatus = this.getShoppingCartStatus(); strategy.appendField(locator, this, "shoppingCartStatus", buffer, theShoppingCartStatus); } { List theOrderItems; theOrderItems = (((this.orderItems!= null)&&(!this.orderItems.isEmpty()))?this.getOrderItems():null); strategy.appendField(locator, this, "orderItems", buffer, theOrderItems); } return buffer; } public int hashCode(ObjectLocator locator, HashCodeStrategy strategy) { int currentHashCode = 1; { long theId; theId = (true?this.getId(): 0L); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "id", theId), currentHashCode, theId); } { long theParentid; theParentid = (true?this.getParentid(): 0L); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "parentid", theParentid), currentHashCode, theParentid); } { double theAmount; theAmount = (true?this.getAmount(): 0.0D); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "amount", theAmount), currentHashCode, theAmount); } { Date theDate; theDate = this.getDate(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "date", theDate), currentHashCode, theDate); } { Customer theCustomer; theCustomer = this.getCustomer(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "customer", theCustomer), currentHashCode, theCustomer); } { String theShoppingCartStatus; theShoppingCartStatus = this.getShoppingCartStatus(); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "shoppingCartStatus", theShoppingCartStatus), currentHashCode, theShoppingCartStatus); } { List theOrderItems; theOrderItems = (((this.orderItems!= null)&&(!this.orderItems.isEmpty()))?this.getOrderItems():null); currentHashCode = strategy.hashCode(LocatorUtils.property(locator, "orderItems", theOrderItems), currentHashCode, theOrderItems); } return currentHashCode; } public int hashCode() { final HashCodeStrategy strategy = JAXBHashCodeStrategy.INSTANCE; return this.hashCode(null, strategy); } @Transient public ObjectMetadata getMetadata() { if (m_validationSession!= null) { m_validationSession.clean(this); } if (m_metadata == null) { m_metadata = new ObjectMetadata(); } return m_metadata; } @XmlTransient public void setValidationSession(ValidationSession validationSession) { m_validationSession = validationSession; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy