package journal.action; import java.util.ArrayList; import java.util.List; import jargs.gnu.CmdLineParser; import journal.schema.TableVersion; public class UserRenamer extends BaseRenamerAction { private CmdLineParser.Option oldNameOption; private CmdLineParser.Option newNameOption; public UserRenamer() { super("UserRenamer"); } @Override public void start() throws Exception { super.start(); } @Override public void help() { System.err.println("\t--action journal.action.UserRenamer -- <options>"); System.err.println("\t\tOptions are\n"); System.err.println("\t\t-o --oldName[=]<old-name> -n --newName[=]<new-name>"); super.help(); } @Override public void finish() throws Exception { super.finish(); } @Override void addArgs(CmdLineParser parser) { oldNameOption = parser.addStringOption('o', "oldName"); newNameOption = parser.addStringOption('n', "newName"); } @Override void processArgs(CmdLineParser parser) { String oldName = (String) parser.getOptionValue(oldNameOption, ""); String newName = (String) parser.getOptionValue(newNameOption, ""); // verify that the correct options match up if( fileName.equals("") ) { if( oldName.equals("") || newName.equals("")) { throw new IllegalArgumentException("Need to specify either filename or old and new name"); } putRenamePair(oldName, newName); } } RenameAction getAction(TableVersion version) { if( !actionMap.containsKey(version)) { RenameAction action = EmptyAction.instance; List<RenameAction> list = new ArrayList<RenameAction>(); if( version.getAttributeByName("user") != null ) { list.add( new SimpleRenameAction("user") ); } if( version.getAttributeByName("owner") != null ) { list.add( new SimpleRenameAction("owner") ); } if( list.size() == 1 ) { action = list.get(0); } else if ( list.size() > 1 ) { action = new CompoundActions(list); } actionMap.put(version, action); } return actionMap.get(version); } }
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#3 | 8023 | Sven Erik Knop |
Complete rewrite of the configuration file, now based on an ini-file format. The ini file has a general [reader] section for settings like verbose, outputFile, case-sensitivity and so on. It also allows to set up a range of Actions and Filters. The section name here is the fully classified class name, followed by settings for the particular actions. An example will make this clearer: ================================================================ [reader] verbose=true [journal.action.UserRenamer] fileName=user.txt patch=True outputFile=user.out [journal.action.ClientRenamer] fileName=client.txt outputFile=client.out patch=true ================================================================ I will provide more example set-ups in the near future. Filters are classes implementing journal.action.Filter (soon to be journal.filter.Filter) which can be chained together and are all executed before the actions. Actions are applied in order that they are given in the config file. |
||
#2 | 8017 | Sven Erik Knop | Fixed patching by adding copy constructor. | ||
#1 | 8016 | Sven Erik Knop | In the middle of refactoring the Renamer classes into the BaseRenamer. |