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