Java Code Examples for org.hibernate.search.bridge.LuceneOptions

The following examples show how to use org.hibernate.search.bridge.LuceneOptions. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
	if (value instanceof Map<?, ?>) {
		@SuppressWarnings("unchecked")
		Map<String, Integer> map = (Map<String, Integer>) value;

		for (Entry<String, Integer> elto : map.entrySet()) {
			if ((Permission.READ & elto.getValue()) != 0) {
				if ("userPermissions".equals(name)) {
					name = "userPermission";
				} else if ("rolePermissions".equals(name)) {
					name = "rolePermission";
				}

				log.debug("Added field '{}' with value '{}'", name, elto.getKey());
				luceneOptions.addFieldToDocument(name, elto.getKey(), document);
			}
		}
	} else {
		log.warn("IllegalArgumentException: Support only Map<String, Integer>");
		throw new IllegalArgumentException("Support only Map<String, Integer>");
	}
}
 
Example 2
/**
 * Get all full names and user names of all users represented by the string of user id's.
 * @see org.hibernate.search.bridge.FieldBridge#set(java.lang.String, java.lang.Object, org.apache.lucene.document.Document,
 *      org.hibernate.search.bridge.LuceneOptions)
 */
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions)
{
  final LicenseDO license = (LicenseDO)value;
  if (StringUtils.isBlank(license.getOwnerIds()) == true) {
    return;
  }
  final UsersProvider usersProvider = new UsersProvider();
  final Collection<PFUserDO> users = usersProvider.getSortedUsers(license.getOwnerIds());
  final StringBuffer buf = new StringBuffer();
  boolean first = true;
  for (final PFUserDO user : users) {
    first = StringHelper.append(buf, first, user.getFullname(), " ");
    buf.append(" ").append(user.getUsername());
  }
  luceneOptions.addFieldToDocument(name, buf.toString(), document);
}
 
Example 3
/**
 * Get all names of ancestor tasks and task itself and creates an index containing all task titles separated by '|'. <br/>
 * Please note: does not work in JUnit test mode.
 * @see org.hibernate.search.bridge.FieldBridge#set(java.lang.String, java.lang.Object, org.apache.lucene.document.Document,
 *      org.hibernate.search.bridge.LuceneOptions)
 */
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions)
{
  final TaskDO task = (TaskDO) value;
  if (SpringContext.getWebApplicationContext() != null) { // Is null in test environment.
    final TaskTree taskTree = SpringContext.getBean(TaskTree.class);
    final TaskNode taskNode = taskTree.getTaskNodeById(task.getId());
    if (taskNode == null) {
      return;
    }
    final List<TaskNode> list = taskNode.getPathToRoot();
    final StringBuffer buf = new StringBuffer();
    for (final TaskNode node : list) {
      buf.append(node.getTask().getTitle()).append("|");
    }
    if (log.isDebugEnabled() == true) {
      log.debug(buf.toString());
    }
    luceneOptions.addFieldToDocument(name, buf.toString(), document);
  }
}
 
Example 4
/**
 * Get all names of groups and users and creates an index containing all user and group names separated by '|'. <br/>
 * @see org.hibernate.search.bridge.FieldBridge#set(java.lang.String, java.lang.Object, org.apache.lucene.document.Document,
 *      org.hibernate.search.bridge.LuceneOptions)
 */
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions)
{
  final TeamCalDO calendar = (TeamCalDO) value;
  final TeamCalDao teamCalDao = Registry.instance().getDao(TeamCalDao.class);
  if (teamCalDao == null) {
    if (Configuration.getInstance().isTestMode() == false) {
      log.error("TeamCalDao not found in registry!");
    }
    return;
  }
  final StringBuffer buf = new StringBuffer();
  appendGroups(teamCalDao.getSortedFullAccessGroups(calendar), buf);
  appendGroups(teamCalDao.getSortedReadonlyAccessGroups(calendar), buf);
  appendGroups(teamCalDao.getSortedMinimalAccessGroups(calendar), buf);
  appendUsers(teamCalDao.getSortedFullAccessUsers(calendar), buf);
  appendUsers(teamCalDao.getSortedReadonlyAccessUsers(calendar), buf);
  appendUsers(teamCalDao.getSortedMinimalAccessUsers(calendar), buf);
  if (log.isDebugEnabled() == true) {
    log.debug(buf.toString());
  }
  luceneOptions.addFieldToDocument(name, buf.toString(), document);
}
 
Example 5
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
	if (value instanceof String) {
		String str = ((String) value).toLowerCase();
		log.debug("Added field '{}' with value '{}'", name, str);
		luceneOptions.addFieldToDocument(name, str, document);
	} else {
		log.warn("IllegalArgumentException: Support only String");
		throw new IllegalArgumentException("Support only String");
	}
}
 
Example 6
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
	if (value instanceof PersistentFile) {
		PersistentFile pf = (PersistentFile) value;
		LazyField field = new LazyField(name, pf, luceneOptions);
		document.add(field);
	} else {
		log.warn("IllegalArgumentException: Support only String");
		throw new IllegalArgumentException("Support only String");
	}
}
 
