1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package com.ontotext.ordi.rdbms;
19
20 import java.util.ArrayList;
21
22 import org.openrdf.model.Resource;
23 import org.openrdf.model.URI;
24 import org.openrdf.model.Value;
25
26 import com.ontotext.ordi.exception.ORDIException;
27 import com.ontotext.ordi.exception.ORDIReadOnlyException;
28 import com.ontotext.ordi.iterator.CloseableIterator;
29 import com.ontotext.ordi.iterator.CloseableIteratorImpl;
30 import com.ontotext.ordi.tripleset.TStatement;
31 import com.ontotext.ordi.tripleset.impl.TQueryConnectionImpl;
32 import com.ontotext.ordi.mapper.processor.Processor;
33 import com.ontotext.ordi.mapper.model.RDFResultSet;
34
35 public class RDBMSConnection extends TQueryConnectionImpl {
36
37 private static final String READ_ONLY_ERROR = "The source does not support write operations!";
38 private Processor processor;
39 private RDBMSAdapter source;
40
41 public RDBMSConnection(RDBMSAdapter source, Processor processor) {
42 super(source);
43 if (processor == null) {
44 throw new IllegalArgumentException();
45 }
46 this.processor = processor;
47 this.source = source;
48 }
49
50 public TStatement addStatement(Resource subj, URI pred, Value obj,
51 URI namedGraph) throws ORDIException {
52 throw new ORDIReadOnlyException(READ_ONLY_ERROR);
53 }
54
55 public TStatement addStatement(Resource subj, URI pred, Value obj,
56 URI namedGraph, URI... ts) throws ORDIException {
57 throw new ORDIReadOnlyException(READ_ONLY_ERROR);
58 }
59
60 public int associateTripleset(Resource subj, URI pred, Value obj,
61 URI namedGraph, URI... ts) {
62 return 0;
63 }
64
65 public int deassociateTripleset(Resource subj, URI pred, Value obj,
66 URI namedGraph, URI... ts) {
67 return 0;
68 }
69
70 public CloseableIterator<? extends Value> getValuesOfType(URI uri)
71 throws ORDIException {
72 return new CloseableIteratorImpl<Value>(new ArrayList<Value>()
73 .iterator());
74 }
75
76 public int removeStatement(Resource subj, URI pred, Value obj,
77 URI namedGraph) throws ORDIException {
78 throw new ORDIReadOnlyException(READ_ONLY_ERROR);
79 }
80
81 public CloseableIterator<? extends TStatement> search(Resource subj,
82 URI pred, Value obj, URI namedGraph, URI ts) throws ORDIException {
83 RDFResultSet resultSet = processor
84 .evaluate(subj, pred, obj, namedGraph);
85 RDBMSCloseableIterator iterator = new RDBMSCloseableIterator(resultSet,
86 source.getTriplesetFactory());
87 return iterator;
88 }
89
90 public boolean isOpen() {
91 return true;
92 }
93
94 public boolean isReadOnly() {
95 return true;
96 }
97 }