private void creaPopUpMappingTaskTreeTargetDuplicate() {
   this.popUpMenuTargetDuplicate = new JPopupMenu();
   MappingTask mappingTask = scenario.getMappingTask();
   if (mappingTask != null) {
     this.popUpMenuTargetDuplicate.add(
         new ActionDuplicateSetNode(this, targetSchemaTree, mappingTask.getTargetProxy()));
   }
 }
Пример #2
0
 public static String generateCasting(
     VariablePathExpression attributePath, String columnName, MappingTask mappingTask) {
   INode attributeNode =
       new FindNode()
           .findNodeInSchema(attributePath.getAbsolutePath(), mappingTask.getTargetProxy());
   String value = attributeNode.getChild(0).getLabel();
   String castedColumnName = mappingTask.getDBMSHandler().forceCast(columnName, value);
   return castedColumnName;
 }
Пример #3
0
 public void visitComplexConjunctiveQuery(ComplexConjunctiveQuery complexQuery) {
   stack.add(0, complexQuery);
   //        List<FormulaVariable> universalVariables =
   // variableFinder.getUniversalVariables(variableMaps, stack);
   //        variables.add(0, universalVariables);
   result.append(
       generateConjunctionString(
           complexQuery.getGenerators(),
           variables,
           mappingTask.getSourceProxy().getIntermediateSchema()));
   result.append(generateBuiltinsForSelections(complexQuery));
   List<Expression> equalities = variableFinder.getEqualities(variableMaps, stack);
   if (!equalities.isEmpty()) {
     result.append(generateEqualityString(equalities, variables, false));
   }
   // intersection
   if (complexQuery.hasIntersection()) {
     if (useSaveFormat) {
       result.append(", \n");
     } else {
       result
           .append("\n")
           .append(generateIndent())
           .append(utility.SECONDARY_INDENT)
           .append("and ");
     }
     SimpleConjunctiveQuery intersectionQuery = complexQuery.getConjunctionForIntersection();
     stack.add(0, intersectionQuery);
     List<FormulaVariable> existentialVariables =
         variableFinder.getExistentialVariables(variableMaps, stack);
     variables.add(0, existentialVariables);
     if (!existentialVariables.isEmpty() && !useSaveFormat) {
       result.append("exist ");
       result.append(utility.printVariables(existentialVariables));
     }
     if (!useSaveFormat) {
       result.append(" (// base view ").append(intersectionQuery.getId()).append("\n");
     }
     result.append(
         generateConjunctionString(
             intersectionQuery.getGenerators(),
             variables,
             mappingTask.getSourceProxy().getIntermediateSchema()));
     List<Expression> intersectionEqualities = variableFinder.getEqualities(variableMaps, stack);
     if (!intersectionEqualities.isEmpty()) {
       result.append(generateEqualityString(intersectionEqualities, variables, false));
     }
     variables.remove(0);
     stack.remove(0);
     if (!useSaveFormat) {
       result.append("\n").append(generateIndent()).append(utility.SECONDARY_INDENT).append(")");
     }
   }
   //        variables.remove(0);
   stack.remove(0);
 }
 private void creaPopUpMappingTaskTreeSourceDuplicate() {
   this.popUpMenuSourceDuplicate = new JPopupMenu();
   MappingTask mappingTask = scenario.getMappingTask();
   if (mappingTask != null) {
     this.popUpMenuSourceDuplicate.add(
         new ActionDuplicateSetNode(this, sourceSchemaTree, mappingTask.getSourceProxy()));
     this.popUpMenuSourceDuplicate.add(
         new ActionSelectionCondition(this, sourceSchemaTree, mappingTask.getSourceProxy()));
   }
 }
Пример #5
0
 private String generateFinalInsert(MappingTask mappingTask) {
   StringBuilder result = new StringBuilder();
   for (SetAlias targetVariable : mappingTask.getTargetProxy().getMappingData().getVariables()) {
     List<FORule> relevantTgds =
         findRelevantTGDs(targetVariable, mappingTask.getMappingData().getSTTgds());
     if (!relevantTgds.isEmpty()) {
       result.append(generateInsertForRelationAfterExchange(targetVariable, mappingTask));
     }
   }
   return result.toString();
 }
