本文整理汇总了Java中org.hibernate.search.bridge.LuceneOptions.addFieldToDocument方法的典型用法代码示例。如果您正苦于以下问题:Java LuceneOptions.addFieldToDocument方法的具体用法?Java LuceneOptions.addFieldToDocument怎么用?Java LuceneOptions.addFieldToDocument使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.hibernate.search.bridge.LuceneOptions
的用法示例。
在下文中一共展示了LuceneOptions.addFieldToDocument方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
@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>");
}
}
示例2: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
/**
* 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);
}
示例3: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
/**
* 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);
}
}
示例4: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
/**
* 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);
}
示例5: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
if (!(value instanceof JsonValueWrapper)) {
throw new IllegalArgumentException("This FieldBridge can only be applied to a JsonValueWrapper");
}
valueWrapper = (JsonValueWrapper) value;
json = valueWrapper.getJson();
try {
Map<String, Object> entryAsMap = (Map<String, Object>) mapper.readValue(json, Object.class);
for (String field : entryAsMap.keySet()) {
if (entryAsMap.get(field) instanceof Number) {
log.warn("Number field recognized. Field: " + field + " value: " + entryAsMap.get(field) +
" Indexing of number fields will be supported in later versions.");
} else {
luceneOptions.addFieldToDocument(field, entryAsMap.get(field).toString(), document);
}
}
} catch (Exception e) {
log.error("EXCEPTION occurred in JsonValueWrapperFieldBridge during adding fields into Lucene Document.", e);
}
}
示例6: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
@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");
}
}
示例7: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
if (value == null) {
return;
}
if (!(value instanceof Collection)) {
throw new IllegalArgumentException("This FieldBridge only supports Collection of Enum properties.");
}
Collection<?> objects = (Collection<?>) value;
for (Object object : objects) {
luceneOptions.addFieldToDocument(name, objectToString(object), document);
}
}
示例8: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
if (value == null) {
return;
}
if (!(value instanceof Collection)) {
throw new IllegalArgumentException("This FieldBridge only supports Collection of String properties.");
}
Collection<?> objects = (Collection<?>) value;
for (Object object : objects) {
luceneOptions.addFieldToDocument(name, objectToString(object), document);
}
}
示例9: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
if (value == null) {
return;
}
luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
示例10: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
if (value == null) {
return;
}
if (!(value instanceof Collection)) {
throw new IllegalArgumentException("This FieldBridge only supports Collection of GenericEntity properties.");
}
Collection<?> objects = (Collection<?>) value;
for (Object object : objects) {
luceneOptions.addFieldToDocument(name, objectToString(object), document);
}
}
示例11: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
if (value == null) {
if (luceneOptions.indexNullAs() != null) {
luceneOptions.addFieldToDocument(name, luceneOptions.indexNullAs(), document);
}
} else {
BigDecimal bdValue = (BigDecimal)value;
applyToLuceneOptions(luceneOptions, name, bdValue.doubleValue(), document);
}
}
示例12: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
/**
* @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);
}
示例13: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
/**
* @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);
}
示例14: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
/**
* @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);
}
示例15: set
import org.hibernate.search.bridge.LuceneOptions; //导入方法依赖的package包/类
/**
* @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);
}