コード例 #1
0
  /**
   * get all the existing elements
   *
   * @param pleles
   * @param plele
   * @param paths
   * @param path
   */
  private void collectionPaths(
      paloelements pleles, paloelement plele, List<List> paths, List<String> path) {

    int[] childIDs = plele.getElementChildren();
    int i = 0;
    List<String> tempPath = null;
    if (plele.hasChildren()) {
      tempPath = new ArrayList<String>();
      for (String s : path) {
        tempPath.add(s);
      }
    }
    if (childIDs != null) {
      for (long id : childIDs) {
        paloelement child = pleles.getElementByIdentifier(id);
        List copyPath = null;
        if (i != 0) {
          copyPath = new ArrayList<String>();
          for (String s : tempPath) {
            copyPath.add(s);
          }
          paths.add(copyPath);
          copyPath.add(child.getName());
          collectionPaths(pleles, child, paths, copyPath);
        } else {
          path.add(child.getName());
          collectionPaths(pleles, child, paths, path);
        }
        i++;
      }
    }
  }
コード例 #2
0
  public void createBulk(paloelements paloElements) throws paloexception {
    try {

      for (int x = iNbOfCols; x > 1; x--) {

        HashMap<String, HashSet<String>> al = new HashMap<String, HashSet<String>>();
        for (String[] strArr : lstTalendMainIn) {
          String strParent = strArr[x - 2];
          String strChild = strArr[x - 1];
          if (al.containsKey(strParent) == false) {
            al.put(strParent, new HashSet<String>());
          }
          al.get(strParent).add(strChild);
        }

        // System.out.println(al==null);
        Set<?> set = al.entrySet();
        Iterator<?> i = set.iterator();
        while (i.hasNext()) {
          Map.Entry me = (Map.Entry) i.next();

          paloelement plElm = paloElements.getElement((String) me.getKey());
          // System.out.println(null==plElm);
          if (null != plElm) {

            SortedSet<Integer> sorter = new TreeSet<Integer>();
            HashSet<?> hS = (HashSet<?>) me.getValue();
            Iterator<?> i2 = hS.iterator();
            while (i2.hasNext()) {
              String strEntry = (String) i2.next();
              paloelement plConsElm = paloElements.getElement(strEntry);
              if (plConsElm != null) sorter.add((int) plConsElm.getElementIdentifier());
            }

            int[] iArrplConsOld = null;
            if (plElm.hasChildren()) iArrplConsOld = plElm.getElementChildren();

            if (iArrplConsOld != null) {
              for (int oi = 0; oi < iArrplConsOld.length; oi++) {
                sorter.add(iArrplConsOld[oi]);
              }
            }

            Iterator<Integer> itSorted = sorter.iterator();
            StringBuilder sbValues2 = new StringBuilder();
            StringBuilder sbTypes2 = new StringBuilder();

            for (int zi = 0; itSorted.hasNext(); zi++) {
              if (zi > 0) {
                sbValues2.append(",");
                sbTypes2.append(",");
              }
              sbValues2.append(itSorted.next().intValue());
              sbTypes2.append("1");
              // merged[zi] =
              // ((Integer)itSorted.next()).intValue();
            }

            // System.out.println(sbValues2.toString() + " " +
            // sbTypes2.toString());

            // System.out.println("Jetzt");
            // try{
            if (hS != null)
              plElm.updateElementConsolidation(sbValues2.toString(), sbTypes2.toString(), false);
            // }catch(Exception e){
            // System.out.println("ddd");
            // }

            // paloCons.addElementToConsolidation(paloElements.getElement(tConsElement.getElementName()),tConsElement.getFactor());
            // System.out.println(me.getKey() + " : " +
            // me.getValue() );
          }
        }
      }
    } catch (Exception e) {
      System.out.println("Hier " + e.toString());
    }
  }