package journal.action; import java.util.ArrayList; import java.util.List; import jargs.gnu.CmdLineParser; import journal.schema.TableVersion; public class ClientRenamer extends BaseRenamerAction { private CmdLineParser.Option oldNameOption; private CmdLineParser.Option newNameOption; public ClientRenamer() { super("ClientRenamer"); } @Override public void start() throws Exception { super.start(); } @Override public void help() { System.err.println("\t--action journal.action.ClientRenamer -- <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("client") != null ) { list.add( new SimpleRenameAction("client") ); } if( version.getAttributeByName("cfile") != null) { list.add( new ClientRenameAction("cfile")); } if( version.getTable().getName().equals("db.view")) { list.add( new SimpleRenameAction("name")); list.add( new ClientRenameAction("vfile")); } if( version.getTable().getName().equals("db.domain")) { list.add( new SimpleRenameAction("name")); } 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 | |
---|---|---|---|---|---|
#4 | 8027 | Sven Erik Knop |
Moved exceptions to their own package. Enabled new Action FilepathRenamer (not fully tested yet). |
||
#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. | ||
//guest/sven_erik_knop/java/JournalReader/src/journal/action/ClientUserRenamer.java | |||||
#4 | 8015 | Sven Erik Knop | Now with counter reestablished. | ||
#3 | 8014 | Sven Erik Knop |
Extracted a base class. Not quite finished since I need a counter class as well. |
||
#2 | 8013 | Sven Erik Knop |
Rewrite of ClientUserRenamer. Now based on a saner model using a set of Actions instead of lots of state variables. Note that the counter currently does not work and simply returns 0 changes. |
||
#1 | 8012 | Sven Erik Knop | Rename Renamer to ClientUserRenamer for clarification. | ||
//guest/sven_erik_knop/java/JournalReader/src/journal/action/Renamer.java | |||||
#3 | 7823 | Sven Erik Knop |
Updated the Renamer tool to solve the problem that owners of specs such as labels and client workspaces wouldn't get updated. Jar file with updated version submitted as well. |
||
#2 | 7626 | Sven Erik Knop |
Removed obsolete imports. Added jar file manifest to build.xml |
||
#1 | 7527 | Sven Erik Knop |
JournalReader, now in its proper place. Documentation to follow. |