Пример #6
0
 private void addNegationsForCoverages(FORule tgd, FORule rule, MappingTask mappingTask) {
   CoverageMap coverageMap = mappingTask.getMappingData().getSTCoverageMap();
   List<Coverage> coverages = coverageMap.getCoverage(tgd);
   if ((coverages.isEmpty() || !mappingTask.getConfig().rewriteCoverages())) {
     return;
   }
   for (Coverage coverage : coverages) {
     NegatedComplexQuery negatedQuery = generateNegatedQueryForCoverage(coverage);
     negatedQuery.setProvenance(SpicyEngineConstants.COVERAGE + " of " + tgd.getId());
     rule.getComplexSourceQuery().addNegatedComplexQuery(negatedQuery);
   }
 }
Пример #7
0
  @Override
  public void performAction() {
    Properties config = new Properties();
    config.setProperty(
        IComputeQuality.class.getSimpleName(),
        "it.unibas.spicy.findmappings.strategies.computequality.ComputeQualityStructuralAnalysis");
    Application.reset(config);
    executeInjection();
    mappingFinder.cleanUp();
    Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
    MappingTask mappingTask = scenario.getMappingTask();
    if (mappingTask.getTargetProxy().getInstances().isEmpty()) {
      NotifyDescriptor nd =
          new NotifyDescriptor.Message(
              NbBundle.getMessage(Costanti.class, Costanti.WARNING_NOT_TARGET_INSTANCES),
              DialogDescriptor.WARNING_MESSAGE);
      DialogDisplayer.getDefault().notify(nd);
      return;
    }
    checkValueCorrespondenceInMappingTask(mappingTask);
    SwingWorker swingWorker =
        new SwingWorker() {

          private Scenario scenario;

          @Override
          protected Object doInBackground() throws Exception {
            scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
            MappingTask mappingTask = scenario.getMappingTask();

            List<AnnotatedMappingTask> bestMappingTasks =
                mappingFinder.findBestMappings(mappingTask);
            modello.putBean(Costanti.BEST_MAPPING_TASKS, bestMappingTasks);
            IOProvider.getDefault().getIO(Costanti.FLUSSO_SPICY, false).select();
            return true;
          }

          @Override
          protected void done() {
            try {
              if ((Boolean) get() && !isCancelled()) {
                actionViewSpicy.performActionWithScenario(this.scenario);
                actionViewBestMappings.performActionWithScenario(this.scenario);
              }
            } catch (InterruptedException ex) {
              logger.error(ex);
            } catch (ExecutionException ex) {
              logger.error(ex);
            }
          }
        };
    swingWorker.execute();
  }
Пример #8
0
 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);
   }
 }
Пример #9
0
 public List<FORule> rewriteTgds(List<FORule> originalTgds, MappingTask mappingTask) {
   if (mappingTask.isLoadedFromParser() && mappingTask.getConfig().noRewriting()) {
     return cleanLoadedTgds(originalTgds);
   }
   List<FORule> rewrittenRules = null;
   if (mappingTask.getMappingData().hasSelfJoinsInTgdConclusions()) {
     RewriteTgdsWithSelfJoins selfJoinRewriter = new RewriteTgdsWithSelfJoins();
     rewrittenRules = selfJoinRewriter.rewriteTgdsWithSelfJoins(originalTgds, mappingTask);
   } else {
     rewrittenRules = rewriteTgdsWithoutSelfJoins(originalTgds, mappingTask);
   }
   //        RenameVariables renamer = new RenameVariables();
   //        List<FORule> result = renamer.renameAliasesInRules(rewrittenRules);
   //        return result;
   return rewrittenRules;
 }
  public void findCorrespondences(String inputFile, String outputFile) throws DAOException {
    DAOMappingTask daoMappingTask = new DAOMappingTask();
    MappingTask mappingTask = daoMappingTask.loadMappingTask(5, inputFile, false);
    INode source = mappingTask.getSourceProxy().getSchema();
    INode target = mappingTask.getTargetProxy().getSchema();

    NodeExtractorVisitor visitorSource = new NodeExtractorVisitor();
    source.accept(visitorSource);
    List<INode> sourceAttributes = visitorSource.getResult();

    NodeExtractorVisitor visitorTarget = new NodeExtractorVisitor();
    target.accept(visitorTarget);
    List<INode> targetAttributes = visitorTarget.getResult();

    generateCorrespondences(sourceAttributes, targetAttributes, mappingTask);
    daoMappingTask.saveMappingTask(mappingTask, outputFile);
  }
