001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel.model.dataformat; 018 019import java.util.HashMap; 020import java.util.List; 021import java.util.Map; 022 023import javax.xml.bind.annotation.XmlAccessType; 024import javax.xml.bind.annotation.XmlAccessorType; 025import javax.xml.bind.annotation.XmlAttribute; 026import javax.xml.bind.annotation.XmlElement; 027import javax.xml.bind.annotation.XmlRootElement; 028import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 029 030import org.apache.camel.model.DataFormatDefinition; 031import org.apache.camel.model.PropertyDescriptionsAdapter; 032import org.apache.camel.spi.Metadata; 033 034/** 035 * Any23 data format is used for parsing data to RDF. 036 */ 037@Metadata(firstVersion = "3.0.0", label = "dataformat,transformation", title = "Any23") 038@XmlRootElement(name = "any23") 039@XmlAccessorType(XmlAccessType.FIELD) 040public class Any23DataFormat extends DataFormatDefinition { 041 042 @XmlAttribute 043 @Metadata(defaultValue = "RDF4JMODEL") 044 private Any23Type outputFormat; 045 @XmlJavaTypeAdapter(PropertyDescriptionsAdapter.class) 046 private Map<String, String> configuration = new HashMap<String, String>(); 047 @XmlElement 048 private List<String> extractors; 049 @XmlAttribute 050 private String baseURI; 051 052 public Any23DataFormat() { 053 super("any23"); 054 } 055 056 public Any23DataFormat(String baseuri) { 057 this(); 058 this.baseURI = baseuri; 059 } 060 061 public Any23DataFormat(String baseuri, Any23Type outputFormat) { 062 this(baseuri); 063 this.outputFormat = outputFormat; 064 } 065 066 public Any23DataFormat(String baseuri, Any23Type outputFormat, Map<String, String> configurations) { 067 this(baseuri, outputFormat); 068 this.outputFormat = outputFormat; 069 this.configuration = configurations; 070 } 071 072 public Any23DataFormat(String baseuri, Any23Type outputFormat, Map<String, String> configurations, List<String> extractors) { 073 this(baseuri, outputFormat, configurations); 074 this.outputFormat = outputFormat; 075 this.configuration = configurations; 076 this.extractors = extractors; 077 } 078 079 public Any23Type getOutputFormat() { 080 return outputFormat; 081 } 082 083 /** 084 * What RDF syntax to unmarshal as, can be: NTRIPLES, TURTLE, NQUADS, 085 * RDFXML, JSONLD, RDFJSON, RDF4JMODEL. It is by default: RDF4JMODEL. 086 */ 087 public void setOutputFormat(Any23Type outputFormat) { 088 this.outputFormat = outputFormat; 089 } 090 091 public Map<String, String> getConfiguration() { 092 return configuration; 093 } 094 095 /** 096 * Configurations for Apache Any23 as key-value pairs in order to customize 097 * the extraction process. The list of supported parameters can be found 098 * <a href= 099 * "https://github.com/apache/any23/blob/master/api/src/main/resources/default-configuration.properties">here</a>. 100 * If not provided, a default configuration is used. 101 */ 102 public void setConfiguration(Map<String, String> configurations) { 103 this.configuration = configurations; 104 } 105 106 public List<String> getExtractors() { 107 return extractors; 108 } 109 110 /** 111 * List of Any23 extractors to be used in the unmarshal operation. A list of 112 * the available extractors can be found here 113 * <a href="https://any23.apache.org/getting-started.html">here</a>. If not 114 * provided, all the available extractors are used. 115 */ 116 public void setExtractors(List<String> extractors) { 117 this.extractors = extractors; 118 } 119 120 public String getBaseURI() { 121 return baseURI; 122 } 123 124 /** 125 * The URI to use as base for building RDF entities if only relative paths 126 * are provided. 127 */ 128 public void setBaseURI(String baseURI) { 129 this.baseURI = baseURI; 130 } 131 132}