Java 类org.hibernate.search.bridge.LuceneOptions 实例源码

项目:document-management-system    文件:MapFieldBridge.java   
@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>");
    }
}
项目:MathMLCanEval    文件:CanonicOutputBridge.java   
private Field newField(String name, String value, LuceneOptions luceneOptions,Analyzer analyzer)
{
    Field f =new Field(name,value,
            luceneOptions.getStore(),
            luceneOptions.getIndex(),
            luceneOptions.getTermVector()
    );

    f.setBoost(luceneOptions.getBoost());

    if(analyzer != null)
    {
        f.setTokenStream(analyzer.tokenStream(name, new StringReader(value)));
    }

    return f;
}
项目:projectforge-webapp    文件:HibernateSearchUsersBridge.java   
/**
 * 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);
}
项目:projectforge-webapp    文件:HibernateSearchTaskPathBridge.java   
/**
 * 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);
  }
}
项目:projectforge-webapp    文件:HibernateSearchUsersGroupsBridge.java   
/**
 * 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);
}
项目:infinispan-odata-server    文件:JsonValueWrapperFieldBridge.java   
@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);
    }
}
项目:Sound.je    文件:CoreBridgeDiscriminator.java   
@Override
public final void set(final String name,
                      final Object submittedValue,
                      final Document document,
                      final LuceneOptions luceneOptions) {

    final BridgeController.Presets presets = BridgeController.builder()
            .baseName(name)
            .document(document)
            .luceneOptions(luceneOptions)
            .build().new Presets();

    save(name, submittedValue, presets);
}
项目:document-management-system    文件:LowerCaseFieldBridge.java   
@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");
    }
}
项目:document-management-system    文件:LazyFieldBridge.java   
@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");
    }
}
项目:owsi-core-parent    文件:GenericEntityCollectionLongIdFieldBridge.java   
@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.addNumericFieldToDocument(name, objectToLong(object), document);
    }
}
项目:owsi-core-parent    文件:EnumCollectionFieldBridge.java   
@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);
    }
}
项目:owsi-core-parent    文件:StringCollectionFieldBridge.java   
@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);
    }
}
项目:owsi-core-parent    文件:GenericEntityIdFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    if (value == null) {
        return;
    }
    luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
项目:owsi-core-parent    文件:GenericEntityLongIdFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    if (value == null) {
        return;
    }
    luceneOptions.addNumericFieldToDocument(name, objectToLong(value), document);
}
项目:owsi-core-parent    文件:GenericEntityCollectionIdFieldBridge.java   
@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);
    }
}
项目:owsi-core-parent    文件:GenericEntityReferenceFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    if (value == null) {
        return;
    }
    luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
项目:infinispan-avro    文件:ValueWrapperFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
   if (name.contains(Support.DELIMITER))
      throw new CacheException("Name cannot contains delimiter \""+ Support.DELIMITER+"\"");
   GenericData.Record record = (GenericData.Record) value;
   Schema schema = record.getSchema();
   add(document, schema.getType(), "", value, schema);
}
项目:hawkular-alerts    文件:TagsBridge.java   
@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);
    }
}
项目:webdsl    文件:WebDSLDynamicFieldBridge.java   
@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() ) );
}
 }
项目:hapi-fhir    文件:BigDecimalNumericFieldBridge.java   
@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);
    }
}
项目:MathMLCanEval    文件:CanonicOutputBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions)
{
    if(value instanceof Collection<?>)
    {
        Collection<CanonicOutput> canonicOutputs = (Collection<CanonicOutput>) value;

        for(CanonicOutput co : canonicOutputs)
        {
            convertCanonicOutput(co, document, luceneOptions);
        }

        document.add(newField("coRuns", String.valueOf(canonicOutputs.size()), luceneOptions, null));
    }
}
项目:projectforge-webapp    文件:HibernateSearchAuftragsPositionBridge.java   
/**
 * @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);
}
项目:projectforge-webapp    文件:HibernateSearchKost2Bridge.java   
/**
 * @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);
}
项目:projectforge-webapp    文件:HibernateSearchKost1Bridge.java   
/**
 * @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);
}
项目:projectforge-webapp    文件:HibernateSearchProjectKostBridge.java   
/**
 * @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);
}
项目:spring-data-snowdrop    文件:MyCustomFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
  luceneOptions.addFieldToDocument(name + ".custom.name", (String) value, document);
  luceneOptions.addFieldToDocument(name + ".custom.dynamicName", (String) value, document);
}
项目:document-management-system    文件:LazyField.java   
public LazyField(String name, PersistentFile persistentFile, LuceneOptions luceneOptions) {
    super(name, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector());
    lazy = true;
    this.persistentFile = persistentFile;
}
项目:tweetarchive    文件:TweetYearBridge.java   
@Override
public void set(final String name, final Object value, final Document document, final LuceneOptions luceneOptions) {
    final TweetEntity tweet = (TweetEntity) value;
    luceneOptions.addFieldToDocument(name, String.valueOf(tweet.getCreatedAt().getYear()), document);
}
项目:owsi-core-parent    文件:MaterializedStringValueFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
项目:owsi-core-parent    文件:MaterializedPrimitiveValueFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
项目:owsi-core-parent    文件:NullEncodingGenericEntityReferenceFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
项目:owsi-core-parent    文件:NullEncodingGenericEntityIdFieldBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
项目:hawkular-alerts    文件:TagsBridge.java   
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    luceneOptions.addFieldToDocument(name, objectToString(value), document);
}
项目:webdsl    文件:UUIDFieldBridge.java   
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);
}
项目:hapi-fhir    文件:BigDecimalNumericFieldBridge.java   
protected void applyToLuceneOptions(LuceneOptions luceneOptions, String name, Number value, Document document) {
    luceneOptions.addNumericFieldToDocument(name, value, document);
}
项目:MathMLCanEval    文件:CanonicOutputBridge.java   
private void convertCanonicOutput(CanonicOutput canonicOutput,Document document,LuceneOptions luceneOptions)
{
    SimilarityForms sf = SimilarityFormConverterWrapper.getConverter().process(canonicOutput);             

    document.add(newField("co.configuration.id", 
            canonicOutput.getApplicationRun().getConfiguration().getId().toString(), 
            luceneOptions, 
            new StandardAnalyzer(Version.LUCENE_36)
        )
    );

    document.add(newField("co.revision.id", 
            canonicOutput.getApplicationRun().getRevision().getId().toString(), 
            luceneOptions, 
            new StandardAnalyzer(Version.LUCENE_36)
        )
    );

    document.add(newField("co.applicationrun.id", 
            canonicOutput.getApplicationRun().getId().toString(), 
            luceneOptions, 
            new StandardAnalyzer(Version.LUCENE_36)
        )
    );

    if(canonicOutput.getAnnotations() != null && !canonicOutput.getAnnotations().isEmpty())
    {
        for(Annotation a : canonicOutput.getAnnotations())
        {
            document.add(newField("co.annotation", a.getAnnotationContent(), luceneOptions, new StandardAnalyzer(Version.LUCENE_36)));
        }
    }        

    // mathml is converted into Single String representation
    // which is stored in co.distanceForm
    document.add(newField("co.distanceForm",sf.getDistanceForm(),luceneOptions,null));

    PerFieldAnalyzerWrapper keywordAnalyzer = new PerFieldAnalyzerWrapper(new KeywordAnalyzer());

    for(String s : sf.getCountForm().keySet())
    {
        document.add(newField("co.element", s+"="+sf.getCountForm().get(s), luceneOptions, keywordAnalyzer)); 
    }

    logger.info("Canonic output ["+canonicOutput.getId()+"] indexed.");
}
项目:projectforge-webapp    文件:HibernateSearchUserRightIdBridge.java   
/**
 * @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);
}
项目:my-paper    文件:BigDecimalNumericFieldBridge.java   
/**
 * 设置BigDecimal对象
 * 
 * @param name
 *            名称
 * @param value
 *            值
 * @param document
 *            document
 * @param luceneOptions
 *            luceneOptions
 */
@Override
public void set(String name, Object value, Document document, LuceneOptions luceneOptions) {
    if (value != null) {
        BigDecimal decimalValue = (BigDecimal) value;
        luceneOptions.addNumericFieldToDocument(name, decimalValue.doubleValue(), document);
    }
}
项目:oscm    文件:ProductClassBridgeIT.java   
private LuceneOptions mockLuceneOptions() {
    return null;

}
项目:development    文件:ProductClassBridgeIT.java   
private LuceneOptions mockLuceneOptions() {
    return null;

}