View Javadoc

1   /*
2    ORDI - Ontology Repository and Data Integration
3   
4    Copyright (c) 2004-2007, OntoText Lab. / SIRMA
5   
6    This library is free software; you can redistribute it and/or modify it under
7    the terms of the GNU Lesser General Public License as published by the Free
8    Software Foundation; either version 2.1 of the License, or (at your option)
9    any later version.
10   This library is distributed in the hope that it will be useful, but WITHOUT
11   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12   FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13   details.
14   You should have received a copy of the GNU Lesser General Public License along
15   with this library; if not, write to the Free Software Foundation, Inc.,
16   59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17   */
18  package com.ontotext.ordi.tripleset;
19  
20  import java.util.List;
21  
22  import org.openrdf.model.Resource;
23  import org.openrdf.model.URI;
24  import org.openrdf.model.Value;
25  import org.openrdf.query.BindingSet;
26  import org.openrdf.query.Dataset;
27  import org.openrdf.query.algebra.TupleExpr;
28  
29  import com.ontotext.ordi.Connection;
30  import com.ontotext.ordi.exception.ORDIException;
31  import com.ontotext.ordi.iterator.CloseableIterator;
32  
33  /**
34   * Connection to data source to support tripleset data model.
35   * 
36   * @author vassil
37   * 
38   */
39  public interface TConnection extends Connection {
40  
41      /**
42       * Adds a new statement.
43       * 
44       * @return the newly added statement to the store
45       * @throws ORDIException
46       */
47      public TStatement addStatement(Resource subj, URI pred, Value obj,
48              URI namedGraph) throws ORDIException;
49  
50      /**
51       * Adds a new statement and associated it with a collection of tripleses.
52       * 
53       * @return the newly added statement to the store
54       * @throws ORDIException
55       */
56      public TStatement addStatement(Resource subj, URI pred, Value obj,
57              URI namedGraph, URI... ts) throws ORDIException;
58  
59      /**
60       * Removes one or multiple statements.
61       * 
62       * @return the number of deleted statements
63       * @throws ORDIException
64       */
65      public int removeStatement(Resource subj, URI pred, Value obj,
66              URI namedGraph) throws ORDIException;
67  
68      /**
69       * Associates one or multiple statements.
70       * 
71       * @return the number of newly associated statements
72       */
73      public int associateTripleset(Resource subj, URI pred, Value obj,
74              URI namedGraph, URI... ts);
75  
76      /**
77       * Deassociates one or multiple statements.
78       * 
79       * @return the number of modified statements
80       */
81      public int deassociateTripleset(Resource subj, URI pred, Value obj,
82              URI namedGraph, URI... ts);
83  
84      /**
85       * Gets all statements based on a pattern match.
86       * 
87       * @return iterator to the matched statements
88       * @throws ORDIException
89       */
90      public CloseableIterator<? extends TStatement> search(Resource subj,
91              URI pred, Value obj, URI namedgraph, URI ts) throws ORDIException;
92  
93      /**
94       * Gets iterator to specific type of values.
95       * 
96       * @param uri
97       *            of the value types
98       * @return iterators to all values of the specified type
99       * @throws ORDIException
100      */
101     public CloseableIterator<? extends Value> getValuesOfType(URI uri)
102             throws ORDIException;
103 
104     /**
105      * Adds a new connection listener.
106      * 
107      * @param listener
108      */
109     public void addListener(Listener listener);
110 
111     /**
112      * Removes previously associated connection listener.
113      * 
114      * @param listener
115      */
116     public void removeListener(Listener listener);
117 
118     /**
119      * Lists all associated connection listeners.
120      * 
121      * @return list of listeners
122      */
123     public List<Listener> listListeners();
124 
125     /**
126      * Evaluates abstract query expression and executes it.
127      * 
128      * @param tupleExpr
129      *            abstract query expression
130      * @param bindings
131      *            the keys reference variables to be bound to result values
132      * @param includeInferred
133      *            to include inferred statements in the result
134      * @return result object
135      * @throws ORDIException
136      */
137     @Deprecated
138     public CloseableIterator<? extends BindingSet> evaluate(
139             TupleExpr tupleExpr, BindingSet bindings, boolean includeInferred)
140             throws ORDIException;
141 
142     public CloseableIterator<? extends BindingSet> evaluate(
143             TupleExpr tupleExpr, BindingSet bindings, Dataset dataset,
144             boolean includeInferred, URI tripleset) throws ORDIException;
145 }