Пример #11
0
 public String getDeleteTablesScript(MappingTask mappingTask) {
   StringBuilder result = new StringBuilder();
   List<PathExpression> setPaths =
       new GenerateSetVariables().findSetAbsolutePaths(mappingTask.getTargetProxy());
   for (PathExpression pathExpression : setPaths) {
     INode node = new FindNode().findNodeInSchema(pathExpression, mappingTask.getTargetProxy());
     if (!(node instanceof SetCloneNode)) {
       result
           .append("delete from ")
           .append(TARGET_SCHEMA_NAME)
           .append(".")
           .append(pathExpression.getLastStep())
           .append(";\n");
     }
   }
   return result.toString();
 }
Пример #12
0
 private static String generateSQLForSkolemTable(MappingTask mappingTask) {
   StringBuilder result = new StringBuilder();
   result.append(
       "\n--------------------------  SKOLEM TABLE  -------------------------------\n\n");
   result.append(CREATE_TABLE).append(SKOLEM_TABLE_NAME).append("(\n");
   result
       .append(INDENT)
       .append(SKOLEM_TABLE_COLUMN_ID)
       .append(" ")
       .append(mappingTask.getDBMSHandler().getAutoGeneratedColumnType())
       .append(",\n");
   result.append(INDENT).append(SKOLEM_TABLE_COLUMN_SKOLEM);
   result.append(GenerateSQL.getSkolemColumnType(mappingTask.getConfig()));
   allTablesToDelete.add(SKOLEM_TABLE_NAME);
   result.append(");\n");
   return result.toString();
 }
  public void createConnectionWidgets(ICreaWidgetCorrespondences correspondenceCreator) {
    this.glassPane.clearConnections();
    this.glassPane.clearConstants();
    this.glassPane.clearFunctions();
    this.glassPane.validate();
    correspondenceCreator.creaWidgetCorrespondences();
    correspondenceCreator.creaWidgetIconForSelectionCondition();

    MappingTask mappingTask = scenario.getMappingTask();
    if (mappingTask != null) {
      IDataSourceProxy source = mappingTask.getSourceProxy();
      IDataSourceProxy target = mappingTask.getTargetProxy();
      correspondenceCreator.creaWidgetFunctionalDependencies(source, true);
      correspondenceCreator.creaWidgetFunctionalDependencies(target, false);
      return;
    }
  }
Пример #14
0
 private List<FORule> rewriteTgdsWithoutSelfJoins(
     List<FORule> originalTgds, MappingTask mappingTask) {
   if (mappingTask.getConfig().rewriteSubsumptions() == false
       && mappingTask.getConfig().rewriteCoverages() == false) {
     return new ArrayList<FORule>(originalTgds);
   }
   List<FORule> rewrittenRules = new ArrayList<FORule>();
   for (FORule tgd : originalTgds) {
     tgd.getComplexSourceQuery()
         .setProvenance(SpicyEngineConstants.PREMISE + " of " + tgd.getId());
     FORule rule = tgd.clone();
     addNegationsForSubsumptions(tgd, rule, mappingTask);
     addNegationsForCoverages(tgd, rule, mappingTask);
     rewrittenRules.add(rule);
   }
   removeClonesFromConclusions(rewrittenRules);
   Collections.sort(rewrittenRules);
   return rewrittenRules;
 }
