@Override protected void setValue(Object element, Object value) { MongodbTreeViewDTO dto = (MongodbTreeViewDTO) element; // data 수정하자 if (dto.getValue().equals(value.toString())) return; try { // 데이터가 올바른지 검사합니다. MongoDBJavaStrToJavaObj.convStrToObj(dto.getType(), value.toString()); // fully key를 검색합니다. String fullyKey = findRealKey(dto, dto.getRealKey()); if (logger.isDebugEnabled()) logger.debug( "====>[update][real key]======> " + fullyKey + "\t [value]" + value.toString()); MongoDBQuery.updateDocument( userDB, collectionName, dto.getDbObject(), fullyKey, value.toString()); } catch (Exception e) { MessageDialog.openError( null, Messages.TreeViewerEditingSupport_2, Messages.TreeViewerEditingSupport_3 + dto.getType() + Messages.TreeViewerEditingSupport_4); return; } dto.setValue(value.toString()); viewer.refresh(); }
/** execute map reduce */ private void executeMapReduce() throws Exception { String strMap = textMap.getText(); String strReduce = textReduce.getText(); String strFinilize = textFinalize.getText(); String strOutputTarget = textOutputTarget.getText(); MapReduceCommand.OutputType outputType = (MapReduceCommand.OutputType) comboOutputType.getData(comboOutputType.getText()); DBObject dbQuery = null; if (!"".equals(textQuery.getText())) dbQuery = (DBObject) JSON.parse(textQuery.getText()); DBObject dbSort = null; if (!"".equals(textSort.getText())) dbSort = (DBObject) JSON.parse(textSort.getText()); // 쿼리 합니다. DBCollection dbCol = MongoDBQuery.findCollection(userDB, initColName); MapReduceCommand mrCmd = new MapReduceCommand(dbCol, strMap, strReduce, strOutputTarget, outputType, dbQuery); if (!"".equals(strFinilize)) mrCmd.setFinalize(strFinilize); if (dbSort != null) mrCmd.setSort(dbSort); if (getLimit() > 0) mrCmd.setLimit(getLimit()); if (btnJsMode.getSelection()) mrCmd.addExtraOption("jsMode", true); final BasicDBObject searchObj = (BasicDBObject) mrCmd.toDBObject(); if (btnSharded.getSelection()) ((BasicDBObject) searchObj.get("out")).put("sharded", true); if (btnNoneAtomic.getSelection()) ((BasicDBObject) searchObj.get("out")).put("nonAtomic", true); goMapReduce(dbCol, searchObj, outputType); }
@Override public void run() { if (actionType == DB_ACTION.TABLES) { String tbName = (String) sel.getFirstElement(); if (DBDefine.getDBDefine(userDB.getType()) != DBDefine.MONGODB_DEFAULT) { if (MessageDialog.openConfirm( window.getShell(), Messages.ObjectDeleteAction_2, tbName + Messages.ObjectDeleteAction_3)) { // mongodb인지.. try { TadpoleSystemCommons.executSQL(getUserDB(), "drop table " + tbName); // $NON-NLS-1$ refreshTable(); } catch (Exception e) { logger.error(Messages.ObjectDeleteAction_5, e); exeMessage(Messages.ObjectDeleteAction_0, e); } } } else if (DBDefine.getDBDefine(userDB.getType()) == DBDefine.MONGODB_DEFAULT) { if (MessageDialog.openConfirm( window.getShell(), Messages.ObjectDeleteAction_2, tbName + Messages.ObjectDeleteAction_31)) { try { MongoDBQuery.deleteCollection(getUserDB(), tbName); refreshTable(); } catch (Exception e) { logger.error("Collection Delete", e); // $NON-NLS-1$ exeMessage("Collection", e); // $NON-NLS-1$ } } } } else if (actionType == DB_ACTION.VIEWS) { String viewName = (String) sel.getFirstElement(); if (MessageDialog.openConfirm( window.getShell(), Messages.ObjectDeleteAction_8, viewName + Messages.ObjectDeleteAction_9)) { try { TadpoleSystemCommons.executSQL(getUserDB(), "drop view " + viewName); // $NON-NLS-1$ refreshView(); } catch (Exception e) { logger.error(Messages.ObjectDeleteAction_11, e); exeMessage(Messages.ObjectDeleteAction_1, e); } } } else if (actionType == DB_ACTION.INDEXES) { InformationSchemaDAO indexDAO = (InformationSchemaDAO) sel.getFirstElement(); if (MessageDialog.openConfirm( window.getShell(), Messages.ObjectDeleteAction_14, indexDAO.getTABLE_NAME() + Messages.ObjectDeleteAction_15 + indexDAO.getINDEX_NAME() + Messages.ObjectDeleteAction_16)) { try { TadpoleSystemCommons.executSQL( getUserDB(), "drop index " + indexDAO.getINDEX_NAME() + " on " + indexDAO.getTABLE_NAME()); // $NON-NLS-1$ //$NON-NLS-2$ refreshIndexes(); } catch (Exception e) { logger.error(Messages.ObjectDeleteAction_19, e); exeMessage(Messages.ObjectDeleteAction_4, e); } } } else if (actionType == DB_ACTION.PROCEDURES) { ProcedureFunctionDAO procedureDAO = (ProcedureFunctionDAO) sel.getFirstElement(); if (MessageDialog.openConfirm( window.getShell(), Messages.ObjectDeleteAction_23, procedureDAO.getName() + Messages.ObjectDeleteAction_24)) { try { TadpoleSystemCommons.executSQL( getUserDB(), "drop procedure " + procedureDAO.getName()); // $NON-NLS-1$ refreshProcedure(); } catch (Exception e) { logger.error(Messages.ObjectDeleteAction_26, e); exeMessage(Messages.ObjectDeleteAction_10, e); } } } else if (actionType == DB_ACTION.FUNCTIONS) { ProcedureFunctionDAO functionDAO = (ProcedureFunctionDAO) sel.getFirstElement(); if (MessageDialog.openConfirm( window.getShell(), Messages.ObjectDeleteAction_29, functionDAO.getName() + Messages.ObjectDeleteAction_30)) { try { TadpoleSystemCommons.executSQL( getUserDB(), "drop function " + functionDAO.getName()); // $NON-NLS-1$ refreshFunction(); } catch (Exception e) { logger.error(Messages.ObjectDeleteAction_32, e); exeMessage(Messages.ObjectDeleteAction_17, e); } } } else if (actionType == DB_ACTION.TRIGGERS) { TriggerDAO triggerDAO = (TriggerDAO) sel.getFirstElement(); if (MessageDialog.openConfirm( window.getShell(), Messages.ObjectDeleteAction_35, triggerDAO.getTrigger() + Messages.ObjectDeleteAction_36)) { try { TadpoleSystemCommons.executSQL( getUserDB(), "drop trigger " + triggerDAO.getTrigger()); // $NON-NLS-1$ refreshTrigger(); } catch (Exception e) { logger.error(Messages.ObjectDeleteAction_38, e); exeMessage(Messages.ObjectDeleteAction_18, e); } } } } // end method
@Override public void createPartControl(Composite parent) { GridLayout gl_parent = new GridLayout(1, false); gl_parent.marginHeight = 2; gl_parent.verticalSpacing = 2; gl_parent.horizontalSpacing = 2; gl_parent.marginWidth = 2; parent.setLayout(gl_parent); try { commandResult = MongoDBQuery.serverStatusCommandResult(userDB); } catch (Exception e1) { logger.error("Get status command", e1); } CTabFolder tabFolder = new CTabFolder(parent, SWT.NONE); tabFolder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1)); tabFolder.setBorderVisible(false); tabFolder.setSelectionBackground( TadpoleWidgetUtils.getTabFolderBackgroundColor(), TadpoleWidgetUtils.getTabFolderPercents()); CTabItem tbtmServerStatus = new CTabItem(tabFolder, SWT.NONE); tbtmServerStatus.setText(Messages.get().MongoDBInfosEditor_0); compositeServerStatus = new InstanceInformationComposite(tabFolder, SWT.NONE, userDB, commandResult); tbtmServerStatus.setControl(compositeServerStatus); compositeServerStatus.setLayout(new GridLayout(2, false)); new Label(compositeServerStatus, SWT.NONE); CTabItem tbtmCollectionSummary = new CTabItem(tabFolder, SWT.NONE); tbtmCollectionSummary.setText(Messages.get().MongoDBInfosEditor_1); compositeCollectionSummary = new CollectionInformationComposite(tabFolder, SWT.NONE); tbtmCollectionSummary.setControl(compositeCollectionSummary); GridLayout gl_compositeCollectionSummary = new GridLayout(1, false); gl_compositeCollectionSummary.verticalSpacing = 2; gl_compositeCollectionSummary.horizontalSpacing = 2; gl_compositeCollectionSummary.marginHeight = 2; gl_compositeCollectionSummary.marginWidth = 2; compositeCollectionSummary.setLayout(gl_compositeCollectionSummary); CTabItem tbtmLocaks = new CTabItem(tabFolder, SWT.NONE); tbtmLocaks.setText(Messages.get().MongoDBInfosEditor_2); LockComposite compositeLock = new LockComposite(tabFolder, SWT.NONE, userDB, commandResult); tbtmLocaks.setControl(compositeLock); compositeLock.setLayout(gl_compositeCollectionSummary); CTabItem tbtmReplicaInformation = new CTabItem(tabFolder, SWT.NONE); tbtmReplicaInformation.setText(Messages.get().MongoDBInfosEditor_3); ReplicaSetComposite compositeReplicaSet = new ReplicaSetComposite(tabFolder, SWT.NONE, userDB, commandResult); tbtmReplicaInformation.setControl(compositeReplicaSet); compositeReplicaSet.setLayout(gl_compositeCollectionSummary); CTabItem tbtmShardingInformation = new CTabItem(tabFolder, SWT.NONE); tbtmShardingInformation.setText(Messages.get().MongoDBInfosEditor_4); ShardingComposite compositeSharding = new ShardingComposite(tabFolder, SWT.NONE, userDB); tbtmShardingInformation.setControl(compositeSharding); compositeSharding.setLayout(gl_compositeCollectionSummary); if (defaultPage == PAGES.INSTANCE_INFORMATION) tabFolder.setSelection(0); else if (defaultPage == PAGES.COLLECTION_SUMMERY) tabFolder.setSelection(1); else if (defaultPage == PAGES.DB_LOCKS) tabFolder.setSelection(2); else if (defaultPage == PAGES.REPLACA_SET) tabFolder.setSelection(3); else tabFolder.setSelection(4); initData(); }