Java Code Examples for org.eclipse.collections.api.list.MutableList#notEmpty()

The following examples show how to use org.eclipse.collections.api.list.MutableList#notEmpty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Db2PostDeployAction.java    From obevo with Apache License 2.0 6 votes vote down vote up
private void recompileInvalidObjects(RichIterable<PhysicalSchema> physicalSchemas) {
    MutableList<String> warnings = Lists.mutable.empty();
    for (final PhysicalSchema physicalSchema : physicalSchemas) {
        try {
            this.stmtExecutor.executeWithinContext(physicalSchema, new Procedure<Connection>() {
                @Override
                public void value(Connection conn) {
                    stmtExecutor.getJdbcTemplate().update(conn, "CALL SYSPROC.ADMIN_REVALIDATE_DB_OBJECTS(NULL, '" + physicalSchema.getPhysicalName() + "', NULL)");
                }
            });
            LOG.info("Successfully recompiled objects in schema", physicalSchema);
        } catch (DataAccessException e) {
            warnings.add(physicalSchema.getPhysicalName() + ": " + e.getMessage());
            LOG.warn("Failed to recompile objects on schema {}; will not fail the overall deployment due to this", physicalSchema, e);
        }
    }

    if (warnings.notEmpty()) {
        deployMetricsCollector.addMetric(POST_DEPLOY_WARNINGS, "Failures on recompiling invalid objects: " + warnings.makeString("\n"));
    }
}
 
Example 2
Source File: DbMergeInfo.java    From obevo with Apache License 2.0 5 votes vote down vote up
public static RichIterable<DbMergeInfo> parseFromProperties(Configuration config) {
    MutableSet<String> dbs = CollectionAdapter.wrapSet(config.getList(String.class, "instances", Lists.mutable.<String>empty()));

    MutableList<String> exceptions = Lists.mutable.empty();
    MutableList<DbMergeInfo> dbMergeInfos = Lists.mutable.empty();
    for (String db : dbs) {
        Configuration subset = config.subset(db);
        if (subset.containsKey("inputDir")) {
            File inputDir = new File(subset.getString("inputDir"));
            if (!inputDir.canRead()) {
                if (inputDir.getPath().contains("\r")) {
                    exceptions.add("Could not find " + db + "." + "inputDir file (use forward-slash instead of back-slash in path): " + inputDir.getPath().replaceAll("\r", ""));
                } else {
                    exceptions.add("Could not find " + db + "." + "inputDir file: " + inputDir);
                }
            }
            DbMergeInfo mergeInfo = new DbMergeInfo(db, inputDir);
            if (subset.containsKey("driverClassName")) {
                mergeInfo.setDriverClassName(subset.getString("driverClassName"));
                mergeInfo.setUrl(subset.getString("url"));
                mergeInfo.setUsername(subset.getString("username"));
                mergeInfo.setPassword(subset.getString("password"));
                mergeInfo.setPhysicalSchema(subset.getString("physicalSchema"));
            }

            dbMergeInfos.add(mergeInfo);
        }
    }

    if (exceptions.notEmpty()) {
        throw new IllegalArgumentException("Invalid properties found in configuration:\n" + exceptions.collect(new Function<String, String>() {
            @Override
            public String valueOf(String it) {
                return "* " + it;
            }
        }).makeString("\n"));
    }
    return dbMergeInfos;
}