/** * Returns the display name of the field.<p> * * @return the display name of the field */ public String getDisplayName() { if (!isDisplayed()) { return IGNORE_DISPLAY_NAME; } if (m_displayName == null) { return getName(); } else { return m_displayName; } }
/** * Creates a field from the configuration and the provided content.<p> * * The configured name of the field as provided by {@link #getName()} is used.<p> * * If no valid content is provided (that is the content is either <code>null</code> or * only whitespace), then no field is created and <code>null</code> is returned.<p> * * @param content the content to create the field with * * @return a field created from the configuration and the provided content */ public Field createField(String content) { return createField(getName(), content); }
/** * 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 = getFields().iterator(); while (i.hasNext()) { CmsLuceneField field = (CmsLuceneField)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); }
/** * Returns an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration.<p> * * @param analyzer the base analyzer to wrap * * @return an analyzer that wraps the given base analyzer with the analyzers of this individual field configuration */ public Analyzer getAnalyzer(Analyzer analyzer) { // parent folder and last modified lookup fields must use whitespace analyzer WhitespaceAnalyzer ws = new WhitespaceAnalyzer(); Map<String, Analyzer> analyzers = new HashMap<String, Analyzer>(); // first make map the default hard coded fields analyzers.put(CmsSearchField.FIELD_PARENT_FOLDERS, ws); analyzers.put(CmsSearchField.FIELD_CATEGORY, ws); analyzers.put(CmsSearchField.FIELD_DATE_LASTMODIFIED_LOOKUP, ws); analyzers.put(CmsSearchField.FIELD_DATE_CREATED_LOOKUP, ws); for (CmsLuceneField field : getLuceneFields()) { Analyzer fieldAnalyzer = field.getAnalyzer(); if (fieldAnalyzer != null) { // this field has an individual analyzer configured analyzers.put(field.getName(), fieldAnalyzer); } } // return the individual field configured analyzer return new PerFieldAnalyzerWrapper(analyzer, analyzers); }
/** * 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<CmsSelectWidgetOption> getFieldList() { List<CmsSelectWidgetOption> retVal = new ArrayList<CmsSelectWidgetOption>(); try { Iterator<CmsSearchField> i = getSearchFields().iterator(); while (i.hasNext()) { CmsLuceneField field = (CmsLuceneField)i.next(); retVal.add( new CmsSelectWidgetOption( field.getName(), true, getMacroResolver().resolveMacros(field.getDisplayName()))); } } catch (Exception e) { // noop } return retVal; }
while (itFields.hasNext()) { CmsLuceneField curField = (CmsLuceneField)itFields.next(); if (curField.getName().equals(idxFieldName)) { idxField = curField;
while (itFields.hasNext()) { CmsLuceneField field = (CmsLuceneField)itFields.next(); String fieldName = field.getName(); boolean fieldStore = field.isStored(); String fieldIndex = field.getIndexed();
result.append(key(Messages.GUI_LIST_FIELD_ACTION_DELETE_CONF_1, new Object[] {m_field.getName()})); result.append(createWidgetTableEnd()); result.append(dialogBlockEnd());
/** * 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(CmsLuceneField 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); } }
String item = (String)listItem.get(LIST_COLUMN_NAME); CmsLuceneField curField = (CmsLuceneField)itFields.next(); String fieldName = curField.getName(); if (item.equals(fieldName)) { deleteFields.add(curField);
/** * @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()) { field = (CmsLuceneField)itFields.next(); if (field.getName().equals(getParamField())) { result = field.getMappings();
while (itFields.hasNext()) { CmsLuceneField curField = (CmsLuceneField)itFields.next(); if (curField.getName().equals(m_paramField)) {
/** * @see org.opencms.workplace.list.A_CmsListDialog#getListItems() */ @Override protected List<CmsListItem> getListItems() { List<CmsListItem> result = new ArrayList<CmsListItem>(); // get content List<CmsSearchField> fields = getFields(); Iterator<CmsSearchField> itFields = fields.iterator(); CmsLuceneField field; while (itFields.hasNext()) { field = (CmsLuceneField)itFields.next(); CmsListItem item = getList().newItem(field.getName()); String defaultValue = field.getDefaultValue(); if (defaultValue == null) { defaultValue = "-"; } item.set(LIST_COLUMN_NAME, field.getName()); item.set(LIST_COLUMN_DISPLAY, resolveMacros(field.getDisplayName())); item.set(LIST_COLUMN_BOOST, new Float(field.getBoost()).toString()); item.set(LIST_COLUMN_INDEX, field.getIndexed()); item.set(LIST_COLUMN_EXCERPT_HIDE, Boolean.valueOf(field.isInExcerpt())); item.set(LIST_COLUMN_STORE_HIDE, Boolean.valueOf(field.isStored())); item.set(LIST_COLUMN_DEFAULT, defaultValue); result.add(item); } return result; }
/** * Public constructor.<p> * * @param luceneField */ public CmsSolrField(CmsLuceneField luceneField) { super(); String name = luceneField.getName(); IndexSchema schema = OpenCms.getSearchManager().getSolrServerConfiguration().getSolrSchema(); if (schema.hasExplicitField(name)) { // take the lucene field name for Solr } else if ((luceneField.getType() != null) && schema.isDynamicField(luceneField.getName() + "_" + luceneField.getType())) { // try to use the specified type attribute as dynamic field suffix name = luceneField.getName() + "_" + luceneField.getType(); } else { // fallback create a general_text field name = luceneField.getName() + "_txt"; } setName(name); setBoost(luceneField.getBoost()); setDefaultValue(luceneField.getDefaultValue()); for (I_CmsSearchFieldMapping mapping : luceneField.getMappings()) { addMapping(mapping); } }
while (itFields.hasNext()) { CmsLuceneField curField = (CmsLuceneField)itFields.next(); if (curField.getName().equals(getParamField())) { m_field = curField; break;
+ I_CmsXmlConfiguration.A_NAME + "='" + field.getName() + "']"; createField(document, fieldPath, field);
CmsSetupXmlHelper.setValue(document, xpath + "/@" + I_CmsXmlConfiguration.A_NAME, field.getName()); if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(field.getDisplayNameForConfiguration())) { CmsSetupXmlHelper.setValue(