Ejemplo n.º 1
0
  private List getMatchingRowDataList(Map connectorMap, TableData childRt) {
    List filteredList = new ArrayList();
    boolean allPassed = true;
    int size = childRt.getTableSize();
    for (int i = 0; i < size; i++) {
      RowData child = childRt.getRow(i);

      for (Iterator it = connectorMap.keySet().iterator(); it.hasNext(); ) {
        String key = (String) it.next();
        Object keyData = connectorMap.get(key);
        Object rowData = child.getField(key);
        if (rowData == null || !rowData.toString().equalsIgnoreCase(keyData.toString())) {
          allPassed = false;
          break;
        }
      }

      if (allPassed) {
        filteredList.add(child);
      }

      allPassed = true;
    }

    return filteredList;
  }
Ejemplo n.º 2
0
  private void linkParentWithChild(
      TableData parentRt, TableData childRt, String processorName, List connectorList) {
    if (parentRt == null || childRt == null || childRt.getTableSize() == 0) return;

    int size = parentRt.getAllRows().size();
    Map connectorMap = new HashMap();
    for (int i = 0; i < size; i++) {
      RowData parentRow = parentRt.getRow(i);
      populateConnectorMap(connectorMap, parentRow, connectorList);
      parentRow.addChildRowToMap(processorName, getMatchingRowDataList(connectorMap, childRt));

      // clear the map for next row
      connectorMap.clear();
    }
  }
Ejemplo n.º 3
0
  private String populateChildInputs(
      int rowIndex, Map childInputs, RowData parent, String childQuery) {
    String newQuery = childQuery;

    Map newInputs = new HashMap();

    Iterator it = childInputs.keySet().iterator();
    while (it.hasNext()) {
      String key = (String) it.next();
      if (key.startsWith("&")) {
        String fkName = key.substring(1);
        String parentKeyName = (String) childInputs.get(key);
        if (parentKeyName != null) {
          parentKeyName = parentKeyName.toUpperCase();
          String keyInQuery = "?" + fkName;
          if (childQuery.indexOf(keyInQuery) != -1) {
            Object parentData = parent.getField(parentKeyName);
            String newKeyName = fkName + "_" + rowIndex;
            newInputs.put(newKeyName, parentData);
            newQuery = StringUtil.replace(newQuery, keyInQuery, "?" + newKeyName);
          }
        }
      }
    }

    childInputs.putAll(newInputs);

    return newQuery;
  }
Ejemplo n.º 4
0
  private String getColumnSqlDataTypeName(String parentKeyName, RowData parent) {
    String sqlDataTypeName = "";
    RowInfo ri = parent.getRowInfo();
    if (ri != null) {
      sqlDataTypeName = ri.getColmnDataTypeName(ri.getColumnPositionIndex(parentKeyName));
    }

    if (sqlDataTypeName != null && !sqlDataTypeName.equals(""))
      sqlDataTypeName = ":" + sqlDataTypeName;

    return sqlDataTypeName;
  }
Ejemplo n.º 5
0
  // return a string liek this: (?fkName1_rowIndex1, ?fkName2_rowIndex2, ...)
  private String populateConditionPart2(int rowIndex, InputInfo childIp, RowData parent) {
    String part = "(";
    List fkNames = childIp.getFKs();
    if (fkNames != null && fkNames.size() > 0) {
      Map newInputs = new HashMap();
      Map childInputs = childIp.getInputs();
      Iterator it = fkNames.iterator();
      while (it.hasNext()) {
        String fkName = (String) it.next();
        String parentKeyName = (String) childInputs.get("&" + fkName);
        Object parentData = parent.getField(parentKeyName);
        String newKeyName = fkName + "_" + rowIndex;
        newInputs.put(newKeyName, parentData);
        part = part + "?" + newKeyName + getColumnSqlDataTypeName(parentKeyName, parent) + ",";
      }
      childInputs.putAll(newInputs);

      // remove the last comma
      if (part.endsWith(",")) part = part.substring(0, part.lastIndexOf(','));
      part = part + ")";
    }

    return part;
  }
Ejemplo n.º 6
0
 private void populateConnectorMap(Map connectorMap, RowData parentRow, List connectorList) {
   for (Iterator it = connectorList.iterator(); it.hasNext(); ) {
     String key = (String) it.next();
     connectorMap.put(key, parentRow.getField(key));
   }
 }