diff --git a/egovframework.dev.imp.codegen.template.templates/eGovFrameTemplates/crud/java/pkg/service/Sample2DefaultVO.vm b/egovframework.dev.imp.codegen.template.templates/eGovFrameTemplates/crud/java/pkg/service/Sample2DefaultVO.vm index 5d20754d1..72f10be88 100644 --- a/egovframework.dev.imp.codegen.template.templates/eGovFrameTemplates/crud/java/pkg/service/Sample2DefaultVO.vm +++ b/egovframework.dev.imp.codegen.template.templates/eGovFrameTemplates/crud/java/pkg/service/Sample2DefaultVO.vm @@ -6,52 +6,55 @@ package $voPackage; import java.io.Serializable; -import org.apache.commons.lang3.builder.ToStringBuilder; /** - * @Class Name : ${defaultVoClassName}.java - * @Description : ${model.entity.pcName} Default VO class - * @Modification Information - * + * ${model.entity.pcName} Default VO class + * * @author ${author} * @since ${createDate} * @version 1.0 * @see - * - * Copyright (C) All right reserved. + * + *
+ *  == 개정이력(Modification Information) ==
+ *
+ *   수정일      수정자           수정내용
+ *  -------    --------    ---------------------------
+ *   ${createDate}  ${author}          최초 생성
+ *
+ *      
*/ public class ${defaultVoClassName} implements Serializable { private static final long serialVersionUID = 1L; - + /** 검색조건 */ - private String searchCondition = ""; - - /** 검색Keyword */ - private String searchKeyword = ""; - - /** 검색사용여부 */ - private String searchUseYn = ""; - - /** 현재페이지 */ - private int pageIndex = 1; - - /** 페이지갯수 */ - private int pageUnit = 10; - - /** 페이지사이즈 */ - private int pageSize = 10; - - /** firstIndex */ - private int firstIndex = 1; - - /** lastIndex */ - private int lastIndex = 1; - - /** recordCountPerPage */ - private int recordCountPerPage = 10; - - + private String searchCondition = ""; + + /** 검색Keyword */ + private String searchKeyword = ""; + + /** 검색사용여부 */ + private String searchUseYn = ""; + + /** 현재페이지 */ + private int pageIndex = 1; + + /** 페이지갯수 */ + private int pageUnit = 10; + + /** 페이지사이즈 */ + private int pageSize = 10; + + /** firstIndex */ + private int firstIndex = 1; + + /** lastIndex */ + private int lastIndex = 1; + + /** recordCountPerPage */ + private int recordCountPerPage = 10; + public int getFirstIndex() { return firstIndex; } @@ -77,55 +80,51 @@ public class ${defaultVoClassName} implements Serializable { } public String getSearchCondition() { - return searchCondition; - } - - public void setSearchCondition(String searchCondition) { - this.searchCondition = searchCondition; - } + return searchCondition; + } - public String getSearchKeyword() { - return searchKeyword; - } + public void setSearchCondition(String searchCondition) { + this.searchCondition = searchCondition; + } - public void setSearchKeyword(String searchKeyword) { - this.searchKeyword = searchKeyword; - } + public String getSearchKeyword() { + return searchKeyword; + } - public String getSearchUseYn() { - return searchUseYn; - } + public void setSearchKeyword(String searchKeyword) { + this.searchKeyword = searchKeyword; + } - public void setSearchUseYn(String searchUseYn) { - this.searchUseYn = searchUseYn; - } + public String getSearchUseYn() { + return searchUseYn; + } - public int getPageIndex() { - return pageIndex; - } + public void setSearchUseYn(String searchUseYn) { + this.searchUseYn = searchUseYn; + } - public void setPageIndex(int pageIndex) { - this.pageIndex = pageIndex; - } + public int getPageIndex() { + return pageIndex; + } - public int getPageUnit() { - return pageUnit; - } + public void setPageIndex(int pageIndex) { + this.pageIndex = pageIndex; + } - public void setPageUnit(int pageUnit) { - this.pageUnit = pageUnit; - } + public int getPageUnit() { + return pageUnit; + } - public int getPageSize() { - return pageSize; - } + public void setPageUnit(int pageUnit) { + this.pageUnit = pageUnit; + } - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } + public int getPageSize() { + return pageSize; + } - public String toString() { - return ToStringBuilder.reflectionToString(this); - } + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } } diff --git a/egovframework.dev.imp.codegen.template.templates/eGovFrameTemplates/crud/java/pkg/service/Sample2VO.vm b/egovframework.dev.imp.codegen.template.templates/eGovFrameTemplates/crud/java/pkg/service/Sample2VO.vm index 2c4ac32b8..5904e41ee 100644 --- a/egovframework.dev.imp.codegen.template.templates/eGovFrameTemplates/crud/java/pkg/service/Sample2VO.vm +++ b/egovframework.dev.imp.codegen.template.templates/eGovFrameTemplates/crud/java/pkg/service/Sample2VO.vm @@ -7,38 +7,44 @@ package $voPackage; /** - * @Class Name : ${voClassName}.java - * @Description : ${model.entity.pcName} VO class - * @Modification Information - * + * ${model.entity.pcName} VO class + * * @author ${author} * @since ${createDate} * @version 1.0 * @see - * - * Copyright (C) All right reserved. + * + *
+ *  == 개정이력(Modification Information) ==
+ *
+ *   수정일      수정자           수정내용
+ *  -------    --------    ---------------------------
+ *   ${createDate}  ${author}          최초 생성
+ *
+ *      
*/ -public class ${voClassName} extends ${defaultVoClassName}{ - private static final long serialVersionUID = 1L; - +public class ${voClassName} extends ${defaultVoClassName} { + + private static final long serialVersionUID = 1L; + #set($i=0) #foreach($attribute in $model.attributes) - /** ${attribute.name} */ - private ${attribute.javaType} ${attribute.ccName}; - + /** ${attribute.name} */ + private ${attribute.javaType} ${attribute.ccName}; + #set($i=$i+1) #end ## #set($i=0) #foreach($attribute in $model.attributes) - public ${attribute.javaType} get${attribute.pcName}() { - return this.${attribute.ccName}; - } - - public void set${attribute.pcName}(${attribute.javaType} ${attribute.ccName}) { - this.${attribute.ccName} = ${attribute.ccName}; - } - + public ${attribute.javaType} get${attribute.pcName}() { + return this.${attribute.ccName}; + } + + public void set${attribute.pcName}(${attribute.javaType} ${attribute.ccName}) { + this.${attribute.ccName} = ${attribute.ccName}; + } + #set($i=$i+1) #end } diff --git a/egovframework.dev.imp.templates/ant/build.xml b/egovframework.dev.imp.templates/ant/build.xml new file mode 100644 index 000000000..67a2e5d40 --- /dev/null +++ b/egovframework.dev.imp.templates/ant/build.xml @@ -0,0 +1,92 @@ + + + simple example build file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + model=${model} + src.model=${src.model} + build.model=${build.model} + + util=${util} + src.util=${src.util} + build.util=${build.util} + + eGovFrameTemplates=${eGovFrameTemplates} + src.eGovFrameTemplates=${src.eGovFrameTemplates} + build.eGovFrameTemplates=${build.eGovFrameTemplates} + + + DSTAMP=${DSTAMP} + + + + + + + + + + + + + \ No newline at end of file diff --git a/egovframework.dev.imp.templates/pom.xml b/egovframework.dev.imp.templates/pom.xml index 86604c29a..9c23bdae3 100644 --- a/egovframework.dev.imp.templates/pom.xml +++ b/egovframework.dev.imp.templates/pom.xml @@ -1,13 +1,31 @@ - - 4.0.0 - egovframework.dev.imp - templates - 0.0.1-SNAPSHOT - - - org.apache.velocity - velocity - 1.6.2 - - + + 4.0.0 + egovframework.dev.imp + templates + 0.0.1-SNAPSHOT + + + org.apache.velocity + velocity + 1.6.2 + + + + + org.incava + java-diff + 1.1 + test + + + + junit + junit + 4.13.2 + test + + + \ No newline at end of file diff --git a/egovframework.dev.imp.templates/src/main/java/ResourceUtils.java b/egovframework.dev.imp.templates/src/main/java/ResourceUtils.java index 2b096757b..1be1f0050 100644 --- a/egovframework.dev.imp.templates/src/main/java/ResourceUtils.java +++ b/egovframework.dev.imp.templates/src/main/java/ResourceUtils.java @@ -1,66 +1,66 @@ - - -import java.util.ArrayList; -import java.util.Arrays; - -import org.eclipse.core.resources.IProject; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; - -/** - * - * 리소스 관리 유틸리티 클래스 - *

NOTE: 리소스 생성시 폴더 존재 여부 확인과 폴더 생성을 위한 유틸리티 - * - * @author 개발환경 개발팀 이흥주 - * @since 2009.08.03 - * @version 1.0 - * @see - * - *

- *  == 개정이력(Modification Information) ==
- *   
- *   수정일      수정자           수정내용
- *  -------    --------    ---------------------------
- *   2009.08.03  이흥주          최초 생성
- *
- * 
- */ -public class ResourceUtils { - - - /** - * - * 자바 프로젝트 로부터 소스 경로 가져오기 - * - * @param project - * @return - */ - @SuppressWarnings("unused") - public static String[] getSourcePath(IProject project) { - ArrayList path = new ArrayList(); - - IJavaProject javaProject = JavaCore.create(project); - if ((javaProject == null) || (!javaProject.exists())) - return null; - try { - IClasspathEntry[] classpath; - ArrayList entries; - classpath = javaProject.getRawClasspath(); - entries = - new ArrayList(Arrays.asList(classpath)); - for(int i=0; i< classpath.length; i++){ - if (classpath[i].getEntryKind() == IClasspathEntry.CPE_SOURCE){ - path.add(classpath[i].getPath().toString()); - } - - } - } - catch(Exception ex) { - ex.printStackTrace(); - } - - return (String[])path.toArray(new String[path.size()]); - } -} +// +// +//import java.util.ArrayList; +//import java.util.Arrays; +// +//import org.eclipse.core.resources.IProject; +//import org.eclipse.jdt.core.IClasspathEntry; +//import org.eclipse.jdt.core.IJavaProject; +//import org.eclipse.jdt.core.JavaCore; +// +///** +// * +// * 리소스 관리 유틸리티 클래스 +// *

NOTE: 리소스 생성시 폴더 존재 여부 확인과 폴더 생성을 위한 유틸리티 +// * +// * @author 개발환경 개발팀 이흥주 +// * @since 2009.08.03 +// * @version 1.0 +// * @see +// * +// *

+// *  == 개정이력(Modification Information) ==
+// *   
+// *   수정일      수정자           수정내용
+// *  -------    --------    ---------------------------
+// *   2009.08.03  이흥주          최초 생성
+// *
+// * 
+// */ +//public class ResourceUtils { +// +// +// /** +// * +// * 자바 프로젝트 로부터 소스 경로 가져오기 +// * +// * @param project +// * @return +// */ +// @SuppressWarnings("unused") +// public static String[] getSourcePath(IProject project) { +// ArrayList path = new ArrayList(); +// +// IJavaProject javaProject = JavaCore.create(project); +// if ((javaProject == null) || (!javaProject.exists())) +// return null; +// try { +// IClasspathEntry[] classpath; +// ArrayList entries; +// classpath = javaProject.getRawClasspath(); +// entries = +// new ArrayList(Arrays.asList(classpath)); +// for(int i=0; i< classpath.length; i++){ +// if (classpath[i].getEntryKind() == IClasspathEntry.CPE_SOURCE){ +// path.add(classpath[i].getPath().toString()); +// } +// +// } +// } +// catch(Exception ex) { +// ex.printStackTrace(); +// } +// +// return (String[])path.toArray(new String[path.size()]); +// } +//} diff --git a/egovframework.dev.imp.templates/src/main/java/TemplateUtil.java b/egovframework.dev.imp.templates/src/main/java/TemplateUtil.java index b65ac7eb1..8564094db 100644 --- a/egovframework.dev.imp.templates/src/main/java/TemplateUtil.java +++ b/egovframework.dev.imp.templates/src/main/java/TemplateUtil.java @@ -1,58 +1,58 @@ - - -import org.eclipse.core.resources.IProject; - -/** - * - * Velocity 템플릿에서 사용되어지는 유틸리티 클래스 - *

NOTE: Velocity 템플릿내에서 사용되어지는 유용한 유틸리티 - * - * @author 개발환경 개발팀 이흥주 - * @since 2009.08.03 - * @version 1.0 - * @see - * - *

- *  == 개정이력(Modification Information) ==
- *   
- *   수정일      수정자           수정내용
- *  -------    --------    ---------------------------
- *   2009.08.03  이흥주          최초 생성
- *
- * 
- */ -public class TemplateUtil { - - /** 프로젝트 */ - private final IProject project; - - /** - * - * 생성자 - * - * @param project - */ - public TemplateUtil(IProject project) { - this.project = project; - } - - /** - * - * 전체 경로에서 소스 패스를 제거 - * - * @param path - * @return - */ - public String removeSourcePath(String path){ - - String result = path; - - String[] sourcePaths = ResourceUtils.getSourcePath(project); - for(String sourcePath : sourcePaths){ - if (path.indexOf(sourcePath) == 0) { - result = path.substring(sourcePath.length()); - } - } - return result; - } -} +// +// +//import org.eclipse.core.resources.IProject; +// +///** +// * +// * Velocity 템플릿에서 사용되어지는 유틸리티 클래스 +// *

NOTE: Velocity 템플릿내에서 사용되어지는 유용한 유틸리티 +// * +// * @author 개발환경 개발팀 이흥주 +// * @since 2009.08.03 +// * @version 1.0 +// * @see +// * +// *

+// *  == 개정이력(Modification Information) ==
+// *   
+// *   수정일      수정자           수정내용
+// *  -------    --------    ---------------------------
+// *   2009.08.03  이흥주          최초 생성
+// *
+// * 
+// */ +//public class TemplateUtil { +// +// /** 프로젝트 */ +// private final IProject project; +// +// /** +// * +// * 생성자 +// * +// * @param project +// */ +// public TemplateUtil(IProject project) { +// this.project = project; +// } +// +// /** +// * +// * 전체 경로에서 소스 패스를 제거 +// * +// * @param path +// * @return +// */ +// public String removeSourcePath(String path){ +// +// String result = path; +// +// String[] sourcePaths = ResourceUtils.getSourcePath(project); +// for(String sourcePath : sourcePaths){ +// if (path.indexOf(sourcePath) == 0) { +// result = path.substring(sourcePath.length()); +// } +// } +// return result; +// } +//} diff --git a/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/Attribute.java b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/Attribute.java new file mode 100644 index 000000000..cfb79e1f3 --- /dev/null +++ b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/Attribute.java @@ -0,0 +1,113 @@ +/* + * Copyright 2008-2009 MOSPA(Ministry of Security and Public Administration). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package egovframework.dev.imp.codegen.template.model; + +/** + * + * 어트리뷰트 정보 클래스 + *

NOTE: 어트리뷰트(데이터베이스 특정 테이블의 컬럼) 정보를 담기위한 모델 클래스 + * + * @author 개발환경 개발팀 이흥주 + * @since 2009.08.03 + * @version 1.0 + * @see + * + *

+ *  == 개정이력(Modification Information) ==
+ *   
+ *   수정일      수정자           수정내용
+ *  -------    --------    ---------------------------
+ *   2009.08.03  이흥주          최초 생성
+ *
+ * 
+ */ +public class Attribute extends DbModelElement { + + /** + * + * 생성자 + * + * @param name + */ + public Attribute(String name) { + super(name); + } + + /** 데이터 타입 */ + private String type; + + /** 자바 타입 */ + private String javaType; + + /** 프라이머리 키 여부 */ + private boolean isPrimaryKey; + + /** + * 필수 키 여부 가져오기 + * @return + */ + public boolean getIsPrimaryKey() { + return isPrimaryKey; + } + + /** + * 필수 키 여부 가져오기 + * @return + */ + public boolean isPrimaryKey() { + return isPrimaryKey; + } + + /** + * 필수키 여부 세팅하기 + * @param isPrimaryKey + */ + public void setPrimaryKey(boolean isPrimaryKey) { + this.isPrimaryKey = isPrimaryKey; + } + + /** + * 자바 타입 가져오기 + * @return + */ + public String getJavaType() { + return javaType; + } + + /** + * 자바 타입 세팅하기 + * @param javaType + */ + public void setJavaType(String javaType) { + this.javaType = javaType; + } + + /** + * 타입 가져오기 + * @return + */ + public String getType() { + return type; + } + + /** + * 타입 세팅하기 + * @param type + */ + public void setType(String type) { + this.type = type; + } +} diff --git a/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/DataModelContext.java b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/DataModelContext.java new file mode 100644 index 000000000..2171a12f1 --- /dev/null +++ b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/DataModelContext.java @@ -0,0 +1,135 @@ +/* + * Copyright 2008-2009 MOSPA(Ministry of Security and Public Administration). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package egovframework.dev.imp.codegen.template.model; + +import java.util.List; +/** + * + * 데이터베이스 Context 클래스 + *

NOTE: 데이터베이스 정보 및 테이블, 컬럼 정보를 담기위한 클래스 + * + * @author 개발환경 개발팀 이흥주 + * @since 2009.08.03 + * @version 1.0 + * @see + * + *

+ *  == 개정이력(Modification Information) ==
+ *   
+ *   수정일      수정자           수정내용
+ *  -------    --------    ---------------------------
+ *   2009.08.03  이흥주          최초 생성
+ *
+ * 
+ */ +public class DataModelContext { + + /** 데이터베이스 벤더 */ + private String vender; + /** 데이터베이스 제품 명 */ + private String databaseProductName; + /** 엔티티(테이블) 정보 */ + private Entity entity; + /** 어트리뷰트(컬럼) 정보 */ + private List attributes; + /** 기본키 컬럼 정보 */ + private List primaryKeys; + + /** + * 데이타베이스 제품명 + * @return + */ + public String getDatabaseProductName() { + return databaseProductName; + } + + /** + * 데이타베이스 제품명 세팅하기 + * @param databaseProductName + */ + public void setDatabaseProductName(String databaseProductName) { + this.databaseProductName = databaseProductName; + } + + /** + * 벤더 정보 가져오기 + * @return + */ + public String getVender() { + return vender; + } + + /** + * 벤더 정보 세팅하기 + * @param vender + */ + public void setVender(String vender) { + this.vender = vender; + } + + + /** + * 기본키 목록 가져오기 + * + * @return + */ + public List getPrimaryKeys() { + return primaryKeys; + } + + /** + * 기본키 목록 세팅하기 + * @param primaryKeys + */ + public void setPrimaryKeys(List primaryKeys) { + this.primaryKeys = primaryKeys; + } + + /** + * 엔티티 가져오기 + * @return + */ + public Entity getEntity() { + return entity; + } + + /** + * 엔티티 세팅하기 + * + * @param entity + */ + public void setEntity(Entity entity) { + this.entity = entity; + } + + /** + * 속성 목록 가져오기 + * + * @return + */ + public List getAttributes() { + return attributes; + } + + /** + * 속성 목록 세팅하기 + * + * @param attributes + */ + public void setAttributes(List attributes) { + this.attributes = attributes; + } +} diff --git a/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/DbModelElement.java b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/DbModelElement.java new file mode 100644 index 000000000..6c78538e2 --- /dev/null +++ b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/DbModelElement.java @@ -0,0 +1,156 @@ +/* + * Copyright 2008-2009 MOSPA(Ministry of Security and Public Administration). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package egovframework.dev.imp.codegen.template.model; + +import egovframework.dev.imp.codegen.template.util.NamingUtils; + +/** + * + * 데이터베이스 모델 요소의 상위 클래스 + *

NOTE: 데이터베이스 모델 요소(테이블, 컬럼)의 최상위 클래스로서 + * DB명을 세팅하면 Java 코드젠에서 사용되어지는 여러 케이싱 명칭을 반환할 수 있다. + * + * @author 개발환경 개발팀 이흥주 + * @since 2009.08.03 + * @version 1.0 + * @see + * + *

+ *  == 개정이력(Modification Information) ==
+ *   
+ *   수정일      수정자           수정내용
+ *  -------    --------    ---------------------------
+ *   2009.08.03  이흥주          최초 생성
+ *
+ * 
+ */ +public class DbModelElement { + /** 이름 */ + private String name; + /** Upper Case 명 */ + private String ucName; + /** Lower Case 명 */ + private String lcName; + /** Camel Case 명 */ + private String ccName; + /** Pascal Case 명 */ + private String pcName; + + /** + * + * 생성자 + * + * @param name 이름 + */ + public DbModelElement(String name){ + setName(name); + } + + /** + * 이름 가져오기 + * + * @return + */ + public String getName() { + return name; + } + + /** + * 이름 세팅하기 + * + * @param name + */ + public void setName(String name) { + this.name = name; + setUcName(name.toUpperCase()); + setLcName(name.toLowerCase()); + setCcName(NamingUtils.convertUnderscoreNameToCamelcase(name)); + setPcName(NamingUtils.convertCamelcaseToPascalcase(getCcName())); + } + + /** + * 대문자 이름 반환 + * + * @return + */ + public String getUcName() { + return ucName; + } + + + /** + * 대문자 이름 세팅 + * + * @param uppercaseName + */ + public void setUcName(String uppercaseName) { + this.ucName = uppercaseName; + } + + /** + * 소문자 이름 반환 + * + * @return + */ + public String getLcName() { + return lcName; + } + + /** + * 소문자 이름 세팅 + * + * @param lowercaseName + */ + public void setLcName(String lowercaseName) { + this.lcName = lowercaseName; + } + + /** + * 카멜 케이스 이름 반환 + * + * @return + */ + public String getCcName() { + return ccName; + } + + /** + * 카멜 케이스 이름 세팅 + * + * @param camelcaseName + */ + public void setCcName(String camelcaseName) { + this.ccName = camelcaseName; + } + + /** + * 파스칼 케이스 이름 반환 + * @return + */ + public String getPcName() { + return pcName; + } + + /** + * 파스칼 케이스 이름 세팅 + * @param pascalcaseName + */ + public void setPcName(String pascalcaseName) { + this.pcName = pascalcaseName; + } + + +} diff --git a/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/Entity.java b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/Entity.java new file mode 100644 index 000000000..06585eda8 --- /dev/null +++ b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/model/Entity.java @@ -0,0 +1,49 @@ +/* + * Copyright 2008-2009 MOSPA(Ministry of Security and Public Administration). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package egovframework.dev.imp.codegen.template.model; + +/** + * + * 엔티티 정보 클래스 + *

NOTE: 어트리뷰트(데이터베이스 테이블) 정보를 담기위한 모델 클래스 + * + * @author 개발환경 개발팀 이흥주 + * @since 2009.08.03 + * @version 1.0 + * @see + * + *

+ *  == 개정이력(Modification Information) ==
+ *   
+ *   수정일      수정자           수정내용
+ *  -------    --------    ---------------------------
+ *   2009.08.03  이흥주          최초 생성
+ *
+ * 
+ */ +public class Entity extends DbModelElement { + + /** + * + * 생성자 + * + * @param name 이름 + */ + public Entity(String name) { + super(name); + } + +} diff --git a/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/util/NamingUtils.java b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/util/NamingUtils.java new file mode 100644 index 000000000..a61917585 --- /dev/null +++ b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/codegen/template/util/NamingUtils.java @@ -0,0 +1,89 @@ +/* + * Copyright 2008-2009 MOSPA(Ministry of Security and Public Administration). + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package egovframework.dev.imp.codegen.template.util; + +/** + * + * 네이밍 변환 유틸리티 클래스 + *

NOTE: 언더스코어 네이밍을 카멜, 파스칼 케이싱으로 변환하기 위한 유틸리티 + * + * @author 개발환경 개발팀 이흥주 + * @since 2009.08.03 + * @version 1.0 + * @see + * + *

+ *  == 개정이력(Modification Information) ==
+ *   
+ *   수정일      수정자           수정내용
+ *  -------    --------    ---------------------------
+ *   2009.08.03  이흥주          최초 생성
+ *
+ * 
+ */ +public class NamingUtils { + + /** + * + * 언더스코어 명칭을 카멜케이싱 명칭으로 변환 + * + * @param name + * @return + */ + public static String convertUnderscoreNameToCamelcase(String name){ + StringBuffer result = new StringBuffer(); + boolean nextIsUpper = false; + if (name != null && name.length() > 0) { + if (name.length() > 1 && name.substring(1,2).equals("_")) { + result.append(name.substring(0, 1).toUpperCase()); + } + else { + result.append(name.substring(0, 1).toLowerCase()); + } + String s = null; + for (int i = 1; i < name.length(); i++) { + s = name.substring(i, i + 1); + if (s.equals("_")) { + nextIsUpper = true; + } + else { + if (nextIsUpper) { + result.append(s.toUpperCase()); + nextIsUpper = false; + } + else { + result.append(s.toLowerCase()); + } + } + } + } + return result.toString(); + } + + /** + * + * 카멜케이싱 명칭을 파스칼케이싱 명칭으로 변환 + * + * @param name + * @return + */ + public static String convertCamelcaseToPascalcase(String name){ + StringBuffer result = new StringBuffer(); + result.append(name.substring(0, 1).toUpperCase()); + result.append(name.substring(1)); + return result.toString(); + } +} diff --git a/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/templates/TemplatesPlugin.java b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/templates/TemplatesPlugin.java index 15f444e1b..a85beac27 100644 --- a/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/templates/TemplatesPlugin.java +++ b/egovframework.dev.imp.templates/src/main/java/egovframework/dev/imp/templates/TemplatesPlugin.java @@ -1,50 +1,50 @@ -package egovframework.dev.imp.templates; - -import org.eclipse.ui.plugin.AbstractUIPlugin; -import org.osgi.framework.BundleContext; - -/** - * The activator class controls the plug-in life cycle - */ -public class TemplatesPlugin extends AbstractUIPlugin { - - // The plug-in ID - public static final String PLUGIN_ID = "egovframework.dev.imp.templates"; - - // The shared instance - private static TemplatesPlugin plugin; - - /** - * The constructor - */ - public TemplatesPlugin() { - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) - */ - public void start(BundleContext context) throws Exception { - super.start(context); - plugin = this; - } - - /* - * (non-Javadoc) - * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) - */ - public void stop(BundleContext context) throws Exception { - plugin = null; - super.stop(context); - } - - /** - * Returns the shared instance - * - * @return the shared instance - */ - public static TemplatesPlugin getDefault() { - return plugin; - } - -} +//package egovframework.dev.imp.templates; +// +//import org.eclipse.ui.plugin.AbstractUIPlugin; +//import org.osgi.framework.BundleContext; +// +///** +// * The activator class controls the plug-in life cycle +// */ +//public class TemplatesPlugin extends AbstractUIPlugin { +// +// // The plug-in ID +// public static final String PLUGIN_ID = "egovframework.dev.imp.templates"; +// +// // The shared instance +// private static TemplatesPlugin plugin; +// +// /** +// * The constructor +// */ +// public TemplatesPlugin() { +// } +// +// /* +// * (non-Javadoc) +// * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) +// */ +// public void start(BundleContext context) throws Exception { +// super.start(context); +// plugin = this; +// } +// +// /* +// * (non-Javadoc) +// * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) +// */ +// public void stop(BundleContext context) throws Exception { +// plugin = null; +// super.stop(context); +// } +// +// /** +// * Returns the shared instance +// * +// * @return the shared instance +// */ +// public static TemplatesPlugin getDefault() { +// return plugin; +// } +// +//} diff --git a/egovframework.dev.imp.templates/src/main/java/model/Attribute.java b/egovframework.dev.imp.templates/src/main/java/model/Attribute.java index 75dedc4c9..a5d0cd57c 100644 --- a/egovframework.dev.imp.templates/src/main/java/model/Attribute.java +++ b/egovframework.dev.imp.templates/src/main/java/model/Attribute.java @@ -1,26 +1,26 @@ -package model; - -public class Attribute extends NameCasing { - public Attribute(String name) { - super(name); - } - - private String type; - private String javaType; - - public String getJavaType() { - return javaType; - } - - public void setJavaType(String javaType) { - this.javaType = javaType; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } -} +//package model; +// +//public class Attribute extends NameCasing { +// public Attribute(String name) { +// super(name); +// } +// +// private String type; +// private String javaType; +// +// public String getJavaType() { +// return javaType; +// } +// +// public void setJavaType(String javaType) { +// this.javaType = javaType; +// } +// +// public String getType() { +// return type; +// } +// +// public void setType(String type) { +// this.type = type; +// } +//} diff --git a/egovframework.dev.imp.templates/src/main/java/model/DataModelContext.java b/egovframework.dev.imp.templates/src/main/java/model/DataModelContext.java index 74b3cb2aa..a3c323b40 100644 --- a/egovframework.dev.imp.templates/src/main/java/model/DataModelContext.java +++ b/egovframework.dev.imp.templates/src/main/java/model/DataModelContext.java @@ -1,57 +1,57 @@ -package model; - -import java.util.List; - -public class DataModelContext { - private String author; - private String createDate; - private String team; - - public String getAuthor() { - return author; - } - public String getTeam() { - return team; - } - public void setTeam(String team) { - this.team = team; - } - public void setAuthor(String author) { - this.author = author; - } - public String getCreateDate() { - return createDate; - } - public void setCreateDate(String createDate) { - this.createDate = createDate; - } - private String packageName; - public String getPackageName() { - return packageName; - } - public void setPackageName(String packageName) { - this.packageName = packageName; - } - private Entity entity; - private List attributes; - private List primaryKeys; - - public List getPrimaryKeys() { - return primaryKeys; - } - public void setPrimaryKeys(List primaryKeys) { - this.primaryKeys = primaryKeys; - } - public Entity getEntity() { - return entity; - } - public void setEntity(Entity entity) { - this.entity = entity; - } - public List getAttributes() { - return attributes; - } - public void setAttributes(List attributes) { - this.attributes = attributes; - } -} +//package model; +// +//import java.util.List; +// +//public class DataModelContext { +// private String author; +// private String createDate; +// private String team; +// +// public String getAuthor() { +// return author; +// } +// public String getTeam() { +// return team; +// } +// public void setTeam(String team) { +// this.team = team; +// } +// public void setAuthor(String author) { +// this.author = author; +// } +// public String getCreateDate() { +// return createDate; +// } +// public void setCreateDate(String createDate) { +// this.createDate = createDate; +// } +// private String packageName; +// public String getPackageName() { +// return packageName; +// } +// public void setPackageName(String packageName) { +// this.packageName = packageName; +// } +// private Entity entity; +// private List attributes; +// private List primaryKeys; +// +// public List getPrimaryKeys() { +// return primaryKeys; +// } +// public void setPrimaryKeys(List primaryKeys) { +// this.primaryKeys = primaryKeys; +// } +// public Entity getEntity() { +// return entity; +// } +// public void setEntity(Entity entity) { +// this.entity = entity; +// } +// public List getAttributes() { +// return attributes; +// } +// public void setAttributes(List attributes) { +// this.attributes = attributes; +// } +//} diff --git a/egovframework.dev.imp.templates/src/main/java/model/Entity.java b/egovframework.dev.imp.templates/src/main/java/model/Entity.java index 0be5287dd..cd3d12d22 100644 --- a/egovframework.dev.imp.templates/src/main/java/model/Entity.java +++ b/egovframework.dev.imp.templates/src/main/java/model/Entity.java @@ -1,9 +1,9 @@ -package model; - -public class Entity extends NameCasing { - - public Entity(String name) { - super(name); - } - -} +//package model; +// +//public class Entity extends NameCasing { +// +// public Entity(String name) { +// super(name); +// } +// +//} diff --git a/egovframework.dev.imp.templates/src/main/java/model/NameCasing.java b/egovframework.dev.imp.templates/src/main/java/model/NameCasing.java index a5ec5a257..cbc9841ef 100644 --- a/egovframework.dev.imp.templates/src/main/java/model/NameCasing.java +++ b/egovframework.dev.imp.templates/src/main/java/model/NameCasing.java @@ -1,52 +1,52 @@ -package model; - -import utils.NamingUtils; - -public class NameCasing { - private String name; - private String ucName; - private String lcName; - private String ccName; - private String pcName; - - public NameCasing(String name){ - setName(name); - } - - public String getName() { - return name; - } - public void setName(String name) { - this.name = name; - setUcName(name.toUpperCase()); - setLcName(name.toLowerCase()); - setCcName(NamingUtils.convertUnderscoreNameToCamelcase(name)); - setPcName(NamingUtils.convertCamelcaseToPascalcase(getCcName())); - } - public String getUcName() { - return ucName; - } - public void setUcName(String uppercaseName) { - this.ucName = uppercaseName; - } - public String getLcName() { - return lcName; - } - public void setLcName(String lowercaseName) { - this.lcName = lowercaseName; - } - public String getCcName() { - return ccName; - } - public void setCcName(String camelcaseName) { - this.ccName = camelcaseName; - } - public String getPcName() { - return pcName; - } - public void setPcName(String pascalcaseName) { - this.pcName = pascalcaseName; - } - - -} +//package model; +// +//import utils.NamingUtils; +// +//public class NameCasing { +// private String name; +// private String ucName; +// private String lcName; +// private String ccName; +// private String pcName; +// +// public NameCasing(String name){ +// setName(name); +// } +// +// public String getName() { +// return name; +// } +// public void setName(String name) { +// this.name = name; +// setUcName(name.toUpperCase()); +// setLcName(name.toLowerCase()); +// setCcName(NamingUtils.convertUnderscoreNameToCamelcase(name)); +// setPcName(NamingUtils.convertCamelcaseToPascalcase(getCcName())); +// } +// public String getUcName() { +// return ucName; +// } +// public void setUcName(String uppercaseName) { +// this.ucName = uppercaseName; +// } +// public String getLcName() { +// return lcName; +// } +// public void setLcName(String lowercaseName) { +// this.lcName = lowercaseName; +// } +// public String getCcName() { +// return ccName; +// } +// public void setCcName(String camelcaseName) { +// this.ccName = camelcaseName; +// } +// public String getPcName() { +// return pcName; +// } +// public void setPcName(String pascalcaseName) { +// this.pcName = pascalcaseName; +// } +// +// +//} diff --git a/egovframework.dev.imp.templates/src/main/java/operation/CrudCodeGen.java b/egovframework.dev.imp.templates/src/main/java/operation/CrudCodeGen.java index ae69c70cf..e2c5669f2 100644 --- a/egovframework.dev.imp.templates/src/main/java/operation/CrudCodeGen.java +++ b/egovframework.dev.imp.templates/src/main/java/operation/CrudCodeGen.java @@ -1,11 +1,10 @@ package operation; +import java.io.IOException; import java.io.StringWriter; import java.io.Writer; import java.util.Properties; -import model.DataModelContext; - import org.apache.velocity.Template; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; @@ -13,63 +12,181 @@ import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; +import egovframework.dev.imp.codegen.template.model.DataModelContext; + public class CrudCodeGen { - public String generate(DataModelContext dataModel, String templateFile) throws Exception{ + public String generate(DataModelContext dataModel, String templateFile, CrudWizard crudWizard) { StringWriter sw = new StringWriter(); - generate(dataModel, templateFile, sw); - + generate(dataModel, templateFile, sw, crudWizard); + System.out.println(sw.toString()); - - return sw.toString(); + + return sw.toString(); } - - private void generate(DataModelContext dataModel, String templateFile, Writer writer) throws Exception{ + + private void generate(DataModelContext dataModel, String templateFile, Writer writer, CrudWizard crudWizard) { String templateEncoding = "UTF-8"; - - Properties p = new Properties() ; - p.setProperty("resource.loader", "class"); - p.setProperty("class.resource.loader.class","org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); - - p.setProperty("file.resource.loader.cache", "false"); - p.setProperty("file.resource.loader.modificationCheckInterval", "0"); - Velocity.init(p); + Properties p = new Properties(); + p.setProperty("resource.loader", "class"); + p.setProperty("class.resource.loader.class", + "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + + p.setProperty("file.resource.loader.cache", "false"); + p.setProperty("file.resource.loader.modificationCheckInterval", "0"); + + try { + Velocity.init(p); + } catch (Exception e) { + throw new IllegalArgumentException(e); + } VelocityContext context = new VelocityContext(); - context.put("package", dataModel.getPackageName()); - context.put("entity", dataModel.getEntity()); - context.put("attributes", dataModel.getAttributes()); - context.put("primaryKeys", dataModel.getPrimaryKeys()); - context.put("createDate", dataModel.getCreateDate()); - context.put("author", dataModel.getAuthor()); - - +// context.put("package", dataModel.getPackageName()); +// context.put("entity", dataModel.getEntity()); +// context.put("attributes", dataModel.getAttributes()); +// context.put("primaryKeys", dataModel.getPrimaryKeys()); +// context.put("createDate", dataModel.getCreateDate()); +// context.put("author", dataModel.getAuthor()); + + context.put("model", dataModel); + + context.put("author", crudWizard.getAuthor()); + context.put("createDate", crudWizard.getCreateDate()); + context.put("mapperFolder", crudWizard.getMapperFolder()); + context.put("daoPackage", crudWizard.getDaoPackage()); + context.put("mapperPackage", crudWizard.getMapperPackage()); + context.put("voPackage", crudWizard.getVoPackage()); + context.put("servicePackage", crudWizard.getServicePackage()); + context.put("implPackage", crudWizard.getImplPackage()); + context.put("controllerPackage", crudWizard.getControllerPackage()); + context.put("jspFolder", crudWizard.getJspFolder()); + Template template = null; - try - { + try { template = Velocity.getTemplate(templateFile, templateEncoding); - } - catch( ResourceNotFoundException rnfe ) - { + } catch (ResourceNotFoundException rnfe) { rnfe.printStackTrace(); - } - catch( ParseErrorException pee ) - { + } catch (ParseErrorException pee) { // syntax error: problem parsing the template - } - catch( MethodInvocationException mie ) - { + } catch (MethodInvocationException mie) { // something invoked in the template // threw an exception + } catch (Exception e) { + } + + try { + template.merge(context, writer); + } catch (ResourceNotFoundException | ParseErrorException | MethodInvocationException | IOException e) { + throw new IllegalArgumentException(e); + } + + } + + public static class CrudWizard { + + private String author; + + private String createDate; + + private String mapperFolder; + + private String daoPackage; + + private String mapperPackage; + + private String voPackage; + + private String servicePackage; + + private String implPackage; + + private String controllerPackage; + + private String jspFolder; + + public String getAuthor() { + return author; + } + + public void setAuthor(String author) { + this.author = author; + } + + public String getCreateDate() { + return createDate; + } + + public void setCreateDate(String createDate) { + this.createDate = createDate; + } + + public String getMapperFolder() { + return mapperFolder; + } + + public void setMapperFolder(String mapperFolder) { + this.mapperFolder = mapperFolder; + } + + public String getDaoPackage() { + return daoPackage; + } + + public void setDaoPackage(String daoPackage) { + this.daoPackage = daoPackage; + } + + public String getMapperPackage() { + return mapperPackage; + } + + public void setMapperPackage(String mapperPackage) { + this.mapperPackage = mapperPackage; + } + + public String getVoPackage() { + return voPackage; + } + + public void setVoPackage(String voPackage) { + this.voPackage = voPackage; + } + + public String getServicePackage() { + return servicePackage; + } + + public void setServicePackage(String servicePackage) { + this.servicePackage = servicePackage; + } + + public String getImplPackage() { + return implPackage; + } + + public void setImplPackage(String implPackage) { + this.implPackage = implPackage; + } + + public String getControllerPackage() { + return controllerPackage; + } + + public void setControllerPackage(String controllerPackage) { + this.controllerPackage = controllerPackage; + } + + public String getJspFolder() { + return jspFolder; + } + + public void setJspFolder(String jspFolder) { + this.jspFolder = jspFolder; } - catch( Exception e ) - {} - template.merge( context, writer ); - - } - + } diff --git a/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring-java.vm b/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring-java.vm new file mode 100644 index 000000000..315b045e2 --- /dev/null +++ b/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring-java.vm @@ -0,0 +1,34 @@ +package ${txtConfigPackage}; + +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.ehcache.EhCacheCacheManager; +import org.springframework.cache.ehcache.EhCacheManagerFactoryBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.ClassPathResource; + +@Configuration +@EnableCaching +public class ${templateUtil.substringAfterLast(${txtClassName}, ".")} { + + @Bean + public EhCacheManagerFactoryBean ehCacheManagerFactoryBean() { + EhCacheManagerFactoryBean factoryBean = new EhCacheManagerFactoryBean(); + factoryBean.setConfigLocation(new ClassPathResource("${templateUtil.removeSourcePath(${txtConfigLocation})}")); + factoryBean.setShared(true); + return factoryBean; + } + + @Bean + public EhCacheCacheManager cacheManager(EhCacheManagerFactoryBean ehCacheManagerFactoryBean) { + return new EhCacheCacheManager(ehCacheManagerFactoryBean.getObject()); + } + + /* pom.xml에 다음 라이브러리 추가 필요 + + net.sf.ehcache + ehcache + 2.10.9.2 + + */ +} \ No newline at end of file diff --git a/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring.vm b/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring.vm index 112f4a9fa..a52475e46 100644 --- a/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring.vm +++ b/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring.vm @@ -1,14 +1,26 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:cache="http://www.springframework.org/schema/cache" + xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd + http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-4.0.xsd"> - + + + - + - + + + \ No newline at end of file diff --git a/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring.xml b/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring.xml index 89b5e6fef..ef858ea7c 100644 --- a/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring.xml +++ b/egovframework.dev.imp.templates/src/main/resources/eGovFrameTemplates/cache/ehcacheConfigForSpring.xml @@ -5,19 +5,34 @@ - Select config file. + Select config package or path. - - - - - + + + + + + + + + + + + + -