示例#1
0
 /**
  * Check if a pack's dependencies are resolved.
  *
  * @param pack
  * @return
  */
 private boolean dependenciesResolved(Pack pack) {
   if (!pack.hasDependencies()) {
     return true;
   }
   for (String dependentPackName : pack.getDependencies()) {
     if (!isChecked(nameToRow.get(dependentPackName))) {
       return false;
     }
   }
   return true;
 }
示例#2
0
 /** Creates the reverse dependency graph */
 private void reverseDeps() {
   // name to pack map
   namesObj = new HashMap<String, Pack>();
   for (Pack pack : packs) {
     namesObj.put(pack.getName(), pack);
   }
   // process each pack
   for (Pack pack : packs) {
     List<String> deps = pack.getDependencies();
     for (int j = 0; deps != null && j < deps.size(); j++) {
       String name = deps.get(j);
       Pack parent = namesObj.get(name);
       parent.addDependant(pack.getName());
     }
   }
 }
示例#3
0
  /**
   * Ensure that parent packs know which packs are their children. Ensure that packs who have
   * dependants know which packs depend on them
   *
   * @param packs packs visible to the user
   * @param nameToPack mapping from pack names to pack objects
   * @return packs
   */
  private List<Pack> setPackProperties(List<Pack> packs, Map<String, Pack> nameToPack) {
    Pack parent;
    for (Pack pack : packs) {
      if (pack.hasParent()) {
        String parentName = pack.getParent();
        parent = nameToPack.get(parentName);
        parent.addChild(pack.getName());
      }

      if (pack.hasDependencies()) {
        for (String name : pack.getDependencies()) {
          parent = nameToPack.get(name);
          parent.addDependant(pack.getName());
        }
      }
    }
    return packs;
  }