Project

General

Profile

« Previous | Next » 

Revision 8839

Add PROV relationships to the Solr schema. Populate the fields using the RdfXmlSubprocessor

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/annotation/RdfXmlSubprocessor.java
20 20
import java.io.IOException;
21 21
import java.io.InputStream;
22 22
import java.net.MalformedURLException;
23
import java.net.URI;
24
import java.net.URISyntaxException;
23 25
import java.util.ArrayList;
24 26
import java.util.Arrays;
25 27
import java.util.Date;
......
129 131
    	// read the annotation
130 132
		InputStream source = toInputStream(rdfXmlDocument);
131 133
    	String name = indexDocument.getIdentifier();
134
    	
135
    	//Check if the identifier is a valid URI and if not, make it one by prepending "http://"
136
    	URI nameURI = new URI(name);
137
    	String scheme = nameURI.getScheme();
138
    	if((scheme == null) || (scheme.isEmpty())){
139
    		name = "http://" + name;
140
    	}
141
    	
132 142
    	boolean loaded = dataset.containsNamedModel(name);
133 143
		if (!loaded) {
134 144
			OntModel ontModel = ModelFactory.createOntologyModel();
metacat-index/src/main/resources/application-context-oa.xml
12 12
				<ref bean="annotation.characteristic" />
13 13
				<ref bean="annotation.creator" />
14 14
				<ref bean="prov.wasDerivedFrom" />
15
				
15
				<ref bean="prov.wasGeneratedBy" />
16
				<ref bean="prov.wasInformedBy" />
17
				<ref bean="prov.used" />
16 18
			</list>
17 19
		</property>	
18 20
	</bean>
19 21
	
20
	<bean id="prov.wasDerivedFrom" class="edu.ucsb.nceas.metacat.index.annotation.SparqlField">
21
		<constructor-arg name="name" value="wasDerivedFrom" />
22
		<constructor-arg name="query">
23
			<value>
24
				<![CDATA[
25
				PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
26
				PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
27
				PREFIX owl: <http://www.w3.org/2002/07/owl#> 
28
				PREFIX j.0: <http://www.w3.org/ns/prov#> 
29
				PREFIX ore: <http://www.openarchives.org/ore/terms/> 
30
				PREFIX dcterms: <http://purl.org/dc/terms/>
31

  
32
				SELECT ?pid ?wasDerivedFrom
33
				FROM <$GRAPH_NAME>
34
				WHERE { 
35
						
36
					?derived_data		j.0:wasDerivedFrom	?primary_data .
37
					?derived_data		dcterms:identifier 	?pid . 
38
					?primary_data		dcterms:identifier 	?wasDerivedFrom .
39
						
40
				 	} 
41
				 ]]>
42
			</value>
43
		</constructor-arg>
44
	</bean>
45
	
46 22
	<bean id="annotation.standard" class="edu.ucsb.nceas.metacat.index.annotation.SparqlField">
47 23
		<constructor-arg name="name" value="standard_sm" />
48 24
		<constructor-arg name="query">
......
139 115
		</constructor-arg>
140 116
		<!--property name="multivalue" value="false" /-->
141 117
	</bean>
118
	
119
	<bean id="prov.wasDerivedFrom" class="edu.ucsb.nceas.metacat.index.annotation.SparqlField">
120
		<constructor-arg name="name" value="wasDerivedFrom" />
121
		<constructor-arg name="query">
122
			<value>
123
				<![CDATA[
124
				PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
125
				PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
126
				PREFIX owl: <http://www.w3.org/2002/07/owl#> 
127
				PREFIX prov: <http://www.w3.org/ns/prov#> 
128
				PREFIX ore: <http://www.openarchives.org/ore/terms/> 
129
				PREFIX dcterms: <http://purl.org/dc/terms/>
142 130

  
131
				SELECT (str(?pidValue) as ?pid) (str(?wasDerivedFromValue) as ?wasDerivedFrom)
132
				FROM <$GRAPH_NAME>
133
				WHERE { 
134
						
135
					?derived_data		prov:wasDerivedFrom	?primary_data .
136
					?derived_data		dcterms:identifier 	?pidValue . 
137
					?primary_data		dcterms:identifier 	?wasDerivedFromValue .
138
						
139
				 	} 
140
				 ]]>
141
			</value>
142
		</constructor-arg>
143
	</bean>
144
	
145
	<bean id="prov.wasGeneratedBy" class="edu.ucsb.nceas.metacat.index.annotation.SparqlField">
146
		<constructor-arg name="name" value="wasGeneratedBy" />
147
		<constructor-arg name="query">
148
			<value>
149
				<![CDATA[
150
				PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
151
				PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
152
				PREFIX owl: <http://www.w3.org/2002/07/owl#> 
153
				PREFIX prov: <http://www.w3.org/ns/prov#> 
154
				PREFIX ore: <http://www.openarchives.org/ore/terms/> 
155
				PREFIX dcterms: <http://purl.org/dc/terms/>
156

  
157
				SELECT (str(?pidValue) as ?pid) (str(?wasGeneratedByValue) as ?wasGeneratedBy)
158
				FROM <$GRAPH_NAME>
159
				WHERE { 
160
						
161
					?result			prov:wasGeneratedBy	?activity .
162
					?result			dcterms:identifier	?pidValue . 
163
					?activity		dcterms:identifier	?wasGeneratedByValue .
164
						
165
				 	} 
166
				 ]]>
167
			</value>
168
		</constructor-arg>
169
	</bean>
170
	
171
	<bean id="prov.wasInformedBy" class="edu.ucsb.nceas.metacat.index.annotation.SparqlField">
172
		<constructor-arg name="name" value="wasInformedBy" />
173
		<constructor-arg name="query">
174
			<value>
175
				<![CDATA[
176
				PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
177
				PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
178
				PREFIX owl: <http://www.w3.org/2002/07/owl#> 
179
				PREFIX prov: <http://www.w3.org/ns/prov#> 
180
				PREFIX ore: <http://www.openarchives.org/ore/terms/> 
181
				PREFIX dcterms: <http://purl.org/dc/terms/>
182

  
183
				SELECT (str(?pidValue) as ?pid) (str(?wasInformedByValue) as ?wasInformedBy)
184
				FROM <$GRAPH_NAME>
185
				WHERE { 
186
						
187
					?activity				prov:wasInformedBy	?previousActivity .
188
					?activity				dcterms:identifier	?pidValue . 
189
					?previousActivity		dcterms:identifier	?wasInformedByValue .
190
						
191
				 	} 
192
				 ]]>
193
			</value>
194
		</constructor-arg>
195
	</bean>
196
	
197
	<bean id="prov.used" class="edu.ucsb.nceas.metacat.index.annotation.SparqlField">
198
		<constructor-arg name="name" value="used" />
199
		<constructor-arg name="query">
200
			<value>
201
				<![CDATA[
202
				PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
203
				PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> 
204
				PREFIX owl: <http://www.w3.org/2002/07/owl#> 
205
				PREFIX prov: <http://www.w3.org/ns/prov#> 
206
				PREFIX ore: <http://www.openarchives.org/ore/terms/> 
207
				PREFIX dcterms: <http://purl.org/dc/terms/>
208

  
209
				SELECT (str(?pidValue) as ?pid) (str(?usedValue) as ?used)
210
				FROM <$GRAPH_NAME>
211
				WHERE { 
212
						
213
					?activity		prov:used			?data .
214
					?activity		dcterms:identifier	?pidValue . 
215
					?data			dcterms:identifier	?usedValue .
216
						
217
				 	} 
218
				 ]]>
219
			</value>
220
		</constructor-arg>
221
	</bean>
222

  
143 223
</beans>

Also available in: Unified diff