private void performUpdate(Update update) throws Exception { try { print(update.getMessage()); update.doUpdate(); print("...done\n"); } catch (Exception e) { print("\n\t" + e + "\n"); } }
public void handleDirections(Update update) throws InvalidObjectException { Message message = update.getMessage(); if (message != null && message.hasText()) { if (languageMessages.contains(message.getFrom().getId())) { onLanguageSelected(message); } else { String language = DatabaseManager.getInstance().getUserLanguage(update.getMessage().getFrom().getId()); if (message.getText().startsWith(Commands.setLanguageCommand)) { onSetLanguageCommand(message, language); } else if (message.getText().startsWith(Commands.startDirectionCommand)) { onStartdirectionsCommand(message, language); } else if ((message.getText().startsWith(Commands.help) || (message.getText().startsWith(Commands.startCommand) || !message.isGroupMessage())) && DatabaseManager.getInstance().getUserDestinationStatus(message.getFrom().getId()) == -1) { sendHelpMessage(message, language); } else if (!message.getText().startsWith("/")) { if (DatabaseManager.getInstance().getUserDestinationStatus(message.getFrom().getId()) == WATING_ORIGIN_STATUS && message.hasReplayMessage() && DatabaseManager.getInstance() .getUserDestinationMessageId(message.getFrom().getId()) == message.getReplyToMessage().getMessageId()) { onOriginReceived(message, language); } else if (DatabaseManager.getInstance() .getUserDestinationStatus(message.getFrom().getId()) == WATING_DESTINY_STATUS && message.hasReplayMessage() && DatabaseManager.getInstance() .getUserDestinationMessageId(message.getFrom().getId()) == message.getReplyToMessage().getMessageId()) { onDestinationReceived(message, language); } else if (!message.hasReplayMessage()) { if (DatabaseManager.getInstance().getUserDestinationStatus(message.getFrom().getId()) == -1) { sendHelpMessage(message, language); } else { SendMessage sendMessageRequest = new SendMessage(); sendMessageRequest.setText( LocalisationService.getInstance().getString("youNeedReplyDirections", language)); sendMessageRequest.setChatId(message.getChatId().toString()); SenderHelper.SendApiMethod(sendMessageRequest, TOKEN); } } } } } }
@Test public void testAlternativeSetters() { // given VersionNumber version = VersionNumber.version(23, 47, 78, 0); boolean developmentVersion = true; EUpdateStrategy strategy = EUpdateStrategy.EXECUTE; // when Update update = UpdateBuilder.builder() .setVersionNumber(version) .setDevelopmentVersion(developmentVersion) .setUpdateStrategy(strategy) .build(); // then assertThat(update.getVersionNumber()) .as("Builder should set version number properly") .isNotNull() .isEqualTo(version); assertThat(update.isDevelopmentVersion()) .as("Builder should set development version properly") .isEqualTo(developmentVersion); assertThat(update.getUpdateStrategy()) .as("Builder should set update strategy properly") .isNotNull() .isEqualTo(strategy); }
@Override public void bridgeEstablished() { /* Only rebuild launchers if the updater is not waiting for the bridge to come back, * as the GUI will be restarted shortly */ if (updateScene == null || (!updateScene.isAwaitingBridgeEstablish() && !updateScene.isAwaitingGUIRestart())) { log.info(String.format("Bridge established, rebuilding all launchers")); rebuildAllLaunchers(); if (context.getBridge().isServiceUpdating()) { setMode(Mode.UPDATE); } else { final StringProperty prop = Configuration.getDefault().temporaryOnStartConnectionProperty(); String tmp = prop.get(); if (!StringUtils.isBlank(tmp)) { try { Connection c = context.getBridge().getConnectionService().getConnection(Long.parseLong(tmp)); if (c == null) throw new Exception("No connection with id of " + tmp); log.info( String.format( "Using temporary 'on start' connection %d (%s)", c.getId(), c.getHostname())); context.getBridge().connect(c); } catch (Exception e) { log.error("Failed to start temporary 'on start' connection.", e); } prop.set(""); } } } }
@Test(timeout = 100000) public void testBatchWithSameRow() throws Exception { String tableName = TABLE_NAME_PREFIX + "-testBatchWithSameRow"; table = createTable(tableName, basicSchema, new CreateTableOptions()); KuduSession session = syncClient.newSession(); session.setFlushMode(SessionConfiguration.FlushMode.MANUAL_FLUSH); // Insert 25 rows, one per batch, along with 50 updates for each, and a delete at the end, // while also clearing the cache between each batch half the time. The delete is added here // so that a misplaced update would fail if it happens later than its delete. for (int i = 0; i < 25; i++) { session.apply(createInsert(i)); for (int j = 0; j < 50; j++) { Update update = table.newUpdate(); PartialRow row = update.getRow(); row.addInt(basicSchema.getColumnByIndex(0).getName(), i); row.addInt(basicSchema.getColumnByIndex(1).getName(), 1000); session.apply(update); } Delete del = table.newDelete(); PartialRow row = del.getRow(); row.addInt(basicSchema.getColumnByIndex(0).getName(), i); session.apply(del); session.flush(); if (i % 2 == 0) { client.emptyTabletsCacheForTable(table.getTableId()); } } assertEquals(0, countRowsInScan(client.newScannerBuilder(table).build())); }
public static void main(String args[]) { // Update u = new Update(); // u.updateDecubito("teste", "teste"); // try{ // String url = "http://127.0.0.1:8888/getTime"; //localhost // // HttpClient httpClient = new DefaultHttpClient(); // List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); // nameValuePairs.add(new BasicNameValuePair("obj","ponto")); // nameValuePairs.add(new BasicNameValuePair("parte","occiptal")); // //nameValuePairs.add(new BasicNameValuePair("value", "teste10")); // // UrlEncodedFormEntity form; // form = new UrlEncodedFormEntity(nameValuePairs); // form.setContentEncoding(HTTP.UTF_8); // // HttpPost postRequest = new HttpPost(url); // postRequest.setEntity(form); // HttpResponse response = httpClient.execute(postRequest); // ResponseHandler<String> handler = new BasicResponseHandler(); // String body = handler.handleResponse(response); // System.out.println("Body "+body); // } // catch(IOException e){ // e.printStackTrace(); // } Update update = new Update(); update.updateDecubito(Decubito.DORSAL.getNome(), 20.8); }
public void visit(Update entity) { wGetVisitor1().visit(entity.getTableName()); wGetVisitor1().visit(entity.getSetClauses()); wGetVisitor1().visit(entity.getFromClauses()); wGetVisitor1().visit(entity.getWhereExpr()); wGetVisitor1().visit(entity.getLimit()); }
public int update(String sql, Object... args) { Update stmt = createStatement(sql); int position = 0; for (Object arg : args) { stmt.bind(position++, arg); } return stmt.execute(); }
public void update() throws Exception { Update[] updates = getUpdates(); for (int i = 0; i < updates.length; i++) { Update update = updates[i]; if (update.shouldBeApplied()) performUpdate(update); } saveProperties(); }
private void hidePanels(Update upd) { if (upd.getView() instanceof TextView) { showPanel(TEXT_VIEW); } else if (upd.getView() instanceof TreeView) { showPanel(TREE_VIEW); } else if (upd.getView() instanceof XmlView) { showPanel(XML_VIEW); } }
public void setMode(Mode mode) { if (mode != this.mode) { Mode previousMode = this.mode; this.mode = mode; log.info(String.format("Dock mode is now %s", mode)); switch (mode) { case LAUNCHERS: rebuildIcons(); setAvailable(); flinger.recentre(); break; case UPDATE: try { // Starting an update, so hide the all other windows hideIfShowing(signInPopup); hideIfShowing(optionsPopup); hideIfShowing(resourceGroupPopup); setAvailable(); updateScene = (Update) context.openScene( Update.class, Configuration.getDefault().isVertical() ? "Vertical" : null); Scene scn = updateScene.getScene(); scn.setFill(new Color(0, 0, 0, 0)); /* * The update popup will get future update events, but it * needs this one to initialize */ updateScene.initUpdate(appsToUpdate, previousMode); Parent sceneRoot = scn.rootProperty().get(); scn.setRoot(new Group()); if (cfg.isVertical()) ((VBox) sceneRoot).minWidthProperty().bind(shortcuts.heightProperty()); else ((HBox) sceneRoot).minHeightProperty().bind(shortcuts.widthProperty()); flinger.getContent().getChildren().clear(); flinger.getContent().getChildren().add(sceneRoot); } catch (IOException ioe) { log.error("Failed to load update scene.", ioe); } break; case IDLE: flinger.getContent().getChildren().clear(); setAvailable(); break; default: throw new UnsupportedOperationException(); } } }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Update other = (Update) obj; if (!getOuterType().equals(other.getOuterType())) return false; if (key == null) { if (other.key != null) return false; } else if (!key.equals(other.key)) return false; if (type != other.type) return false; return true; }
@Test public void requestDataMultipleClientRequest() { Doc doc = new Doc("indexName", "indexType", "1"); Index indexDocument = new Index("index", "type", "id", "\"indexDocumentData\""); Update update = new Update(doc, "\"updateData\""); assertEquals("\"updateData\"", update.getData().toString()); assertEquals("POST", update.getRestMethodName()); assertEquals("indexName/indexType/1/_update", update.getURI()); assertEquals("\"indexDocumentData\"", indexDocument.getData().toString()); assertEquals("PUT", indexDocument.getRestMethodName()); assertEquals("index/type/id", indexDocument.getURI()); }
@Override void add(final Update update, final QueryContext qc) throws QueryException { // check permissions if (update instanceof NameUpdate) { if (!qc.context.perm(Perm.CREATE, ((NameUpdate) update).name())) throw BASX_PERM_X.get(update.info(), Perm.CREATE); } else if (update instanceof DataUpdate) { if (!qc.context.perm(Perm.WRITE, ((DataUpdate) update).data().meta.name)) throw BASX_PERM_X.get(update.info(), Perm.WRITE); } else if (update instanceof UserUpdate) { if (!qc.context.perm(Perm.ADMIN, null)) throw BASX_PERM_X.get(update.info(), Perm.ADMIN); } else { throw Util.notExpected("Unknown update type: " + update); } super.add(update, qc); }
/** * 执行插入更新操作 * * @param tablename * @param mid * @param fieldsValue */ private void insertUpdate(String tablename, String mid, String[] fieldsValue) { checkSession(); KuduTable table; if (Constants.UPUSERS_ATTR_TABLE.equals(tablename)) { table = table_attr; } else { table = table_days; } try { Insert insert = table.newInsert(); PartialRow row = insert.getRow(); setInsertValue(mid, Constants.ATTR_INSERT_FIELDS, fieldsValue, row); OperationResponse rsInsert = session.apply(insert); if (rsInsert.hasRowError()) { if ("key already present".equals(rsInsert.getRowError().getMessage())) { Update update = table.newUpdate(); PartialRow urow = update.getRow(); setUpdateValue(mid, Constants.ATTR_UPDATE_FIELDS, fieldsValue, urow); OperationResponse rsUpdate = session.apply(update); if (rsUpdate.hasRowError()) { System.out.println( "=======================================ERROR UPDATE :" + rsUpdate.getRowError()); } else { System.out.println( "=======================================UPDATE DATA:" + mid + ":" + Arrays.toString(fieldsValue)); } } else { System.out.println( "=======================================ERROR INSERT :" + rsInsert.getRowError()); } } else { System.out.println( "=======================================INSERT DATA:" + mid + ":" + Arrays.toString(fieldsValue)); } } catch (Exception e) { collector.reportError(e); } }
@Override public String toString(final int indent) { final String s = indent(indent); final StringBuilder sb = new StringBuilder(); final Map<String /* prefix */, String /* uri */> prefixDecls = getPrefixDecls(); // if (getProperty(Annotations.TIMEOUT) != null) { // sb.append("\n"); // sb.append(s); // sb.append("timeout=" + getTimeout()); // } if (prefixDecls != null) { for (Map.Entry<String, String> e : prefixDecls.entrySet()) { sb.append("\n"); sb.append(s); sb.append("PREFIX "); sb.append(e.getKey()); sb.append(": <"); sb.append(e.getValue()); sb.append(">"); } } for (Update n : this) { sb.append(n.toString(indent + 1)); } return sb.toString(); }
@Override public void bridgeLost() { log.info(String.format("Bridge lost, rebuilding all launchers")); Platform.runLater( () -> { if (updateScene == null || !updateScene.isAwaitingBridgeLoss()) setMode(Mode.IDLE); rebuildAllLaunchers(); }); // TODO // Stop connecting process if bridge lost during an upgrade }
/** * @param message * @param installationDescription * @param description * @throws CantUpdateApplicationException */ private void runUpdate(InstallationDescription current, InstallationDescription target) throws CantUpdateApplicationException { if (!askUserToProceed()) { this.cantUpdate("You can't login with old application version."); } else { if (logger.isDebugEnabled()) { logger.debug( "Create update builder from " + current.getApplicationVersionObj() + " to " + target.getApplicationVersionObj()); } final UpdateBuilder builder = new UpdateBuilder(current, target); final Update update = builder.getResult(); if (logger.isDebugEnabled()) { logger.debug("Update created " + update); } UpdateResult result = update.perform(this.filesDownloader); this.updateProcessListener.updated(result); } }
@Override public String toSql() { String sql = ""; sql += mUpdate.toSql(); sql += "SET " + mSet + " "; if (mWhere != null) { sql += "WHERE " + mWhere + " "; } return sql; }
/* (non-Javadoc) * @see org.fosstrak.ale.wsdl.alelr.epcglobal.ALELRServicePortType#update(org.fosstrak.ale.wsdl.alelr.epcglobal.Update parms )* */ public org.fosstrak.ale.wsdl.alelr.epcglobal.UpdateResult update(Update parms) throws ValidationExceptionResponse, InUseExceptionResponse, ImplementationExceptionResponse, SecurityExceptionResponse, NoSuchNameExceptionResponse, ImmutableReaderExceptionResponse, ReaderLoopExceptionResponse { LOG.debug("update"); try { logicalReaderManager.update(parms.getName(), parms.getSpec()); } catch (org.fosstrak.ale.exception.NoSuchNameException e) { throw new NoSuchNameExceptionResponse(e.getMessage(), e); } catch (org.fosstrak.ale.exception.SecurityException e) { throw new SecurityExceptionResponse(e.getMessage(), e); } catch (org.fosstrak.ale.exception.ImplementationException e) { throw new ImplementationExceptionResponse(e.getMessage(), e); } catch (org.fosstrak.ale.exception.InUseException e) { throw new InUseExceptionResponse(e.getMessage(), e); } catch (org.fosstrak.ale.exception.ImmutableReaderException e) { throw new ImmutableReaderExceptionResponse(e.getMessage(), e); } catch (org.fosstrak.ale.exception.ValidationException e) { throw new ValidationExceptionResponse(e.getMessage(), e); } catch (org.fosstrak.ale.exception.ReaderLoopException e) { throw new ReaderLoopExceptionResponse(e.getMessage(), e); } return null; }
@Test public void testUpdate() throws Exception { Handle h = openHandle(); Update insert = h.createStatement("insert into something_else (name) values (:name)"); insert.bind("name", "Brian"); Long id1 = insert.executeAndReturnGeneratedKeys(LongColumnMapper.WRAPPER).first(); Assert.assertNotNull(id1); Update update = h.createStatement("update something_else set name = :name where id = :id"); update.bind("id", id1); update.bind("name", "Tom"); Long id2 = update.executeAndReturnGeneratedKeys(LongColumnMapper.WRAPPER).first(); Assert.assertNull(id2); }
@Override public void confirmUpdate(SimpleMicroBlogNode other_, Update upd_) { boolean acquired = false; while (!acquired) { try { int wait = (int) (Math.random() * 10); acquired = lock.tryLock(wait, TimeUnit.MILLISECONDS); if (acquired) { System.out.println( ident + ": recvd confirm: " + upd_.getUpdateText() + " from " + other_.getIdent()); } else { Thread.sleep(wait); } } catch (InterruptedException e) { } finally { if (acquired) lock.unlock(); } } }
@Override protected void onCleanUp() { if (updateScene != null) { updateScene.cleanUp(); } if (signInScene != null) { signInScene.cleanUp(); } if (optionsScene != null) { optionsScene.cleanUp(); } if (statusContent != null) { statusContent.cleanUp(); } cfg.sizeProperty().removeListener(sizeChangeListener); cfg.colorProperty().removeListener(colorChangeListener); cfg.topProperty().removeListener(borderChangeListener); cfg.bottomProperty().removeListener(borderChangeListener); cfg.leftProperty().removeListener(borderChangeListener); cfg.rightProperty().removeListener(borderChangeListener); }
@Test public void logUpdateResult_create_success_dryRun() { final RpslObject maintainer = RpslObject.parse("mntner: TST-MNT"); final UpdateResult updateResult = new UpdateResult( maintainer, maintainer, Action.CREATE, UpdateStatus.SUCCESS, new ObjectMessages(), 0, true); when(update.getCredentials()).thenReturn(new Credentials()); when(updateContext.createUpdateResult(update)).thenReturn(updateResult); subject.logUpdateResult(updateRequest, updateContext, update, stopwatch); verify(logger) .info( matches( "\\[\\s*0\\] 0[,.]000 ns DRY CREATE mntner TST-MNT \\(1\\) SUCCESS : <E0,W0,I0> AUTH - null")); }
@Test public void testInsert() throws Exception { Handle h = openHandle(); Update insert1 = h.createStatement("insert into something_else (name) values (:name)"); insert1.bind("name", "Brian"); Long id1 = insert1.executeAndReturnGeneratedKeys(LongColumnMapper.WRAPPER).first(); Assert.assertNotNull(id1); Update insert2 = h.createStatement("insert into something_else (name) values (:name)"); insert2.bind("name", "Tom"); Long id2 = insert2.executeAndReturnGeneratedKeys(LongColumnMapper.WRAPPER).first(); Assert.assertNotNull(id2); Assert.assertTrue(id2 > id1); }
private void handleOnDuplicate(DbException de) { if (de.getErrorCode() != ErrorCode.DUPLICATE_KEY_1) { throw de; } if (duplicateKeyAssignmentMap == null || duplicateKeyAssignmentMap.isEmpty()) { throw de; } ArrayList<String> variableNames = new ArrayList<String>(duplicateKeyAssignmentMap.size()); for (int i = 0; i < columns.length; i++) { String key = session.getCurrentSchemaName() + "." + table.getName() + "." + columns[i].getName(); variableNames.add(key); session.setVariable(key, list.get(getCurrentRowNumber() - 1)[i].getValue(session)); } Update command = new Update(session); command.setTableFilter(new TableFilter(session, table, null, true, null)); for (Column column : duplicateKeyAssignmentMap.keySet()) { command.setAssignment(column, duplicateKeyAssignmentMap.get(column)); } Index foundIndex = searchForUpdateIndex(); if (foundIndex != null) { command.setCondition(prepareUpdateCondition(foundIndex)); } else { throw DbException.getUnsupportedException( "Unable to apply ON DUPLICATE KEY UPDATE, no index found!"); } command.prepare(); command.update(); for (String variableName : variableNames) { session.setVariable(variableName, ValueNull.INSTANCE); } }
public static List<Object> performSearch( Update command, String cacheName, InfinispanConnection conn) throws TranslatorException { return performSearch(command.getWhere(), null, cacheName, conn); }
public void update() { for (Update u : observers) u.update(); repaint(); }
@Test public void testBuilder() { // given String packageName = "some package name"; String packageId = "1"; String versionNumber = "23.45.78.00"; String developmentVersion = "true"; String updateId = "2"; String changes = "some changes"; String strategy = "unzip"; String originalName = "name.zip"; String relativePath = "/"; String command = "some command"; Package _package = PackageBuilder.builder().setName(packageName).setVersionNumber("1.0.0.0").build(); File file = new File("/"); // when Update update = UpdateBuilder.builder() .setID(updateId) .setPackageName(packageName) .setPackageID(packageId) .setPackage(_package) .setVersionNumber(versionNumber) .setChanges(changes) .setDevelopmentVersion(developmentVersion) .setUpdateStrategy(strategy) .setOriginalName(originalName) .setRelativePath(relativePath) .setCommand(command) .setFile(file) .build(); // then assertThat(update.getPackageName()) .as("Builder should set package name properly") .isNotNull() .isEqualTo(packageName); assertThat(update.getPackageID()) .as("Builder should set package ID properly") .isNotNull() .isEqualTo(packageId); assertThat(update.getPackage()) .as("Builder should set Package properly") .isNotNull() .isEqualTo(_package); assertThat(update.getVersionNumber()) .as("Builder should set version number properly") .isNotNull() .isEqualTo(version(versionNumber)); assertThat(update.isDevelopmentVersion()) .as("Builder should set development version properly") .isEqualTo(Boolean.valueOf(developmentVersion)); assertThat(update.getID()) .as("Builder should set update ID properly") .isNotNull() .isEqualTo(updateId); assertThat(update.getUpdateStrategy()) .as("Builder should set update strategy properly") .isNotNull() .isEqualTo(Enums.parseMessage(EUpdateStrategy.class, strategy)); assertThat(update.getChanges()) .as("Builder should set changes properly") .isNotNull() .isEqualTo(changes); assertThat(update.getOriginalName()) .as("Builder should set original name properly") .isNotNull() .isEqualTo(originalName); assertThat(update.getRelativePath()) .as("Builder should set relative path properly") .isNotNull() .isEqualTo(""); assertThat(update.getCommand()) .as("Builder should set command properly") .isNotNull() .isEqualTo(command); assertThat(update.getFile()).as("Builder should set file properly").isNotNull().isEqualTo(file); }