/** * Returns a list of CmsSearchFieldMappingTypes for the type select box.<p> * * @return a list of CmsSearchFieldMappingTypes */ private List<CmsSelectWidgetOption> getTypeWidgetConfiguration() { List<CmsSelectWidgetOption> result = new ArrayList<CmsSelectWidgetOption>(); result.add(new CmsSelectWidgetOption(CmsSearchFieldMappingType.CONTENT.toString(), true)); result.add(new CmsSelectWidgetOption(CmsSearchFieldMappingType.PROPERTY.toString(), false)); result.add(new CmsSelectWidgetOption(CmsSearchFieldMappingType.PROPERTY_SEARCH.toString(), false)); result.add(new CmsSelectWidgetOption(CmsSearchFieldMappingType.ITEM.toString(), false)); return result; } }
/** * @see org.opencms.util.A_CmsModeIntEnumeration#toString() */ @Override public String toString() { switch (getMode()) { case 1: return STR_PROPERTY; case 2: return STR_PROPERTY_SEARCH; case 3: return STR_ITEM; case 4: return STR_DYNAMIC; case 0: default: return STR_CONTENT; } } }
/** * The hash code depends on the type and the parameter.<p> * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { if (m_hashCode == 0) { int hashCode = 73 * (m_type == null ? 29 : m_type.hashCode()); if (m_param != null) { hashCode += m_param.hashCode(); } m_hashCode = hashCode; } return m_hashCode; }
/** * @see org.opencms.search.fields.I_CmsSearchFieldMapping#setType(java.lang.String) */ public void setType(String type) { CmsSearchFieldMappingType mappingType = CmsSearchFieldMappingType.valueOf(type); if (mappingType == null) { // invalid mapping type has been used, throw an exception throw new CmsRuntimeException( new CmsMessageContainer(Messages.get(), Messages.ERR_FIELD_TYPE_UNKNOWN_1, new Object[] {type})); } setType(mappingType); }
if ((field.getLocale() != null) && mapping.getType().equals(CmsSearchFieldMappingType.CONTENT)) {
/** * Sets the mapping type as a String.<p> * * @param type the name of the type to set */ public void setType(String type) { CmsSearchFieldMappingType mappingType = CmsSearchFieldMappingType.valueOf(type); if (mappingType == null) { // invalid mapping type has been used, throw an exception throw new CmsRuntimeException(new CmsMessageContainer( Messages.get(), Messages.ERR_FIELD_TYPE_UNKNOWN_1, new Object[] {type})); } setType(mappingType); } }
/** * Returns the String value of the mapping type.<p> * * @return String value of the mapping type */ public String getType() { if ((m_mapping != null) && (m_mapping.getType() != null)) { return m_mapping.getType().toString(); } return ""; }
/** * @see org.opencms.util.A_CmsModeIntEnumeration#toString() */ @Override public String toString() { switch (getMode()) { case 1: return STR_PROPERTY; case 2: return STR_PROPERTY_SEARCH; case 3: return STR_ITEM; case 4: return STR_DYNAMIC; case 5: return STR_ATTRIBUTE; case 0: default: return STR_CONTENT; } } }
/** * The hash code depends on the type and the parameter.<p> * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { if (m_hashCode == 0) { int hashCode = 73 * ((m_type == null) ? 29 : m_type.hashCode()); if (m_param != null) { hashCode += m_param.hashCode(); } m_hashCode = hashCode; } return m_hashCode; }
/** * @see org.opencms.workplace.CmsWorkplace#initWorkplaceRequestValues(org.opencms.workplace.CmsWorkplaceSettings, javax.servlet.http.HttpServletRequest) */ @SuppressWarnings({"unchecked", "rawtypes"}) @Override protected void initWorkplaceRequestValues(CmsWorkplaceSettings settings, HttpServletRequest request) { // initialize parameters and dialog actions in super implementation super.initWorkplaceRequestValues(settings, request); // save the current search index source Map dialogObject = (Map)getDialogObject(); if (dialogObject == null) { dialogObject = new HashMap(); dialogObject.put(PARAM_FIELDCONFIGURATION, m_fieldconfiguration); dialogObject.put(PARAM_FIELD, m_field); dialogObject.put(PARAM_PARAM, m_mapping.getParam()); if (m_mapping.getType() != null) { dialogObject.put(PARAM_TYPE, m_mapping.getType().toString()); } else { dialogObject.put(PARAM_TYPE, m_mapping.getType()); } setDialogObject(dialogObject); } }
switch (getType().getMode()) { case 0: // content if (extractionResult != null) {
CmsSearchFieldMapping mapping = (CmsSearchFieldMapping)itMappings.next(); html.append(" <li>\n").append(" "); html.append(mapping.getType().toString()); if (CmsStringUtil.isNotEmpty(mapping.getParam())) { html.append("=").append(mapping.getParam()).append("\n");
switch (getType().getMode()) { case 0: // content if (extractionResult != null) {
CmsSearchFieldMapping mapping = (CmsSearchFieldMapping)itMappings.next(); html.append(" <li>\n").append(" "); html.append(mapping.getType().toString()); if (CmsStringUtil.isNotEmpty(mapping.getParam())) { html.append("=").append(mapping.getParam()).append("\n");
CmsSearchFieldMapping mapping = (CmsSearchFieldMapping)itMappings.next(); html.append(" <li>\n").append(" "); html.append(mapping.getType().toString()); if (CmsStringUtil.isNotEmpty(mapping.getParam())) { html.append("=").append(mapping.getParam()).append("\n");
/** * @see org.opencms.workplace.CmsWidgetDialog#actionCommit() */ @Override public void actionCommit() { List<Throwable> errors = new ArrayList<Throwable>(); try { // if new create it first boolean found = false; Iterator<I_CmsSearchFieldMapping> itMappings = m_field.getMappings().iterator(); while (itMappings.hasNext()) { I_CmsSearchFieldMapping curMapping = itMappings.next(); if (curMapping.getType().toString().equals(m_mapping.getType().toString()) && (((curMapping.getParam() == null) && (m_mapping.getParam() == null)) || (curMapping.getParam().equals(m_mapping.getParam())))) { found = true; } } if (!found) { m_field.addMapping(m_mapping); } writeConfiguration(); } catch (Throwable t) { errors.add(t); } // set the list of errors to display when saving failed setCommitErrors(errors); }
/** * @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; }
String itemType = (String)listItem.get(LIST_COLUMN_TYPE); if (curMapping.getType().toString().equals(itemType) && (((curMapping.getParam() == null) && (itemValue == null)) || (curMapping.getParam().equals(itemValue)))) {
/** * Removes a search field mapping from the given field.<p> * * @param field the field * @param mapping mapping to remove from the field * * @return true if remove was successful, false if preconditions for removal are ok but the given * mapping was unknown. * * @throws CmsIllegalStateException if the given mapping is the last mapping inside the given field. */ public boolean removeSearchFieldMapping(CmsSearchField field, CmsSearchFieldMapping mapping) throws CmsIllegalStateException { if (field.getMappings().size() < 2) { throw new CmsIllegalStateException(Messages.get().container( Messages.ERR_FIELD_MAPPING_DELETE_2, mapping.getType().toString(), field.getName())); } else { if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key( Messages.LOG_REMOVE_FIELD_MAPPING_INDEX_2, mapping.toString(), field.getName())); } return field.getMappings().remove(mapping); } }