if ("scaffold".equals(typeName)) {
//generate application controller
String cagPath = templateRoot + File.separator +
"controller" + File.separator +
"ApplicationController.tmpl";
Generator cag = new ControllerApplicationGenerator(cagPath, allProps);
cag.generate(false);
//generate controller
String csgPath = templateRoot + File.separator +
"controller" + File.separator +
"ControllerScaffold.tmpl";
Generator csg = new ControllerScaffoldGenerator(csgPath, allProps, connName, controller, model, table);
csg.generate();
String cstgPath = templateRoot + File.separator +
"controller" + File.separator +
"ControllerScaffoldTest.tmpl";
Generator cstg = new ControllerScaffoldTestGenerator(cstgPath, allProps, connName, controller, model, table);
cstg.generate();
//generate model
if (!enhance) {
String mgPath = templateRoot + File.separator +
"model" + File.separator +
"ModelHelper.tmpl";
Generator mcg = new ModelHelperGenerator(mgPath, allProps, connName, model, table, enhance);
mcg.generate();
}
String mgPath = templateRoot + File.separator +
"model" + File.separator +
"Model.tmpl";
Generator mg = new ModelGenerator(mgPath, allProps, connName, model, table, enhance);
mg.generate();
String mtgPath = templateRoot + File.separator +
"model" + File.separator +
"ModelTest.tmpl";
Generator mtg = new ModelTestGenerator(mtgPath, allProps, connName, model, table, enhance);
mtg.generate();
//generate views
String vigPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold" + File.separator +
"index.tmpl";
Generator vig = new ViewIndexGenerator(vigPath, allProps, connName, controller, model, table);
vig.generate();
String vsgPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold" + File.separator +
"show.tmpl";
Generator vsg = new ViewShowGenerator(vsgPath, allProps, connName, controller, model, table);
vsg.generate();
String vagPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold" + File.separator +
"add.tmpl";
Generator vag = new ViewAddGenerator(vagPath, allProps, connName, controller, model, table);
vag.generate();
String vegPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold" + File.separator +
"edit.tmpl";
Generator veg = new ViewEditGenerator(vegPath, allProps, connName, controller, model, table);
veg.generate();
String vpgPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold" + File.separator +
"paged_list.tmpl";
Generator vpg = new ViewPagedGenerator(vpgPath, allProps, connName, controller, model, table);
vpg.generate();
//update resources
Generator rg = new ResourceGenerator(allProps, controller);
rg.generate();
} else if ("scaffold-ajax".equals(typeName)) {
//generate application controller
String cagPath = templateRoot + File.separator +
"controller" + File.separator +
"ApplicationController.tmpl";
Generator cag = new ControllerApplicationGenerator(cagPath, allProps);
cag.generate(false);
//generate controller
String csgPath = templateRoot + File.separator +
"controller" + File.separator +
"ControllerScaffoldAjax.tmpl";
Generator csg = new ControllerScaffoldGenerator(csgPath, allProps, connName, controller, model, table);
csg.generate();
String cstgPath = templateRoot + File.separator +
"controller" + File.separator +
"ControllerScaffoldTest.tmpl";
Generator cstg = new ControllerScaffoldTestGenerator(cstgPath, allProps, connName, controller, model, table);
cstg.generate();
//generate model
if (!enhance) {
String mgPath = templateRoot + File.separator +
"model" + File.separator +
"ModelHelper.tmpl";
Generator mcg = new ModelHelperGenerator(mgPath, allProps, connName, model, table, enhance);
mcg.generate();
}
String mgPath = templateRoot + File.separator +
"model" + File.separator +
"Model.tmpl";
Generator mg = new ModelGenerator(mgPath, allProps, connName, model, table, enhance);
mg.generate();
String mtgPath = templateRoot + File.separator +
"model" + File.separator +
"ModelTest.tmpl";
Generator mtg = new ModelTestGenerator(mtgPath, allProps, connName, model, table, enhance);
mtg.generate();
//generate views
String vigPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold-ajax" + File.separator +
"index.tmpl";
Generator vig = new ViewIndexGenerator(vigPath, allProps, connName, controller, model, table);
vig.generate();
String vsgPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold-ajax" + File.separator +
"show.tmpl";
Generator vsg = new ViewShowGenerator(vsgPath, allProps, connName, controller, model, table);
vsg.generate();
String vagPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold-ajax" + File.separator +
"add.tmpl";
Generator vag = new ViewAddGenerator(vagPath, allProps, connName, controller, model, table);
vag.generate();
String vegPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold-ajax" + File.separator +
"edit.tmpl";
Generator veg = new ViewEditGenerator(vegPath, allProps, connName, controller, model, table);
veg.generate();
String vpgPath = templateRoot + File.separator +
"view" + File.separator +
"scaffold-ajax" + File.separator +
"paged_list.tmpl";
Generator vpg = new ViewPagedGenerator(vpgPath, allProps, connName, controller, model, table);
vpg.generate();
//update resources
Generator rg = new ResourceGenerator(allProps, controller);
rg.generate();
}
else if ("controller".equals(typeName)) {
//generate application controller
String cagPath = templateRoot + File.separator +
"controller" + File.separator +
"ApplicationController.tmpl";
Generator cag = new ControllerApplicationGenerator(cagPath, allProps);
cag.generate(false);
controller = getControllerName(useImplicitAppName, args, false);
String[] actions = null;
if (useImplicitAppName) {
if (args.length == 2) {
actions = new String[1];
actions[0] = "index";
}
else {
actions = new String[args.length-2];
System.arraycopy(args, 2, actions, 0, actions.length);
}
}
else {
if (args.length == 3) {
actions = new String[1];
actions[0] = "index";
}
else {
actions = new String[args.length-3];
System.arraycopy(args, 3, actions, 0, actions.length);
}
}
String cgPath = templateRoot + File.separator +
"controller" + File.separator +
"ActionController.tmpl";
Generator cg = new ControllerGenerator(cgPath, allProps, controller, actions);
cg.generate();
String ctgPath = templateRoot + File.separator +
"controller" + File.separator +
"ActionControllerTest.tmpl";
Generator ctg = new ControllerTestGenerator(ctgPath, allProps, controller, actions);
ctg.generate();
//generate view
String vigPath = templateRoot + File.separator +
"view" + File.separator +
"action.tmpl";
int views = actions.length;
Generator vig = null;
for (int i = 0; i < views; i++) {
vig = new ViewActionGenerator(vigPath, allProps, controller, actions[i]);
vig.generate();
}
}
else if ("model".equals(typeName)) {
if (!enhance) {
String mgPath = templateRoot + File.separator +
"model" + File.separator +
"ModelHelper.tmpl";
Generator mcg = new ModelHelperGenerator(mgPath, allProps, connName, model, table, enhance);
mcg.generate();
}
String mgPath = templateRoot + File.separator +
"model" + File.separator +
"Model.tmpl";
Generator mg = new ModelGenerator(mgPath, allProps, connName, model, table, enhance);
mg.generate();
String mtgPath = templateRoot + File.separator +
"model" + File.separator +
"ModelTest.tmpl";
Generator mtg = new ModelTestGenerator(mtgPath, allProps, connName, model, table, enhance);
mtg.generate();
}
else {
throw new Exception("Type name \"" + typeName + "\" is not supported.");
}
}