Commits

tbrugz committed bd1daa9

sqlrun: added property 'sqlrun.filterbyids'

Comments (0)

Files changed (2)

sqlrun.template.properties

 # TODO: 'sqlrun.commit.inverval' - for 'statement' commit strategy (default is 100?)
 # TODO: sqlrun.commit.inverval=1000
 
+# only executes specified ids
+#sqlrun.filterbyids=05, 10
+
 #
 # execs are processed in alphanumeric-ordered way
 #

src_run/tbrugz/sqldump/sqlrun/SQLRun.java

 	//properties
 	static final String PROP_COMMIT_STATEGY = "sqlrun.commit.strategy";
 	static final String PROP_LOGINVALIDSTATEMENTS = SQLRUN_PROPS_PREFIX+SUFFIX_LOGINVALIDSTATEMENTS;
+	static final String PROP_FILTERBYIDS = "sqlrun.filterbyids";
 
 	//suffix groups
 	static final String[] PROC_SUFFIXES = { SUFFIX_FILE, SUFFIX_FILES, SUFFIX_STATEMENT, SUFFIX_IMPORT, SUFFIX_QUERY };
 	final Properties papp = new ParametrizedProperties();
 	Connection conn;
 	CommitStrategy commitStrategy = CommitStrategy.FILE;
+	List<String> filterByIds = null;
 	
 	void end() throws SQLException {
 		if(conn!=null) {
 		long initTime = System.currentTimeMillis();
 
 		Set<String> procIds = new TreeSet<String>();
+		if(filterByIds!=null) {
+			log.info("filter by ids: "+filterByIds);
+		}
 		for(String key: execkeys) {
 			String procId = getExecId(key, PREFIX_EXEC);
-			procIds.add(procId);
+			if(filterByIds==null || filterByIds.contains(procId)) {
+				procIds.add(procId);
+			}
 		}
 		//Collections.sort(procIds);
-		log.info("processing ids in exec order: "+Utils.join(procIds, ", "));
+		if(procIds.size()==0) {
+			log.warn("no processing ids selected for execution...");
+		}
+		else {
+			log.info("processing ids in exec order: "+Utils.join(procIds, ", ")+" ["+procIds.size()+" ids selected]");
+		}
 		
 		StmtProc srproc = new StmtProc();
 		srproc.setConnection(conn);
 			boolean isExecId = false;
 			String procId = getExecId(key, PREFIX_EXEC);
 			String action = key.substring((PREFIX_EXEC+procId).length());
+			if(filterByIds!=null && !filterByIds.contains(procId)) { continue; }
+			
 			if(endsWithAny(key, PROC_SUFFIXES)) {
 				log.info(">>> processing: id = '"+procId+"' ; action = '"+action+"'");
 				isExecId = true;
 		allAuxSuffixes.addAll(new CSVImporter().getAuxSuffixes());
 		allAuxSuffixes.addAll(new RegexImporter().getAuxSuffixes());
 		allAuxSuffixes.addAll(new QueryDumper().getAuxSuffixes());
+		filterByIds = Utils.getStringListFromProp(papp, PROP_FILTERBYIDS, ",");
 		
 		commitStrategy = getCommitStrategy( papp.getProperty(PROP_COMMIT_STATEGY), commitStrategy );
 		conn = SQLUtils.ConnectionUtil.initDBConnection(CONN_PROPS_PREFIX, papp, commitStrategy==CommitStrategy.AUTO_COMMIT);