Appendix - Old DSL Functions

This appendix lists the main old Domain-Specific Language (DSL) functions that you could use with Structured Data Consolidation (SDC), the Consolidation Server's ancestor. For each, you can find the Groovy and Java equivalent functions.

DSL

delete()

Groovy

deleteDocument(it, false /* shouldBeRecursive */)

Java

handler.deleteDocument(document, false /* shouldBeRecursive */)

DSL

delete(uri)

Groovy

deleteDocument(uri, false /* shouldBeRecursive */)

Java

handler.deleteDocument(uri, false /* shouldBeRecursive */)

DSL

addCustomDirective(name, value)

Groovy

it.withDirective(name, value)

Java

handler.withDirective(name, value)

DSL

clearCustomDirective(name)

Groovy

it.deleteDirective(name)

Java

handler.deleteDirective(name)

DSL

vertexGet(path("path.to.nodes"))

Groovy

match(it, "path.to.nodes")*.last().flatten()

Java

GraphMatchHelpers.getPathsEnd(handler.match(document, "path.to.nodes"))

DSL

deleteParts(metaName)

Groovy

it.deleteParts(metaName)

Java

document.deleteParts(metaName)

DSL

distinct(["Foo", "Bar", "Foo"])

Groovy

["Foo", "Bar", "Foo"].unique()

Java

ImmutableSet.of("Foo", "Bar", "Foo")

DSL

hasMeta(name)

Groovy

it.hasMeta(name)

Java

document.hasMeta(name)

DSL

skipIf(docType, expression)

Groovy

process(docType) { if (expression) { discard() } ... }

Java

public String get[Transformation|Aggregation]Type() { return docType; } public void process(... handler, ... document) { if (expression) { handler.discard(); } }

DSL

metaDel(metaName)

Groovy

it.deleteMeta(metaName)

Java

document.deleteMeta(metaName)

DSL

metaGet(pathExpression, metaName)

Groovy

match(it, pathExpression)*.last().flatten().collect { it.getMetas(metaName) }.flatten()

Java

final List<String> result = new ArrayList<>(); or (final IAggregationDocument doc : GraphMatchHelpers.getPathsEnd(handler.match(document, pathExpression))) { result.addAll(doc.getMetas(metaName)); } return result;

DSL

metaGet(paths list, metaName, metaDefaultValue)

Groovy

paths list*.last().flatten().collect { value = it.getMeta(metaName) (value) ? value : metaDefaultValue }

Java

final List<String> result = new ArrayList<>(); for (final IAggregationDocument doc : GraphMatchHelpers.getPathsEnd(paths list)) { final String value = doc.getMeta(metaName)); result.add((value == null) ? metaDefaultValue : value); } return result;

DSL

metaSet(metaName, metaValue)

Groovy

it.withMeta(metaName, metaValue)

Java

document.withMeta(metaName, metaValue);

DSL

metaSet(metaName, metaValues)

Groovy

it.withMeta(metaName, metaValues)

Java

document.withMeta(metaName, metaValues);

DSL

metaSet(pathExpression)

Groovy

for (doc in match(it, pathExpression)*.last().flatten()) { it.withMetas(doc.getAllMetas()) }

Java

for (final IAggregationDocument doc : GraphMatchHelpers.getPathsEnd(handler.match(document, pathExpression))) { document.withMetas(doc.getAllMetas())); }

DSL

metaSet(targetMetaName, pathExpression, sourceMetaName)

Groovy

metas = match(it, pathExpression)*.last().flatten().collect { it.getMetas(sourceMetaName) } for (m in metas) { it.withMeta(targetMetaName, m) }

Java

final List<List<String>> selection = new ArrayList<>(); for (final IAggregationDocument doc : GraphMatchHelpers.getPathsEnd(handler.match(document, pathExpression))) { selection.add(doc.getMetas(metaName))); } for (final List<String> metas : selection) { document.withMeta(targetMetaName, metas); }

DSL

metaSet(pathExpression, metasList)

Groovy

docs = match(it, pathExpression)*.last().flatten() for (doc in docs) { for (metaName in metasList) { values = doc.getMetas(metaName) if (values) { it.withMeta(metaName, values) } } }

Java

for (final IAggregationDocument doc : GraphMatchHelpers.getPathsEnd(handler.match(document, pathExpression))) { for (final metaName : metasList) { final List<String> values = doc.getMetas(metaName); if (values != null) { document.withMeta(metaName, values); } } }

DSL

metaSet(targetMeta, pathExpression, sourceMeta, allowedTypes)

Groovy

docs = match(it, pathExpression)*.last().flatten().collect { if (allowedTypes.contains(it.getType()) { it } } for (doc in docs.flatten().minus(null)) { values = doc.getMetas(sourceMeta) if (values) { it.withMeta(targetMeta, values) } }

Java

final List<IAggregationDocument> selection = new ArrayList<>(); for (final IAggregationDocument doc : GraphMatchHelpers.getPathsEnd(handler.match(document, pathExpression))) { if (allowedTypes.contains(doc.getType())) { selection.add(doc); } }for (final IAggregationDocument doc : selection) { final List<String> metas = doc.getMetas(sourceMeta); if ((metas != null) && ! metas.isEmpty()) { document.withMeta(targetMeta, metas); } }

DSL

metaSet(targetMeta, pathExpression, sourceMeta, conditionMeta, allowedValues)

Groovy

docs = match(it, pathExpression)*.last().flatten().collect { if (allowedValues.contains(it.getMetas(conditionMeta)) { it } } for (doc in docs.flatten().minus(null)) { values = doc.getMetas(sourceMeta) if (values) { it.withMeta(targetMeta, values) } }

Java

final List<IAggregationDocument> selection = new ArrayList<>(); for (final IAggregationDocument doc : GraphMatchHelpers.getPathsEnd(handler.match(document, pathExpression))) { if (allowedValues.contains(doc.getMetas(conditionMeta)) { selection.add(doc); } } for (final IAggregationDocument doc : selection) { final List<String> metas = doc.getMetas(sourceMeta); if ((metas != null) && ! metas.isEmpty()) { document.withMeta(targetMeta, metas); } }