Exemplo n.º 1
0
    private void addPaths(
        List<List<AbilityFacade>> abilityPaths,
        List<AbilityFacade> preAbilities,
        ArrayList<AbilityFacade> path) {
      if (path.size() > 20) {

        Logging.errorPrint(
            "Found probable ability prereq cycle ["
                + StringUtils.join(path, ",")
                + "] with prereqs ["
                + StringUtils.join(preAbilities, ",")
                + "]. Skipping.");
        return;
      }
      for (AbilityFacade preAbility : preAbilities) {
        @SuppressWarnings("unchecked")
        ArrayList<AbilityFacade> pathclone = (ArrayList<AbilityFacade>) path.clone();
        pathclone.add(preAbility);
        List<AbilityFacade> preAbilities2 = dataset.getPrereqAbilities(preAbility);
        // Don't include self references in the path
        preAbilities2.remove(preAbility);
        preAbilities2.removeAll(pathclone);
        if (preAbilities2.isEmpty()) {
          abilityPaths.add(pathclone);
        } else {
          addPaths(abilityPaths, preAbilities2, pathclone);
        }
      }
    }
Exemplo n.º 2
0
    @Override
    public List<TreeViewPath<AbilityFacade>> getPaths(AbilityFacade pobj) {
      List<List<AbilityFacade>> abilityPaths = new ArrayList<List<AbilityFacade>>();
      addPaths(abilityPaths, dataset.getPrereqAbilities(pobj), new ArrayList<AbilityFacade>());
      if (abilityPaths.isEmpty()) {
        return Collections.singletonList(new TreeViewPath<AbilityFacade>(pobj));
      }

      List<TreeViewPath<AbilityFacade>> paths = new ArrayList<TreeViewPath<AbilityFacade>>();
      for (List<AbilityFacade> path : abilityPaths) {
        Collections.reverse(path);
        paths.add(new TreeViewPath<AbilityFacade>(path.toArray(), pobj));
      }
      return paths;
    }