Пример #15
0
 public static String targetRelationName(
     SetAlias variable, MappingTask mappingTask, int chainingStep) {
   SetNode bindingNode =
       variable.getBindingNode(mappingTask.getTargetProxy().getIntermediateSchema());
   String result = variable.getBindingPathExpression().getLastStep();
   if (bindingNode instanceof SetCloneNode) {
     result = ((SetCloneNode) bindingNode).getOriginalNodePath().getLastStep();
   }
   return getTargetSchemaName(chainingStep) + "." + result;
 }
Пример #16
0
 private void addCorrespondencesToCandidate(MappingTask mappingTask) {
   List<ValueCorrespondence> candidateCorrespondences = new ArrayList<ValueCorrespondence>();
   for (ValueCorrespondence valueCorrespondence : mappingTask.getValueCorrespondences()) {
     if (checkValueCorrespondences(valueCorrespondence)) {
       for (ValueCorrespondence candidateCorrespondence :
           mappingTask.getCandidateCorrespondences()) {
         if (valueCorrespondence.hasEqualPaths(candidateCorrespondence)) {
           candidateCorrespondences.add(candidateCorrespondence);
           break;
         }
       }
       mappingTask.addCandidateCorrespondence(valueCorrespondence);
     }
   }
   mappingTask.getValueCorrespondences().clear();
   mappingTask.getCandidateCorrespondences().removeAll(candidateCorrespondences);
   Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
   MappingTaskTopComponent mappingTaskTopComponent = scenario.getMappingTaskTopComponent();
   mappingTaskTopComponent.getJLayeredPane().getGlassPane().clearConnectionLayer();
 }
Пример #17
0
 //////////////////////////// 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;
 }
Пример #18
0
 private String generateFinalInserts(MappingTask mappingTask) {
   StringBuilder result = new StringBuilder();
   if (mappingTask.getConfig().useSkolemTable()) {
     result.append(
         "\n------------------------------  FINAL INSERTS  -----------------------------------\n\n");
     result.append(
         "\n------------------------------  INSERT INTO TARGET DATABASE  ---------------------------\n");
     result.append(generateFinalInsert(mappingTask));
   }
   return result.toString();
 }
 ////////////////////////////    ANALISI    ///////////////////////////
 public void drawScene(
     CreaWidgetAlberi widgetCreator, ICreaWidgetCorrespondences correspondenceCreator) {
   MappingTask mappingTask = scenario.getMappingTask();
   if (mappingTask == null) {
     this.analizzato = false;
     return;
   }
   IDataSourceProxy source = mappingTask.getSourceProxy();
   IDataSourceProxy target = mappingTask.getTargetProxy();
   createTrees(source, target);
   createTreeWidgets(source, target, widgetCreator);
   createConnectionWidgets(correspondenceCreator);
   //        updateTree();
   this.analizzato = true;
   this.sourceSchemaTree.updateUI();
   this.targetSchemaTree.updateUI();
   this.moveToFront(this.glassPane);
   this.setVisible(true);
   this.glassPane.getScene().setMaximumBounds(this.glassPane.getScene().getBounds());
   initListener();
 }
