Ejemplo n.º 1
0
 private void extractMetaTables() throws LensException {
   List<String> tabAliases = new ArrayList<String>(qb.getTabAliases());
   Set<String> missing = new HashSet<String>();
   for (String alias : tabAliases) {
     boolean added = addQueriedTable(alias);
     if (!added) {
       missing.add(alias);
     }
   }
   for (String alias : missing) {
     // try adding them as joinchains
     boolean added = addJoinChain(alias, false);
     if (!added) {
       log.info("Queried tables do not exist. Missing table:{}", alias);
       throw new LensException(LensCubeErrorCode.NEITHER_CUBE_NOR_DIMENSION.getLensErrorInfo());
     }
   }
 }
Ejemplo n.º 2
0
  private boolean addJoinChain(String alias, boolean isOptional) throws LensException {
    boolean retVal = false;
    String aliasLowerCaseStr = alias.toLowerCase();
    JoinChain joinchain = null;

    if (getCube() != null) {
      JoinChain chainByName = getCube().getChainByName(aliasLowerCaseStr);
      if (chainByName != null) {
        joinchain = chainByName;
        retVal = true;
      }
    }

    if (!retVal) {
      for (Dimension table : dimensions) {
        JoinChain chainByName = table.getChainByName(aliasLowerCaseStr);
        if (chainByName != null) {
          joinchain = chainByName;
          retVal = true;
          break;
        }
      }
    }

    if (retVal) {
      joinchains.put(aliasLowerCaseStr, new JoinChain(joinchain));
      String destTable = joinchain.getDestTable();
      boolean added = addQueriedTable(alias, destTable, isOptional, true);
      if (!added) {
        log.info("Queried tables do not exist. Missing tables:{}", destTable);
        throw new LensException(LensCubeErrorCode.NEITHER_CUBE_NOR_DIMENSION.getLensErrorInfo());
      }
      log.info("Added join chain for {}", destTable);
      return true;
    }

    return retVal;
  }