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", enums = "NTRIPLES,TURTLE,NQUADS,RDFXML,JSONLD,RDFJSON,RDF4JMODEL",
044              javaType = "org.apache.camel.dataformat.any23.Any23OutputFormat")
045    private String outputFormat;
046    @XmlJavaTypeAdapter(PropertyDescriptionsAdapter.class)
047    private Map<String, String> configuration = new HashMap<>();
048    @XmlElement
049    private List<String> extractors;
050    @XmlAttribute
051    private String baseURI;
052
053    public Any23DataFormat() {
054        super("any23");
055    }
056
057    public Any23DataFormat(String baseuri) {
058        this();
059        this.baseURI = baseuri;
060    }
061
062    public Any23DataFormat(String baseuri, Any23Type outputFormat) {
063        this(baseuri);
064        this.outputFormat = outputFormat.name();
065    }
066
067    public Any23DataFormat(String baseuri, Any23Type outputFormat, Map<String, String> configurations) {
068        this(baseuri, outputFormat);
069        this.outputFormat = outputFormat.name();
070        this.configuration = configurations;
071    }
072
073    public Any23DataFormat(String baseuri, Any23Type outputFormat, Map<String, String> configurations, List<String> extractors) {
074        this(baseuri, outputFormat, configurations);
075        this.outputFormat = outputFormat.name();
076        this.configuration = configurations;
077        this.extractors = extractors;
078    }
079
080    public String getOutputFormat() {
081        return outputFormat;
082    }
083
084    /**
085     * What RDF syntax to unmarshal as, can be: NTRIPLES, TURTLE, NQUADS,
086     * RDFXML, JSONLD, RDFJSON, RDF4JMODEL. It is by default: RDF4JMODEL.
087     */
088    public void setOutputFormat(String outputFormat) {
089        this.outputFormat = outputFormat;
090    }
091
092    public Map<String, String> getConfiguration() {
093        return configuration;
094    }
095
096    /**
097     * Configurations for Apache Any23 as key-value pairs in order to customize
098     * the extraction process. The list of supported parameters can be found
099     * <a href=
100     * "https://github.com/apache/any23/blob/master/api/src/main/resources/default-configuration.properties">here</a>.
101     * If not provided, a default configuration is used.
102     */
103    public void setConfiguration(Map<String, String> configurations) {
104        this.configuration = configurations;
105    }
106
107    public List<String> getExtractors() {
108        return extractors;
109    }
110
111    /**
112     * List of Any23 extractors to be used in the unmarshal operation. A list of
113     * the available extractors can be found here
114     * <a href="https://any23.apache.org/getting-started.html">here</a>. If not
115     * provided, all the available extractors are used.
116     */
117    public void setExtractors(List<String> extractors) {
118        this.extractors = extractors;
119    }
120
121    public String getBaseURI() {
122        return baseURI;
123    }
124
125    /**
126     * The URI to use as base for building RDF entities if only relative paths
127     * are provided.
128     */
129    public void setBaseURI(String baseURI) {
130        this.baseURI = baseURI;
131    }
132
133}