Пример #20
0
 private void addNegationsForSubsumptions(FORule tgd, FORule rule, MappingTask mappingTask) {
   if (logger.isDebugEnabled()) logger.debug("********* Adding negations for tgd: \n" + tgd);
   SubsumptionMap tgdDag = mappingTask.getMappingData().getSTSubsumptionMap();
   if (logger.isDebugEnabled()) logger.debug("********* Subsumption Map: \n" + tgdDag);
   List<Subsumption> subsumptions = tgdDag.getFathers(tgd);
   if (logger.isDebugEnabled()) logger.debug("Subsumptions: " + subsumptions);
   if (logger.isDebugEnabled()) logger.debug("Config : " + mappingTask.getConfig());
   if ((subsumptions.isEmpty() || !mappingTask.getConfig().rewriteSubsumptions())) {
     return;
   }
   for (Subsumption subsumption : subsumptions) {
     List<VariableCorrespondence> leftCorrespondences = subsumption.getLeftCorrespondences();
     List<VariableCorrespondence> rightCorrespondences = subsumption.getRightCorrespondences();
     TargetEqualities equalities = new TargetEqualities(leftCorrespondences, rightCorrespondences);
     NegatedComplexQuery negatedQuery =
         new NegatedComplexQuery(
             subsumption.getRightTgd().getComplexSourceQuery().clone(), equalities);
     negatedQuery.setProvenance(subsumption.getId());
     rule.getComplexSourceQuery().addNegatedComplexQuery(negatedQuery);
   }
 }
 @Override
 public void performAction() {
   Scenario scenario = (Scenario) modello.getBean(Costanti.CURRENT_SCENARIO);
   MappingTask mappingTask = scenario.getMappingTask();
   if (mappingTask.getValueCorrespondences().size() == 0
       && mappingTask.getMappingData().getSTTgds().isEmpty()) {
     NotifyDescriptor nd =
         new NotifyDescriptor.Message(
             NbBundle.getMessage(Costanti.class, Costanti.EMPTY_CORRESPONDENCES),
             DialogDescriptor.WARNING_MESSAGE);
     DialogDisplayer.getDefault().notify(nd);
     return;
   }
   try {
     openTransformationWindows();
     openInstanceWindows();
     enableActions();
   } catch (Exception ex) {
     DialogDisplayer.getDefault()
         .notify(new NotifyDescriptor.Message(ex.getMessage(), DialogDescriptor.ERROR_MESSAGE));
   }
 }
Пример #22
0
 //////////////////////////// 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;
 }
Пример #23
0
 private String generateConjunctionString(
     List<SetAlias> setVariables, List<List<FormulaVariable>> variables, INode schema) {
   StringBuilder localResult = new StringBuilder();
   List<SetAlias> sortedAliases = new ArrayList<SetAlias>(setVariables);
   Collections.sort(sortedAliases);
   for (int i = 0; i < sortedAliases.size(); i++) {
     SetAlias sourceVariable = sortedAliases.get(i);
     localResult.append(generateIndent());
     if (!useSaveFormat) {
       localResult.append(
           utility.printAtomName(sourceVariable, mappingTask.getSourceProxy().isNested()));
     } else {
       localResult.append(
           utility.printAtomNameForSaveFormat(
               sourceVariable, mappingTask.getSourceProxy().isNested()));
     }
     List<VariablePathExpression> attributePaths = sourceVariable.getFirstLevelAttributes(schema);
     for (int j = 0; j < attributePaths.size(); j++) {
       VariablePathExpression attributePath = attributePaths.get(j);
       FormulaVariable attributeVariable = findVariableForPath(attributePath, variables);
       localResult.append(attributePath.getLastStep()).append(": ");
       if (useSaveFormat) {
         localResult.append("$");
       }
       localResult.append(attributeVariable.toShortString());
       if (j != attributePaths.size() - 1) {
         localResult.append(", ");
       }
     }
     localResult.append(")");
     if (i != sortedAliases.size() - 1) {
       localResult.append(", \n");
     }
   }
   return localResult.toString();
 }
Пример #24
0
 ///////////////////////////    SKOLEMS   ///////////////////////////////
 private String printSkolems(FORule rule, MappingTask mappingTask) {
   StringBuilder result = new StringBuilder();
   List<FormulaVariable> existentialVariables = rule.getExistentialFormulaVariables(mappingTask);
   for (FormulaVariable variable : existentialVariables) {
     String generatorString = findGeneratorForVariable(variable, rule, mappingTask);
     result.append(variable.toShortString()).append(": ").append(generatorString).append("\n");
   }
   if (mappingTask.getTargetProxy().isNested()) {
     for (SetAlias alias : rule.getTargetView().getGenerators()) {
       VariablePathExpression bindingPath = alias.getBindingPathExpression();
       String generatorString = findGeneratorForPath(bindingPath, rule, mappingTask);
       result.append(alias.toShortString()).append(": ").append(generatorString).append("\n");
     }
   }
   return result.toString();
 }
 private void generateCorrespondences(
     List<INode> sourceAttributes, List<INode> targetAttributes, MappingTask mappingTask) {
   for (INode sourceAttribute : sourceAttributes) {
     for (INode targetAttribute : targetAttributes) {
       if (sourceAttribute.getLabel().equals(targetAttribute.getLabel())) {
         PathExpression sourcePath =
             new GeneratePathExpression().generatePathFromRoot(sourceAttribute);
         PathExpression targetPath =
             new GeneratePathExpression().generatePathFromRoot(targetAttribute);
         ValueCorrespondence correspondence = new ValueCorrespondence(sourcePath, targetPath);
         mappingTask.addCorrespondence(correspondence);
         break;
       }
     }
   }
 }
