예제 #1
0
 private static NCube prepareCube(NCube cube) {
   applyAdvices(cube.getApplicationID(), cube);
   String cubeName = cube.getName().toLowerCase();
   if (!cube.getMetaProperties().containsKey("cache")
       || Boolean.TRUE.equals(
           cube.getMetaProperty(
               "cache"))) { // Allow cubes to not be cached by specified 'cache':false as a cube
                            // meta-property.
     getCacheForApp(cube.getApplicationID()).put(cubeName, cube);
   }
   return cube;
 }
예제 #2
0
  public static List<NCube> getNCubesFromResource(String name) {
    String lastSuccessful = "";
    try {
      Object[] cubes = getJsonObjectFromResource(name);
      List<NCube> cubeList = new ArrayList<>(cubes.length);

      for (Object cube : cubes) {
        JsonObject ncube = (JsonObject) cube;
        String json = JsonWriter.objectToJson(ncube);
        NCube nCube = NCube.fromSimpleJson(json);
        nCube.sha1();
        addCube(nCube.getApplicationID(), nCube);
        lastSuccessful = nCube.getName();
        cubeList.add(nCube);
      }

      return cubeList;
    } catch (Exception e) {
      String s =
          "Failed to load cubes from resource: "
              + name
              + ", last successful cube: "
              + lastSuccessful;
      LOG.warn(s);
      throw new RuntimeException(s, e);
    }
  }
예제 #3
0
 /**
  * Load n-cube, bypassing any caching. This is necessary for n-cube-editor (IDE time usage). If
  * the IDE environment is clustered, cannot be getting stale copies from cache. Any advices in the
  * manager will be applied to the n-cube.
  *
  * @return NCube of the specified name from the specified AppID, or null if not found.
  */
 public static NCube loadCube(ApplicationID appId, String cubeName) {
   NCube ncube = getPersister().loadCube(appId, cubeName);
   if (ncube == null) {
     return null;
   }
   applyAdvices(ncube.getApplicationID(), ncube);
   Map<String, Object> cubes = getCacheForApp(appId);
   cubes.put(cubeName.toLowerCase(), ncube); // Update cache
   return ncube;
 }