private MetaProperty newMetaProperty(final KProperty<?> property) { Set<Class<?>> types = new CopyOnWriteArraySet<Class<?>>() {{ add(property.getValue().getClass()); }}; return new MetaPropertyImpl(property.getName(), property.isSearchable(), property.isSortable(), types); } }
private Set<Field> buildDefaultField(KProperty<?> prop, ProtobufType int32) { return Collections.singleton(this.createField(ProtobufScope.OPTIONAL, int32, this.sanitize(prop.getName()), prop.isSortable(), prop.isSearchable())); }
public void updateMetaModel(final KObject object) { final MetaObject metaObject = metaModelStore.getMetaObject(object.getType().getName()); if (metaObject == null) { metaModelStore.add(newMetaObject(object)); } else { Optional.ofNullable(object.getProperties()) .ifPresent(kProperties -> { for (final KProperty property : object.getProperties()) { final Optional<MetaProperty> metaProperty = metaObject.getProperty(property.getName()); if (!metaProperty.isPresent()) { metaObject.addProperty(newMetaProperty(property)); } else { metaProperty.get().addType(property.getValue().getClass()); if (property.isSearchable()) { metaProperty.get().setAsSearchable(); } } } metaModelStore.update(metaObject); }); } }
for (final IndexableField field : fields) { doc.add(field); if (field instanceof TextField && !(property.getValue() instanceof Boolean)) { allText.append(field.stringValue()).append('\n');
private KProperty<?> getProperty(KObject document, String name) { return StreamSupport .stream(document.getProperties().spliterator(), false) .filter(kProperty -> kProperty.getName().equals(name)) .findAny().get(); }
.iterator() .forEachRemaining(kprop -> Optional.ofNullable(descriptor.findFieldByName(toProtobufFormat(kprop.getName()))) .ifPresent(field -> props .putIfAbsent(field.getNumber(), MetaObject.META_OBJECT_FULL_TEXT, props.values().stream() .filter(kProperty -> kProperty.isSearchable() && !(kProperty.getValue() instanceof Boolean)) .map(kProperty -> String.valueOf(kProperty.getValue()).toLowerCase()) .collect(joining("\n"))); try { KProperty<?> kProperty = props.get(number); this.writeField(toProtobufFormat(kProperty.getName()), kProperty.getValue(), protoStreamWriter); } catch (IOException e) {
private Set<Field> build(KProperty<?> prop) { Class<?> aClass = prop.getValue().getClass(); ProtobufType.INT64); } else if (VersionHistory.class.isAssignableFrom(aClass)) { return this.build((VersionHistory) prop.getValue()); } else if (Collection.class.isAssignableFrom(aClass)) { return buildDefaultField(prop,
private Set<Field> buildDefaultField(KProperty<?> prop, ProtobufType int32) { return Collections.singleton(this.createField(ProtobufScope.OPTIONAL, int32, this.sanitize(prop.getName()), prop.isSortable(), prop.isSearchable())); }
private KProperty<?> getProperty(KObject document, String name) { return StreamSupport .stream(document.getProperties().spliterator(), false) .filter(kProperty -> kProperty.getName().equals(name)) .findAny().get(); }
private Set<String> getDataTypeNamesFromKObject( final KObject kObject ) { final Set<String> dataTypeNames = new HashSet<>(); if ( kObject == null ) { return dataTypeNames; } for ( KProperty property : kObject.getProperties() ) { if ( property.getName().equals( ResourceType.JAVA.toString() ) ) { dataTypeNames.add(property.getValue().toString()); } } return dataTypeNames; }
private List<ElasticMetaProperty> build(KProperty<?> property) { if (Enum.class.isAssignableFrom(property.getValue().getClass())) { return Arrays.asList(new ElasticMetaProperty(property.getName(), property.getValue().toString().toLowerCase(), new HashSet<>(Arrays.asList(String.class)), property.isSortable(), property.isSearchable())); if (FileTime.class.isAssignableFrom(property.getValue().getClass())) { return Arrays.asList(new ElasticMetaProperty(property.getName(), String.valueOf(((FileTime) property.getValue()).toMillis()), new HashSet<>(Arrays.asList(Long.class)), property.isSortable(), property.isSearchable())); if (Date.class.isAssignableFrom(property.getValue().getClass())) { return Arrays.asList(new ElasticMetaProperty(property.getName(), String.valueOf(((Date) property.getValue()).getTime()), new HashSet<>(Arrays.asList(Long.class)), property.isSortable(), property.isSearchable())); if (Collection.class.isAssignableFrom(property.getValue().getClass())) { Collection<Object> values = ((Collection) property.getValue()); String content = values.stream() .map(Object::toString) .collect(Collectors.joining(" ")); return Arrays.asList(new ElasticMetaProperty(property.getName(),
.iterator() .forEachRemaining(kprop -> Optional.ofNullable(descriptor.findFieldByName(toProtobufFormat(kprop.getName()))) .ifPresent(field -> props .putIfAbsent(field.getNumber(), MetaObject.META_OBJECT_FULL_TEXT, props.values().stream() .filter(kProperty -> kProperty.isSearchable() && !(kProperty.getValue() instanceof Boolean)) .map(kProperty -> String.valueOf(kProperty.getValue()).toLowerCase()) .collect(joining("\n"))); try { KProperty<?> kProperty = props.get(number); this.writeField(toProtobufFormat(kProperty.getName()), kProperty.getValue(), protoStreamWriter); } catch (IOException e) {
private Set<Field> build(KProperty<?> prop) { Class<?> aClass = prop.getValue().getClass(); ProtobufType.INT64); } else if (VersionHistory.class.isAssignableFrom(aClass)) { return this.build((VersionHistory) prop.getValue()); } else if (Collection.class.isAssignableFrom(aClass)) { return buildDefaultField(prop,
private KProperty<?> getProperty(KObject document, String name) { return StreamSupport .stream(document.getProperties().spliterator(), false) .filter(kProperty -> kProperty.getName().equals(name)) .findAny().get(); }
private Map<String, Map<String, String>> getRuleFlowGroupNamesNamesFromKObject(final KObject kObject) { final Map<String, Map<String, String>> ruleFlowGroupNames = new HashMap<String, Map<String, String>>(); if (kObject == null) { return ruleFlowGroupNames; } for (KProperty property : kObject.getProperties()) { if (property.getName().equals(SharedPartIndexTerm.TERM + ":" + PartType.RULEFLOW_GROUP.toString())) { if (ruleFlowGroupNames.containsKey(property.getValue().toString())) { final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey()))); ruleFlowGroupNames.get(property.getValue().toString()).put("name", property.getValue().toString()); ruleFlowGroupNames.get(property.getValue().toString()).put("filename", path.getFileName()); ruleFlowGroupNames.get(property.getValue().toString()).put("pathuri", path.toURI()); } else { final Path path = Paths.convert(ioService.get(URI.create(kObject.getKey()))); ruleFlowGroupNames.put(property.getValue().toString(), new HashMap<String, String>()); ruleFlowGroupNames.get(property.getValue().toString()).put("name", property.getValue().toString()); ruleFlowGroupNames.get(property.getValue().toString()).put("filename", path.getFileName()); ruleFlowGroupNames.get(property.getValue().toString()).put("pathuri", path.toURI()); } } } return ruleFlowGroupNames; } }
private List<ElasticMetaProperty> build(KProperty<?> property) { if (Enum.class.isAssignableFrom(property.getValue().getClass())) { return Arrays.asList(new ElasticMetaProperty(property.getName(), property.getValue().toString().toLowerCase(), new HashSet<>(Arrays.asList(String.class)), property.isSortable(), property.isSearchable())); if (FileTime.class.isAssignableFrom(property.getValue().getClass())) { return Arrays.asList(new ElasticMetaProperty(property.getName(), String.valueOf(((FileTime) property.getValue()).toMillis()), new HashSet<>(Arrays.asList(Long.class)), property.isSortable(), property.isSearchable())); if (Date.class.isAssignableFrom(property.getValue().getClass())) { return Arrays.asList(new ElasticMetaProperty(property.getName(), String.valueOf(((Date) property.getValue()).getTime()), new HashSet<>(Arrays.asList(Long.class)), property.isSortable(), property.isSearchable())); if (Collection.class.isAssignableFrom(property.getValue().getClass())) { Collection<Object> values = ((Collection) property.getValue()); String content = values.stream() .map(Object::toString) .collect(Collectors.joining(" ")); return Arrays.asList(new ElasticMetaProperty(property.getName(),
assertEquals("aFile.txt", getProperty(documents.get(0), "filename").getValue()); assertEquals("bFile.txt", getProperty(documents.get(1), "filename").getValue()); assertEquals("cFile1.txt", getProperty(documents.get(2), "filename").getValue()); assertEquals("CFile2.txt", getProperty(documents.get(3), "filename").getValue());
private KProperty<?> getProperty(KObject document, String name) { return StreamSupport .stream(document.getProperties().spliterator(), false) .filter(kProperty -> kProperty.getName().equals(name)) .findAny().get(); }
.filter((kp) -> kp.getName().equals(PackageNameIndexTerm.TERM)) .findFirst(); .flatMap((pkg) -> Optional.of(pkg.getValue().toString())) .ifPresent((pkgName) -> kProperties .stream() .filter((kp) -> kp.getName().equals(ResourceType.RULE.toString())) .forEach((r) -> ruleNames.add(new RuleName(r.getValue() .toString() .replace(pkgName,