/** * @see java.lang.Object#toString() */ @Override public String toString() { return getName(); } }
/** * Returns the list of configured field names (Strings).<p> * * @return the list of configured field names (Strings) */ public List<String> getFieldNames() { if (m_fieldNames == null) { // lazy initialize the field names m_fieldNames = new ArrayList<String>(); for (CmsSearchField field : m_fields) { m_fieldNames.add(field.getName()); } } // create a copy of the list to prevent changes in other classes return new ArrayList<String>(m_fieldNames); }
/** * Returns the configured {@link CmsSearchField} instance with the given name.<p> * * @param name the search field name to look up * * @return the configured {@link CmsSearchField} instance with the given name */ public CmsSearchField getField(String name) { if (m_fieldLookup == null) { // lazy initialize the field names m_fieldLookup = new HashMap<String, CmsSearchField>(); for (CmsSearchField field : m_fields) { m_fieldLookup.put(field.getName(), field); } } return m_fieldLookup.get(name); }
/** * Two fields are equal if the name of the Lucene field is equal.<p> * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if ((obj instanceof CmsSearchField)) { return CmsStringUtil.isEqual(m_name, ((CmsSearchField)obj).getName()); } return false; }
/** * Returns the list of configured field names (Strings).<p> * * @return the list of configured field names (Strings) */ public List<String> getFieldNames() { if (m_fieldNames == null) { // lazy initialize the field names m_fieldNames = new ArrayList<String>(); Iterator<CmsSearchField> i = m_fields.iterator(); while (i.hasNext()) { m_fieldNames.add((i.next()).getName()); } } // create a copy of the list to prevent changes in other classes return new ArrayList<String>(m_fieldNames); }
/** * Returns the configured {@link CmsSearchField} instance with the given name.<p> * * @param name the search field name to look up * * @return the configured {@link CmsSearchField} instance with the given name */ public CmsSearchField getField(String name) { if (m_fieldLookup == null) { // lazy initialize the field names m_fieldLookup = new HashMap<String, CmsSearchField>(); Iterator<CmsSearchField> i = m_fields.iterator(); while (i.hasNext()) { CmsSearchField field = i.next(); m_fieldLookup.put(field.getName(), field); } } return m_fieldLookup.get(name); }
/** * Returns the field names used for a regular result.<p> * * @return the field names used for a regular result */ public Set<String> getReturnFields() { if (m_fieldAdded) { for (CmsSearchField field : getLuceneFields()) { if (field.isStored() && !LAZY_FIELDS.contains(field.getName())) { m_returnFields.add(field.getName()); } } } m_fieldAdded = false; return m_returnFields; } }
/** * Returns a list of all field names (Strings) that are used in generating the search excerpt.<p> * * @return a list of all field names (Strings) that are used in generating the search excerpt */ public List<String> getExcerptFieldNames() { if (m_excerptFieldNames == null) { // lazy initialize the field names m_excerptFieldNames = new ArrayList<String>(); Iterator<CmsSearchField> i = m_fields.iterator(); while (i.hasNext()) { CmsSearchField field = i.next(); if (field.isInExcerptAndStored()) { m_excerptFieldNames.add(field.getName()); } } } // create a copy of the list to prevent changes in other classes return new ArrayList<String>(m_excerptFieldNames); }
/** * Adds fields.<p> * * @param fields the fields to add */ public void addFields(Collection<CmsSearchField> fields) { for (CmsSearchField field : fields) { if (!getFieldNames().contains(field.getName())) { addField(field); } } }
/** * Adds a Solr field for an element.<p> * * @param contentDefinition the XML content definition this XML content handler belongs to * @param field the Solr field * @param type the type, specifying if the field should be attached to the document of the XML content or to all container pages the content is placed on */ protected void addSearchField( CmsXmlContentDefinition contentDefinition, CmsSearchField field, I_CmsXmlContentHandler.MappingType type) { Locale locale = null; if (field instanceof CmsSolrField) { locale = ((CmsSolrField)field).getLocale(); } String key = CmsXmlUtils.concatXpath(locale != null ? locale.toString() : null, field.getName()); switch (type) { case PAGE: m_searchFieldsPage.put(key, field); break; case ELEMENT: default: m_searchFields.put(key, field); break; } }
/** * Returns a list of <code>{@link CmsSelectWidgetOption}</code> objects for field list selection.<p> * * @return a list of <code>{@link CmsSelectWidgetOption}</code> objects */ private List getFieldList() { List retVal = new ArrayList(); try { Iterator i = getFields().iterator(); while (i.hasNext()) { CmsSearchField field = (CmsSearchField)i.next(); retVal.add(new CmsSelectWidgetOption(field.getName(), true, getMacroResolver().resolveMacros( field.getDisplayName()))); } } catch (Exception e) { // noop } return retVal; }
result.addAnalyzer(field.getName(), fieldAnalyzer);
/** * 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); } }
/** * Removes a search field from the field configuration.<p> * * @param fieldConfiguration the field configuration * @param field field to remove from the field configuration * * @return true if remove was successful, false if preconditions for removal are ok but the given * field was unknown. * * @throws CmsIllegalStateException if the given field is the last field inside the given field configuration. */ public boolean removeSearchFieldConfigurationField( CmsSearchFieldConfiguration fieldConfiguration, CmsSearchField field) throws CmsIllegalStateException { if (fieldConfiguration.getFields().size() < 2) { throw new CmsIllegalStateException(Messages.get().container( Messages.ERR_CONFIGURATION_FIELD_DELETE_2, field.getName(), fieldConfiguration.getName())); } else { if (LOG.isInfoEnabled()) { LOG.info(Messages.get().getBundle().key( Messages.LOG_REMOVE_FIELDCONFIGURATION_FIELD_INDEX_2, field.getName(), fieldConfiguration.getName())); } return fieldConfiguration.getFields().remove(field); } }
/** * @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; for (CmsSearchField field : m_fieldconfiguration.getFields()) { if (field.getName().equals(m_field.getName())) { found = true; } } if (!found) { m_fieldconfiguration.addField(m_field); } if (checkWriteConfiguration()) { writeConfiguration(); } } catch (Throwable t) { errors.add(t); } // set the list of errors to display when saving failed setCommitErrors(errors); }
while (itFields.hasNext()) { CmsSearchField curField = itFields.next(); if (curField.getName().equals(getParamField())) { m_field = curField; break;
store = Field.Store.YES; Field result = new Field(getName(), content, store, index); if (getBoost() != BOOST_DEFAULT) { result.setBoost(getBoost());