예제 #1
0
  /*
   * create a pipleline by giving a json configuration to FunfManger,
   * and get back the handle
   */
  private Pipeline getOrCreatePipeline() {
    // TODO Auto-generated method stub
    // try to get the pipeline, if not create a pipeline configuration here
    // <string name="mainPipelineConfig">{"@type":"edu.mit.dig.funftest.MainPipeline"}</string>
    // try
    parser = new JsonParser();
    Log.i(TAG, "Try to get pipeline from FunfMananger:" + mBoundFunfManager.toString());
    Pipeline pipeline = mBoundFunfManager.getRegisteredPipeline(pipelineName);

    if (gson == null) {
      gson = mBoundFunfManager.getGson();
    }

    if (pipeline == null) {
      Log.i(TAG, "We don't have the pipeline name:" + pipelineName + " ,try to create a new one");
      String pipeConfigStr =
          "{\"@type\":\"com.google.appinventor.components.runtime.SensorDBPipeline\"}";

      // add to funfManager by calling this new function, it will create Pipeline and register to
      // FunfManger

      mBoundFunfManager.createPipeline(pipelineName, pipeConfigStr);
      Log.i(TAG, "pipelineName:" + pipelineName);
      return mBoundFunfManager.getRegisteredPipeline(pipelineName);
    }

    return pipeline;
  }