Search indexing all values (now getControlledVocabulariesDisplayValueLocalized returns a list of all the values and the DSIndexer manages these values)

A return statement is added if the item has no collection
This commit is contained in:
Rania Stathopoulou
2012-09-14 19:49:27 +03:00
parent 33da186e6c
commit b05c6a3288
2 changed files with 94 additions and 95 deletions

View File

@@ -362,105 +362,100 @@ public class Util {
/**
* Get the localized respective "displayed-value" from the given
* "stored-value" for a specific metadata field of a DSpace Item, by reading
* input-forms.xml. In this case the localized input-forms is used, e.g. input-forms_el.xml
*
* @param item
* The Dspace Item
* @param values
* A DCValue[] array of the specific "stored-value(s)"
* @param schema
* A String with the schema name of the metadata field
* @param element
* A String with the element name of the metadata field
* @param qualifier
* A String with the qualifier name of the metadata field
* @param Locale
* The given locale
* @return A String of the respective "displayed-value"
*/
/**
* Get a list of all the respective "displayed-value(s)" from the given
* "stored-value(s)" for a specific metadata field of a DSpace Item, by reading
* input-forms.xml
*
* @param item
* The Dspace Item
* @param values
* A DCValue[] array of the specific "stored-value(s)"
* @param schema
* A String with the schema name of the metadata field
* @param element
* A String with the element name of the metadata field
* @param qualifier
* A String with the qualifier name of the metadata field
* @return A list of the respective "displayed-values"
*/
public static String getControlledVocabulariesDisplayValueLocalized(Item item, DCValue[] values, String schema, String element, String qualifier, Locale locale) throws SQLException, DCInputsReaderException{
public static List getControlledVocabulariesDisplayValueLocalized(Item item, DCValue[] values, String schema, String element, String qualifier, Locale locale) throws SQLException, DCInputsReaderException{
String toReturn="";
DCInput myInputs = null;
boolean myInputsFound=false;
String formFileName = I18nUtil.getInputFormsFileName(locale);
DCInputSet inputSet = null;
List toReturn=new ArrayList<String>();
DCInput myInputs = null;
boolean myInputsFound=false;
String formFileName = I18nUtil.getInputFormsFileName(locale);
DCInputSet inputSet = null;
//Read the input form file for the specific collection
DCInputsReader inputsReader = null;
String col_handle = "";
//Read the input form file for the specific collection
DCInputsReader inputsReader = null;
String col_handle = "";
Collection collection = item.getOwningCollection();
Collection collection = item.getOwningCollection();
if (collection==null)
{
col_handle = "db-id/" + item.getID();
}
else {
col_handle = collection.getHandle();
}
if (inputsReader == null) {
// read configurable submissions forms data
inputsReader = new DCInputsReader(formFileName);
if (collection==null)
{
// col_handle = "db-id/" + item.getID();
return null;
}
else {
col_handle = collection.getHandle();
}
if (inputsReader == null) {
// read configurable submissions forms data
inputsReader = new DCInputsReader(formFileName);
}
inputSet = inputsReader.getInputs(col_handle);
}
inputSet = inputsReader.getInputs(col_handle);
//Replace the values of DCValue[] with the correct ones in case of controlled vocabularies
String currentField = schema+"."+element+(qualifier==null?"":"."+qualifier);
//Replace the values of DCValue[] with the correct ones in case of controlled vocabularies
String currentField = schema+"."+element+(qualifier==null?"":"."+qualifier);
if (inputSet!=null){
if (inputSet!=null){
int pageNums= inputSet.getNumberPages();
int pageNums= inputSet.getNumberPages();
for (int p=0;p<pageNums;p++){
for (int p=0;p<pageNums;p++){
DCInput[] inputs = inputSet.getPageRows(p, false, false);
DCInput[] inputs = inputSet.getPageRows(p, false, false);
if (inputs!=null){
if (inputs!=null){
for (int i=0; i<inputs.length;i++){
String inputField=inputs[i].getSchema()+"."+inputs[i].getElement()+(inputs[i].getQualifier()==null?"":"."+inputs[i].getQualifier());
if (currentField.equals(inputField)){
for (int i=0; i<inputs.length;i++){
String inputField=inputs[i].getSchema()+"."+inputs[i].getElement()+(inputs[i].getQualifier()==null?"":"."+inputs[i].getQualifier());
if (currentField.equals(inputField)){
myInputs = inputs[i];
myInputsFound=true;
break;
myInputs = inputs[i];
myInputsFound=true;
break;
}
}
}
if (myInputsFound) break;
}
}
}
}
}
if (myInputsFound) break;
}
}
if (myInputsFound) {
if (myInputsFound) {
for (int j = 0; j < values.length; j++){
for (int j = 0; j < values.length; j++){
String pairsName = myInputs.getPairsType();
String stored_value = values[j].value;
String displayVal = myInputs.getDisplayString(pairsName,stored_value);
String pairsName = myInputs.getPairsType();
String stored_value = values[j].value;
String displayVal = myInputs.getDisplayString(pairsName,stored_value);
if (displayVal!=null && !"".equals(displayVal)){
if (displayVal!=null && !"".equals(displayVal)){
return displayVal;
}
toReturn.add(displayVal);
}
}
}
}
}
return toReturn;
return toReturn;
}
}

View File

@@ -1071,30 +1071,34 @@ public class DSIndexer
//Index the controlled vocabularies localized display values for all localized input-forms.xml (e.g. input-forms_el.xml)
if ("inputform".equalsIgnoreCase(indexConfigArr[i].type)){
List newValues=new ArrayList<String>();
String displayValue;
Locale[] supportedLocales=I18nUtil.getSupportedLocales();
List newValues=new ArrayList<String>();
String displayValue;
Locale[] supportedLocales=I18nUtil.getSupportedLocales();
//Get the display value of the respective stored value
for (int k=0;k<supportedLocales.length;k++){
List displayValues=new ArrayList<String>();
displayValues = org.dspace.app.util.Util.getControlledVocabulariesDisplayValueLocalized(item, mydc,indexConfigArr[i].schema, indexConfigArr[i].element, indexConfigArr[i].qualifier, supportedLocales[k]);
if (displayValues!=null && !displayValues.isEmpty()){
for (int d=0;d<displayValues.size();d++){
newValues.add(displayValues.get(d));
}
}
//Get the display value of the respective stored value
for (int k=0;k<supportedLocales.length;k++){
}
displayValue = org.dspace.app.util.Util.getControlledVocabulariesDisplayValueLocalized(item, mydc,indexConfigArr[i].schema, indexConfigArr[i].element, indexConfigArr[i].qualifier, supportedLocales[k]);
newValues.add(displayValue);
}
if (newValues!=null){
for (int m=0;m<newValues.size();m++){
if (!"".equals(newValues.get(m))){
if (newValues!=null){
for (int m=0;m<newValues.size();m++){
if (!"".equals(newValues.get(m))){
String toAdd=(String) newValues.get(m);
doc.add( new Field(indexConfigArr[i].indexName,
toAdd,
Field.Store.YES,
Field.Index.ANALYZED));
}
}
}
String toAdd=(String) newValues.get(m);
doc.add( new Field(indexConfigArr[i].indexName,
toAdd,
Field.Store.YES,
Field.Index.ANALYZED));
}
}
}
}