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.carriage.pdfbox.xmp; 019 020import org.apache.xmpbox.XMPMetadata; 021import org.apache.xmpbox.schema.PDFAExtensionSchema; 022import org.apache.xmpbox.schema.XMPSchema; 023import org.apache.xmpbox.type.Cardinality; 024import org.apache.xmpbox.type.PropertyType; 025import org.apache.xmpbox.type.StructuredType; 026import org.apache.xmpbox.type.TextType; 027import org.apache.xmpbox.type.Types; 028 029/** 030 * @author Vadim Bauer 031 * 032 */ 033/** 034 * 035 * The Class XMP ZUGFeRD Schema. 036 * 037 * This is an example of the result:: 038 * <pre><code> 039 * <rdf:Description rdf:about="" xmlns:zf="urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#"> 040 * <zf:ConformanceLevel>BASIC</zf:ConformanceLevel> 041 * <zf:DocumentFileName>ZUGFeRD-invoice.xml</zf:DocumentFileName> 042 * <zf:DocumentType>INVOICE</zf:DocumentType> 043 * <zf:Version>1.0</zf:Version> 044 * </rdf:Description> 045 *</code></pre> 046 */ 047@StructuredType(preferedPrefix = "zf", namespace = "urn:ferd:pdfa:CrossIndustryDocument:invoice:1p0#") 048public class XMPSchemaZugferd1p0 extends PDFAExtensionSchema { 049 050 /** The Constant CONFORMANCE_LEVEL. */ 051 @PropertyType(type = Types.Text, card = Cardinality.Simple) 052 public static final String CONFORMANCE_LEVEL = "ConformanceLevel"; 053 054 /** The Constant DOCUMENT_FILE_NAME. */ 055 @PropertyType(type = Types.Text, card = Cardinality.Simple) 056 public static final String DOCUMENT_FILE_NAME = "DocumentFileName"; 057 058 /** The Constant DOCUMENT_TYPE. */ 059 @PropertyType(type = Types.Text, card = Cardinality.Simple) 060 public static final String DOCUMENT_TYPE = "DocumentType"; 061 062 /** The Constant VERSION. */ 063 @PropertyType(type = Types.Text, card = Cardinality.Simple) 064 public static final String VERSION = "Version"; 065 066 @PropertyType(type = Types.PDFAType, card = Cardinality.Seq) 067 public static final String VALUE_TYPE = "valueType"; 068 069 /** 070 * Instantiates a new XMP schema ZUGFeRD 1.0. 071 * 072 * Set sensible default values 073 * 074 * @param metadata the parent XMP document that this schema will be part of. 075 */ 076 public XMPSchemaZugferd1p0(XMPMetadata metadata) { 077 super(metadata); 078 setDocumentType("INVOICE"); 079 setDocumentFileName("ZUGFeRD-invoice.xml"); 080 } 081 082 /** 083 * Instantiates a new XMP schema zugferd1p0. 084 * 085 * @param metadata the metadata 086 * @param customPrefix the user defined prefix that should differ from zf 087 */ 088 public XMPSchemaZugferd1p0(XMPMetadata metadata, String customPrefix) { 089 super(metadata, customPrefix); 090 } 091 092 /** 093 * Gets the ZUGFeRD conformance level. 094 * 095 * Possible values are: BASIC, COMFORT, EXTENDED 096 * 097 * @return the ZUGFeRD conformance level 098 */ 099 public TextType getConformanceLevelProperty() { 100 return (TextType) getProperty(CONFORMANCE_LEVEL); 101 } 102 103 /** 104 * Gets the ZUGFeRD conformance level. 105 * 106 * Possible values are: BASIC, COMFORT, EXTENDED 107 * 108 * @return the ZUGFeRD conformance level 109 */ 110 public String getConformanceLevel() { 111 TextType tt = getConformanceLevelProperty(); 112 return tt == null ? null : tt.getStringValue(); 113 } 114 115 /** 116 * Sets the ZUGFeRD conformance level. 117 * 118 * Possible values are: BASIC, COMFORT, EXTENDED 119 * 120 * @param conformanceLevel the ZUGFeRD conformance level 121 */ 122 public void setConformanceLevel(String conformanceLevel) { 123 addProperty(createTextType(CONFORMANCE_LEVEL, conformanceLevel)); 124 } 125 126 /** 127 * Gets the ZUGFeRD document file name. 128 * 129 * Currently known value is ZUGFeRD-invoice.xml 130 * 131 * @return the document file name 132 */ 133 public TextType getDocumentFileNameProperty() { 134 return (TextType) getProperty(DOCUMENT_FILE_NAME); 135 } 136 137 /** 138 * Gets the ZUGFeRD document file name. 139 * 140 * Currently known value is ZUGFeRD-invoice.xml 141 * 142 * @return the document file name 143 */ 144 public String getDocumentFileName() { 145 TextType tt = getDocumentFileNameProperty(); 146 return tt == null ? null : tt.getStringValue(); 147 } 148 149 /** 150 * Sets the ZUGFeRD document file name. 151 * 152 * Currently known value is ZUGFeRD-invoice.xml 153 * 154 * @param documentFileName the new document file name 155 */ 156 public void setDocumentFileName(String documentFileName) { 157 addProperty(createTextType(DOCUMENT_FILE_NAME, documentFileName)); 158 } 159 160 /** 161 * Gets the ZUGFeRD document type. 162 * 163 * As of writing only INVOICE is supported 164 * 165 * @return the ZUGFeRD document type 166 */ 167 public TextType getDocumentTypeProperty() { 168 return (TextType) getProperty(DOCUMENT_TYPE); 169 170 } 171 172 /** 173 * Gets the ZUGFeRD document type. 174 * 175 * As of writing only INVOICE is supported 176 * 177 * @return the document type 178 */ 179 public String getDocumentType() { 180 TextType tt = getDocumentTypeProperty(); 181 return tt == null ? null : tt.getStringValue(); 182 } 183 184 /** 185 * Sets the ZUGFeRD document type. 186 * 187 * As of writing only INVOICE is supported 188 * 189 * @param documentType the new document file name 190 */ 191 public void setDocumentType(String documentType) { 192 addProperty(createTextType(DOCUMENT_TYPE, documentType)); 193 } 194 195 /** 196 * Gets the version. 197 * 198 * @return the version 199 */ 200 public TextType getVersionProperty() { 201 return (TextType) getProperty(VERSION); 202 } 203 204 /** 205 * Gets the version. 206 * 207 * @return the version 208 */ 209 public String getVersion() { 210 TextType tt = getVersionProperty(); 211 return tt == null ? null : tt.getStringValue(); 212 } 213 214 /** 215 * Sets the version. 216 * 217 * @param version the new version 218 */ 219 public void setVersion(String version) { 220 TextType textType = createTextType(VERSION, version); 221 addProperty(textType); 222 } 223 224}