예제 #1
0
 /**
  * get all existing elements and pass for the addMainInToTransformList() method
  *
  * @param pleles
  * @return
  * @throws paloexception
  */
 public void getAllExistPaloDimensionElements(paloelements pleles) throws paloexception {
   maxDepthElement(pleles);
   // List<String> sr = new ArrayList<String>();
   String[] arr = null;
   paths = new HashMap<String, List<List>>();
   for (paloelement plElm : pleles.getElements()) {
     // if element has no parent it means it's root element
     if (plElm.getElementParents() == null) {
       List elementPaths = new ArrayList<List>();
       List path = new ArrayList<String>();
       elementPaths.add(path);
       path.add(plElm.getName());
       paths.put(plElm.getName(), elementPaths);
       collectionPaths(pleles, plElm, elementPaths, path);
     }
   }
   for (String key : paths.keySet()) {
     List<List> elementPaths = paths.get(key);
     for (List<String> path : elementPaths) {
       arr = new String[maxDepth];
       for (int i = 0; i < path.size(); i++) {
         arr[i] = path.get(i);
       }
       addMainInToTransformList(arr);
     }
   }
 }
예제 #2
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++;
      }
    }
  }
예제 #3
0
 /**
  * return all the elements max Depth
  *
  * @param pleles
  * @return
  * @throws paloexception
  */
 public int maxDepthElement(paloelements pleles) throws paloexception {
   long depth = 0;
   for (paloelement plElm : pleles.getElements()) {
     if (depth < plElm.getElementDepth()) {
       depth = plElm.getElementDepth();
     }
   }
   maxDepth = (int) depth + 1;
   return maxDepth;
 }
예제 #4
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());
    }
  }