コード例 #1
0
  public void loadModel(KBWorkspaceObjectData modelData, boolean showAllRxns) {
    if (modelData == null || modelData.getId() == null || modelData.getWorkspace() == null) return;

    eventBus.fireEvent(new LoadingEvent(false));
    rpc.getKBaseMetabolicModel(
        modelData.getId(),
        modelData.getWorkspace(),
        new AsyncCallback<KBMetabolicModel>() {

          @Override
          public void onFailure(Throwable caught) {
            Window.alert("Remote procedure call failure: getKBaseMetabolicModel");
            setState(State.NO_MODELS_LOADED);
            eventBus.fireEvent(new LoadingEvent(true));
          }

          @Override
          public void onSuccess(KBMetabolicModel model) {
            // fire it off to the rest of the app.
            eventBus.fireEvent(
                new MetabolicModelLoadedEvent(model, view.getShowAllCheckBox().getValue()));
            if (model == null || model.getId().length() == 0) {
              Window.alert(
                  "Sorry, unable to display that model. Please try again.\nIf this problem persists, please contact the site administrator.");
            } else setState(State.MODEL_SELECTED);
            eventBus.fireEvent(new LoadingEvent(true));
          }
        });
  }
コード例 #2
0
  public void loadFBAResults(KBWorkspaceObjectData fbaData, boolean showAllRxns) {
    if (fbaData == null || fbaData.getId() == null || fbaData.getWorkspace() == null) return;

    eventBus.fireEvent(new LoadingEvent(false));
    rpc.getKBaseFBAResult(
        fbaData.getId(),
        fbaData.getWorkspace(),
        new AsyncCallback<KBFBAResult>() {
          @Override
          public void onFailure(Throwable caught) {
            Window.alert("Remote procedure call failure: getKBaseFBAResult");
            setState(State.NO_FBAS_LOADED);
            eventBus.fireEvent(new LoadingEvent(true));
          }

          @Override
          public void onSuccess(KBFBAResult fba) {
            // fire it off to the rest of the app.
            if (fba == null || fba.getId().length() == 0) {
              Window.alert(
                  "Sorry, unable to display that FBA result. Please try again.\n If this problem persists, please contact the site administrator.");
            } else {
              setState(State.FBA_SELECTED);
              view.getFBATextBox()
                  .setText(
                      fba.getId()
                          + " - "
                          + fba.getWorkspace()
                          + " - Biomass: "
                          + fba.getObjective());
              eventBus.fireEvent(
                  new FBAResultLoadedEvent(fba, view.getShowAllCheckBox().getValue()));
            }
            eventBus.fireEvent(new LoadingEvent(true));
          }
        });
  }
コード例 #3
0
  /**
   * Should be invoked when a user logs in or out. In either case, it should check whether the
   * current user has access to currently loaded models or FBA results.
   */
  public void processUserChange() {
    /* Do a lookup (getModel or get FBA result) on each item in order.
     * Keep the keepable ones, remove, but tag the non-keepable ones.
     * If any were removed from the list, alert the user.
     */
    if (!modelDataProvider.getList().isEmpty()) {
      List<KBWorkspaceObjectData> modelData = new ArrayList<KBWorkspaceObjectData>();
      modelData.addAll(modelDataProvider.getList());

      eventBus.fireEvent(new LoadingEvent(false));
      rpc.getObjectsWithValidPermissions(
          modelData,
          new AsyncCallback<List<KBWorkspaceObjectData>>() {
            @Override
            public void onFailure(Throwable caught) {
              eventBus.fireEvent(new LoadingEvent(true));
              Window.alert("Sorry, an error occurred while checking model\nviewing permissions");
            }

            @Override
            public void onSuccess(List<KBWorkspaceObjectData> validData) {
              if (validData.size() < modelDataProvider.getList().size()) {
                Window.alert(
                    "Changing login status has removed access to some models.\nResetting view...");
                modelDataProvider.getList().clear();
                if (validData.size() > 0) {
                  modelDataProvider.getList().addAll(validData);
                } else setState(State.NO_MODELS_LOADED);
                eventBus.fireEvent(new MetabolicModelLoadedEvent(null));
              }
              eventBus.fireEvent(new LoadingEvent(true));
            }
          });
    }

    if (!fbaDataProvider.getList().isEmpty()) {
      List<KBWorkspaceObjectData> fbaData = new ArrayList<KBWorkspaceObjectData>();
      fbaData.addAll(fbaDataProvider.getList());

      eventBus.fireEvent(new LoadingEvent(false));
      rpc.getObjectsWithValidPermissions(
          fbaDataProvider.getList(),
          new AsyncCallback<List<KBWorkspaceObjectData>>() {
            @Override
            public void onFailure(Throwable caught) {
              eventBus.fireEvent(new LoadingEvent(true));
              Window.alert(
                  "Sorry, an error occurred while checking fba\nresult viewing permissions");
            }

            @Override
            public void onSuccess(List<KBWorkspaceObjectData> validData) {
              if (validData.size() < fbaDataProvider.getList().size()) {
                Window.alert(
                    "Changing login status has removed access to some FBA results.\nResetting view...");
                fbaDataProvider.getList().clear();
                if (validData.size() > 0) {
                  fbaDataProvider.getList().addAll(validData);
                  setState(State.FBA_LOADED);
                }
                eventBus.fireEvent(new FBAResultLoadedEvent(null));
              }
              eventBus.fireEvent(new LoadingEvent(true));
            }
          });
    }
  }