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.mapper.rdbms;
19  
20  import org.openrdf.model.Resource;
21  import org.openrdf.model.URI;
22  import org.openrdf.model.Value;
23  
24  import com.ontotext.ordi.mapper.model.DataHandler;
25  import com.ontotext.ordi.mapper.model.MapperDescriptor;
26  import com.ontotext.ordi.mapper.model.PredicatePattern;
27  import com.ontotext.ordi.mapper.processor.RDFResultManager;
28  
29  public abstract class PredicatePatternBase implements PredicatePattern {
30  
31      protected URI predicate;
32      protected URI namedGraph;
33      protected String query;
34      protected DataHandler subjectHandler;
35      protected DataHandler objectHandler;
36      protected MapperDescriptor descriptor;
37      protected URI dataSource;
38  
39      public PredicatePatternBase(MapperDescriptor descriptor,
40              DataHandler subjectHandler, DataHandler objectHandler,
41              URI predicate, URI namedGraph, String query, URI dataSource) {
42          if (descriptor == null || subjectHandler == null
43                  || objectHandler == null || predicate == null
44                  || dataSource == null) {
45              throw new IllegalArgumentException();
46          }
47          this.subjectHandler = subjectHandler;
48          this.objectHandler = objectHandler;
49          this.descriptor = descriptor;
50          this.namedGraph = namedGraph;
51          this.predicate = predicate;
52          this.query = query;
53          this.dataSource = dataSource;
54      }
55  
56      public URI getPredicate() {
57          return predicate;
58      }
59  
60      public URI getNamedGraph() {
61          return namedGraph;
62      }
63  
64      public String getQuery() {
65          return query;
66      }
67  
68      public DataHandler getSubjectHandler() {
69          return subjectHandler;
70      }
71  
72      public DataHandler getObjectHandler() {
73          return objectHandler;
74      }
75  
76      public MapperDescriptor getMapperDescriptor() {
77          return descriptor;
78      }
79  
80      public URI getDataSource() {
81          return dataSource;
82      }
83  
84      public abstract void execute(Resource subject, URI pred, Value value,
85              URI namedGraph, RDFResultManager resultHandler);
86  
87      public abstract boolean isValid();
88  }