Revision 42719
Added by Giorgos Alexiou about 8 years ago
RDFizer.java | ||
---|---|---|
21 | 21 |
} |
22 | 22 |
|
23 | 23 |
// public static String RDFizeEntityRow(List<String> row,VirtGraph graph, JSONObject mappings, Configuration conf, MapCountries mapCountries,MapLanguages mapLanguages){ |
24 |
public static String RDFizeEntityRow(List<String> row,BoneCPDataSource ds, JSONObject mappings, Configuration conf, MapCountries mapCountries,MapLanguages mapLanguages, String defaultGraph){ |
|
24 |
public static String[] RDFizeEntityRow(List<String> row,BoneCPDataSource ds, JSONObject mappings, Configuration conf, MapCountries mapCountries,MapLanguages mapLanguages, String defaultGraph){
|
|
25 | 25 |
|
26 | 26 |
// VirtModel model = new VirtModel(graph); |
27 | 27 |
|
28 | 28 |
// String graph = conf.get("lod.defaultGraph"); |
29 | 29 |
|
30 |
String insertQuery =""; |
|
30 |
String[] buildQuery = new String[2]; |
|
31 |
buildQuery[0]=""; |
|
32 |
buildQuery[1]=""; |
|
33 |
|
|
34 |
// String insertQuery =""; |
|
35 |
// String deleteQuery=""; |
|
31 | 36 |
|
32 | 37 |
String baseURI = conf.get("lod.baseURI"); |
33 | 38 |
String id = row.get(1).toString(); |
... | ... | |
43 | 48 |
// log.error("Could not ASK "+e.toString(),e); |
44 | 49 |
// } |
45 | 50 |
// |
46 |
// |
|
51 |
|
|
52 |
|
|
53 |
buildQuery[1]+= "<"+resourceURI+"> ?p ?o. "; |
|
54 |
|
|
47 | 55 |
// if(ask){ |
48 |
try{ |
|
49 |
deleteResource(ds.getConnection(), resourceURI, defaultGraph); |
|
50 |
}catch(Exception e){ |
|
51 |
log.error("Could not DELETE "+resourceURI+" "+e.toString(),e); |
|
52 |
} |
|
56 |
// try{ |
|
57 |
// deleteResource(ds.getConnection(), resourceURI, defaultGraph); |
|
58 |
// }catch(Exception e){ |
|
59 |
// log.error("Could not DELETE "+resourceURI+" "+e.toString(),e); |
|
53 | 60 |
// } |
54 | 61 |
//#################################################################################### |
55 | 62 |
|
... | ... | |
73 | 80 |
|
74 | 81 |
if(i==0){ |
75 | 82 |
String resourceType = propertyObject.getString(propertyString); |
76 |
insertQuery+="<"+resourceURI+"> <"+propertyString+"> <"+resourceType+">"; |
|
83 |
// insertQuery+="<"+resourceURI+"> <"+propertyString+"> <"+resourceType+">"; |
|
84 |
buildQuery[0]+="<"+resourceURI+"> <"+propertyString+"> <"+resourceType+">"; |
|
77 | 85 |
continue; |
78 | 86 |
} |
79 | 87 |
|
... | ... | |
89 | 97 |
String countryURI = mapCountries.getCountryURI(value); |
90 | 98 |
URI uri = new URI(countryURI); |
91 | 99 |
if(countryURI.equals("")){ |
92 |
insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
100 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
101 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
|
93 | 102 |
continue; |
94 | 103 |
} |
95 |
insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
104 |
// insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
105 |
buildQuery[0]+="; <"+propertyString+"> <"+uri+">"; |
|
96 | 106 |
// log.info("COUNTRY "+countryURI+" FROM "+value); |
97 | 107 |
}catch(Exception e){ |
98 |
insertQuery+="; <"+propertyString+"> \""+value+"\"";
|
|
108 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\"";
|
|
99 | 109 |
// log.error("No country URI for: "+e.toString(),e); |
100 | 110 |
continue; |
101 | 111 |
} |
... | ... | |
107 | 117 |
String langURI = mapLanguages.getLangURI(value); |
108 | 118 |
URI uri = new URI(langURI); |
109 | 119 |
if(langURI.equals("")){ |
110 |
insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
120 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
121 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
|
111 | 122 |
continue; |
112 | 123 |
} |
113 |
insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
124 |
// insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
125 |
buildQuery[0]+="; <"+propertyString+"> <"+uri+">"; |
|
114 | 126 |
// log.info("LANG "+langURI+" FROM "+value.trim()); |
115 | 127 |
}catch(Exception e){ |
116 |
insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
128 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
129 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
|
117 | 130 |
// log.error("No Language URI for: "+e.toString(),e); |
118 | 131 |
continue; |
119 | 132 |
} |
... | ... | |
124 | 137 |
String[] splittedValue = value.split(conf.get("lod.seperator")); |
125 | 138 |
for(String v:splittedValue){ |
126 | 139 |
v= v.replace(conf.get("lod.seperator"), "").trim(); |
127 |
insertQuery+="; <"+propertyString+"> \""+v+"\""; |
|
140 |
// insertQuery+="; <"+propertyString+"> \""+v+"\""; |
|
141 |
buildQuery[0]+="; <"+propertyString+"> \""+v+"\""; |
|
128 | 142 |
} |
129 | 143 |
}else{ |
130 | 144 |
if(value.startsWith("http://")){ |
131 | 145 |
try{ |
132 | 146 |
if(value.contains(" ")){ |
133 |
insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
147 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
148 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
|
149 |
|
|
134 | 150 |
}else{ |
135 | 151 |
value = value.replaceAll("\\s","-"); |
136 | 152 |
URI uri = new URI(value); |
137 |
insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
153 |
// insertQuery+="; <"+propertyString+"> <"+uri+">"; |
|
154 |
buildQuery[0]+="; <"+propertyString+"> <"+uri+">"; |
|
138 | 155 |
} |
139 | 156 |
}catch(Exception e){ |
140 |
insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
157 |
// insertQuery+="; <"+propertyString+"> \""+value+"\""; |
|
158 |
buildQuery[0]+="; <"+propertyString+"> \""+value+"\""; |
|
141 | 159 |
// log.error("NOT URI "+e.toString(),e); |
142 | 160 |
continue; |
143 | 161 |
} |
144 | 162 |
} |
145 |
else insertQuery+="; <"+propertyString+"> \""+value+"\"";
|
|
163 |
else buildQuery[0]+="; <"+propertyString+"> \""+value+"\"";
|
|
146 | 164 |
} |
147 | 165 |
|
148 | 166 |
} |
149 | 167 |
|
150 |
insertQuery+=". "; |
|
168 |
// insertQuery+=". "; |
|
169 |
buildQuery[0]+=". "; |
|
151 | 170 |
|
152 |
return insertQuery;
|
|
171 |
return buildQuery;
|
|
153 | 172 |
|
154 | 173 |
} |
155 | 174 |
|
156 | 175 |
// public static String RDFizeRelationRow(List<String> row, VirtGraph graph, JSONObject mappings, Configuration conf){ |
157 |
public static String RDFizeRelationRow(List<String> row, JSONObject mappings, Configuration conf){ |
|
176 |
public static String[] RDFizeRelationRow(List<String> row, JSONObject mappings, Configuration conf){
|
|
158 | 177 |
|
159 |
String insertQuery = ""; |
|
178 |
// String insertQuery = ""; |
|
179 |
String[] buildQuery = new String[1]; |
|
180 |
buildQuery[0]=""; |
|
160 | 181 |
String baseURI = conf.get("lod.baseURI"); |
161 | 182 |
JSONObject typeMappings = mappings.getJSONArray(row.get(0)).getJSONObject(0); |
162 | 183 |
String sourceType = typeMappings.getString("sourceType"); |
... | ... | |
166 | 187 |
String property = typeMappings.getString("property"); |
167 | 188 |
String sourceURI = baseURI+row.get(Integer.parseInt(sourceType))+"/"+row.get(Integer.parseInt(sourceId)); |
168 | 189 |
String targetURI = baseURI+row.get(Integer.parseInt(targetType))+"/"+row.get(Integer.parseInt(targetId)); |
169 |
insertQuery= "<"+sourceURI+"> <"+property+"> <"+targetURI+">. "; |
|
170 |
return insertQuery; |
|
190 |
// insertQuery= "<"+sourceURI+"> <"+property+"> <"+targetURI+">. "; |
|
191 |
buildQuery[0]="<"+sourceURI+"> <"+property+"> <"+targetURI+">. "; |
|
192 |
// return insertQuery; |
|
193 |
return buildQuery; |
|
171 | 194 |
} |
172 | 195 |
|
173 | 196 |
public static boolean resourceExists(Connection conn, String resourceURI, String graph){ |
Also available in: Unified diff
changes the way we delete triples