use of com.enonic.xp.data.PropertyVisitor in project xp by enonic.
the class NodeStoreDocumentFactory method addNodeDataProperties.
private void addNodeDataProperties(final IndexItems.Builder builder) {
PropertyVisitor visitor = new PropertyVisitor() {
@Override
public void visit(final Property property) {
if (!isNullOrEmpty(property.getString())) {
final IndexConfig configForData = node.getIndexConfigDocument().getConfigForPath(property.getPath());
if (configForData == null) {
throw new RuntimeException("Missing index configuration for data " + property.getPath());
}
builder.add(property, node.getIndexConfigDocument());
addReferenceAggregation(property);
}
}
private void addReferenceAggregation(final Property property) {
if (property.getType().equals(ValueTypes.REFERENCE)) {
builder.add(NodeIndexPath.REFERENCE, property.getValue(), createDefaultDocument(IndexConfig.MINIMAL));
}
}
};
visitor.traverse(this.node.data());
}
use of com.enonic.xp.data.PropertyVisitor 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);
}
Aggregations