-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathStdTriplesMap.java
More file actions
117 lines (97 loc) · 3.51 KB
/
StdTriplesMap.java
File metadata and controls
117 lines (97 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
* Copyright 2011 Antidot opensource@antidot.net
* https://github.com/antidot/db2triples
*
* DB2Triples is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* DB2Triples is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/***************************************************************************
*
* R2RML Model : Standard TriplesMap Class
*
* A triples map specifies a rule for translating each
* row of a logical table to zero or more RDF triples.
*
****************************************************************************/
package be.ugent.mmlab.rml.model;
import java.util.HashSet;
import java.util.Set;
import net.antidot.semantic.rdf.rdb2rdf.r2rml.exception.InvalidR2RMLStructureException;
public class StdTriplesMap implements TriplesMap {
private Set<PredicateObjectMap> predicateObjectMaps;
private SubjectMap subjectMap;
private LogicalSource logicalSource;
private String name;
private String guard;
public StdTriplesMap(LogicalSource logicalSource,
Set<StdPredicateObjectMap> predicateObjectMaps,
StdSubjectMap subjectMap, String name,String guard) throws InvalidR2RMLStructureException {
setSubjectMap(subjectMap);
setLogicalSource(logicalSource);
setPredicateObjectMap(predicateObjectMaps);
setName(name);
setGuardObjectMap(guard);
}
private void setGuardObjectMap(String guard) {
this.guard=guard;
}
public void setLogicalSource(LogicalSource logicalTable) {
/*if (logicalTable == null)
throw new InvalidR2RMLStructureException(
"[StdTriplesMap:setLogicalTable] A logical table is required.");*/
this.logicalSource = logicalTable;
}
public void setPredicateObjectMap(
Set<StdPredicateObjectMap> predicateObjectMaps) {
this.predicateObjectMaps = new HashSet<PredicateObjectMap>();
if (predicateObjectMaps == null) return;
this.predicateObjectMaps.addAll(predicateObjectMaps);
// Update prediacte object map
for (PredicateObjectMap pom : predicateObjectMaps) {
if (pom.getOwnTriplesMap() != null) {
if (pom.getOwnTriplesMap() != this)
throw new IllegalStateException(
"[StdTriplesMap:setPredicateObjectMap] "
+ "The predicateObject map child "
+ "already contains another triples Map !");
} else
pom.setOwnTriplesMap(this);
}
}
public LogicalSource getLogicalSource() {
return logicalSource;
}
public Set<PredicateObjectMap> getPredicateObjectMaps() {
return predicateObjectMaps;
}
public SubjectMap getSubjectMap() {
return subjectMap;
}
public void setSubjectMap(SubjectMap subjectMap) throws InvalidR2RMLStructureException {
/*if (subjectMap == null)
throw new InvalidR2RMLStructureException(
"[StdTriplesMap:setLogicalTable] A subject map is required.");*/
this.subjectMap = subjectMap;
}
public void addPredicateObjectMap(PredicateObjectMap predicateObjectMap) {
if (predicateObjectMap != null)
predicateObjectMaps.add(predicateObjectMap);
}
public String getName() {
return this.name;
}
public void setName(String name) {
if (name != null)
this.name = name;
}
}