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;
019
020import io.konik.jaxb.adapter.CountryAdapter;
021import io.konik.zugferd.unqualified.ID;
022
023import java.util.ArrayList;
024import java.util.List;
025
026import javax.validation.Valid;
027import javax.xml.bind.annotation.XmlAccessType;
028import javax.xml.bind.annotation.XmlAccessorType;
029import javax.xml.bind.annotation.XmlElement;
030import javax.xml.bind.annotation.XmlType;
031import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
032import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
033
034import com.neovisionaries.i18n.CountryCode;
035
036/**
037 * = The Trade Product
038 */
039@XmlAccessorType(XmlAccessType.FIELD)
040@XmlType(name = "TradeProductType", propOrder = { "globalId", "sellerAssignedId", "buyerAssignedId", "name",
041      "description", "characteristics", "classifications", "origins", "containedProducts" })
042public class Product {
043
044   @XmlElement(name = "GlobalID")
045   private ID globalId;
046
047   @XmlElement(name = "SellerAssignedID")
048   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
049   private String sellerAssignedId;
050
051   @XmlElement(name = "BuyerAssignedID")
052   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
053   private String buyerAssignedId;
054
055   @XmlElement(name = "Name")
056   private String name;
057
058   @XmlElement(name = "Description")
059   private String description;
060   
061   @Valid
062   @XmlElement(name = "ApplicableProductCharacteristic")
063   private List<ProductCharacteristic> characteristics;
064
065   @XmlElement(name = "DesignatedProductClassification")
066   @Valid
067   private List<ProductClassification> classifications;
068
069   @Valid
070   @XmlElement(name = "OriginTradeCountry")
071   @XmlJavaTypeAdapter(value = CountryAdapter.class)
072   private List<CountryCode> origins;
073
074   @XmlElement(name = "IncludedReferencedProduct")
075   @Valid
076   private List<ReferencedProduct> containedProducts;
077
078   /**
079    * Gets the global id.
080    *
081    * @return the global id
082    */
083   public ID getGlobalId() {
084      return globalId;
085   }
086
087   /**
088    * Sets the global id.
089    *
090    * @param productGlobalId the product global id
091    * @return the trade product
092    */
093   public Product setGlobalId(ID productGlobalId) {
094      this.globalId = productGlobalId;
095      return this;
096   }
097
098   /**
099    * Gets the seller assigned id.
100    *
101    * @return the seller assigned id
102    */
103   public String getSellerAssignedId() {
104      return sellerAssignedId;
105   }
106
107   /**
108    * Sets the seller assigned id.
109    *
110    * @param sellerAssignedId the new seller assigned id
111    * @return the trade product
112    */
113   public Product setSellerAssignedId(String sellerAssignedId) {
114      this.sellerAssignedId = sellerAssignedId;
115      return this;
116   }
117
118   /**
119    * Gets the buyer assigned id.
120    *
121    * @return the buyer assigned id
122    */
123   public String getBuyerAssignedId() {
124      return buyerAssignedId;
125   }
126
127   /**
128    * Sets the buyer assigned id.
129    *
130    * @param buyerAssignedId the new buyer assigned id
131    * @return the trade product
132    */
133   public Product setBuyerAssignedId(String buyerAssignedId) {
134      this.buyerAssignedId = buyerAssignedId;
135      return this;
136   }
137
138   /**
139    * Gets the name.
140    *
141    * @return the name
142    */
143   public String getName() {
144      return name;
145   }
146
147   /**
148    * Sets the name.
149    *
150    * @param name the new name
151    * @return the trade product
152    */
153   public Product setName(String name) {
154      this.name = name;
155      return this;
156   }
157
158   /**
159    * Gets the description.
160    *
161    * @return the description
162    */
163   public String getDescription() {
164      return description;
165   }
166
167   /**
168    * Sets the description.
169    *
170    * @param description the new description
171    * @return the product
172    */
173   public Product setDescription(String description) {
174      this.description = description;
175      return this;
176   }
177
178   /**
179    * Gets the characteristics.
180    *
181    * @return the characteristics
182    */
183   public List<ProductCharacteristic> getCharacteristics() {
184      if (characteristics == null) {
185         characteristics = new ArrayList<ProductCharacteristic>();
186      }
187      return characteristics;
188   }
189
190   /**
191    * Sets the characteristics.
192    *
193    * @param characteristic the characteristics
194    * @return the product
195    */
196   public Product setCharacteristics(ProductCharacteristic characteristic) {
197      getCharacteristics().add(characteristic);
198      return this;
199   }
200
201   /**
202    * Gets the classifications.
203    *
204    * @return the classifications
205    */
206   public List<ProductClassification> getClassifications() {
207      if (classifications == null) {
208         classifications = new ArrayList<ProductClassification>();
209      }
210      return classifications;
211   }
212
213   /**
214    * Sets the classifications.
215    *
216    * @param classification the classifications
217    * @return the product
218    */
219   public Product setClassifications(ProductClassification classification) {
220      getClassifications().add(classification);
221      return this;
222   }
223
224   /**
225    * Gets the origin trade country.
226    *
227    * @return the origin trade country
228    */
229   public List<CountryCode> getOrigins() {
230      if (origins == null) {
231         origins = new ArrayList<CountryCode>();
232      }
233      return origins;
234   }
235
236   /**
237    * Adds a origin trade country.
238    *
239    * @param originCountry the additional origin country
240    * @return the trade product
241    */
242   public Product addOrigins(CountryCode originCountry) {
243      getOrigins().add(originCountry);
244      return this;
245   }
246
247   /**
248    * Gets the contained products.
249    *
250    * @return the contained products
251    */
252   public List<ReferencedProduct> getContainedProducts() {
253      if (containedProducts == null) {
254         containedProducts = new ArrayList<ReferencedProduct>();
255      }
256      return containedProducts;
257   }
258
259   /**
260    * Additional contained products.
261    *
262    * @param containedProduct the contained product
263    * @return the product
264    */
265   public Product addContainedProducts(ReferencedProduct containedProduct) {
266      getContainedProducts().add(containedProduct);
267      return this;
268   }
269
270}