int fieldCounter = 0;
i = 0;
boolean keepMetadata = true;
while (i < os.getChildCount()) {
SpecificationNode sn = os.getChild(i++);
if (sn.getType().equals(SolrConfig.NODE_FIELDMAP)) {
String source = sn.getAttributeValue(SolrConfig.ATTRIBUTE_SOURCE);
String target = sn.getAttributeValue(SolrConfig.ATTRIBUTE_TARGET);
if (target != null && target.length() == 0) {
target = null;
}
String targetDisplay = target;
if (target == null)
{
target = "";
targetDisplay = "(remove)";
}
// It's prefix will be...
String prefix = "solr_fieldmapping_" + Integer.toString(fieldCounter);
out.print(
" <tr class=\""+(((fieldCounter % 2)==0)?"evenformrow":"oddformrow")+"\">\n"+
" <td class=\"formcolumncell\">\n"+
" <a name=\""+prefix+"\">\n"+
" <input type=\"button\" value=\"Delete\" alt=\""+Messages.getAttributeString(locale,"SolrConnector.DeleteFieldMapping")+Integer.toString(fieldCounter+1)+"\" onclick='javascript:deleteFieldMapping("+Integer.toString(fieldCounter)+");'/>\n"+
" <input type=\"hidden\" name=\""+prefix+"_op\" value=\"Continue\"/>\n"+
" <input type=\"hidden\" name=\""+prefix+"_source\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(source)+"\"/>\n"+
" <input type=\"hidden\" name=\""+prefix+"_target\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(target)+"\"/>\n"+
" </a>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(source)+"</nobr>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr>"+org.apache.manifoldcf.ui.util.Encoder.bodyEscape(targetDisplay)+"</nobr>\n"+
" </td>\n"+
" </tr>\n"
);
fieldCounter++;
}
else if(sn.getType().equals(SolrConfig.NODE_KEEPMETADATA)) {
keepMetadata = Boolean.parseBoolean(sn.getAttributeValue(SolrConfig.ATTRIBUTE_VALUE));
}
}
if (fieldCounter == 0)
{
out.print(
" <tr class=\"formrow\"><td class=\"formmessage\" colspan=\"3\">" + Messages.getBodyString(locale,"SolrConnector.NoFieldMappingSpecified") + "</td></tr>\n"
);
}
String keepMetadataValue;
if (keepMetadata)
keepMetadataValue = " checked=\"true\"";
else
keepMetadataValue = "";
out.print(
" <tr class=\"formrow\"><td class=\"formseparator\" colspan=\"3\"><hr/></td></tr>\n"+
" <tr class=\"formrow\">\n"+
" <td class=\"formcolumncell\">\n"+
" <a name=\"solr_fieldmapping\">\n"+
" <input type=\"button\" value=\"" + Messages.getAttributeString(locale,"SolrConnector.Add") + "\" alt=\"" + Messages.getAttributeString(locale,"SolrConnector.AddFieldMapping") + "\" onclick=\"javascript:addFieldMapping();\"/>\n"+
" </a>\n"+
" <input type=\"hidden\" name=\"solr_fieldmapping_count\" value=\""+fieldCounter+"\"/>\n"+
" <input type=\"hidden\" name=\"solr_fieldmapping_op\" value=\"Continue\"/>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr><input type=\"text\" size=\"15\" name=\"solr_fieldmapping_source\" value=\"\"/></nobr>\n"+
" </td>\n"+
" <td class=\"formcolumncell\">\n"+
" <nobr><input type=\"text\" size=\"15\" name=\"solr_fieldmapping_target\" value=\"\"/></nobr>\n"+
" </td>\n"+
" </tr>\n"+
" </table>\n"+
" </td>\n"+
" </tr>\n"+
" <tr><td class=\"separator\" colspan=\"2\"><hr/></td></tr>\n"+
" <tr>\n"+
" <td class=\"description\"><nobr>"+Messages.getBodyString(locale,"SolrConnector.KeepAllMetadata")+"</nobr></td>\n"+
" <td class=\"value\">\n"+
" <input type=\"checkbox\""+keepMetadataValue+" name=\"solr_keepallmetadata\" value=\"true\"/>\n"+
" </td>\n"+
" </tr>\n"+
"</table>\n"
);
}
else
{
// Hiddens for field mapping
i = 0;
int fieldCounter = 0;
String keepMetadataValue = "true";
while (i < os.getChildCount()) {
SpecificationNode sn = os.getChild(i++);
if (sn.getType().equals(SolrConfig.NODE_FIELDMAP)) {
String source = sn.getAttributeValue(SolrConfig.ATTRIBUTE_SOURCE);
String target = sn.getAttributeValue(SolrConfig.ATTRIBUTE_TARGET);
if (target == null)
target = "";
// It's prefix will be...
String prefix = "solr_fieldmapping_" + Integer.toString(fieldCounter);
out.print(
"<input type=\"hidden\" name=\""+prefix+"_source\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(source)+"\"/>\n"+
"<input type=\"hidden\" name=\""+prefix+"_target\" value=\""+org.apache.manifoldcf.ui.util.Encoder.attributeEscape(target)+"\"/>\n"
);
fieldCounter++;
}
else if(sn.getType().equals(SolrConfig.NODE_KEEPMETADATA))
{
keepMetadataValue = sn.getAttributeValue(SolrConfig.ATTRIBUTE_VALUE);
}
}
out.print(
"<input type=\"hidden\" name=\"solr_keepallmetadata\" value=\""+keepMetadataValue+"\"/>\n"
);