Exemplo n.º 1
0
 private FormulaVariable findExistentialVariable(
     VariablePathExpression attributePath, List<FormulaVariable> existentialFormulaVariables) {
   for (FormulaVariable formulaVariable : existentialFormulaVariables) {
     if (SpicyEngineUtility.containsPathWithSameVariableId(
         formulaVariable.getTargetOccurrencePaths(), attributePath)) {
       return formulaVariable;
     }
   }
   throw new IllegalArgumentException(
       "Unable to find variable for path "
           + attributePath
           + " in "
           + SpicyEngineUtility.printVariableList(existentialFormulaVariables));
 }
Exemplo n.º 2
0
 /////////////////////////////////   INTERMEDIATE NODE
 // /////////////////////////////////////////////////
 private ISkolemPart generateSkolemFunctionForIntermediateNode(
     SkolemFunctionGenerator generator, MappingTask mappingTask) {
   StringBuilder functionName = new StringBuilder();
   functionName.append("SK_");
   functionName.append(SpicyEngineUtility.removeRootLabel(generator.getName()));
   return generateAppendWithFunctionName(functionName.toString(), generator, mappingTask);
 }
Exemplo n.º 3
0
 private boolean containsSameAliases(
     ComplexConjunctiveQuery complexQuery, SimpleConjunctiveQuery simpleQuery) {
   for (SetAlias simple : simpleQuery.getVariables()) {
     if (SpicyEngineUtility.containsVariableWithSameId(complexQuery.getGenerators(), simple)) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 4
0
 private FormulaVariable findUniversalVariableForTargetPath(
     VariablePathExpression attributePath, List<FormulaVariable> universalFormulaVariables) {
   for (FormulaVariable formulaVariable : universalFormulaVariables) {
     if (SpicyEngineUtility.containsPathWithSameVariableId(
         formulaVariable.getTargetOccurrencePaths(), attributePath)) {
       return formulaVariable;
     }
   }
   return null;
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 private FormulaVariable findVariableForPath(
     VariablePathExpression attributePath, List<List<FormulaVariable>> variables) {
   //        for (int i = variables.size() - 1; i >= 0; i--) {
   for (int i = 0; i < variables.size(); i++) {
     List<FormulaVariable> variableList = variables.get(i);
     for (FormulaVariable formulaVariable : variableList) {
       if (SpicyEngineUtility.containsPathWithSameVariableId(
           formulaVariable.getOriginalSourceOccurrencePaths(), attributePath)) {
         return formulaVariable;
       }
     }
     for (FormulaVariable formulaVariable : variableList) {
       if (SpicyEngineUtility.containsPathWithSameVariableId(
           formulaVariable.getSourceOccurrencePaths(), attributePath)) {
         return formulaVariable;
       }
     }
   }
   throw new IllegalArgumentException(
       "Unable to find variable for path "
           + attributePath
           + " in "
           + SpicyEngineUtility.printListOfVariableLists(variables));
 }
Exemplo n.º 7
0
 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;
 }
Exemplo n.º 8
0
 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;
 }