/** * DOC scorreia Comment method "main". * * @param args */ public static void main(String[] args) { TypedProperties connectionParams = PropertiesLoader.getProperties(IndicatorEvaluator.class, "db.properties"); String driverClassName = connectionParams.getProperty("driver"); String dbUrl = connectionParams.getProperty("url"); try { // create connection java.sql.Connection connection = ConnectionUtils.createConnection(dbUrl, driverClassName, connectionParams); Connection dataProvider = new AnalysisCreationTest().getDataManager(); // --- test connection evaluator String catalog = "test"; ConnectionEvaluator evaluator = new ConnectionEvaluator(); evaluator.setConnection(connection); // --- create indicators ConnectionIndicator connectionIndicator = SchemaFactory.eINSTANCE.createConnectionIndicator(); evaluator.storeIndicator(dataProvider, connectionIndicator); // SchemaIndicator schemaIndic = SchemaFactory.eINSTANCE.createSchemaIndicator(); // evaluator.storeIndicator(new CatalogSchema(catalog, null), schemaIndic); String sql = createSql(catalog); ReturnCode rc = evaluator.evaluateIndicators(sql, false); if (!rc.isOk()) { System.err.println("Failed to evaluate indicator: " + rc.getMessage()); } // store in file File file = new File("out/myi." + IndicatorsPackage.eNAME); EMFUtil util = new EMFUtil(); util.setUsePlatformRelativePath(false); if (!util.addPoolToResourceSet(file.toURI().toString(), connectionIndicator)) { System.err.println(util.getLastErrorMessage()); } File dp = new File("out/dp.prv"); // util.addPoolToResourceSet(new File("out/dp.prv"), dataProvider); util.addPoolToResourceSet(dp, dataProvider); List<Catalog> tdCatalogs = ConnectionHelper.getCatalogs(dataProvider); for (Catalog tdCatalog : tdCatalogs) { util.addPoolToResourceSet( new File("out/" + tdCatalog.getName() + "." + FactoriesUtil.CAT), tdCatalog); } util.save(); ConnectionUtils.closeConnection(connection); } catch (SQLException e) { // TODO Auto-generated catch block log.error(e, e); } catch (InstantiationException e) { // TODO Auto-generated catch block log.error(e, e); } catch (IllegalAccessException e) { // TODO Auto-generated catch block log.error(e, e); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block log.error(e, e); } }
private static String getProperties(String key, String defaultString) { return PropertiesLoader.getProperties(THAT, "characters.properties") .getProperty(key, defaultString); // $NON-NLS-1$ }
private Map<String, String> initParameterMap() { Map<String, String> returnMap = new HashMap<String, String>(); TypedProperties connectionParams = PropertiesLoader.getProperties( MetadataFillFactoryTest.class, "connectionParameter.properties"); returnMap.put( "SqlTypeName", connectionParams.get("SqlTypeName") == null ? null : connectionParams.get("SqlTypeName").toString()); returnMap.put( "driverClassName", connectionParams.get("driver") == null ? null : connectionParams.get("driver").toString()); returnMap.put( "jdbcUrl", connectionParams.get("url") == null ? null : connectionParams.get("url").toString()); returnMap.put( "user", connectionParams.get("user") == null ? null : connectionParams.get("user").toString()); returnMap.put( "password", connectionParams.get("password") == null ? null : connectionParams.get("password").toString()); returnMap.put( "aDDParameter", connectionParams.get("aDDParameter") == null ? null : connectionParams.get("aDDParameter").toString()); returnMap.put( "author", connectionParams.get("author") == null ? null : connectionParams.get("author").toString()); returnMap.put( "host", connectionParams.get("host") == null ? null : connectionParams.get("host").toString()); returnMap.put( "name", connectionParams.get("name") == null ? null : connectionParams.get("name").toString()); returnMap.put( "status", connectionParams.get("status") == null ? null : connectionParams.get("status").toString()); returnMap.put( "port", connectionParams.get("port") == null ? null : connectionParams.get("port").toString()); returnMap.put( "version", connectionParams.get("version") == null || connectionParams.get("version").toString().isEmpty() ? null : connectionParams.get("version").toString()); returnMap.put( "retrieveAllMetadata", connectionParams.get("retrieveAllMetadata") == null ? null : connectionParams.get("retrieveAllMetadata").toString()); returnMap.put( "purpose", connectionParams.get("purpose") == null ? null : connectionParams.get("purpose").toString()); return returnMap; }