Пример #26
0
  private void checkValueCorrespondenceInMappingTask(MappingTask mappingTask) {

    if (!mappingTask.getValueCorrespondences().isEmpty()) {
      if (firstCheck == null) {
        NotifyDescriptor nd =
            new NotifyDescriptor.Confirmation(
                NbBundle.getMessage(Costanti.class, Costanti.FIND_VALUE_CORRESPONDENCES),
                DialogDescriptor.YES_NO_OPTION);
        DialogDisplayer.getDefault().notify(nd);
        if (nd.getValue().equals(NotifyDescriptor.YES_OPTION)) {
          this.firstCheck = true;
          addCorrespondencesToCandidate(mappingTask);
        } else {
          this.firstCheck = false;
        }
      }
    }
  }
Пример #27
0
 //    private static List<SetAlias> extractDifferentVariables(List<SetAlias> variables) {
 //        List<SetAlias> result = new ArrayList<SetAlias>();
 //        for (SetAlias variable : variables) {
 //            if (!containsVariableWithSameName(variable, result)) {
 //                result.add(variable);
 //            }
 //        }
 //        return result;
 //    }
 //    private static boolean containsVariableWithSameName(SetAlias variable, List<SetAlias>
 // variables) {
 //        for (SetAlias setAlias : variables) {
 //            if (setAlias.hasSameId(variable)) {
 //                return true;
 //            }
 //        }
 //        return false;
 //    }
 private static String generateProjectionOnAllAttributes(
     List<SetAlias> variables, MappingTask mappingTask) {
   StringBuilder result = new StringBuilder();
   for (int i = 0; i < variables.size(); i++) {
     SetAlias variable = variables.get(i);
     List<VariablePathExpression> attributes =
         variable.getAttributes(mappingTask.getSourceProxy().getIntermediateSchema());
     for (int j = 0; j < attributes.size(); j++) {
       VariablePathExpression attribute = attributes.get(j);
       result.append(DOUBLE_INDENT).append(GenerateSQL.attributeNameWithVariable(attribute));
       result.append(" AS ").append(attributeNameInVariable(attribute));
       if (j != attributes.size() - 1) result.append(",\n");
     }
     if (i != variables.size() - 1) result.append(",\n");
   }
   result.append("\n");
   return result.toString();
 }
Пример #28
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;
 }
Пример #29
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;
 }
Пример #30
0
 private String findGeneratorForVariable(
     FormulaVariable variable, FORule rule, MappingTask mappingTask) {
   List<FormulaVariable> universalVariables =
       rule.getUniversalFormulaVariablesInTarget(mappingTask);
   TGDGeneratorsMap generatorsMap = rule.getGenerators(mappingTask);
   for (VariablePathExpression targetPath : variable.getTargetOccurrencePaths()) {
     IValueGenerator generator =
         generatorsMap.getGeneratorForLeaf(
             targetPath, mappingTask.getTargetProxy().getIntermediateSchema());
     if (generator != null && generator instanceof SkolemFunctionGenerator) {
       SkolemFunctionGenerator skolemGenerator = (SkolemFunctionGenerator) generator;
       return skolemGenerator.toStringWithVariableArguments(universalVariables);
     }
   }
   return NullValueGenerator.getInstance().toString();
   // throw new IllegalArgumentException("Unable to find generator for variable: " +
   // variable.toLongString() + "\nin rule: " + rule + "\n" +
   // SpicyEngineUtility.printVariableList(rule.getExistentialFormulaVariables(mappingTask)) +
   // "\nGenerators: " + generatorsMap);
 }