private List<VariableCorrespondence> getOriginalCorrespondences(Coverage coverage) { List<VariableCorrespondence> originalCorrespondences = new ArrayList<VariableCorrespondence>(); for (CoverageAtom atomCoverage : coverage.getCoveringAtoms()) { originalCorrespondences.addAll(atomCoverage.getOriginalCorrespondences()); } return originalCorrespondences; }
public List<VariableCorrespondence> getTargetCorrespondences(CoverageAtom atomCoverage) { List<VariableCorrespondence> targetCorrespondences = new ArrayList<VariableCorrespondence>(); for (FormulaAtom coveringAtom : atomCoverage.getCoveringAtoms()) { for (FormulaPosition position : coveringAtom.getPositions()) { if (position.isUniversal()) { targetCorrespondences.add(position.getCorrespondence()); } } } return targetCorrespondences; }
private NegatedComplexQuery generateNegatedQueryForCoverage(Coverage coverage) { if (logger.isDebugEnabled()) logger.debug("************ Generating query for coverage:\n" + coverage); ComplexConjunctiveQuery complexQuery = new ComplexConjunctiveQuery(); List<VariableCorrespondence> matchingCorrespondences = new ArrayList<VariableCorrespondence>(); for (CoverageAtom coverageAtom : coverage.getCoveringAtoms()) { SimpleConjunctiveQuery simpleQuery = coverageAtom.getFirstCoveringAtom().getTgd().getSimpleSourceView(); List<VariableCorrespondence> matchingCorrespondencesForConjunction = coverageAtom.getMatchingCorrespondences(); List<VariableCorrespondence> targetCorrespondencesForConjunction = getTargetCorrespondences(coverageAtom); if (containsSameAliases(complexQuery, simpleQuery)) { QueryRenaming queryRenaming = aliasRenamer.renameAliasesInSimpleConjunctiveQuery(simpleQuery); simpleQuery = (SimpleConjunctiveQuery) queryRenaming.getRenamedView(); targetCorrespondencesForConjunction = renamerUtility.renameSourceSetAliasesInCorrespondences( targetCorrespondencesForConjunction, queryRenaming.getRenamings()); matchingCorrespondencesForConjunction = renamerUtility.renameSourceSetAliasesInCorrespondences( matchingCorrespondencesForConjunction, queryRenaming.getRenamings()); } complexQuery.addConjunction(simpleQuery); complexQuery.addCorrespondencesForConjuntion(targetCorrespondencesForConjunction); matchingCorrespondences.addAll(matchingCorrespondencesForConjunction); } complexQuery.setJoinConditions(coverage.getTargetJoinConditions()); complexQuery.setCyclicJoinConditions(coverage.getTargetCyclicJoinConditions()); ComplexQueryWithNegations coverageView = new ComplexQueryWithNegations(complexQuery); coverageView.setProvenance(coverage.toShortString()); TargetEqualities equalities = new TargetEqualities(getOriginalCorrespondences(coverage), matchingCorrespondences); NegatedComplexQuery negatedQuery = new NegatedComplexQuery(coverageView, equalities); if (logger.isDebugEnabled()) logger.debug("************ Final result:\n" + negatedQuery); return negatedQuery; }