queriedServiceBindings.put(docType, sb);\r
authRefFieldsByService.put(docType, authRefFields);\r
docTypes.add(docType);\r
- /*\r
- // HACK - need to get qualified properties from the ServiceBinding\r
- String prefix = "";\r
- if(docType.equalsIgnoreCase("Intake"))\r
- prefix = "intakes_common:";\r
- else if(docType.equalsIgnoreCase("Loanin"))\r
- prefix = "loansin_common:";\r
- else if(docType.equalsIgnoreCase("Acquisition"))\r
- prefix = "acquisitions_common:";\r
- */\r
Collection<String> fields = authRefFields.values();\r
for (String field : fields) {\r
// Build up the where clause for each authRef field\r
// such as "fieldCollectors", of a repeatable authority reference\r
// field, such as "fieldCollector".\r
Object fieldValue = docModel.getProperty(strings[0], strings[1]);\r
- fRefFound = refNameFoundInField(refName, fieldValue);\r
- if (fRefFound) {\r
+ boolean fRefMatches = refNameFoundInField(refName, fieldValue);\r
+ if (fRefMatches) {\r
sourceField = authRefDescendantField;\r
- ilistItem.setSourceField(sourceField);\r
- // FIXME Returns only the first field in which the refName is found.\r
- // We may want to return all; this may require multiple sourceFields\r
- // in the list item schema; or else multiple list items, one per sourceField.\r
- // See CSPACE-2863 for a discussion of how this might be handled.\r
- break;\r
+ // Handle multiple fields matching in one Doc. See CSPACE-2863.\r
+ if(fRefFound) {\r
+ // We already added ilistItem, so we need to clone that and add again\r
+ ilistItem = cloneAuthRefDocItem(ilistItem, sourceField);\r
+ } else {\r
+ ilistItem.setSourceField(sourceField);\r
+ fRefFound = true;\r
+ }\r
+ list.add(ilistItem);\r
}\r
\r
} catch (ClientException ce) {\r
"getAuthorityRefDocs: Problem fetching: " + sourceField, ce);\r
}\r
}\r
- // Used before going to schema-qualified field names.\r
- /*\r
- for(String field:matchingAuthRefFields){\r
- try {\r
- if(refName.equals(docModel.getPropertyValue(field))) {\r
- ilistItem.setSourceField(field);\r
- fRefFound = true;\r
- break;\r
- }\r
- } catch(ClientException ce) {\r
- throw new RuntimeException(\r
- "getAuthorityRefDocs: Problem fetching: "+field, ce);\r
- }\r
- }\r
- * \r
- */\r
if (!fRefFound) {\r
throw new RuntimeException(\r
"getAuthorityRefDocs: Could not find refname in object:"\r
+ docType + ":" + csid);\r
}\r
- list.add(ilistItem);\r
}\r
return wrapperList;\r
}\r
+ \r
+ private static AuthorityRefDocList.AuthorityRefDocItem cloneAuthRefDocItem(\r
+ AuthorityRefDocList.AuthorityRefDocItem ilistItem, String sourceField) {\r
+ AuthorityRefDocList.AuthorityRefDocItem newlistItem = new AuthorityRefDocList.AuthorityRefDocItem();\r
+ newlistItem.setDocId(ilistItem.getDocId());\r
+ newlistItem.setDocName(ilistItem.getDocName());\r
+ newlistItem.setDocNumber(ilistItem.getDocNumber());\r
+ newlistItem.setDocType(ilistItem.getDocType());\r
+ newlistItem.setUri(ilistItem.getUri());\r
+ newlistItem.setSourceField(sourceField);\r
+ return newlistItem;\r
+ }\r
\r
/*\r
* Identifies whether the refName was found in the supplied field.\r
"entryNumber-" + identifier,\r
"entryDate-" + identifier,\r
currentOwnerRefName,\r
- depositorRefName,\r
+ // Use currentOwnerRefName twice to test fix for CSPACE-2863\r
+ currentOwnerRefName, //depositorRefName,\r
conditionCheckerAssessorRefName,\r
insurerRefName,\r
valuerRefName );\r
\r
// Optionally output additional data about list members for debugging.\r
boolean iterateThroughList = true;\r
- boolean fFoundIntake = false;\r
+ int nIntakesFound = 0;\r
if(iterateThroughList && logger.isDebugEnabled()){\r
List<AuthorityRefDocList.AuthorityRefDocItem> items =\r
list.getAuthorityRefDocItem();\r
item.getDocName() + "] Number:[" +\r
item.getDocNumber() + "] in field:[" +\r
item.getSourceField() + "]");\r
- if(!fFoundIntake && knownIntakeId.equalsIgnoreCase(item.getDocId())) {\r
- fFoundIntake = true;\r
+ if(knownIntakeId.equalsIgnoreCase(item.getDocId())) {\r
+ nIntakesFound++;\r
}\r
i++;\r
}\r
- Assert.assertTrue(fFoundIntake, "Did not find Intake with authref!");\r
+ //\r
+ Assert.assertTrue((nIntakesFound==2), "Did not find Intake (twice) with authref!");\r
}\r
}\r
\r