001/* Copyright (C) 2014 konik.io
002 *
003 * This file is part of the Konik library.
004 *
005 * The Konik library is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * The Konik library is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with the Konik library. If not, see <http://www.gnu.org/licenses/>.
017 */
018package io.konik.zugferd.entity.trade;
019
020import io.konik.jaxb.bindable.entity.TradeDeliveryTermsAdapter;
021import io.konik.zugferd.entity.CommonAgreement;
022import io.konik.zugferd.entity.ReferencedDocument;
023import io.konik.zugferd.entity.TradeParty;
024
025import java.util.ArrayList;
026import java.util.List;
027
028import javax.validation.Valid;
029import javax.xml.bind.annotation.XmlElement;
030import javax.xml.bind.annotation.XmlType;
031import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
032
033/**
034 * 
035 * = The Trade Agreement.
036 * 
037 */
038@XmlType(propOrder = { "buyerReference", "seller", "buyer", "productEndUser", "deliveryTerms", "buyerOrder",
039      "contract", "additional", "customerOrder" })
040public class Agreement implements CommonAgreement<ReferencedDocument, ReferencedDocumentAdditional> {
041
042   private String buyerReference;
043   @Valid
044   private TradeParty seller;
045   @Valid
046   private TradeParty buyer;
047   @Valid
048   private TradeParty productEndUser;
049   @Valid
050   private String deliveryTerms;
051   @Valid
052   private ReferencedDocument buyerOrder;
053   @Valid
054   private ReferencedDocument contract;
055   @Valid
056   private List<ReferencedDocumentAdditional> additional;
057   @Valid
058   private ReferencedDocument customerOrder;
059
060   /**
061    * Gets the buyer reference.
062    * 
063    * The reference to ease the attribution for the buyer
064    * 
065    * Profile:: COMFORT
066    * 
067    * @return the buyer reference
068    */
069   @XmlElement(name = "BuyerReference")
070   public String getBuyerReference() {
071      return buyerReference;
072   }
073
074   /**
075    * Sets the buyer reference.
076    * 
077    * The reference to ease the attribution for the buyer
078    * 
079    * Profile:: COMFORT
080    *
081    * @param buyerReference the new buyer reference
082    * @return the trade agreement
083    */
084   public Agreement setBuyerReference(String buyerReference) {
085      this.buyerReference = buyerReference;
086      return this;
087   }
088
089   /**
090    * Gets the seller.
091    *
092    * @return the seller
093    */
094   @XmlElement(name = "SellerTradeParty")
095   public TradeParty getSeller() {
096      return seller;
097   }
098
099   /**
100    * Sets the seller.
101    *
102    * @param seller the seller
103    * @return the agreement
104    */
105   public Agreement setSeller(TradeParty seller) {
106      this.seller = seller;
107      return this;
108   }
109
110   /**
111    * Gets the product end user.
112    *
113    * @return the product end user
114    */
115   @XmlElement(name = "ProductEndUserTradeParty")
116   public TradeParty getProductEndUser() {
117      return productEndUser;
118   }
119
120   /**
121    * Sets the product end user.
122    *
123    * @param productEndUser the new product end user
124    * @return the agreement
125    */
126   public Agreement setProductEndUser(TradeParty productEndUser) {
127      this.productEndUser = productEndUser;
128      return this;
129   }
130
131   /**
132    * Gets the buyer trade party.
133    *
134    * @return the buyer trade party
135    */
136   @XmlElement(name = "BuyerTradeParty")
137   public TradeParty getBuyer() {
138      return buyer;
139   }
140
141   /**
142    * Sets the buyer trade party.
143    *
144    * @param buyer the new buyer trade party
145    * @return the supply chain trade agreement
146    */
147   public Agreement setBuyer(TradeParty buyer) {
148      this.buyer = buyer;
149      return this;
150   }
151
152   /**
153    * Gets the delivery terms.
154    *
155    * Profile:: EXTENDED
156    *
157    * @return the delivery terms
158    */
159   @XmlElement(name = "ApplicableTradeDeliveryTerms")
160   @XmlJavaTypeAdapter(value = TradeDeliveryTermsAdapter.class)
161   public String getDeliveryTerms() {
162      return deliveryTerms;
163   }
164
165   /**
166    * Sets the delivery terms.
167    *
168    * Profile:: EXTENDED
169    *
170    * @param deliveryTerms the delivery terms
171    */
172   public void setDeliveryTerms(String deliveryTerms) {
173      this.deliveryTerms = deliveryTerms;
174   }
175
176   /**
177    * Gets the buyer order referenced document.
178    *
179    * @return the buyer order referenced document
180    */
181   @Override
182   @XmlElement(name = "BuyerOrderReferencedDocument")
183   public ReferencedDocument getBuyerOrder() {
184      return buyerOrder;
185   }
186
187   /**
188    * Sets the buyer order referenced document.
189    *
190    * @param buyerOrder the new buyer order referenced document
191    * @return the supply chain trade agreement
192    */
193   @Override
194   public Agreement setBuyerOrder(ReferencedDocument buyerOrder) {
195      this.buyerOrder = buyerOrder;
196      return this;
197   }
198
199   /**
200    * Gets the contract referenced document.
201    * 
202    * Profile:: COMFORT
203    *
204    * @return the contract referenced document
205    */
206   @Override
207   @XmlElement(name = "ContractReferencedDocument")
208   public ReferencedDocument getContract() {
209      return contract;
210   }
211
212   /**
213    * Sets the contract referenced document.
214    * 
215    * Profile:: COMFORT
216    *
217    * @param contract the new contract referenced document
218    * @return the supply chain trade agreement
219    */
220   @Override
221   public Agreement setContract(ReferencedDocument contract) {
222      this.contract = contract;
223      return this;
224   }
225
226   /**
227    * Gets the additional.
228    *
229    * @return the additional
230    */
231   @Override
232   @XmlElement(name = "AdditionalReferencedDocument")
233   public List<ReferencedDocumentAdditional> getAdditional() {
234      if (additional == null) {
235         additional = new ArrayList<ReferencedDocumentAdditional>();
236      }
237      return additional;
238   }
239
240   /**
241    * Adds the additional.
242    *
243    * @param additionalReference the additional reference
244    * @return the common agreement
245    */
246   @Override
247   public Agreement addAdditional(ReferencedDocumentAdditional additionalReference) {
248      getAdditional().add(additionalReference);
249      return this;
250   }
251
252   /**
253    * Gets the customer order referenced document.
254    * 
255    * Profile:: COMFORT
256    *
257    * @return the customer order referenced document
258    */
259   @Override
260   @XmlElement(name = "CustomerOrderReferencedDocument")
261   public ReferencedDocument getCustomerOrder() {
262      return customerOrder;
263   }
264
265   /**
266    * Sets the customer order referenced document.
267    * 
268    * Profile:: COMFORT
269    *
270    * @param customerOrder the new customer order referenced document
271    * @return the supply chain trade agreement
272    */
273   @Override
274   public Agreement setCustomerOrder(ReferencedDocument customerOrder) {
275      this.customerOrder = customerOrder;
276      return this;
277   }
278}