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.validator.annotation.Basic; 022import io.konik.validator.annotation.Comfort; 023import io.konik.validator.annotation.Extended; 024import io.konik.validator.annotation.NotBlank; 025import io.konik.zugferd.entity.CommonAgreement; 026import io.konik.zugferd.entity.ReferencedDocument; 027import io.konik.zugferd.entity.TradeParty; 028 029import java.util.ArrayList; 030import java.util.List; 031 032import javax.validation.Valid; 033import javax.validation.constraints.NotNull; 034import javax.xml.bind.annotation.XmlElement; 035import javax.xml.bind.annotation.XmlType; 036import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 037 038/** 039 * 040 * = The Trade Agreement. 041 * 042 */ 043@XmlType(propOrder = { "buyerReference", "seller", "buyer", "productEndUser", "deliveryTerms", "buyerOrder", 044 "contract", "additional", "customerOrder" }) 045public class Agreement implements CommonAgreement<ReferencedDocument, ReferencedDocumentAdditional> { 046 047 private String buyerReference; 048 private TradeParty seller; 049 private TradeParty buyer; 050 private TradeParty productEndUser; 051 private String deliveryTerms; 052 private ReferencedDocument buyerOrder; 053 private ReferencedDocument contract; 054 private List<ReferencedDocumentAdditional> additional; 055 private ReferencedDocument customerOrder; 056 057 /** 058 * Gets the buyer reference. 059 * 060 * The reference to ease the attribution for the buyer 061 * 062 * @return the buyer reference 063 */ 064 @Comfort 065 @XmlElement(name = "BuyerReference") 066 public String getBuyerReference() { 067 return buyerReference; 068 } 069 070 /** 071 * Sets the buyer reference. 072 * 073 * The reference to ease the attribution for the buyer 074 * 075 * @param buyerReference the new buyer reference 076 * @return the trade agreement 077 */ 078 public Agreement setBuyerReference(String buyerReference) { 079 this.buyerReference = buyerReference; 080 return this; 081 } 082 083 /** 084 * Gets the seller trade party 085 * 086 * @return the seller 087 */ 088 @NotNull 089 @Valid 090 @Basic 091 @XmlElement(name = "SellerTradeParty") 092 public TradeParty getSeller() { 093 return seller; 094 } 095 096 /** 097 * Sets the seller trade party 098 * 099 * @param seller the seller 100 * @return the agreement 101 */ 102 public Agreement setSeller(TradeParty seller) { 103 this.seller = seller; 104 return this; 105 } 106 107 /** 108 * Gets the product end user. 109 * 110 * @return the product end user 111 */ 112 @Valid 113 @Extended 114 @XmlElement(name = "ProductEndUserTradeParty") 115 public TradeParty getProductEndUser() { 116 return productEndUser; 117 } 118 119 /** 120 * Sets the product end user. 121 * 122 * @param productEndUser the new product end user 123 * @return the agreement 124 */ 125 public Agreement setProductEndUser(TradeParty productEndUser) { 126 this.productEndUser = productEndUser; 127 return this; 128 } 129 130 /** 131 * Gets the buyer trade party. 132 * 133 * @return the buyer trade party 134 */ 135 @XmlElement(name = "BuyerTradeParty") 136 public TradeParty getBuyer() { 137 return buyer; 138 } 139 140 /** 141 * Sets the buyer trade party. 142 * 143 * @param buyer the new buyer trade party 144 * @return the supply chain trade agreement 145 */ 146 public Agreement setBuyer(TradeParty buyer) { 147 this.buyer = buyer; 148 return this; 149 } 150 151 /** 152 * Gets the delivery terms Incoterms code. 153 * 154 * @return the delivery terms Incoterms code 155 */ 156 @Extended 157 @NotBlank(groups=Extended.class) 158 @XmlElement(name = "ApplicableTradeDeliveryTerms") 159 @XmlJavaTypeAdapter(value = TradeDeliveryTermsAdapter.class) 160 public String getDeliveryTerms() { 161 return deliveryTerms; 162 } 163 164 /** 165 * Sets the delivery terms Incoterms code. 166 * 167 * @param deliveryTerms the delivery Incoterms terms 168 * @return 169 */ 170 public Agreement setDeliveryTerms(String deliveryTerms) { 171 this.deliveryTerms = deliveryTerms; 172 return this; 173 } 174 175 /** 176 * Gets the buyer order referenced document. 177 * 178 * @return the buyer order referenced document 179 */ 180 @Comfort 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 * @return the contract referenced document 203 */ 204 @Comfort 205 @Override 206 @XmlElement(name = "ContractReferencedDocument") 207 public ReferencedDocument getContract() { 208 return contract; 209 } 210 211 /** 212 * Sets the contract referenced document. 213 * 214 * @param contract the new contract referenced document 215 * @return the supply chain trade agreement 216 */ 217 @Override 218 public Agreement setContract(ReferencedDocument contract) { 219 this.contract = contract; 220 return this; 221 } 222 223 /** 224 * Gets the additional. 225 * 226 * @return the additional 227 */ 228 @Extended 229 @Override 230 @XmlElement(name = "AdditionalReferencedDocument") 231 public List<ReferencedDocumentAdditional> getAdditional() { 232 if (additional == null) { 233 additional = new ArrayList<ReferencedDocumentAdditional>(); 234 } 235 return additional; 236 } 237 238 /** 239 * Adds the additional. 240 * 241 * @param additionalReference the additional reference 242 * @return the common agreement 243 */ 244 @Override 245 public Agreement addAdditional(ReferencedDocumentAdditional additionalReference) { 246 getAdditional().add(additionalReference); 247 return this; 248 } 249 250 /** 251 * Gets the customer order referenced document. 252 * 253 * @return the customer order referenced document 254 */ 255 @Comfort 256 @Override 257 @XmlElement(name = "CustomerOrderReferencedDocument") 258 public ReferencedDocument getCustomerOrder() { 259 return customerOrder; 260 } 261 262 /** 263 * Sets the customer order referenced document. 264 * 265 * @param customerOrder the new customer order referenced document 266 * @return the supply chain trade agreement 267 */ 268 @Override 269 public Agreement setCustomerOrder(ReferencedDocument customerOrder) { 270 this.customerOrder = customerOrder; 271 return this; 272 } 273}