/** * Creates a new mapping node.<p> * * @param document the document to modify * @param xpath the xpath to the field mapping, ie <code>opencms/search/fieldconfigurations/fieldconfiguration[name='...']/fields/field[@name="..."]/mappings/mapping[@type='...']</code> * @param mapping the field mapping */ protected void createFieldMapping(Document document, String xpath, CmsSearchFieldMapping mapping) { CmsSetupXmlHelper.setValue(document, xpath + "/@" + I_CmsXmlConfiguration.A_TYPE, mapping.getType().toString()); CmsSetupXmlHelper.setValue(document, xpath + "/@" + I_CmsXmlConfiguration.A_DEFAULT, mapping.getDefaultValue()); // add class attribute (if required) if (!mapping.getClass().equals(CmsSearchFieldMapping.class) || (mapping.getType() == CmsSearchFieldMappingType.DYNAMIC)) { CmsSetupXmlHelper.setValue( document, xpath + "/@" + I_CmsXmlConfiguration.A_CLASS, mapping.getClass().getName()); } if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(mapping.getParam())) { CmsSetupXmlHelper.setValue(document, xpath, mapping.getParam()); } }
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() { List<CmsListItem> result = new ArrayList<CmsListItem>(); // get content List<I_CmsSearchFieldMapping> mappings = getMappings(); Iterator<I_CmsSearchFieldMapping> itMappings = mappings.iterator(); CmsSearchFieldMapping mapping; while (itMappings.hasNext()) { mapping = (CmsSearchFieldMapping)itMappings.next(); CmsListItem item = getList().newItem(mapping.getType().toString()); String defaultValue = mapping.getDefaultValue(); String param = mapping.getParam(); if (defaultValue == null) { defaultValue = "-"; } if (param == null) { param = "-"; } item.set(LIST_COLUMN_VALUE, param); item.set(LIST_COLUMN_TYPE, mapping.getType().toString()); item.set(LIST_COLUMN_DEFAULT, defaultValue); result.add(item); } return result; }
Element mappingElement = fieldElement.addElement(N_MAPPING); mappingElement.addAttribute(A_TYPE, mapping.getType().toString()); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(mapping.getDefaultValue())) { mappingElement.addAttribute(A_DEFAULT, mapping.getDefaultValue());
content = getDefaultValue();
content = getDefaultValue();