Exemple #1
0
 /** Still used in getNCubesFromResource */
 private static Object[] getJsonObjectFromResource(String name) throws IOException {
   JsonReader reader = null;
   try {
     URL url = NCubeManager.class.getResource("/" + name);
     File jsonFile = new File(url.getFile());
     InputStream in = new BufferedInputStream(new FileInputStream(jsonFile));
     reader = new JsonReader(in, true);
     return (Object[]) reader.readObject();
   } finally {
     IOUtilities.close(reader);
   }
 }
  /** {@inheritDoc} */
  @Override
  public BasicOperator deserialize(final JSONObject serializedOperator) throws JSONException {
    /*
     * instanciate the subgraphcontainer formatter, which is used for
     * subgraph execution
     */
    final SubgraphContainerFormatter serializer =
        new SubgraphContainerFormatter(this.dataset, this.operatorCreator, this.application);

    final JSONObject _serializedOperator = serializedOperator.getJSONObject("subgraph");
    final Root r = serializer.deserialize(_serializedOperator);
    /*
     * deserialize the key of the subgraph container
     */
    final String subgraphKey = (String) serializedOperator.get("key");
    Object obj = null;
    try {
      obj = JsonReader.jsonToJava(subgraphKey);
    } catch (final IOException e) {
      e.printStackTrace();
    }
    /*
     * read out the subgraphType, otherwise set default
     */
    String subgraphType = (String) serializedOperator.get("type");
    if (subgraphType == null) {
      subgraphType = SubgraphContainer.class.getName();
    }
    /*
     * create the subgraph container with the given key and executer
     */
    return this.invoke(subgraphType, r, obj, this.executer);
  }
Exemple #3
0
  public static Map<String, Object> getSystemParams() {
    final ConcurrentMap<String, Object> params = systemParams;

    if (params != null) {
      return params;
    }

    synchronized (NCubeManager.class) {
      if (systemParams == null) {
        String jsonParams = SystemUtilities.getExternalVariable(NCUBE_PARAMS);
        systemParams = new ConcurrentHashMap<>();

        if (StringUtilities.hasContent(jsonParams)) {
          try {
            systemParams = new ConcurrentHashMap<>(JsonReader.jsonToMaps(jsonParams));
          } catch (Exception e) {
            LOG.warn("Parsing of NCUBE_PARAMS failed.  " + jsonParams);
          }
        }
      }
    }
    return systemParams;
  }