Exemplo n.º 1
0
  private static List<String> convertDbaList(
      List<xquerysearch.domain.result.DBA> dbasResult,
      List<DBA> dbas,
      List<BBA> bbas,
      IdCounter id) {
    List<String> localBaRefs = new ArrayList<String>();

    if (dbasResult == null || dbas == null) {
      return localBaRefs;
    }

    for (xquerysearch.domain.result.DBA dba : dbasResult) {
      List<String> loopBaRefs = new ArrayList<String>();

      if (dba.getDbas() != null && dba.getDbas().size() > 0) {
        loopBaRefs = convertDbaList(dba.getDbas(), dbas, bbas, id);
      } else if (dba.getBbas() != null && dba.getBbas().size() > 0) {
        loopBaRefs = convertBbaList(bbas, dba.getBbas(), id);
      }

      DBA dbaOut =
          ResultForOutputObjectConverter.convert(dba.getConnective(), id.toString(), loopBaRefs);

      dbas.add(dbaOut);
      localBaRefs.add(id.toString());
      id.increment();
    }

    return localBaRefs;
  }
Exemplo n.º 2
0
  private static List<String> convertBbaList(
      List<BBA> bbas, List<xquerysearch.domain.result.BBA> bbasResult, IdCounter id) {
    List<String> localBaRefs = new ArrayList<String>();

    for (xquerysearch.domain.result.BBA resultBba : bbasResult) {
      BBA bbaOut = ResultForOutputObjectConverter.convert(resultBba, id.toString());
      bbaOut.setId(id.toString());
      bbas.add(bbaOut);
      localBaRefs.add(id.toString());
      id.increment();
    }

    return localBaRefs;
  }
Exemplo n.º 3
0
 private static void convertDbaListFirstLevel(
     List<xquerysearch.domain.result.DBA> dbasResult,
     List<DBA> dbas,
     List<BBA> bbas,
     IdCounter id) {
   List<String> baRefs = convertDbaList(dbasResult, dbas, bbas, id);
   dbas.add(ResultForOutputObjectConverter.convert("Conjunction", id.toString(), baRefs));
 }
Exemplo n.º 4
0
  @Override
  public EvalResult produceOutput(PrintStream out) throws Exception {
    SwitchNode switchNode = scope.getSwitchNode();
    if (switchNode == null) {
      throw new Exception("Default outside switch");
    }
    String label = IdCounter.GetNewLabel();
    out.printf("br label %%%s\n", label);
    out.printf("%s:\n", label);

    switchNode.setDefaultLabel(label);
    return null;
  }
Exemplo n.º 5
0
  /**
   * Fills given lists with data from given list of {@link Result}.
   *
   * @param bbas
   * @param dbas
   * @param hits
   * @param results
   */
  private static void convertResult(
      List<BBA> bbas, List<DBA> dbas, List<Hit> hits, Result result, IdCounter id) {

    Hit hit = ResultForOutputObjectConverter.convert(result);

    Rule rule = result.getRule();

    if (rule != null) {
      String antecedentId = null;
      String consequentId = null;
      String conditionId = null;

      Cedent antecedent = rule.getAntecedent();
      Cedent consequent = rule.getConsequent();
      Cedent condition = rule.getCondition();

      if (antecedent != null) {
        // id.increment();
        convertDbaListFirstLevel(antecedent.getDbas(), dbas, bbas, id);
        antecedentId = id.toString();
      }
      if (consequent != null) {
        // id.increment();
        convertDbaListFirstLevel(consequent.getDbas(), dbas, bbas, id);
        consequentId = id.toString();
      }
      if (condition != null) {
        // id.increment();
        convertDbaListFirstLevel(condition.getDbas(), dbas, bbas, id);
        conditionId = id.toString();
      }

      hit.setAssociationRule(
          ResultForOutputObjectConverter.convert(rule, antecedentId, consequentId, conditionId));
    }
    hits.add(hit);
  }