use of com.enonic.xp.index.PathIndexConfig in project xp by enonic.
the class IndexConfigDocMapper method serialize.
private void serialize(final MapGenerator gen, final PatternIndexConfigDocument document) {
gen.map(DEFAULT_CONFIG);
serialize(gen, document.getDefaultConfig());
gen.end();
gen.array(CONFIG_ARRAY);
final ImmutableSortedSet<PathIndexConfig> pathIndexConfigs = document.getPathIndexConfigs();
for (final PathIndexConfig pathIndexConfig : pathIndexConfigs) {
gen.map();
gen.value(CONFIG_PATH, pathIndexConfig.getPath().toString());
gen.map(CONFIG_SETTINGS);
serialize(gen, pathIndexConfig.getIndexConfig());
gen.end();
gen.end();
}
gen.end();
}
use of com.enonic.xp.index.PathIndexConfig in project xp by enonic.
the class HtmlAreaNodeDataUpgrader method upgradeNodeData.
private void upgradeNodeData(final PropertySet nodeData, final PatternIndexConfigDocument indexConfigDocument) {
final List<Pattern> htmlAreaPatterns = indexConfigDocument.getPathIndexConfigs().stream().filter(this::hasHtmlStripperProcessor).map(PathIndexConfig::getPath).map(PropertyPath::toString).map(HtmlAreaNodeDataUpgrader::toPattern).collect(Collectors.toList());
final PropertyVisitor propertyVisitor = new PropertyVisitor() {
@Override
public void visit(final Property property) {
if (isHtmlAreaProperty(property)) {
upgradeHtmlAreaProperty(property, false);
} else if (isBackwardCompatibleHtmlAreaProperty(property)) {
upgradeHtmlAreaProperty(property, true);
}
}
private boolean isHtmlAreaProperty(Property property) {
return ValueTypes.STRING.equals(property.getType()) && htmlAreaPatterns.stream().anyMatch(htmlPattern -> htmlPattern.matcher(property.getPath().toString()).matches());
}
private boolean isBackwardCompatibleHtmlAreaProperty(Property property) {
return ValueTypes.STRING.equals(property.getType()) && BACKWARD_COMPATIBILITY_HTML_PROPERTY_PATH_PATTERNS.stream().anyMatch(htmlPattern -> htmlPattern.matcher(property.getPath().toString()).matches());
}
};
propertyVisitor.traverse(nodeData);
}
use of com.enonic.xp.index.PathIndexConfig in project xp by enonic.
the class IndexConfigFactoryTest method path_index_configs.
@Test
public void path_index_configs() throws Exception {
final PatternIndexConfigDocument fullConfig = createFullConfig();
final ImmutableSortedSet<PathIndexConfig> pathIndexConfigs = fullConfig.getPathIndexConfigs();
assertEquals(3, pathIndexConfigs.size());
assertEquals(IndexConfig.FULLTEXT, fullConfig.getConfigForPath(PropertyPath.from("displayName")));
}
Aggregations