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;
022
023import java.util.Date;
024
025import javax.validation.constraints.NotNull;
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   public Date getIssued() {
077      return new Date(issued.getTime());
078   }
079
080   /**
081    * Sets the issue date time.
082    * 
083    * @param issued the new issue date time
084    * @return the referenced document
085    */
086   public ReferencedDocument setIssued(Date issued) {
087      this.issued = new Date(issued.getTime());
088      return this;
089   }
090
091   /**
092    * Sets the reference document identifier.
093    * 
094    * Examples:: Order number, document number, number of customer order, delivery note numbers
095    *
096    * @param referenceDocumentIdentifier the id of the document
097    * @return the referenced document
098    */
099   public ReferencedDocument setId(String referenceDocumentIdentifier) {
100      id = referenceDocumentIdentifier;
101      return this;
102   }
103
104   /**
105    * Gets the identifier.
106    * 
107    * Examples:: Order number, document number, number of customer order, delivery note numbers
108    * 
109    * @return the id the identifier of the referenced document
110    */
111   @NotNull(groups = Comfort.class)
112   public String getId() {
113      return id;
114   }
115}