private static boolean isInsertModeStaticData(Change staticData) { return isInsertModeStaticData(staticData.getConvertedContent()); }
private static boolean isInsertModeStaticData(Change staticData) { return isInsertModeStaticData(staticData.getConvertedContent()); }
@Override protected boolean shouldApplyGrants(Change artifact) { return artifact.getApplyGrants() != null ? artifact.getApplyGrants().booleanValue() : CREATE_TABLE_MATCHER.matcher(artifact.getConvertedContent()).matches(); }
@Override protected boolean shouldApplyGrants(Change artifact) { return artifact.getApplyGrants() != null ? artifact.getApplyGrants().booleanValue() : CREATE_TABLE_MATCHER.matcher(artifact.getConvertedContent()).matches(); }
ToStringBuilder toStringBuilder() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append(this.getSchema()) .append(this.getChangeName()) .append(this.getObjectName()) .append(this.getChangeType()) .append(this.getConvertedContent()) .append(this.getContentHash()) .append(this.getOrderWithinObject()) ; }
@Override public void deploy(Change change, CommandExecutionContext cec) { MongoDatabase database = mongoClient.getDatabase(change.getPhysicalSchema(env).getPhysicalName()); final BasicDBObject command = new BasicDBObject(); command.put("eval", change.getConvertedContent()); Document result = database.runCommand(command); LOG.info("Result: {}", result); }
ToStringBuilder toStringBuilder() { return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE) .append(this.getSchema()) .append(this.getChangeName()) .append(this.getObjectName()) .append(this.getChangeType()) .append(this.getConvertedContent()) .append(this.getContentHash()) .append(this.getOrderWithinObject()) ; }
@Override public void deploy(Change change, CommandExecutionContext cec) { MongoDatabase database = mongoClient.getDatabase(change.getPhysicalSchema(env).getPhysicalName()); final BasicDBObject command = new BasicDBObject(); command.put("eval", change.getConvertedContent()); Document result = database.runCommand(command); LOG.info("Result: {}", result); }
void deployArtifact(Connection conn, Change artifact) { MutableList<String> sqls = MultiLineStringSplitter.createSplitterOnSpaceAndLine("GO").valueOf(artifact.getConvertedContent()); int index = 0; for (String sql : sqls) { index++; if (StringUtils.isBlank(sql)) { LOG.debug("Skipping blank sql"); } else { LOG.debug("Executing change #{} in the artifact", index); try { dialect.doTryBlockForArtifact(conn, this.sqlExecutor, artifact); this.sqlExecutor.getJdbcTemplate().update(conn, sql); } catch (DataAccessException e) { throw new DeployerRuntimeException("Could not execute DDL:\nfor artifact [[[" + artifact.getDisplayString() + "]]] while executing SQL: [[[\n" + sql + "\n]]]", e); } finally { dialect.doFinallyBlockForArtifact(conn, this.sqlExecutor, artifact); } } } } }
void deployArtifact(Connection conn, Change artifact) { MutableList<String> sqls = MultiLineStringSplitter.createSplitterOnSpaceAndLine("GO").valueOf(artifact.getConvertedContent()); int index = 0; for (String sql : sqls) { index++; if (StringUtils.isBlank(sql)) { LOG.debug("Skipping blank sql"); } else { LOG.debug("Executing change #{} in the artifact", index); try { dialect.doTryBlockForArtifact(conn, this.sqlExecutor, artifact); this.sqlExecutor.getJdbcTemplate().update(conn, sql); } catch (DataAccessException e) { throw new DeployerRuntimeException("Could not execute DDL:\nfor artifact [[[" + artifact.getDisplayString() + "]]] while executing SQL: [[[\n" + sql + "\n]]]", e); } finally { dialect.doFinallyBlockForArtifact(conn, this.sqlExecutor, artifact); } } } } }
when(artifact.getPhysicalSchema(env)).thenReturn(new PhysicalSchema(schema)); when(artifact.getObjectName()).thenReturn(table); when(artifact.getConvertedContent()).thenReturn( "AID,BID\n" + "1,2\n" +
@Test public void testMissingPrimaryKeys() { expectedEx.expect(IllegalStateException.class); expectedEx.expectMessage("CSV-based static data loads require primary key or unique index on table " + table.toUpperCase() + ", but none found"); this.jdbc.execute(conn, "CREATE TABLE " + schema + "." + table + " (\n" + "AID INT NOT NULL,\n" + "BID INT NOT NULL,\n" + ")\n"); DbEnvironment env = new DbEnvironment(); env.setPlatform(PLATFORM); Change artifact = mock(Change.class); when(artifact.getPhysicalSchema(env)).thenReturn(new PhysicalSchema(schema)); when(artifact.getObjectName()).thenReturn(table); when(artifact.getConvertedContent()).thenReturn( "AID,BID\n" + "1,2\n" + "2,3\n" + "3,4\n" + "4,4\n" ); CsvStaticDataDeployer csvStaticDataDeployer = new CsvStaticDataDeployer(env, getSqlExecutor(), this.ds, metadataManager, new H2DbPlatform()); csvStaticDataDeployer.deployArtifact(artifact); }
"UPDATETIMEFIELD"); when(artifact.getConvertedContent()).thenReturn( "AID^BID^STRINGFIELD^TIMESTAMPFIELD^CID^UPDATETIMEFIELD\n" + "1^2^AB,C^2012-01-01 12:12:12^^(null)\n" +
when(artifact.getPhysicalSchema(env)).thenReturn(new PhysicalSchema(schema)); when(artifact.getObjectName()).thenReturn(table); when(artifact.getConvertedContent()).thenReturn( "AID^BID\n" + "1^2\n" +
"InvalidTimeFieldColumn"); when(artifact.getConvertedContent()).thenReturn( "AID^BID^STRINGFIELD^TIMESTAMPFIELD^CID^UPDATETIMEFIELD\n" + "1^2^AB,C^2012-01-01 12:12:12^^(null)\n" +
when(artifact.getConvertedContent()).thenReturn( columnHeaders + "\n" + "1^2^AB,C^2012-01-01 12:12:12^\n" + when(artifact.getConvertedContent()).thenReturn( columnHeaders + "\n" + "1^2^AB,C^2012-01-01 12:12:12^\n" +
when(artifact.getConvertedContent()).thenReturn( columnHeaders + "\n" + "1^2^AB,C^2012-01-01 12:12:12^\n" +
when(artifact.getConvertedContent()).thenReturn( columnHeaders + "\n" + "2,null\n" +
when(artifact.getPhysicalSchema(env)).thenReturn(new PhysicalSchema(schema)); when(artifact.getObjectName()).thenReturn(table); when(artifact.getConvertedContent()).thenReturn( "AID^BID\n" + "1^2\n" +