Changeset 33341 for main/trunk/greenstone3
- Timestamp:
- 2019-07-23T11:07:30+12:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/AbstractGS2DocumentRetrieve.java
r32467 r33341 227 227 if (index == -1) { 228 228 // metadata is for this node 229 return info.getMultiInfo(metadata);229 return getMetaValuesForOID(node_id, current_info, metadata); 230 230 } 231 231 // we need to get metadata for one or more different nodes 232 // we have a relation root, parent, ancestors, siblings, children, descend ents232 // we have a relation root, parent, ancestors, siblings, children, descendants, entire 233 233 String relation = metadata.substring(0, index); 234 234 String relation_id=""; … … 236 236 if (relation.equals("root")) { 237 237 relation_id = OID.getTop(node_id); 238 if ( relation_id.equals(node_id)) {239 // use the current node info240 return info.getMultiInfo(metadata);241 } else {242 return getMetaValuesForOID(relation_id, metadata);243 244 }238 if (!relation_id.equals(node_id)) { 239 // get the dbinfo for the root node 240 current_info = this.coll_db.getInfo(relation_id); 241 } 242 return getMetaValuesForOID(relation_id, current_info, metadata); 243 } 244 245 245 if (relation.equals("parent")) { 246 246 relation_id = OID.getParent(node_id); … … 249 249 return null; 250 250 } 251 return getMetaValuesForOID(relation_id, metadata);251 return getMetaValuesForOID(relation_id, null, metadata); 252 252 } 253 253 … … 261 261 while (!relation_id.equals(current_id)) { 262 262 263 Vector<String> more_values = getMetaValuesForOID(relation_id, metadata);263 Vector<String> more_values = getMetaValuesForOID(relation_id, null, metadata); 264 264 if (more_values != null) { 265 265 values.addAll(0, more_values); … … 283 283 return null; 284 284 } 285 } 285 // drop through to children part 286 } 287 288 Vector<String> values = new Vector<String>(); 286 289 if (relation.equals("children")) { 287 Vector<String> values = new Vector<String>(); 288 String contains = current_info.getInfo("contains"); 290 processChildren(node_id, current_info, metadata, values, false); 291 return values; 292 } 293 294 if (relation.equals("entire")) { 295 // this is the same as doing descendants on root 296 relation_id = OID.getTop(node_id); 297 298 // first of all, add root node info 299 300 if (relation_id.equals(node_id)) { 301 current_info = info; 302 } else { 303 current_info = this.coll_db.getInfo(relation_id); 304 } 305 values = getMetaValuesForOID(relation_id, current_info, metadata); 306 307 node_id = relation_id; 308 relation = "descendants"; 309 // drop through to next part 310 } 311 312 313 if (relation.equals("descendants")) { 314 processChildren(node_id, current_info, metadata, values, true); 315 return values; 316 } 317 // unknown relation 318 // we assume that maybe the metadata has an _ in the name, so get the original name 319 return info.getMultiInfo(relation+GSConstants.META_RELATION_SEP+metadata); 320 321 } 322 323 protected void processChildren(String node_id, DBInfo info, String metadata, Vector<String> values, 324 boolean recursive) { 325 String contains = info.getInfo("contains"); 289 326 contains = StringUtils.replace(contains, "\"", node_id); 290 327 String[] children = contains.split(";"); … … 292 329 293 330 String child_id = children[i]; 294 Vector<String> more_values = getMetaValuesForOID(child_id, metadata);331 Vector<String> more_values = getMetaValuesForOID(child_id, null, metadata); 295 332 if (more_values != null) { 296 333 values.addAll(more_values); 297 334 } 298 } 299 return values; 300 } 301 if (relation.equals("descendents")) { 335 if (recursive) { 336 DBInfo child_info = this.coll_db.getInfo(child_id); 337 processChildren(child_id, child_info, metadata, values, recursive); 338 } 339 } 340 } 341 342 protected Vector<String> getMetaValuesForOID(String oid, DBInfo info, String metadata) { 343 344 DBInfo this_info; 345 if (info != null) { 346 this_info = info; 347 } else { 348 this_info = this.coll_db.getInfo(oid); 349 } 350 if (this_info == null) { 302 351 return null; 303 352 } 304 // unknown relation305 // we assume that maybe the metadata has an _ in the name, so get the original name306 return info.getMultiInfo(relation+GSConstants.META_RELATION_SEP+metadata);307 308 }309 353 310 311 protected Vector<String> getMetaValuesForOID(String oid, String metadata) { 312 DBInfo info = this.coll_db.getInfo(oid); 313 if (info == null) { 314 return null; 315 } 316 317 Vector<String> values = info.getMultiInfo(metadata); 354 Vector<String> values = this_info.getMultiInfo(metadata); 318 355 // lets look through the values and look for [xxx] things. We need to look up metadata for them. 319 356 if (values == null) { return values; } … … 326 363 for (int i=0; i<metas.length; i++) { 327 364 String meta = metas[i]; 328 String meta_val = info.getInfo(meta); 365 String meta_val; 366 // hack for parent(Top). gs2 had lots of other modifiers, but is this the only one that was used in 367 // metadata values?? 368 if (meta.startsWith("parent(Top):")) { 369 String nmeta = meta.substring(12); // or 13? 370 String root_id = OID.getTop(oid); 371 DBInfo root_info = this.coll_db.getInfo(root_id); 372 meta_val = root_info.getInfo(nmeta); 373 } else { 374 meta_val = this_info.getInfo(meta); 375 } 329 376 if (!meta_val.equals("")) { 330 377 val = StringUtils.replace(val,"["+meta+"]",meta_val);
Note:
See TracChangeset
for help on using the changeset viewer.