public Map<String,Collection<?>> executeProgram(String programName, Set<String> contexts) throws LDPathException {
Map<String,Collection<?>> results = new HashMap<String,Collection<?>>();
SiteManagerBackend backend = new SiteManagerBackend(referencedSiteManager);
String ldPathProgram = getProgramByName(programName);
ValueFactory vf = InMemoryValueFactory.getInstance();
EntityhubLDPath ldPath = new EntityhubLDPath(backend, vf);
Program<Object> program = null;
try {
program = ldPath.parseProgram(LDPathUtils.constructReader(ldPathProgram));
} catch (LDPathParseException e) {
logger.error("Should never happen!!!!!", e);
return Collections.emptyMap();
}
Representation representation;
for (String context : contexts) {
representation = ldPath.execute(vf.createReference(context), program);
Iterator<String> fieldNames = representation.getFieldNames();
while (fieldNames.hasNext()) {
String fieldName = fieldNames.next();
Iterator<Object> valueIterator = representation.get(fieldName);
Set<Object> values = new HashSet<Object>();