//	MapReduceOutput mrOutput = null;
  private void goMapReduce(
      final DBCollection dbCol,
      final BasicDBObject basicObj,
      final MapReduceCommand.OutputType mrOType) {
    Job job = new Job("MapReduce search job") { // $NON-NLS-1$
          @Override
          public IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Starting JSON query...", IProgressMonitor.UNKNOWN); // $NON-NLS-1$
            try {

              //					if(mrOType == MapReduceCommand.OutputType.INLINE) {
              //						cmdResult = dbCol.getDB().command(basicObj, dbCol.getOptions());
              //						cmdResult.throwOnError();
              //						mrOutput = new MapReduceOutput(dbCol, basicObj, cmdResult);
              //					} else {
              cmdResult = dbCol.getDB().command(basicObj);
              //						cmdResult.throwOnError();
              //						mrOutput = new MapReduceOutput(dbCol, basicObj, cmdResult);
              //					}
              if (!cmdResult.ok()) {
                throw cmdResult.getException();
              }

            } catch (Exception e) {
              logger.error("mapreduce exception", e); // $NON-NLS-1$
              return new Status(
                  Status.WARNING,
                  Activator.PLUGIN_ID,
                  "mapreduce " + e.getMessage()); // $NON-NLS-1$
            } finally {
              monitor.done();
            }

            return Status.OK_STATUS;
          }
        };

    // job의 event를 처리해 줍니다.
    job.addJobChangeListener(
        new JobChangeAdapter() {
          public void done(IJobChangeEvent event) {

            final IJobChangeEvent jobEvent = event;
            getSite()
                .getShell()
                .getDisplay()
                .asyncExec(
                    new Runnable() {
                      public void run() {
                        if (jobEvent.getResult().isOK()) {
                          try {
                            Iterable<DBObject> iteResult =
                                (Iterable<DBObject>) cmdResult.get("results");
                            compositeResult.refreshDBView(iteResult, 0);
                            compositeResult.setResult();
                          } catch (Exception e) {
                            logger.error("MapReduce Error", e); // $NON-NLS-1$
                            Status errStatus =
                                new Status(
                                    IStatus.ERROR,
                                    Activator.PLUGIN_ID,
                                    e.getMessage(),
                                    e); //$NON-NLS-1$
                            ExceptionDetailsErrorDialog.openError(
                                null,
                                "Error",
                                "MapReduce execute exception",
                                errStatus); //$NON-NLS-1$ //$NON-NLS-2$
                          }
                        } else {
                          //							compositeResult.errorView(jobEvent.getResult().getMessage());
                        }
                      }
                    }); // end display.asyncExec
          } // end done
        }); // end job

    job.setName(userDB.getDisplay_name());
    job.setUser(true);
    job.schedule();
  }
  /**
   * 정보를 최신으로 리프레쉬합니다.
   *
   * @param strObjectName
   */
  public void refreshSynonym(
      final UserDBDAO selectUserDb, final boolean boolRefresh, final String strObjectName) {
    if (!boolRefresh) if (selectUserDb == null) return;
    this.userDB = selectUserDb;

    Job job =
        new Job(Messages.get().MainEditor_45) {
          @Override
          public IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Connect database", IProgressMonitor.UNKNOWN); // $NON-NLS-1$

            try {
              showSynonyms = getSynonymList(userDB);
            } catch (Exception e) {
              logger.error("Synonym Referesh", e); // $NON-NLS-1$

              return new Status(Status.WARNING, Activator.PLUGIN_ID, e.getMessage());
            } finally {
              monitor.done();
            }

            return Status.OK_STATUS;
          }
        };

    job.addJobChangeListener(
        new JobChangeAdapter() {

          public void done(IJobChangeEvent event) {
            final IJobChangeEvent jobEvent = event;

            getSite()
                .getShell()
                .getDisplay()
                .asyncExec(
                    new Runnable() {
                      public void run() {
                        if (jobEvent.getResult().isOK()) {
                          synonymListViewer.setInput(showSynonyms);
                          synonymListViewer.refresh();
                          TableUtil.packTable(synonymListViewer.getTable());

                          // select tabitem
                          getTabFolderObject().setSelection(tbtmSynonym);

                          selectDataOfTable(strObjectName);
                        } else {
                          if (showSynonyms != null) showSynonyms.clear();
                          synonymListViewer.setInput(showSynonyms);
                          synonymListViewer.refresh();
                          TableUtil.packTable(synonymListViewer.getTable());

                          Status errStatus =
                              new Status(
                                  IStatus.ERROR,
                                  Activator.PLUGIN_ID,
                                  jobEvent.getResult().getMessage(),
                                  jobEvent.getResult().getException()); // $NON-NLS-1$
                          ExceptionDetailsErrorDialog.openError(
                              null,
                              "Error",
                              Messages.get().ExplorerViewer_86,
                              errStatus); //$NON-NLS-1$
                        }
                      }
                    }); // end display.asyncExec
          } // end done
        }); // end job

    job.setName(userDB.getDisplay_name());
    job.setUser(true);
    job.schedule();
  }
  @Override
  protected void initializeGraphicalViewer() {
    //		super.initializeGraphicalViewer();

    Job job =
        new Job("ERD Initialize") {
          @Override
          public IStatus run(IProgressMonitor monitor) {
            monitor.beginTask("Painting table object", IProgressMonitor.UNKNOWN);

            try {
              RdbFactory factory = RdbFactory.eINSTANCE;

              if (db == null) {

                // 모든 table 정보를 가져온다.
                if (isAllTable) {
                  db = TadpoleModelUtils.INSTANCE.getDBAllTable(monitor, userDB);
                  // 부분 테이블 정보를 처리한다.
                } else {
                  db = factory.createDB();
                }

                db.setDbType(userDB.getDbms_type() + " (" + userDB.getDisplay_name() + ")");
              }

              // 하위 호환을 위한 코드 .
              if (db.getStyle() == null) {
                Style style = RdbFactory.eINSTANCE.createStyle();
                style.setDb(db);
                db.setStyle(style);
              }

            } catch (Exception e) {
              logger.error("ERD Initialize excepiton", e);

              return new Status(Status.WARNING, Activator.PLUGIN_ID, e.getMessage());
            } finally {
              monitor.done();
            }

            /////////////////////////////////////////////////////////////////////////////////////////
            return Status.OK_STATUS;
          }
        };

    // job의 event를 처리해 줍니다.
    final TadpoleRDBEditor rdbEditor = this;
    job.addJobChangeListener(
        new JobChangeAdapter() {

          public void done(IJobChangeEvent event) {
            final IJobChangeEvent jobEvent = event;
            getSite()
                .getShell()
                .getDisplay()
                .asyncExec(
                    new Runnable() {
                      public void run() {
                        if (!jobEvent.getResult().isOK()) {

                          // 아래의 try문은 이슈 169의 오류를 검증하기 위한 코드입니다.
                          // https://github.com/hangum/TadpoleForDBTools/issues/169
                          //  근본적인 에러는 해결안됨.  그러나 프로그램에서 에러나고 죽는 그런 경우는 해결.
                          //
                          try {
                            Exception e = new Exception(jobEvent.getResult().getException());
                            Status errStatus =
                                new Status(
                                    IStatus.ERROR,
                                    Activator.PLUGIN_ID,
                                    e.getMessage(),
                                    e); //$NON-NLS-1$
                            ExceptionDetailsErrorDialog.openError(
                                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                                "Error",
                                Messages.get().TadpoleModelUtils_2,
                                errStatus); //$NON-NLS-1$
                          } catch (Exception e) {
                            logger.error(
                                "https://github.com/hangum/TadpoleForDBTools/issues/169 검증오류...",
                                e);
                          }

                          // 오류가 발생했을때는 기본 정보로
                          RdbFactory factory = RdbFactory.eINSTANCE;
                          db = factory.createDB();
                          db.setDbType(userDB.getDbms_type());
                          db.setId(userDB.getUsers());
                          db.setUrl(userDB.getHost());
                        }
                        getGraphicalViewer().setContents(db);

                        // dnd
                        getGraphicalViewer()
                            .addDropTargetListener(
                                new TableTransferDropTargetListener(
                                    rdbEditor, getGraphicalViewer(), userDB, db));
                      }
                    }); // end display.asyncExec
          } // end done
        }); // end job

    job.setName(userDB.getDisplay_name());
    job.setUser(true);
    job.schedule();
  }