Search in sources :

Example 1 with PathIndexConfig

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();
}
Also used : PathIndexConfig(com.enonic.xp.index.PathIndexConfig)

Example 2 with PathIndexConfig

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);
}
Also used : Property(com.enonic.xp.data.Property) ContentConstants(com.enonic.xp.content.ContentConstants) IndexValueProcessor(com.enonic.xp.index.IndexValueProcessor) Logger(org.slf4j.Logger) PropertyVisitor(com.enonic.xp.data.PropertyVisitor) PropertySet(com.enonic.xp.data.PropertySet) LoggerFactory(org.slf4j.LoggerFactory) Set(java.util.Set) ValueFactory(com.enonic.xp.data.ValueFactory) PathIndexConfig(com.enonic.xp.index.PathIndexConfig) Collectors(java.util.stream.Collectors) HashSet(java.util.HashSet) DumpUpgradeStepResult(com.enonic.xp.dump.DumpUpgradeStepResult) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) List(java.util.List) Matcher(java.util.regex.Matcher) Stream(java.util.stream.Stream) Reference(com.enonic.xp.util.Reference) NodeVersion(com.enonic.xp.node.NodeVersion) ValueTypes(com.enonic.xp.data.ValueTypes) PropertyPath(com.enonic.xp.data.PropertyPath) Pattern(java.util.regex.Pattern) PropertyTree(com.enonic.xp.data.PropertyTree) Pattern(java.util.regex.Pattern) PropertyPath(com.enonic.xp.data.PropertyPath) Property(com.enonic.xp.data.Property) PropertyVisitor(com.enonic.xp.data.PropertyVisitor)

Example 3 with PathIndexConfig

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")));
}
Also used : PathIndexConfig(com.enonic.xp.index.PathIndexConfig) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) Test(org.junit.jupiter.api.Test)

Aggregations

PathIndexConfig (com.enonic.xp.index.PathIndexConfig)3 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)2 ContentConstants (com.enonic.xp.content.ContentConstants)1 Property (com.enonic.xp.data.Property)1 PropertyPath (com.enonic.xp.data.PropertyPath)1 PropertySet (com.enonic.xp.data.PropertySet)1 PropertyTree (com.enonic.xp.data.PropertyTree)1 PropertyVisitor (com.enonic.xp.data.PropertyVisitor)1 ValueFactory (com.enonic.xp.data.ValueFactory)1 ValueTypes (com.enonic.xp.data.ValueTypes)1 DumpUpgradeStepResult (com.enonic.xp.dump.DumpUpgradeStepResult)1 IndexValueProcessor (com.enonic.xp.index.IndexValueProcessor)1 NodeVersion (com.enonic.xp.node.NodeVersion)1 Reference (com.enonic.xp.util.Reference)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Collectors (java.util.stream.Collectors)1