@Override public Predicate<? super ChecksumEntry> valueOf(Schema schema) { return schema.getObjectExclusionPredicateBuilder().build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); } });
@Override public Predicate<? super ChecksumEntry> valueOf(Schema schema) { return schema.getObjectExclusionPredicateBuilder().build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); } });
@Override public RichIterable<DbCleanCommand> valueOf(PhysicalSchema physicalSchema) { ImmutableList<DbCleanCommand> schemaDrops = getDropStatements(physicalSchema); MutableCollection<Schema> schemas = physicalSchemaToSchemaMap.get(physicalSchema); for (Schema schema : schemas) { schemaDrops = schemaDrops.select(schema.getObjectExclusionPredicateBuilder().build(new Function<DbCleanCommand, String>() { @Override public String valueOf(DbCleanCommand it) { return it.getObjectType().getName(); } }, DbCleanCommand.TO_OBJECT_NAME)); } return schemaDrops; } }).toList());
@Override public RichIterable<DbCleanCommand> valueOf(PhysicalSchema physicalSchema) { ImmutableList<DbCleanCommand> schemaDrops = getDropStatements(physicalSchema); MutableCollection<Schema> schemas = physicalSchemaToSchemaMap.get(physicalSchema); for (Schema schema : schemas) { schemaDrops = schemaDrops.select(schema.getObjectExclusionPredicateBuilder().build(new Function<DbCleanCommand, String>() { @Override public String valueOf(DbCleanCommand it) { return it.getObjectType().getName(); } }, DbCleanCommand.TO_OBJECT_NAME)); } return schemaDrops; } }).toList());
objectExclusionPredicateBuilder = objectExclusionPredicateBuilder.add(ObjectTypeAndNamePredicateBuilder.parse(excludeObjects, ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE)); final Predicates<? super RevEngDestination> objectExclusionPredicate = objectExclusionPredicateBuilder.build( new Function<RevEngDestination, String>() { @Override
objectExclusionPredicateBuilder = objectExclusionPredicateBuilder.add(ObjectTypeAndNamePredicateBuilder.parse(excludeObjects, ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE)); final Predicates<? super RevEngDestination> objectExclusionPredicate = objectExclusionPredicateBuilder.build( new Function<RevEngDestination, String>() { @Override
private Predicate<? super ChecksumEntry> getPlatformInclusionPredicate(DbEnvironment env) { // 1) exclude those tables that are excluded by default from source code, e.g. explain tables or others that users configure ImmutableSet<Predicate<? super ChecksumEntry>> schemaObjectNamePredicates = env.getSchemas().collect(new Function<Schema, Predicate<? super ChecksumEntry>>() { @Override public Predicate<? super ChecksumEntry> valueOf(Schema schema) { return schema.getObjectExclusionPredicateBuilder().build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); } }); // 2) exclude the audit tables MutableMultimap<String, String> tablesToExclude = Multimaps.mutable.set.empty(); tablesToExclude.putAll(ChangeType.TABLE_STR, Sets.immutable.with( env.getPlatform().convertDbObjectName().valueOf(getArtifactDeployerDao().getAuditContainerName()), env.getPlatform().convertDbObjectName().valueOf(dbChecksumManager.getChecksumContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionAttributeContainerName()) )); ObjectTypeAndNamePredicateBuilder auditTablePredicateBuilder = new ObjectTypeAndNamePredicateBuilder(tablesToExclude.toImmutable(), ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE); Predicates<? super ChecksumEntry> auditTablePredicate = auditTablePredicateBuilder.build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); return auditTablePredicate.and(schemaObjectNamePredicates); }
private Predicate<? super ChecksumEntry> getPlatformInclusionPredicate(DbEnvironment env) { // 1) exclude those tables that are excluded by default from source code, e.g. explain tables or others that users configure ImmutableSet<Predicate<? super ChecksumEntry>> schemaObjectNamePredicates = env.getSchemas().collect(new Function<Schema, Predicate<? super ChecksumEntry>>() { @Override public Predicate<? super ChecksumEntry> valueOf(Schema schema) { return schema.getObjectExclusionPredicateBuilder().build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); } }); // 2) exclude the audit tables MutableMultimap<String, String> tablesToExclude = Multimaps.mutable.set.empty(); tablesToExclude.putAll(ChangeType.TABLE_STR, Sets.immutable.with( env.getPlatform().convertDbObjectName().valueOf(getArtifactDeployerDao().getAuditContainerName()), env.getPlatform().convertDbObjectName().valueOf(dbChecksumManager.getChecksumContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionContainerName()), env.getPlatform().convertDbObjectName().valueOf(getDeployExecutionDao().getExecutionAttributeContainerName()) )); ObjectTypeAndNamePredicateBuilder auditTablePredicateBuilder = new ObjectTypeAndNamePredicateBuilder(tablesToExclude.toImmutable(), ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE); Predicates<? super ChecksumEntry> auditTablePredicate = auditTablePredicateBuilder.build(ChecksumEntry.TO_OBJECT_TYPE, ChecksumEntry.TO_NAME1); return auditTablePredicate.and(schemaObjectNamePredicates); }
@Test public void testStringParsingWithExclusionDefault() { ObjectTypeAndNamePredicateBuilder parse = ObjectTypeAndNamePredicateBuilder.parse("TABLE~tab1,tab2;VIEW~view1", ObjectTypeAndNamePredicateBuilder.FilterType.EXCLUDE); Predicates<? super Pair<String, String>> predicate = parse.build(Functions.<String>firstOfPair(), (Function<Pair<String, String>, String>) (Function) Functions.<String>secondOfPair()); assertTrue(predicate.accept(Tuples.pair("OTHER", "otherInclude"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tab1"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tab2"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tabNo"))); assertFalse(predicate.accept(Tuples.pair("VIEW", "view1"))); assertTrue(predicate.accept(Tuples.pair("VIEW", "viewInclude"))); } }
@Test public void testStringParsing() { ObjectTypeAndNamePredicateBuilder parse = ObjectTypeAndNamePredicateBuilder.parse("TABLE~tab1,tab2;-VIEW~view1", null); Predicates<? super Pair<String, String>> predicate = parse.build(Functions.<String>firstOfPair(), (Function<Pair<String, String>, String>) (Function) Functions.<String>secondOfPair()); assertTrue(predicate.accept(Tuples.pair("OTHER", "otherInclude"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tab1"))); assertTrue(predicate.accept(Tuples.pair("TABLE", "tab2"))); assertFalse(predicate.accept(Tuples.pair("TABLE", "tabNo"))); assertFalse(predicate.accept(Tuples.pair("VIEW", "view1"))); assertTrue(predicate.accept(Tuples.pair("VIEW", "viewInclude"))); }