提交 a623ab36 编写于 作者: 黄勇

Smart4J

上级 92c8c60f
......@@ -9,8 +9,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<groupId>smart</groupId>
<artifactId>smart-generator</artifactId>
<groupId>org.smart4j</groupId>
<artifactId>smart4j-generator</artifactId>
<version>1.0</version>
<dependencies>
......@@ -39,10 +39,10 @@
</exclusion>
</exclusions>
</dependency>
<!-- Smart -->
<!-- Smart4J -->
<dependency>
<groupId>smart</groupId>
<artifactId>smart-framework</artifactId>
<groupId>org.smart4j</groupId>
<artifactId>smart4j-framework</artifactId>
<version>2.2-SNAPSHOT</version>
</dependency>
</dependencies>
......
package smart.generator;
package org.smart4j.generator;
import java.io.FileWriter;
import java.util.Map;
......@@ -9,9 +9,9 @@ import org.apache.velocity.runtime.RuntimeConstants;
import org.apache.velocity.runtime.log.NullLogChute;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import smart.framework.FrameworkConstant;
import smart.framework.util.FileUtil;
import smart.framework.util.StringUtil;
import org.smart4j.framework.core.FrameworkConstant;
import org.smart4j.framework.util.FileUtil;
import org.smart4j.framework.util.StringUtil;
public class CodeGenerator {
......
package smart.generator;
package org.smart4j.generator;
import smart.framework.util.ArrayUtil;
import smart.framework.util.ObjectUtil;
import smart.generator.command.Command;
import org.smart4j.framework.util.ArrayUtil;
import org.smart4j.framework.util.ObjectUtil;
import org.smart4j.generator.command.Command;
public class Invoker {
......
package smart.generator.bean;
package org.smart4j.generator.bean;
public class Column {
......
package smart.generator.bean;
package org.smart4j.generator.bean;
public class Field {
......
package smart.generator.bean;
package org.smart4j.generator.bean;
public class Table {
......
package smart.generator.builder;
package org.smart4j.generator.builder;
import java.util.List;
import java.util.Map;
import smart.generator.bean.Column;
import smart.generator.bean.Table;
import org.smart4j.generator.bean.Column;
import org.smart4j.generator.bean.Table;
public abstract class Builder {
......
package smart.generator.builder.impl;
package org.smart4j.generator.builder.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import smart.framework.util.StringUtil;
import smart.generator.CodeGenerator;
import smart.generator.bean.Column;
import smart.generator.bean.Field;
import smart.generator.bean.Table;
import smart.generator.builder.Builder;
import org.smart4j.framework.util.StringUtil;
import org.smart4j.generator.CodeGenerator;
import org.smart4j.generator.bean.Column;
import org.smart4j.generator.bean.Field;
import org.smart4j.generator.bean.Table;
import org.smart4j.generator.builder.Builder;
public class EntityBuilder extends Builder {
......
package smart.generator.builder.impl;
package org.smart4j.generator.builder.impl;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import smart.generator.CodeGenerator;
import smart.generator.bean.Column;
import smart.generator.bean.Table;
import smart.generator.builder.Builder;
import org.smart4j.generator.CodeGenerator;
import org.smart4j.generator.bean.Column;
import org.smart4j.generator.bean.Table;
import org.smart4j.generator.builder.Builder;
public class SQLBuilder extends Builder {
......
package smart.generator.command;
package org.smart4j.generator.command;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
......@@ -6,7 +6,7 @@ import java.io.IOException;
import java.util.Properties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import smart.framework.util.ArrayUtil;
import org.smart4j.framework.util.ArrayUtil;
public abstract class Command {
......
package smart.generator.command.impl;
package org.smart4j.generator.command.impl;
import java.util.HashMap;
import java.util.Map;
import smart.framework.util.StringUtil;
import smart.generator.CodeGenerator;
import smart.generator.command.Command;
import org.smart4j.framework.util.StringUtil;
import org.smart4j.generator.CodeGenerator;
import org.smart4j.generator.command.Command;
public class CreateActionCommand extends Command {
......
package smart.generator.command.impl;
package org.smart4j.generator.command.impl;
import java.util.HashMap;
import java.util.Map;
import smart.framework.util.FileUtil;
import smart.framework.util.StringUtil;
import smart.generator.CodeGenerator;
import smart.generator.command.Command;
import org.smart4j.framework.util.FileUtil;
import org.smart4j.framework.util.StringUtil;
import org.smart4j.generator.CodeGenerator;
import org.smart4j.generator.command.Command;
public class CreateAppCommand extends Command {
......
package smart.generator.command.impl;
package org.smart4j.generator.command.impl;
import java.util.HashMap;
import java.util.Map;
import smart.framework.util.StringUtil;
import smart.generator.CodeGenerator;
import smart.generator.command.Command;
import org.smart4j.framework.util.StringUtil;
import org.smart4j.generator.CodeGenerator;
import org.smart4j.generator.command.Command;
public class CreateCRUDCommand extends Command {
......
package smart.generator.command.impl;
package org.smart4j.generator.command.impl;
import java.util.HashMap;
import java.util.Map;
import smart.framework.util.StringUtil;
import smart.generator.CodeGenerator;
import smart.generator.command.Command;
import org.smart4j.framework.util.StringUtil;
import org.smart4j.generator.CodeGenerator;
import org.smart4j.generator.command.Command;
public class CreateEntityCommand extends Command {
......
package smart.generator.command.impl;
package org.smart4j.generator.command.impl;
import java.util.HashMap;
import java.util.Map;
import smart.framework.util.StringUtil;
import smart.generator.CodeGenerator;
import smart.generator.command.Command;
import org.smart4j.framework.util.StringUtil;
import org.smart4j.generator.CodeGenerator;
import org.smart4j.generator.command.Command;
public class CreatePageCommand extends Command {
......
package smart.generator.command.impl;
package org.smart4j.generator.command.impl;
import java.util.HashMap;
import java.util.Map;
import smart.framework.util.StringUtil;
import smart.generator.CodeGenerator;
import smart.generator.command.Command;
import org.smart4j.framework.util.StringUtil;
import org.smart4j.generator.CodeGenerator;
import org.smart4j.generator.command.Command;
public class CreateServiceCommand extends Command {
......
package smart.generator.command.impl;
package org.smart4j.generator.command.impl;
import java.io.File;
import java.io.IOException;
......@@ -11,13 +11,13 @@ import jxl.Workbook;
import jxl.read.biff.BiffException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import smart.framework.util.StringUtil;
import smart.generator.bean.Column;
import smart.generator.bean.Table;
import smart.generator.builder.Builder;
import smart.generator.builder.impl.EntityBuilder;
import smart.generator.builder.impl.SQLBuilder;
import smart.generator.command.Command;
import org.smart4j.framework.util.StringUtil;
import org.smart4j.generator.bean.Column;
import org.smart4j.generator.bean.Table;
import org.smart4j.generator.builder.Builder;
import org.smart4j.generator.builder.impl.EntityBuilder;
import org.smart4j.generator.builder.impl.SQLBuilder;
import org.smart4j.generator.command.Command;
public class LoadDictCommand extends Command {
......
......@@ -11,4 +11,4 @@ log4j.appender.file.encoding=UTF-8
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{HH:mm:ss,SSS} %p %c (%L) - %m%n
log4j.logger.smart.generator=ERROR
\ No newline at end of file
log4j.logger.org.smart4j.generator=ERROR
\ No newline at end of file
package smart.generator.test;
package org.smart4j.generator.test;
import org.junit.Test;
import org.junit.runner.RunWith;
import smart.framework.OrderedRunner;
import smart.framework.annotation.Order;
import smart.generator.Invoker;
import smart.generator.command.impl.CreateActionCommand;
import smart.generator.command.impl.CreateAppCommand;
import smart.generator.command.impl.CreateCRUDCommand;
import smart.generator.command.impl.CreateEntityCommand;
import smart.generator.command.impl.CreatePageCommand;
import smart.generator.command.impl.CreateServiceCommand;
import smart.generator.command.impl.LoadDictCommand;
import org.smart4j.framework.test.OrderedRunner;
import org.smart4j.framework.test.annotation.TestOrder;
import org.smart4j.generator.Invoker;
import org.smart4j.generator.command.impl.CreateActionCommand;
import org.smart4j.generator.command.impl.CreateAppCommand;
import org.smart4j.generator.command.impl.CreateCRUDCommand;
import org.smart4j.generator.command.impl.CreateEntityCommand;
import org.smart4j.generator.command.impl.CreatePageCommand;
import org.smart4j.generator.command.impl.CreateServiceCommand;
import org.smart4j.generator.command.impl.LoadDictCommand;
@RunWith(OrderedRunner.class)
public class CommandTest {
@Test
@Order(1)
@TestOrder(1)
public void createAppCommandTest() {
Invoker invoker = new Invoker();
invoker.setCommand(new CreateAppCommand()); // smart create-app
String[] params = {
"C:\\Smart", // Current Path
"demo", // App Name
"smart", // App Group
"smart.demo" // App Package = <App Group> + <App Artifact>
"C:\\Smart4J", // Current Path
"demo", // App Name
"smart", // App Group
"smart.demo" // App Package = <App Group> + <App Artifact>
};
boolean result = invoker.execCommand(params);
if (!result) {
......@@ -35,7 +35,7 @@ public class CommandTest {
}
@Test
@Order(2)
@TestOrder(2)
public void createEntityCommandTest() {
Invoker invoker = new Invoker();
invoker.setCommand(new CreateEntityCommand()); // smart create-entity <entity-name>
......@@ -43,8 +43,8 @@ public class CommandTest {
String[] entityNameArray = {"product", "product-type"};
for (String entityName : entityNameArray) {
String[] params = {
"C:\\Smart\\demo", // Current Path
entityName, // Entity Name
"C:\\Smart4J\\demo", // Current Path
entityName, // Entity Name
};
boolean result = invoker.execCommand(params);
if (!result) {
......@@ -54,7 +54,7 @@ public class CommandTest {
}
@Test
@Order(3)
@TestOrder(3)
public void createServiceCommandTest() {
Invoker invoker = new Invoker();
invoker.setCommand(new CreateServiceCommand()); // smart create-service <service-name>
......@@ -62,8 +62,8 @@ public class CommandTest {
String[] serviceNameArray = {"product", "product-type"};
for (String serviceName : serviceNameArray) {
String[] params = {
"C:\\Smart\\demo", // Current Path
serviceName, // Service Name
"C:\\Smart4J\\demo", // Current Path
serviceName, // Service Name
};
boolean result = invoker.execCommand(params);
if (!result) {
......@@ -73,7 +73,7 @@ public class CommandTest {
}
@Test
@Order(4)
@TestOrder(4)
public void createActionCommandTest() {
Invoker invoker = new Invoker();
invoker.setCommand(new CreateActionCommand()); // smart create-action <action-name>
......@@ -81,8 +81,8 @@ public class CommandTest {
String[] actionNameArray = {"product", "product-type"};
for (String actionName : actionNameArray) {
String[] params = {
"C:\\Smart\\demo", // Current Path
actionName, // Action Name
"C:\\Smart4J\\demo", // Current Path
actionName, // Action Name
};
boolean result = invoker.execCommand(params);
if (!result) {
......@@ -92,7 +92,7 @@ public class CommandTest {
}
@Test
@Order(5)
@TestOrder(5)
public void createPageCommandTest() {
Invoker invoker = new Invoker();
invoker.setCommand(new CreatePageCommand()); // smart create-page <page-name>
......@@ -100,8 +100,8 @@ public class CommandTest {
String[] pageNameArray = {"product", "product-type"};
for (String pageName : pageNameArray) {
String[] params = {
"C:\\Smart\\demo", // Current Path
pageName, // Page Name
"C:\\Smart4J\\demo", // Current Path
pageName, // Page Name
};
boolean result = invoker.execCommand(params);
if (!result) {
......@@ -111,7 +111,7 @@ public class CommandTest {
}
@Test
@Order(6)
@TestOrder(6)
public void createCRUDCommandTest() {
Invoker invoker = new Invoker();
invoker.setCommand(new CreateCRUDCommand()); // smart create-crud <crud-name>
......@@ -119,8 +119,8 @@ public class CommandTest {
String[] crudNameArray = {"customer", "customer-type"};
for (String crudName : crudNameArray) {
String[] params = {
"C:\\Smart\\demo", // Current Path
crudName, // CRUD Name
"C:\\Smart4J\\demo", // Current Path
crudName, // CRUD Name
};
boolean result = invoker.execCommand(params);
if (!result) {
......@@ -130,14 +130,14 @@ public class CommandTest {
}
@Test
@Order(7)
@TestOrder(7)
public void loadDictCommandTest() {
Invoker invoker = new Invoker();
invoker.setCommand(new LoadDictCommand()); // smart load-dict <dict-path>
String[] params = {
"C:\\Smart\\demo", // Current Path
"C:\\Smart\\demo\\db.xls", // Dict Path
"C:\\Smart4J\\demo", // Current Path
"C:\\Smart4J\\demo\\db.xls", // Dict Path
};
boolean result = invoker.execCommand(params);
if (!result) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册