예제 #1
0
 public static List<AttributeRef> findTargetQueriedAttributesForExtTGD(Dependency dependency) {
   List<AttributeRef> queriedAttributes = new ArrayList<AttributeRef>();
   LunaticUtility.addAllIfNotContained(
       queriedAttributes, findTargetQueriedAttributesInPremise(dependency));
   for (FormulaVariable formulaVariable : dependency.getPremise().getLocalVariables()) {
     if (formulaVariable.getConclusionRelationalOccurrences().isEmpty()) {
       continue;
     }
     AttributeRef firstPremiseOccurrenceInTarget =
         getFirstPremiseOccurrenceInTarget(formulaVariable.getPremiseRelationalOccurrences());
     if (firstPremiseOccurrenceInTarget != null) {
       AttributeRef unaliasedPremiseAttribute =
           ChaseUtility.unAlias(firstPremiseOccurrenceInTarget);
       LunaticUtility.addIfNotContained(queriedAttributes, unaliasedPremiseAttribute);
     }
     for (FormulaVariableOccurrence conclusionOccurrence :
         formulaVariable.getConclusionRelationalOccurrences()) {
       AttributeRef attribute = conclusionOccurrence.getAttributeRef();
       if (attribute.getTableAlias().isSource()) {
         continue;
       }
       AttributeRef unaliasedConclusionAttribute =
           ChaseUtility.unAlias(conclusionOccurrence.getAttributeRef());
       LunaticUtility.addIfNotContained(queriedAttributes, unaliasedConclusionAttribute);
     }
   }
   return queriedAttributes;
 }
예제 #2
0
 public static List<AttributeRef> getUniversalAttributesInConclusion(
     List<FormulaVariable> universalVariables) {
   List<AttributeRef> result = new ArrayList<AttributeRef>();
   for (FormulaVariable formulaVariable : universalVariables) {
     LunaticUtility.addIfNotContained(
         result, formulaVariable.getConclusionRelationalOccurrences().get(0).getAttributeRef());
   }
   return result;
 }
예제 #3
0
 public static List<FormulaVariable> findUniversalVariablesInConclusion(Dependency dependency) {
   List<FormulaVariable> result = new ArrayList<FormulaVariable>();
   for (FormulaVariable formulaVariable : dependency.getPremise().getLocalVariables()) {
     if (formulaVariable.getConclusionRelationalOccurrences().size() > 0) {
       result.add(formulaVariable);
     }
   }
   return result;
 }
예제 #4
0
 public static List<FormulaVariable> getUniversalVariablesInConclusion(Dependency dependency) {
   List<FormulaVariable> result = new ArrayList<FormulaVariable>();
   for (FormulaVariable formulaVariable : dependency.getPremise().getLocalVariables()) {
     List<FormulaVariableOccurrence> variablesOccurrence =
         formulaVariable.getConclusionRelationalOccurrences();
     if (!variablesOccurrence.isEmpty()) {
       LunaticUtility.addIfNotContained(result, formulaVariable);
     }
   }
   return result;
 }
예제 #5
0
 public static List<AttributeRef> extractRequestedAttributesWithExistential(
     Dependency dependency) {
   List<AttributeRef> result = new ArrayList<AttributeRef>();
   result.addAll(dependency.getQueriedAttributes());
   for (FormulaVariable variable : dependency.getConclusion().getLocalVariables()) {
     if (variable.getConclusionRelationalOccurrences().size() == 1) {
       continue;
     }
     for (FormulaVariableOccurrence occurrence : variable.getConclusionRelationalOccurrences()) {
       if (logger.isTraceEnabled()) logger.trace("Inspecting occurrence: " + occurrence);
       AttributeRef attribute = occurrence.getAttributeRef();
       AttributeRef unaliasedAttribute = ChaseUtility.unAlias(attribute);
       LunaticUtility.addIfNotContained(result, unaliasedAttribute);
     }
   }
   for (AttributeRef attributeRef : dependency.getAdditionalAttributes()) {
     if (!result.contains(attributeRef)) {
       result.add(attributeRef);
     }
   }
   return result;
 }