Example #1
0
  /**
   * Call this method to add the {@link WabitObject}s in the loaded workspaces to the given session
   * . This is the last step to importing a file into Wabit workspace.
   *
   * <p>If importing is done on multiple threads this operation must be done on the event dispatch
   * thread. This should only be called once for each DAO or the same workspace will be added to the
   * context multiple times.
   *
   * @param session The session that will have {@link WabitObject}s added to it. Null should not be
   *     passed into this method.
   */
  public void addImportedWorkspaceContentToWorkspace(WabitSession session) {
    if (session == null) {
      context.createUserPrompter(
          "Select a workspace to import into.",
          UserPromptType.MESSAGE,
          UserPromptOptions.OK,
          UserPromptResponse.OK,
          null);
      return;
    }

    if (cancelled.get()) return;

    try {
      final WabitWorkspace workspace = session.getWorkspace();
      int importObjectCount = 0;
      WabitSession importingSession = saxHandler.getSession();
      final WabitWorkspace importingWorkspace = importingSession.getWorkspace();
      importObjectCount += importingWorkspace.mergeIntoWorkspace(workspace);
      logger.debug(
          "Imported " + importObjectCount + " objects into " + session.getWorkspace().getName());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
Example #2
0
  /**
   * Call this method to register the loaded workspace with the context in this DAO. This is the
   * last step to loading a file into Wabit.
   *
   * <p>If loading is done on multiple threads this operation must be done on the event dispatch
   * thread. This should only be called once for each DAO or the same workspace will be added to the
   * context multiple times.
   *
   * @return The session that contain the workspaces that have been added to Wabit. This may be null
   *     if the load was cancelled.
   */
  public WabitSession addLoadedWorkspacesToContext() {
    if (cancelled.get()) return null;

    context.registerChildSession(saxHandler.getSession());

    return saxHandler.getSession();
  }