/**
  * Find top level jobs.
  *
  * @param unittype the unittype
  * @return the list
  */
 private List<Job> findTopLevelJobs(Unittype unittype) {
   Job[] jobs = unittype.getJobs().getJobs();
   List<Job> topLevel = new ArrayList<Job>();
   for (Job j : jobs) {
     if (j.getDependency() == null) topLevel.add(j);
   }
   return topLevel;
 }
 public List<TableElement> getJobs(Unittype unittype) throws Exception {
   List<TableElement> list = new ArrayList<TableElement>();
   List<Job> topLevelJobs = findTopLevelJobs(unittype);
   if (topLevelJobs.size() > 0) {
     List<String> topLevelJobnames = convertJobsToNames(topLevelJobs);
     Collections.sort(topLevelJobnames, String.CASE_INSENSITIVE_ORDER);
     for (String jobname : topLevelJobnames) {
       Job topJob = unittype.getJobs().getByName(jobname);
       getJob(unittype, list, topJob, WebConstants.PARAMETERS_START_INDENTATION);
     }
   }
   return list;
 }
 /**
  * Gets the job.
  *
  * @param unittype the unittype
  * @param list the list
  * @param job the job
  * @param nbsp the nbsp
  * @return the job
  * @throws IllegalArgumentException the illegal argument exception
  * @throws SecurityException the security exception
  * @throws IllegalAccessException the illegal access exception
  * @throws InvocationTargetException the invocation target exception
  * @throws NoSuchMethodException the no such method exception
  */
 private void getJob(Unittype unittype, List<TableElement> list, Job job, Integer nbsp)
     throws IllegalArgumentException, SecurityException, IllegalAccessException,
         InvocationTargetException, NoSuchMethodException {
   String id = getTableJobId(job);
   Integer str = nbsp;
   if (getChildren(job).size() > 0) {
     list.add(new TableElement(id, str, job, true));
     List<String> childrenJobnames = convertJobsToNames(getChildren(job));
     Collections.sort(childrenJobnames, String.CASE_INSENSITIVE_ORDER);
     for (String childrenJobname : childrenJobnames) {
       Job childrenJob = unittype.getJobs().getByName(childrenJobname);
       getJob(unittype, list, childrenJob, nbsp + WebConstants.PARAMETERS_NEXT_INDENTATION);
     }
   } else list.add(new TableElement(id, str, job, false));
 }