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.IssueDateTimeAdapter;
021import io.konik.validator.annotation.Comfort;
022import io.konik.validator.annotation.NotBlank;
023
024import java.util.Date;
025
026import javax.xml.bind.annotation.XmlElement;
027import javax.xml.bind.annotation.XmlType;
028import javax.xml.bind.annotation.adapters.CollapsedStringAdapter;
029import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
030
031/**
032 * = The Referenced Document
033 * 
034 * References a external Document.
035 */
036@XmlType(name = "ReferencedDocumentType", propOrder = { "issued", "linePos", "typeCode", "id", "referenceType" })
037public class ReferencedDocument {
038
039   @XmlElement(name = "IssueDateTime")
040   @XmlJavaTypeAdapter(value = IssueDateTimeAdapter.class)
041   private Date issued;
042
043   @XmlElement(name = "LineID")
044   protected String linePos;
045
046   @XmlElement(name = "TypeCode")
047   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
048   protected String typeCode;
049
050   @XmlElement(name = "ID")
051   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
052   private String id;
053
054   @XmlElement(name = "ReferenceTypeCode")
055   @XmlJavaTypeAdapter(CollapsedStringAdapter.class)
056   protected String referenceType;
057
058   protected ReferencedDocument() {
059   }
060
061   /**
062    * The Constructor.
063    *
064    * @param identifier the id value of the referenced document
065    */
066   public ReferencedDocument(String identifier) {
067      super();
068      this.id = identifier;
069   }
070
071   /**
072    * Gets the issue date time.
073    * 
074    * @return the issue date time
075    */
076   @Comfort
077   public Date getIssued() {
078      return new Date(issued.getTime());
079   }
080
081   /**
082    * Sets the issue date time.
083    * 
084    * @param issued the new issue date time
085    * @return the referenced document
086    */
087   public ReferencedDocument setIssued(Date issued) {
088      this.issued = new Date(issued.getTime());
089      return this;
090   }
091
092   /**
093    * Sets the reference document identifier.
094    * 
095    * Examples:: Order number, document number, number of customer order, delivery note numbers
096    *
097    * @param referenceDocumentIdentifier the id of the document
098    * @return the referenced document
099    */
100   public ReferencedDocument setId(String referenceDocumentIdentifier) {
101      id = referenceDocumentIdentifier;
102      return this;
103   }
104
105   /**
106    * Gets the identifier.
107    * 
108    * Examples:: Order number, document number, number of customer order, delivery note numbers
109    * 
110    * @return the id the identifier of the referenced document
111    */
112   @Comfort
113   @NotBlank(groups = Comfort.class)
114   public String getId() {
115      return id;
116   }
117}