コード例 #1
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
  /** Retrieve all cube names that are deeply referenced by ApplicationID + n-cube name. */
  public static void getReferencedCubeNames(ApplicationID appId, String name, Set<String> refs) {
    if (refs == null) {
      throw new IllegalArgumentException(
          "Could not get referenced cube names, null passed in for Set to hold referenced n-cube names, app: "
              + appId
              + ", n-cube: "
              + name);
    }
    validateAppId(appId);
    NCube.validateCubeName(name);
    NCube ncube = getCube(appId, name);
    if (ncube == null) {
      throw new IllegalArgumentException(
          "Could not get referenced cube names, n-cube: "
              + name
              + " does not exist in app: "
              + appId);
    }
    Set<String> subCubeList = ncube.getReferencedCubeNames();

    // TODO: Use explicit stack, NOT recursion

    for (String cubeName : subCubeList) {
      if (!refs.contains(cubeName)) {
        refs.add(cubeName);
        getReferencedCubeNames(appId, cubeName, refs);
      }
    }
  }
コード例 #2
0
ファイル: NCubeManager.java プロジェクト: ccriderGAIG/n-cube
  /**
   * Fetch all the n-cube names for the given ApplicationID. This API will load all cube records for
   * the ApplicationID (NCubeInfoDtos), and then get the names from them.
   *
   * @return Set<String> n-cube names. If an empty Set is returned, then there are no persisted
   *     n-cubes for the passed in ApplicationID.
   */
  public static Set<String> getCubeNames(ApplicationID appId) {
    Map<String, Object> options = new HashMap<>();
    options.put(SEARCH_ACTIVE_RECORDS_ONLY, true);
    List<NCubeInfoDto> cubeInfos = search(appId, null, null, options);
    Set<String> names = new TreeSet<>();

    for (NCubeInfoDto info : cubeInfos) {
      names.add(info.name);
    }

    if (names.isEmpty()) { // Support tests that load cubes from JSON files...
      // can only be in there as ncubes, not ncubeDtoInfo
      for (Object value : getCacheForApp(appId).values()) {
        if (value instanceof NCube) {
          NCube cube = (NCube) value;
          names.add(cube.getName());
        }
      }
    }
    return new CaseInsensitiveSet<>(names);
  }