Example 7
Source Project: hawkular-alerts   Source File: TagsBridge.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    Map<String, String> tags = (Map<String, String>)value;
    for (Map.Entry<String, String> tag : tags.entrySet()) {
        bridge.set(name, tag, document, luceneOptions);
    }
}
 
Example 8
Source Project: webdsl   Source File: WebDSLDynamicFieldBridge.java    License: Apache License 2.0 5 votes vote down vote up
@Override
  public void set(
      String name, Object value, Document document, LuceneOptions luceneOptions) {
for(DynamicSearchField dsf : ( (DynamicSearchFields) value).getDynamicSearchFields_()){
	document.add( new Field( dsf.fieldName, dsf.fieldValue, Store.NO,
            Index.NOT_ANALYZED, luceneOptions.getTermVector() ) );
}
 }
 
Example 9
Source Project: wallride   Source File: CustomFieldValuesBridge.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
	Collection<CustomFieldValue> customFieldValues = (Collection<CustomFieldValue>) value;
	if (customFieldValues != null) {
		for (CustomFieldValue cfv : customFieldValues) {
			if (cfv.getValue() != null) {
				luceneOptions.addFieldToDocument(name + "." + cfv.getCustomField().getCode(), cfv.getValue().toString(), document);
			}
		}
	}
}
 
Example 10
/**
 * @see org.hibernate.search.bridge.FieldBridge#set(java.lang.String, java.lang.Object, org.apache.lucene.document.Document,
 *      org.hibernate.search.bridge.LuceneOptions)
 */
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions)
{
  final AuftragsPositionDO position = (AuftragsPositionDO) value;
  final AuftragDO auftrag = position.getAuftrag();
  final StringBuffer buf = new StringBuffer();
  if (auftrag == null || auftrag.getNummer() == null) {
    return;
  }
  buf.append(auftrag.getNummer()).append(".").append(position.getNumber());
  if (log.isDebugEnabled() == true) {
    log.debug(buf.toString());
  }
  luceneOptions.addFieldToDocument(name, buf.toString(), document);
}
 
Example 11
/**
 * @see org.hibernate.search.bridge.FieldBridge#set(java.lang.String, java.lang.Object, org.apache.lucene.document.Document,
 *      org.hibernate.search.bridge.LuceneOptions)
 */
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions)
{
  final Kost2DO kost2 = (Kost2DO) value;
  final StringBuffer buf = new StringBuffer();
  buf.append(KostFormatter.format(kost2));
  buf.append(' ');
  buf.append(KostFormatter.format(kost2, true));
  luceneOptions.addFieldToDocument(name, buf.toString(), document);
}
 
Example 12
/**
 * @see org.hibernate.search.bridge.FieldBridge#set(java.lang.String, java.lang.Object, org.apache.lucene.document.Document,
 *      org.hibernate.search.bridge.LuceneOptions)
 */
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions)
{
  final Kost1DO kost1 = (Kost1DO) value;
  final StringBuffer buf = new StringBuffer();
  buf.append(KostFormatter.format(kost1));
  buf.append(' ');
  buf.append(KostFormatter.format(kost1, true));
  luceneOptions.addFieldToDocument(name, buf.toString(), document);
}
 
Example 13
/**
 * @see org.hibernate.search.bridge.FieldBridge#set(java.lang.String, java.lang.Object, org.apache.lucene.document.Document,
 *      org.hibernate.search.bridge.LuceneOptions)
 */
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions)
{
  final ProjektDO projekt = (ProjektDO) value;
  final StringBuffer buf = new StringBuffer();
  buf.append(KostFormatter.format(projekt));
  buf.append(' ');
  buf.append(KostFormatter.format(projekt, true));
  luceneOptions.addFieldToDocument(name, buf.toString(), document);
}
 
Example 14
public LazyField(String name, PersistentFile persistentFile, LuceneOptions luceneOptions) {
	super(name, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector());
	lazy = true;
	this.persistentFile = persistentFile;
}
 
Example 15
Source Project: hawkular-alerts   Source File: TagsBridge.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
 
Example 16
Source Project: webdsl   Source File: UUIDFieldBridge.java    License: Apache License 2.0 4 votes vote down vote up
public void set(String name, Object value, Document doc, LuceneOptions options) {
	Field field = new Field(name, value.toString(), options.getStore(), options.getIndex(), options.getTermVector());
	field.setBoost(options.getBoost());
	doc.add(field);
}
 
Example 17
/**
 * @see org.hibernate.search.bridge.FieldBridge#set(java.lang.String, java.lang.Object, org.apache.lucene.document.Document,
 *      org.hibernate.search.bridge.LuceneOptions)
 */
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions)
{
  final UserRightId userRightId = (UserRightId) value;
  luceneOptions.addFieldToDocument(name, userRightId.getId(), document);
}
 
Example 18
Source Project: development   Source File: ProductClassBridgeIT.java    License: Apache License 2.0 2 votes vote down vote up
private LuceneOptions mockLuceneOptions() {
    return null;

}