/**
   * tree에 새로운 항목 추가
   *
   * @param userDB
   * @param defaultOpen default editor open
   */
  public void addUserDB(UserDBDAO userDB, boolean defaultOpen) {
    for (ManagerListDTO dto : treeList) {
      if (dto.getName().equals(userDB.getGroup_name())) {
        dto.addLogin(userDB);

        if (defaultOpen) {
          selectAndOpenView(userDB);
          treeViewer.expandToLevel(userDB, 2);
        }
        return;
      } // end if(dto.getname()....
    } // end for

    // 신규 그룹이면...
    ManagerListDTO managerDto = new ManagerListDTO(userDB.getGroup_name());
    managerDto.addLogin(userDB);
    treeList.add(managerDto);

    if (defaultOpen) {
      selectAndOpenView(userDB);
      treeViewer.expandToLevel(userDB, 2);
    }
  }
Ejemplo n.º 2
0
  //	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();
  }