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);
}
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);
}
Aggregations