Revision 45819
Added by Giorgos Alexiou about 7 years ago
RDFizer.java | ||
---|---|---|
86 | 86 |
|
87 | 87 |
if(i==0){ |
88 | 88 |
String resourceType = propertyObject.getString(propertyString); |
89 |
// insertQuery+="<"+resourceURI+"> <"+propertyString+"> <"+resourceType+">"; |
|
90 | 89 |
buildQuery[0]+="<"+resourceURI+"> <"+propertyString+"> <"+resourceType+">"; |
91 | 90 |
continue; |
92 | 91 |
} |
... | ... | |
103 | 102 |
String countryURI = mapCountries.getCountryURI(value); |
104 | 103 |
URI uri = new URI(countryURI); |
105 | 104 |
if(countryURI.equals("")){ |
106 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
107 | 105 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
108 | 106 |
continue; |
109 | 107 |
} |
110 |
// insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
111 | 108 |
buildQuery[0]+="; <"+propertyString+"> <"+uri+">"; |
112 |
// log.info("COUNTRY "+countryURI+" FROM "+value); |
|
113 | 109 |
}catch(Exception e){ |
114 | 110 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
115 |
// log.error("No country URI for: "+e.toString(),e); |
|
116 | 111 |
continue; |
117 | 112 |
} |
118 | 113 |
continue; |
119 | 114 |
} |
120 | 115 |
|
121 |
if(i==9 && type.equals("result") && !value.equals("und")){
|
|
116 |
if(type.equals("result") && i==9 && !value.equals("und")){
|
|
122 | 117 |
try{ |
123 | 118 |
String langURI = mapLanguages.getLangURI(value); |
124 | 119 |
URI uri = new URI(langURI); |
125 | 120 |
if(langURI.equals("")){ |
126 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
127 | 121 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
128 | 122 |
continue; |
129 | 123 |
} |
130 |
// insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
131 | 124 |
buildQuery[0]+="; <"+propertyString+"> <"+uri+">"; |
132 |
// log.info("LANG "+langURI+" FROM "+value.trim()); |
|
133 | 125 |
}catch(Exception e){ |
134 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
135 | 126 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
136 |
// log.error("No Language URI for: "+e.toString(),e); |
|
137 | 127 |
continue; |
138 | 128 |
} |
139 | 129 |
continue; |
140 | 130 |
} |
141 | 131 |
|
132 |
if(type.equals("datasource") && i==21 && !value.equals("und") && !value.isEmpty()){ |
|
133 |
if(value.contains(conf.get("lod.seperator"))){ |
|
134 |
String[] splittedValue = value.split(conf.get("lod.seperator")); |
|
135 |
for(String v:splittedValue){ |
|
136 |
try{ |
|
137 |
String langURI = mapLanguages.getLangURI(v); |
|
138 |
URI uri = new URI(langURI); |
|
139 |
if(langURI.equals("")){ |
|
140 |
buildQuery[0]+="; <"+propertyString+"> \""+v+"\""; |
|
141 |
continue; |
|
142 |
} |
|
143 |
buildQuery[0]+="; <"+propertyString+"> <"+uri+">"; |
|
144 |
}catch(Exception e){ |
|
145 |
buildQuery[0]+="; <"+propertyString+"> \""+v+"\""; |
|
146 |
continue; |
|
147 |
} |
|
148 |
} |
|
149 |
continue; |
|
150 |
} |
|
151 |
} |
|
152 |
|
|
142 | 153 |
if(value.contains(conf.get("lod.seperator"))){ |
143 | 154 |
String[] splittedValue = value.split(conf.get("lod.seperator")); |
144 | 155 |
for(String v:splittedValue){ |
145 | 156 |
v= v.replace(conf.get("lod.seperator"), "").trim(); |
146 |
// insertQuery+="; <"+propertyString+"> \""+v+"\""; |
|
147 | 157 |
buildQuery[0]+="; <"+propertyString+"> \""+v+"\""; |
148 | 158 |
} |
149 | 159 |
}else{ |
150 | 160 |
if(value.startsWith("http://")){ |
151 | 161 |
try{ |
152 | 162 |
if(value.contains(" ")){ |
153 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
154 | 163 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
155 |
|
|
156 | 164 |
}else{ |
157 | 165 |
value = value.replaceAll("\\s","-"); |
158 | 166 |
URI uri = new URI(value); |
159 |
// insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
160 | 167 |
buildQuery[0]+="; <"+propertyString+"> <"+uri+">"; |
161 | 168 |
} |
162 | 169 |
}catch(Exception e){ |
163 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
164 | 170 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
165 |
// log.error("NOT URI "+e.toString(),e); |
|
166 | 171 |
continue; |
167 | 172 |
} |
168 | 173 |
} |
... | ... | |
171 | 176 |
|
172 | 177 |
} |
173 | 178 |
|
174 |
// insertQuery+=". "; |
|
175 | 179 |
buildQuery[0]+=". "; |
176 | 180 |
|
177 | 181 |
return buildQuery; |
178 | 182 |
|
179 | 183 |
} |
180 | 184 |
|
181 |
// public static String RDFizeRelationRow(List<String> row, VirtGraph graph, JSONObject mappings, Configuration conf){ |
|
182 | 185 |
public static String[] RDFizeRelationRow(List<String> row, JSONObject mappings, Configuration conf){ |
183 | 186 |
|
184 | 187 |
// String insertQuery = ""; |
... | ... | |
193 | 196 |
String property = typeMappings.getString("property"); |
194 | 197 |
String sourceURI = baseURI+row.get(Integer.parseInt(sourceType))+"/"+row.get(Integer.parseInt(sourceId)); |
195 | 198 |
String targetURI = baseURI+row.get(Integer.parseInt(targetType))+"/"+row.get(Integer.parseInt(targetId)); |
196 |
// insertQuery= "<"+sourceURI+"> <"+property+"> <"+targetURI+">. "; |
|
197 | 199 |
buildQuery[0]="<"+sourceURI+"> <"+property+"> <"+targetURI+">. "; |
198 |
// return insertQuery; |
|
199 | 200 |
return buildQuery; |
200 | 201 |
} |
201 | 202 |
|
... | ... | |
208 | 209 |
ResultSet rs=stmt.executeQuery(askQuery); |
209 | 210 |
if(rs.next()) exists=true; |
210 | 211 |
rs.close(); |
211 |
// if(rs.next()) exists=true; |
|
212 | 212 |
stmt.close(); |
213 |
// conn.commit(); |
|
214 | 213 |
conn.close(); |
215 | 214 |
} catch (Exception e) { |
216 | 215 |
log.error("Virtuoso ask Query failed. Query was: "+ askQuery +"\n" + e.toString(), e); |
... | ... | |
233 | 232 |
} |
234 | 233 |
|
235 | 234 |
public static void clearGraph(String graph, Connection conn){ |
236 |
String clearQuery="SPARQL DEFINE sql:log-enable 0 CLEAR GRAPH <"+graph+">";
|
|
235 |
String clearQuery="SPARQL DEFINE sql:log-enable 3 CLEAR GRAPH <"+graph+">";
|
|
237 | 236 |
Statement stmt; |
238 | 237 |
try { |
239 | 238 |
stmt = conn.createStatement(); |
240 | 239 |
stmt.execute(clearQuery); |
241 | 240 |
conn.commit(); |
242 | 241 |
stmt.close(); |
243 |
// conn.commit(); |
|
244 |
// conn.close(); |
|
245 | 242 |
} catch (Exception e) { |
246 | 243 |
log.error("Virtuoso FAILED TO CLEAR graph "+ clearQuery +"\n" + e.toString(), e); |
247 | 244 |
} |
... | ... | |
256 | 253 |
if(checkpointValue==120){ |
257 | 254 |
log.info("CheckPoint Started"); |
258 | 255 |
stmt.execute("checkpoint"); |
259 |
stmt.execute("log_enable(3,1)"); |
|
256 |
// stmt.execute("log_enable(3,1)");
|
|
260 | 257 |
conn.commit(); |
261 | 258 |
log.info("CheckPoint Finished"); |
262 | 259 |
} |
263 | 260 |
|
264 | 261 |
stmt.close(); |
265 |
// |
|
266 |
// conn.close(); |
|
267 | 262 |
} catch (Exception e) { |
268 | 263 |
log.error("Virtuoso set checkpoint failed. Checkpoint was "+ checkpointValue +"\n" + e.toString(), e); |
269 | 264 |
} |
270 | 265 |
} |
266 |
|
|
267 |
public static void autoIndexing(Connection conn, boolean state){ |
|
268 |
Statement stmt; |
|
269 |
String query=""; |
|
270 |
if(state) query = "DB.DBA.RDF_OBJ_FT_RULE_ADD (null, null, 'All')"; |
|
271 |
else query = "DB.DBA.VT_BATCH_UPDATE ('DB.DBA.RDF_OBJ', 'ON', NULL)"; |
|
272 |
try { |
|
273 |
stmt = conn.createStatement(); |
|
274 |
stmt.execute(query); |
|
275 |
log.info("autoIndex "+query); |
|
276 |
stmt.close(); |
|
277 |
} catch (Exception e) { |
|
278 |
log.error("Virtuoso autoIndexing failed. State was "+ query +"\n" + e.toString(), e); |
|
279 |
} |
|
280 |
|
|
281 |
} |
|
271 | 282 |
} |
Also available in: Unified diff
performance improvements + language to datasource