Пример #1
0
 private void deleteJsonJobs(ApplicationInfo appInfo, List<CIJob> selectedJobs)
     throws PhrescoException {
   try {
     if (CollectionUtils.isEmpty(selectedJobs)) {
       return;
     }
     Gson gson = new Gson();
     List<CIJob> jobs = getJobs(appInfo);
     if (CollectionUtils.isEmpty(jobs)) {
       return;
     }
     // all values
     Iterator<CIJob> iterator = jobs.iterator();
     // deletable values
     for (CIJob selectedInfo : selectedJobs) {
       while (iterator.hasNext()) {
         CIJob itrCiJob = iterator.next();
         if (itrCiJob.getName().equals(selectedInfo.getName())) {
           iterator.remove();
           break;
         }
       }
     }
     writeJsonJobs(appInfo, jobs, CI_CREATE_NEW_JOBS);
   } catch (Exception e) {
     throw new PhrescoException(e);
   }
 }
Пример #2
0
 public static Digraph randomizeTree(
     Digraph digraph, int maxChildren, int maxLevels, Random randomizer) {
   int vertexIndex = 1;
   Object root = new Integer(vertexIndex);
   List level = Collections.singletonList(root);
   digraph.addVertex(root);
   for (int i = 1; i < maxLevels; i++) {
     List childLevel = new ArrayList(level.size() * maxChildren);
     for (Iterator j = level.iterator(); j.hasNext(); ) {
       Object parent = j.next();
       int childCount = randomizer.nextInt(maxChildren + 1);
       for (int k = 0; k < childCount; k++) {
         Object child = new Integer(++vertexIndex);
         digraph.addVertex(child);
         digraph.putArc(parent, child, Boolean.TRUE);
         childLevel.add(child);
       }
     }
     if (childLevel.isEmpty()) break;
     level = childLevel;
   }
   return digraph;
 }