Connectors : Consolidation Server : Appendix - Groovy Processors : Company's Hierarchy Example in Groovy
 
Company's Hierarchy Example in Groovy
Let us see how you can implement the Connect Employees to Services and Services to Companies in Groovy.
process("employee") {
def addService = { serviceName, companyName ->
serviceDoc = createDocument("service=" + serviceName + "&", "service")
serviceDoc.directives.datamodel_class = "service"
serviceDoc.addArcTo("service", "company=" + companyName + "&")
yield serviceDoc
serviceDoc //return object
}

if (it.metas.company_name && it.metas.service_name) {
serviceDoc = addService(it.metas.service_name[0], it.metas.company_name[0])
it.addArcTo("employee", serviceDoc.getUri())
}
}
For Count the Number of Employees and Push Updated Documents, a possible implementation could be:
process("company") {
it.metas.nb_employees = match(it, "-service.-employee").size();
}