53
53
import org .apache .jena .rdfconnection .RDFConnectionFactory ;
54
54
import org .apache .jena .riot .Lang ;
55
55
import org .apache .jena .riot .RDFDataMgr ;
56
+ import org .apache .jena .riot .RDFLanguages ;
56
57
import org .apache .jena .riot .out .SinkQuadOutput ;
57
58
import org .apache .jena .riot .out .SinkTripleOutput ;
58
59
import org .apache .jena .shared .PrefixMapping ;
@@ -100,6 +101,10 @@ public interface FLOW_FILE_CONTENTS {
100
101
public static final AllowableValue NON_RDF_DATA = new AllowableValue (FLOW_FILE_CONTENTS .NON_RDF_DATA );
101
102
public static final AllowableValue EMPTY = new AllowableValue (FLOW_FILE_CONTENTS .EMPTY );
102
103
104
+ public static final AllowableValue TURTLE = new AllowableValue (Lang .TURTLE .getLabel ());
105
+ public static final AllowableValue NT = new AllowableValue (Lang .NT .getLabel ());
106
+ public static final AllowableValue JSONLD = new AllowableValue (Lang .JSONLD .getLabel ());
107
+
103
108
public static final PropertyDescriptor BASE_URI = new PropertyDescriptor .Builder ()
104
109
.name ("BASE_URI" )
105
110
.displayName ("Base URI" )
@@ -116,9 +121,18 @@ public interface FLOW_FILE_CONTENTS {
116
121
.addValidator (StandardValidators .NON_BLANK_VALIDATOR )
117
122
.build ();
118
123
124
+ public static final PropertyDescriptor RDF_DATA_INPUT_SYNTAX = new PropertyDescriptor .Builder ()
125
+ .name ("RDF_DATA_INPUT_SYNTAX" )
126
+ .displayName ("RDF Data Input Syntax" )
127
+ .description ("RDF-Syntax of the FlowFile content, only used when Content of flow file is set to rdf-data" )
128
+ .addValidator (StandardValidators .NON_BLANK_VALIDATOR )
129
+ .allowableValues (TURTLE , NT , JSONLD )
130
+ .defaultValue (TURTLE .getValue ())
131
+ .build ();
132
+
119
133
public static final PropertyDescriptor CONTENT_FLOW_FILE = new PropertyDescriptor .Builder ()
120
- .name ("Content of FlowFile " )
121
- .displayName ("Content of the processors input FlowFile" )
134
+ .name ("CONTENT_FLOW_FILE " )
135
+ .displayName ("Content of FlowFile" )
122
136
.description ("Content of the processors input FlowFile" )
123
137
.required (true )
124
138
.addValidator (StandardValidators .NON_BLANK_VALIDATOR )
@@ -138,6 +152,7 @@ protected void init(final ProcessorInitializationContext context) {
138
152
final List <PropertyDescriptor > descriptors = new ArrayList <PropertyDescriptor >();
139
153
descriptors .add (BASE_URI );
140
154
descriptors .add (CONTENT_FLOW_FILE );
155
+ descriptors .add (RDF_DATA_INPUT_SYNTAX );
141
156
descriptors .add (SPARQL_QUERY_PROPERTY );
142
157
this .descriptors = Collections .unmodifiableList (descriptors );
143
158
@@ -165,6 +180,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
165
180
166
181
final String contentFlowFile = context .getProperty (CONTENT_FLOW_FILE ).getValue ();
167
182
final String baseUri = context .getProperty (BASE_URI ).getValue ();
183
+ final String rdfDataInputSyntax = context .getProperty (RDF_DATA_INPUT_SYNTAX ).getValue ();
168
184
final AtomicReference <Stream <SparqlStmt >> stmts = new AtomicReference <>();
169
185
170
186
FlowFile flowFile = session .get ();
@@ -193,7 +209,7 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
193
209
session .read (flowFile , new InputStreamCallback () {
194
210
@ Override
195
211
public void process (InputStream in ) throws IOException {
196
- RDFDataMgr .read (dataset , in , baseUri , Lang . TURTLE );
212
+ RDFDataMgr .read (dataset , in , baseUri , RDFLanguages . nameToLang ( rdfDataInputSyntax ) );
197
213
}
198
214
});
199
215
break ;
0 commit comments