/////////////////////////////////   HYPERGRAPH NODE
 // /////////////////////////////////////////////////
 private ISkolemPart generateHyperGraphSkolemFunction(
     SkolemFunctionGenerator generator, MappingTask mappingTask) {
   // initialize data structures
   Map<SetAlias, List<GeneratorWithPath>> generatorsByAlias =
       new HashMap<SetAlias, List<GeneratorWithPath>>();
   Map<SetAlias, ISkolemPart> partsByAlias = new HashMap<SetAlias, ISkolemPart>();
   Map<VariableJoinCondition, ISkolemPart> partsForJoins =
       new HashMap<VariableJoinCondition, ISkolemPart>();
   initializeDataStructures(
       generator, generatorsByAlias, partsByAlias, partsForJoins, mappingTask);
   // generate tuple strings
   ISkolemPart partForTuples = generatePartForTuples(partsByAlias, mappingTask);
   ISkolemPart partForJoins = generatePartForJoins(generator, partsForJoins, mappingTask);
   ISkolemPart partForVariable = generatePartForVariable(generator, partsForJoins, mappingTask);
   ISkolemPart result = new AppendSkolemPart();
   result.addChild(new StringSkolemPart("SK("));
   result.addChild(new StringSkolemPart("Tuples="));
   result.addChild(partForTuples);
   result.addChild(new StringSkolemPart("**Joins="));
   result.addChild(partForJoins);
   if (generator.getTgd().getTargetView().getAllJoinConditions().size() > 1) {
     result.addChild(new StringSkolemPart("**Var="));
     result.addChild(partForVariable);
   }
   if (generator.getPosition() != null) {
     result.addChild(new StringSkolemPart("**Pos=" + generator.getPosition()));
   }
   result.addChild(new StringSkolemPart(")"));
   return result;
 }
 private ISkolemPart generateAppendWithFunctionName(
     String functionName, SkolemFunctionGenerator generator, MappingTask mappingTask) {
   StringSkolemPart functionString = new StringSkolemPart(functionName);
   ISkolemPart appendForSubGenerators = generateAppendsForSubGenerator(generator, mappingTask);
   ISkolemPart append = new AppendSkolemPart();
   append.addChild(functionString);
   append.addChild(appendForSubGenerators);
   return append;
 }
 private void generatePartsForJoins(
     List<VariableJoinCondition> joinConditions,
     Map<VariableJoinCondition, ISkolemPart> partsForJoins,
     Map<SetAlias, ISkolemPart> partsByAlias,
     MappingTask mappingTask) {
   for (VariableJoinCondition joinCondition : joinConditions) {
     SetAlias fromVariable = joinCondition.getFromVariable();
     SetAlias toVariable = joinCondition.getToVariable();
     ISkolemPart fromGroupPart = findPartForAlias(fromVariable, partsByAlias);
     ISkolemPart fromPathsPart = generatePartForPaths(joinCondition.getFromPaths());
     ISkolemPart toGroupPart = findPartForAlias(toVariable, partsByAlias);
     ISkolemPart toPathsPart = generatePartForPaths(joinCondition.getToPaths());
     ISkolemPart appendFrom = new AppendSkolemPart(false, "", "", ".");
     appendFrom.addChild(fromGroupPart);
     appendFrom.addChild(fromPathsPart);
     ISkolemPart appendTo = new AppendSkolemPart(false, "", "", ".");
     appendTo.addChild(toGroupPart);
     appendTo.addChild(toPathsPart);
     ISkolemPart root =
         new AppendSkolemPart(mappingTask.getConfig().useSortInSkolems(), "[", "]", "=");
     if (joinCondition.getFromPaths().toString().compareTo(joinCondition.getToPaths().toString())
         >= 0) {
       root.addChild(appendFrom);
       root.addChild(appendTo);
     } else {
       root.addChild(appendTo);
       root.addChild(appendFrom);
     }
     partsForJoins.put(joinCondition, root);
   }
 }
 //////////////////////////// first part: tuple part
 private ISkolemPart generatePartForTuples(
     Map<SetAlias, ISkolemPart> partsByAlias, MappingTask mappingTask) {
   List<SetAlias> variables = new ArrayList<SetAlias>(partsByAlias.keySet());
   Collections.sort(variables);
   ISkolemPart append =
       new AppendSkolemPart(mappingTask.getConfig().useSortInSkolems(), "", "", ", ", ", ");
   for (SetAlias setVariable : variables) {
     append.addChild(partsByAlias.get(setVariable));
   }
   return append;
 }
 private ISkolemPart generatePartForPaths(List<VariablePathExpression> paths) {
   ISkolemPart append = new AppendSkolemPart(false, "", "", "-", "-");
   List<String> pathStrings = new ArrayList<String>();
   for (VariablePathExpression path : paths) {
     pathStrings.add(SpicyEngineUtility.removeRootLabel(path.getAbsolutePath()).toString());
   }
   Collections.sort(pathStrings);
   for (String pathString : pathStrings) {
     append.addChild(new StringSkolemPart(pathString));
   }
   return append;
 }
 //////////////////////////// third part: variable part
 private ISkolemPart generatePartForVariable(
     SkolemFunctionGenerator generator,
     Map<VariableJoinCondition, ISkolemPart> partsForJoins,
     MappingTask mappingTask) {
   if (generator.getJoinConditions().isEmpty()) {
     return NullSkolemPart.getInstance();
   }
   ISkolemPart append =
       new AppendSkolemPart(mappingTask.getConfig().useSortInSkolems(), "", "", ", ");
   for (VariableJoinCondition variableJoinCondition : generator.getJoinConditions()) {
     append.addChild(partsForJoins.get(variableJoinCondition));
   }
   return append;
 }
 private ISkolemPart generateAppendsForSubGenerator(
     SkolemFunctionGenerator generator, MappingTask mappingTask) {
   ISkolemPart append =
       new AppendSkolemPart(mappingTask.getConfig().useSortInSkolems(), "(", ")", ", ");
   for (GeneratorWithPath subGeneratorWithPath : generator.getSubGenerators()) {
     VariablePathExpression subGeneratorPath = subGeneratorWithPath.getTargetPath();
     IValueGenerator subGenerator = subGeneratorWithPath.getGenerator();
     ISkolemPart appendForGenerator = new AppendSkolemPart(false, "", "", ": ");
     StringSkolemPart stringPart =
         new StringSkolemPart(
             SpicyEngineUtility.removeRootLabel(subGeneratorPath.getAbsolutePath()));
     SubGeneratorSkolemPart generatorPart = new SubGeneratorSkolemPart(subGenerator);
     appendForGenerator.addChild(stringPart);
     appendForGenerator.addChild(generatorPart);
     append.addChild(appendForGenerator);
   }
   return append;
 }
 private ISkolemPart generatePartForAlias(
     SetAlias variable, List<GeneratorWithPath> subGenerators, MappingTask mappingTask) {
   if (logger.isDebugEnabled())
     logger.debug("Generating part for set alias: " + variable + "\nGenerators: " + subGenerators);
   ISkolemPart generatorsAppend =
       new AppendSkolemPart(mappingTask.getConfig().useSortInSkolems(), "[", "]", ", ");
   for (GeneratorWithPath subGeneratorWithPath : subGenerators) {
     IValueGenerator subGenerator = subGeneratorWithPath.getGenerator();
     PathExpression absolutePath = subGeneratorWithPath.getTargetPath().getAbsolutePath();
     ISkolemPart appendForSubGenerator = new AppendSkolemPart(false, "", "", ": ");
     appendForSubGenerator.addChild(
         new StringSkolemPart(SpicyEngineUtility.removeRootLabel(absolutePath)));
     appendForSubGenerator.addChild(new SubGeneratorSkolemPart(subGenerator));
     generatorsAppend.addChild(appendForSubGenerator);
   }
   if (logger.isDebugEnabled()) logger.debug("Final result: " + generatorsAppend);
   return generatorsAppend;
 }
 //////////////////////////// second part: joins part
 private ISkolemPart generatePartForJoins(
     SkolemFunctionGenerator generator,
     Map<VariableJoinCondition, ISkolemPart> partsForJoins,
     MappingTask mappingTask) {
   List<VariableJoinCondition> joinConditions =
       generator.getTgd().getTargetView().getAllJoinConditions();
   if (joinConditions.isEmpty()) {
     return NullSkolemPart.getInstance();
   }
   List<VariableJoinCondition> sortedConditions =
       new ArrayList<VariableJoinCondition>(joinConditions);
   Collections.sort(sortedConditions);
   ISkolemPart append =
       new AppendSkolemPart(mappingTask.getConfig().useSortInSkolems(), "", "", ", ");
   for (VariableJoinCondition variableJoinCondition : sortedConditions) {
     ISkolemPart joinPart = partsForJoins.get(variableJoinCondition);
     append.addChild(joinPart);
   }
   return append;
 }