@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>"); } }
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; }
/** * 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); }
/** * 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); } }
/** * 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); }
@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); } }
@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); }
@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"); } }
@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"); } }
@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); } }
@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); } }
@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); } }
@Override public void set(String name, Object value, Document document, LuceneOptions luceneOptions) { if (value == null) { return; } luceneOptions.addFieldToDocument(name, objectToString(value), document); }
@Override public void set(String name, Object value, Document document, LuceneOptions luceneOptions) { if (value == null) { return; } luceneOptions.addNumericFieldToDocument(name, objectToLong(value), document); }
@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); } }
@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); }
@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); } }
@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() ) ); } }
@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); } }
@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)); } }
/** * @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); }
/** * @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); }
/** * @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); }
/** * @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); }
@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); }
public LazyField(String name, PersistentFile persistentFile, LuceneOptions luceneOptions) { super(name, luceneOptions.getStore(), luceneOptions.getIndex(), luceneOptions.getTermVector()); lazy = true; this.persistentFile = persistentFile; }
@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); }
@Override public void set(String name, Object value, Document document, LuceneOptions luceneOptions) { luceneOptions.addFieldToDocument(name, objectToString(value), document); }
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); }
protected void applyToLuceneOptions(LuceneOptions luceneOptions, String name, Number value, Document document) { luceneOptions.addNumericFieldToDocument(name, value, document); }
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."); }
/** * @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); }
/** * 设置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); } }
private LuceneOptions mockLuceneOptions() { return null; }