Search in sources :

Example 1 with FlattenedPageIndexUpgrader

use of com.enonic.xp.repo.impl.dump.upgrade.flattenedpage.FlattenedPageIndexUpgrader in project xp by enonic.

the class FlattenedPageIndexUpgraderTest method test.

private void test(final String dataFile, final String oldIndexDocumentFile, final String newIndexDocumentFile) throws Exception {
    final JsonNode pageComponents = loadJson(dataFile);
    final PropertyTree data = new JsonToPropertyTreeTranslator().translate(pageComponents);
    final List<PropertySet> components = Lists.newArrayList(data.getSets("components"));
    if (components.size() == 0) {
        throw new RuntimeException("page components is empty");
    }
    final String descriptorKeyStr = data.getString(PropertyPath.from("components.page.descriptor"));
    if (descriptorKeyStr == null) {
        throw new RuntimeException("page descriptorKey is null");
    }
    final DescriptorKey descriptorKey = DescriptorKey.from(descriptorKeyStr);
    final PatternIndexConfigDocument oldDocument = getIndexConfigDocument(oldIndexDocumentFile);
    final PatternIndexConfigDocument newDocument = new FlattenedPageIndexUpgrader(descriptorKey, components).upgrade(oldDocument);
    assertEquals(getIndexConfigDocument(newIndexDocumentFile), newDocument);
}
Also used : JsonToPropertyTreeTranslator(com.enonic.xp.json.JsonToPropertyTreeTranslator) PropertyTree(com.enonic.xp.data.PropertyTree) PropertySet(com.enonic.xp.data.PropertySet) DescriptorKey(com.enonic.xp.page.DescriptorKey) JsonNode(com.fasterxml.jackson.databind.JsonNode) PatternIndexConfigDocument(com.enonic.xp.index.PatternIndexConfigDocument) FlattenedPageIndexUpgrader(com.enonic.xp.repo.impl.dump.upgrade.flattenedpage.FlattenedPageIndexUpgrader)

Example 2 with FlattenedPageIndexUpgrader

use of com.enonic.xp.repo.impl.dump.upgrade.flattenedpage.FlattenedPageIndexUpgrader in project xp by enonic.

the class IndexConfigUpgrader method upgradePageIndexConfig.

private PatternIndexConfigDocument upgradePageIndexConfig(final PatternIndexConfigDocument sourceDocument, final NodeVersion nodeVersion) {
    final List<PropertySet> components = Lists.newArrayList(nodeVersion.getData().getSets("components"));
    final String descriptorKeyStr = nodeVersion.getData().getString(PropertyPath.from("components.page.descriptor"));
    final DescriptorKey pageDescriptorKey = descriptorKeyStr != null ? DescriptorKey.from(descriptorKeyStr) : null;
    final FlattenedPageIndexUpgrader pageIndexUpgrader = new FlattenedPageIndexUpgrader(pageDescriptorKey, components);
    return pageIndexUpgrader.upgrade(sourceDocument);
}
Also used : PropertySet(com.enonic.xp.data.PropertySet) DescriptorKey(com.enonic.xp.page.DescriptorKey) FlattenedPageIndexUpgrader(com.enonic.xp.repo.impl.dump.upgrade.flattenedpage.FlattenedPageIndexUpgrader)

Aggregations

PropertySet (com.enonic.xp.data.PropertySet)2 DescriptorKey (com.enonic.xp.page.DescriptorKey)2 FlattenedPageIndexUpgrader (com.enonic.xp.repo.impl.dump.upgrade.flattenedpage.FlattenedPageIndexUpgrader)2 PropertyTree (com.enonic.xp.data.PropertyTree)1 PatternIndexConfigDocument (com.enonic.xp.index.PatternIndexConfigDocument)1 JsonToPropertyTreeTranslator (com.enonic.xp.json.JsonToPropertyTreeTranslator)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1