<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>CDM reader</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta name=ProgId content=Excel.Sheet>
<meta name=Generator content="Microsoft Excel 12">
<style id="entity_16221_Styles">
#entities div{
}
<!--table
{mso-displayed-decimal-separator:"\.";
mso-displayed-thousand-separator:"\,";}
#entities div{
margin:10px
}
.header
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:11.0pt;
font-weight:700;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:center;
vertical-align:middle;
border:.5pt solid windowtext;
mso-background-source:auto;
mso-pattern:auto;
white-space:normal;}
.title
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:11.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:general;
vertical-align:middle;
border:.5pt solid windowtext;
mso-background-source:auto;
mso-pattern:auto;
white-space:nowrap;}
.cell
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:11.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:general;
vertical-align:middle;
border:.5pt solid windowtext;
mso-background-source:auto;
mso-pattern:auto;
white-space:normal;}
.content
{padding-top:1px;
padding-right:1px;
padding-left:1px;
mso-ignore:padding;
color:black;
font-size:11.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-number-format:General;
text-align:left;
vertical-align:middle;
border-top:.5pt solid windowtext;
border-right:none;
border-bottom:.5pt solid windowtext;
border-left:none;
mso-background-source:auto;
mso-pattern:auto;
white-space:nowrap;}
ruby
{ruby-align:left;}
rt
{color:windowtext;
font-size:9.0pt;
font-weight:400;
font-style:normal;
text-decoration:none;
font-family:宋体;
mso-generic-font-family:auto;
mso-font-charset:134;
mso-char-type:none;}
-->
</style>
<script type="text/javascript" src="jquery-1.7.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var url="mis.cdm";
var dataType;
var domains=[];
var entities=[];
var inheritances=[];
var loadXML = function(fileRoute){
xmlDoc=null;
if (window.ActiveXObject){
xmlDoc = new ActiveXObject('Msxml2.DOMDocument');
xmlDoc.async=false;
xmlDoc.load(fileRoute);
}
else if (document.implementation && document.implementation.createDocument){
var xmlhttp = new window.XMLHttpRequest();
xmlhttp.open("GET",fileRoute,false);
xmlhttp.send(null);
var xmlDoc = xmlhttp.responseXML.documentElement;
}
else {xmlDoc=null;}
return xmlDoc;
};
//定义JAVA数据类型
var JavaDataType={};
JavaDataType["N"]="BigDecimal";
JavaDataType["DC"]="BigDecimal";
JavaDataType["VA"]="String";
JavaDataType["A"]="String";
JavaDataType["TS"]="Date";
JavaDataType["BT"]="Boolean";
JavaDataType["BIN"]="byte[]";
//定义数据库数据类型
var DbDataType={};
DbDataType["N"]="NUMBER";
DbDataType["DC"]="NUMBER";
DbDataType["VA"]="VARCHAR";
DbDataType["A"]="CHAR";
DbDataType["TS"]="TIMESTAMP";
DbDataType["BT"]="NUMBER";
DbDataType["BIN"]="BLOB";
var dataItemMap={};
var inheritanceMap={};
var inheritanceLinkMap={};
var entityMap={};
var data=loadXML(url);
//获取数据子项
$(data).find("c\\:DataItems").find("o\\:DataItem").each(function(i){
var dataItem={};
dataItem.id=$(this).attr("Id");
dataItem.name=$(this).find("a\\:Name").text();
dataItem.code=$(this).find("a\\:Code").text();
dataItem.type=$(this).find("a\\:DataType").text();
dataItem.leng=$(this).find("a\\:Length").text();
dataItem.comment=$(this).find("a\\:Comment").text();
dataItemMap[dataItem.id]=dataItem;
});
//获取继承对象
$(data).find("c\\:Inheritances").find("o\\:Inheritance").each(function(i){
var t=$(this).attr("Id");
var s=$($(this).find("c\\:ParentEntity").find("o\\:Entity").get(0)).attr("Ref");
inheritanceMap[t]=s;
});
//获取继承关系对(仅适用于单继承)
$(data).find("c\\:InheritanceLinks").find("o\\:InheritanceLink").each(function(i){
var t=$($(this).find("c\\:Object2").find("o\\:Entity").get(0)).attr("Ref");
var s=$($(this).find("c\\:Object1").find("o\\:Inheritance").get(0)).attr("Ref");
inheritanceLinkMap[t]=s;
});
//获取实体
$(data).find("c\\:Entities").find("o\\:Entity").each(function(i){
var entity={};
entity.id=$(this).attr("Id");
entity.name=$(this).children("a\\:Name").text();
entity.code=$(this).children("a\\:Code").text();
entity.comment=$(this).children("a\\:Comment").text();
entity.pk=$($(this).children("c\\:PrimaryIdentifier").get(0)).attr("Ref");
entity.parent=inheritanceMap[inheritanceLinkMap[entity.id]]
entity.items=[];
$(this).children("c\\:Attributes").find("o\\:EntityAttribute").each(function(){
var item=dataItemMap[$($(this).find("c\\:DataItem").find("o\\:DataItem").get(0)).attr("Ref")];
if($(this).find("a\\:BaseAttribute\\.Mandatory").length<1){
item.nullable=false;
}else{
if($($(this).find("a\\:BaseAttribute\\.Mandatory").get(0)).text()==1){
item.nullable=true;
}else{
item.nullable=false;
}
};
entity.items.push(item);
});
entityMap[entity.id]=entity;
entities.push(entity);
});
String.prototype.toProper=function(){
return this.substring(0,1).toUpperCase()+this.substr(1,this.length).toLowerCase();
};
function toProper(single) {
return single.toProper();
}
var calculateProperty=function(name){
var pname=name.split("_");
var nn=pname.map(toProper).join("");
return nn.substring(0,1).toLowerCase()+nn.substr(1,nn.length);
};
var calculatePropertyUp=function(name){
var pname=name.split("_");
return pname.map(toProper).join("");
};
var calculateName=function(name){
var cla={};
var classname=name.split("_");
cla.pkg=classname[0].toLowerCase();
cla.gup=classname[1].toLowerCase();
cla.self=classname.map(toProper).join("");
classname.shift();
cla.name=classname.map(toProper).join("");
return cla;
};
//生成实体表
//实体表个数
var entityCount=entities.length;
//联级读取属性字段
var buildItemCascade=function(entity){
var hm=[];
if(typeof(entity.parent)!='undefined'){
hm.push(buildItemCascade(entityMap[entity.parent]));
}
var itemCount=entity.items.length;
for(var k=0;k<itemCount;k++){
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=cell width=101 style='height:14.25pt;border-top:");
hm.push("none;width:76pt'>");
hm.push(entity.items[k].name);
hm.push("</td>");
hm.push("<td class=cell width=113 style='border-top:none;border-left:none;");
hm.push("width:85pt'>");
hm.push(entity.items[k].code);
hm.push("</td>");
hm.push("<td class=cell width=83 style='border-top:none;border-left:none;");
hm.push("width:62pt'>");
hm.push(entity.items[k].type);
hm.push("</td>");
hm.push("<td class=cell align=right width=77 style='border-top:none;border-left:");
hm.push("none;width:58pt'>");
hm.push(entity.items[k].leng);
hm.push("</td>");
hm.push("<td class=cell align=right width=60 style='border-top:none;border-left:");
hm.push("none;width:58pt'>");
hm.push(entity.items[k].nullable);
hm.push("</td>");
hm.push("<td class=cell width=390 style='border-top:none;border-left:none;");
hm.push("width:293pt'>");
hm.push(entity.items[k].comment);
hm.push("</td>");
hm.push("</tr>");
}
return hm.join("");
};
//读取自己属性字段
var buildItemSelf=function(entity){
var hm=[];
var itemCount=entity.items.length;
for(var k=0;k<itemCount;k++){
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=cell width=101 style='height:14.25pt;border-top:");
hm.push("none;width:76pt'>");
hm.push(entity.items[k].name);
hm.push("</td>");
hm.push("<td class=cell width=113 style='border-top:none;border-left:none;");
hm.push("width:85pt'>");
hm.push(entity.items[k].code);
hm.push("</td>");
hm.push("<td class=cell width=83 style='border-top:none;border-left:none;");
hm.push("width:62pt'>");
hm.push(entity.items[k].type);
hm.push("</td>");
hm.push("<td class=cell align=right width=77 style='border-top:none;border-left:");
hm.push("none;width:58pt'>");
hm.push(entity.items[k].leng);
hm.push("</td>");
hm.push("<td class=cell align=right width=60 style='border-top:none;border-left:");
hm.push("none;width:58pt'>");
hm.push(entity.items[k].nullable);
hm.push("</td>");
hm.push("<td class=cell width=390 style='border-top:none;border-left:none;");
hm.push("width:293pt'>");
hm.push(entity.items[k].comment);
hm.push("</td>");
hm.push("</tr>");
}
return hm.join("");
};
var buildItemProperty=function(entity){
var hm=[];
var ht=[];
var itemCount=entity.items.length;
for(var k=0;k<itemCount;k++){
var hc=[];
var upCode=calculatePropertyUp(entity.items[k].code);
var loCode=calculateProperty(entity.items[k].code);
var tType=entity.items[k].type.replace(/[^a-zA-Z]/g,"");
//判断数据类型是否存在小数
var tleg=entity.items[k].type.replace(/[a-zA-Z]/g,"").split(",");
var tbool=false;
if(tleg.length>1){
tbool=true;
tleg=tleg[1];
}
tType=JavaDataType[tType];
var col=[];
if(tType=='Date'){
col.push(' @Temporal(TemporalType.TIMESTAMP)');
}
col.push(' @Column(name = "');
col.push(entity.items[k].code);
col.push('",');
if(entity.items[k].nullable){
col.push(' nullable = false ');
}else{
col.push(' nullable = true ');
}
//col.push(' ,unique = false ');
if(tType=='Date'){
col.push(',length = 7');
}else if(tType=='Boolean'){
col.push(',precision = 1, scale = 0');
}else if(tType=='String'){
col.push(',length='+entity.items[k].leng);
}else if(tType=='BigDecimal'){
if(tbool){
col.push(',precision = '+entity.items[k].leng+', scale = '+tleg);
}else{
//长度存在时 输出长度 不存在不输出
if(entity.items[k].leng!=null && entity.items[k].leng!="" && entity.items[k].leng){
col.push(',precision = '+entity.items[k].leng+', scale = 0');
}
}
}else if(tType=='BigInteger'){
col.push(',precision = '+entity.items[k].leng+', scale = 0');
}else if(tType=='byte[]'){
col.push(',length='+entity.items[k].leng);
}
col.push(")");
col.push("\n");
//添加注释
hc.push("/**");
hc.push("\n");
hc.push(" *");
hc.push(" <p>");
hc.push(entity.items[k].name);
hc.push(" </p>");
hc.push("\n");
hc.push(" *");
hc.push(" <p>");
hc.push(entity.items[k].comment);
hc.push(" </p>");
hc.push("\n");
hc.push(" */\n");
hm.push(hc.join(""));
hm.push(" private ");
hm.push(tType);
hm.push(" ");
hm.push(loCode);
hm.push(";");
hm.push("\n");
hm.push("\n");
//SET 方法
ht.push(hc.join(""));
ht.push(" public void set");
ht.push(upCode);
ht.push("(");
ht.push(tType);
ht.push(" ");
ht.push(loCode);
ht.push(") {");
ht.push("\n");
ht.push(" this.");
ht.push(loCode);
ht.push(" = ");
ht.push(loCode);
ht.push(";");
ht.push("\n");
ht.push(" }");
ht.push("\n");
//GET 方法
ht.push(hc.join(""));
ht.push(col.join(""));
ht.push(" public ");
ht.push(tType);
ht.push(" get");
ht.push(upCode);
ht.push("(){");
ht.push("\n");
ht.push(" return this.");
ht.push(loCode);
ht.push(";");
ht.push("\n");
ht.push(" }");
ht.push("\n");
};
return hm.join("")+ht.join("");
};
//解析类
var createEntityTable=function(){
var hm=[];
for(var i=0;i<entityCount;i++){
if(entities[i].code=="FND_BASIC_ENTITY" ||
entities[i].code=="FND_BASIC_OBJECT" ||
entities[i].code=="FND_BASIC_NEXUS")continue;
hm.push("<div class='entity' align=center x:publishsource='Excel'>");
hm.push("<table border=0 cellpadding=0 cellspacing=0 style='border-collapse:");
hm.push("collapse;table-layout:fixed;width:574pt'>");
hm.push("<col width=101 style='mso-width-source:userset;mso-width-alt:3232;width:76pt'>");
hm.push("<col width=113 style='mso-width-source:userset;mso-width-alt:3616;width:85pt'>");
hm.push("<col width=83 style='mso-width-source:userset;mso-width-alt:2656;width:62pt'>");
hm.push("<col width=77 style='mso-width-source:userset;mso-width-alt:2464;width:58pt'>");
hm.push("<col width=60 style='mso-width-source:userset;mso-width-alt:2464;width:58pt'>");
hm.push("<col width=390 style='mso-width-source:userset;mso-width-alt:12480;width:293pt'>");
hm.push("<thead>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=title width=101 style='height:14.25pt;width:76pt'>对象名:</td>");
hm.push("<td colspan=5 class='content name' width=663 style='border-right:.5pt solid black;");
hm.push("width:498pt'>");
hm.push(entities[i].name);
hm.push("</td>");
hm.push("</tr>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=title style='height:14.25pt;border-top:none'>代码:</td>");
hm.push(" <td colspan=5 class='content code' style='border-right:.5pt solid black'>");
hm.push(entities[i].code);
hm.push("</td>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=title style='height:14.25pt;border-top:none'>父类:</td>");
hm.push("<td colspan=5 class='content parent' ");
try{
hm.push("parentId='"+entityMap[entities[i].parent].id+"' ");
}catch(e){
}
hm.push(" style='border-right:.5pt solid black'>");
try{
hm.push(entityMap[entities[i].parent].code);
}catch(e){
hm.push(" ");
}
hm.push("</td>");
hm.push("</tr>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=title style='height:14.25pt;border-top:none'>描述:</td>");
hm.push("<td colspan=5 class=content style='border-right:.5pt solid black'>");
hm.push(entities[i].descript);
hm.push("</td>");
hm.push("</tr>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=header width=101 style='height:14.25pt;border-top:");
hm.push("none;width:76pt'>字段名称</td>");
hm.push("<td class=header width=113 style='border-top:none;border-left:none;");
hm.push("width:85pt'>字段代码</td>");
hm.push("<td class=header width=83 style='border-top:none;border-left:none;");
hm.push("width:62pt'>数据类型</td>");
hm.push("<td class=header width=77 style='border-top:none;border-left:none;");
hm.push("width:58pt'>数据长度</td>");
hm.push("<td class=header width=60 style='border-top:none;border-left:none;");
hm.push("width:58pt'>必须项目</td>");
hm.push("<td class=header width=390 style='border-top:none;border-left:none;");
hm.push("width:293pt'>字段备注</td>");
hm.push("</tr>");
hm.push("</thead>");
hm.push("<tbody class='field'>");
hm.push(buildItemSelf(entities[i]));
hm.push("</tbody>");
hm.push("</table>");
hm.push("</div>");
}
$("#models").html(hm.join(""));
};
//解析类
var createEntityModel=function(){
var hq=[];
for(var i=0;i<entityCount;i++){
if(entities[i].code=="FND_BASIC_ENTITY" ||
entities[i].code=="FND_BASIC_OBJECT" ||
entities[i].code=="FND_BASIC_NEXUS")continue;
var hm=[];
//添加包名
hm.push("package ");
hm.push($("#packageName").val());
hm.push(".");
hm.push(entities[i].code.split("_")[0].toLowerCase());
if(entityMap[entities[i].parent].code=="FND_BASIC_NEXUS"){
hm.push(".nexus;");
}else{
hm.push(".entity;");
}
hm.push("\n");
hm.push("\n");
//添加引用包
try{
var cla=calculateName(entityMap[entities[i].parent].code);
hm.push("import ");
hm.push("com.chameleon.structure.core");
hm.push(".entity.");
hm.push(cla.name);
hm.push(";");
hm.push("\n");
}catch(e){}
hm.push("import java.math.*;");
hm.push("\n");
hm.push("import java.util.*;");
hm.push("\n");
hm.push("import javax.persistence.*;");
hm.push("\n");
//添加注释
hm.push("/**");
hm.push("\n");
hm.push(" *");
hm.push(" <p>");
hm.push(entities[i].name);
hm.push(" </p>");
hm.push("\n");
hm.push(" *");
hm.push(" <p>");
hm.push(entities[i].descript);
hm.push(" </p>");
hm.push("\n");
hm.push(" *");
hm.push(" @author 张森( email:anole1982@gmail.com, qq:64248169)");
hm.push("\n");
hm.push(" *");
hm.push(" @since 2012-03-01");
hm.push("\n");
hm.push(" *");
hm.push(" @version v0.1");
hm.push("\n");
hm.push(" */\n");
//添加类注解
hm.push("@Entity");
hm.push("\n");
hm.push('@Table(name = "'+entities[i].code+'", uniqueConstraints = @UniqueConstraint(columnNames = "ID"))');
hm.push("\n");
hm.push('@Inheritance(strategy=InheritanceType.SINGLE_TABLE)');
hm.push("\n");
//添加类名
hm.push("public class ");
var cla=calculateName(entities[i].code);
hm.push(cla.name);
try{
var cla=calculateName(entityMap[entities[i].parent].code);
hm.push(" extends ");
hm.push(cla.name);
}catch(e){
}
hm.push(" {");
hm.push("\n");
//创建属性
hm.push(buildItemProperty(entities[i]));
var cla=calculateName(entities[i].code);
hm.push("}");
hm.push("\n");
var path;
if(entityMap[entities[i].parent].code=="FND_BASIC_NEXUS"){
path=$("#classPath").val()+"/"+cla.pkg+"/nexus/"+cla.name+".java";
}else{
path=$("#classPath").val()+"/"+cla.pkg+"/entity/"+cla.name+".java";
}
path=path.replace(/\//g,"\\\\");
writeFile(hm.join(""),path);
hq.push("<textarea style='width:100%;height:300px'>"+hm.join("")+"</textarea>");
}
$("#models").html(hq.join(""));
};
//解析类
var createDatabaseTable=function(){
var hm=[];
for(var i=0;i<entityCount;i++){
if(entities[i].code=="FND_BASIC_ENTITY" ||
entities[i].code=="FND_BASIC_OBJECT" ||
entities[i].code=="FND_BASIC_NEXUS")continue;
hm.push("<div id='entity' align=center x:publishsource='Excel'>");
hm.push("<table border=0 cellpadding=0 cellspacing=0 style='border-collapse:");
hm.push("collapse;table-layout:fixed;width:574pt'>");
hm.push("<col width=101 style='mso-width-source:userset;mso-width-alt:3232;width:76pt'>");
hm.push("<col width=113 style='mso-width-source:userset;mso-width-alt:3616;width:85pt'>");
hm.push("<col width=83 style='mso-width-source:userset;mso-width-alt:2656;width:62pt'>");
hm.push("<col width=77 style='mso-width-source:userset;mso-width-alt:2464;width:58pt'>");
hm.push("<col width=60 style='mso-width-source:userset;mso-width-alt:2464;width:58pt'>");
hm.push("<col width=390 style='mso-width-source:userset;mso-width-alt:12480;width:293pt'>");
hm.push("<thead>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=title width=101 style='height:14.25pt;width:76pt'>对象名:</td>");
hm.push("<td colspan=5 class=content width=663 style='border-right:.5pt solid black;");
hm.push("width:498pt'>");
hm.push(entities[i].name);
hm.push("</td>");
hm.push("</tr>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=title style='height:14.25pt;border-top:none'>代码:</td>");
hm.push(" <td colspan=5 class=content style='border-right:.5pt solid black'>");
hm.push(entities[i].code);
hm.push("</td>");
hm.push("</tr>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=title style='height:14.25pt;border-top:none'>主键:</td>");
hm.push("<td colspan=5 class=content style='border-right:.5pt solid black'>");
try{
hm.push(entities[i].pk);
}catch(e){
hm.push(" ");
}
hm.push("</td>");
hm.push("</tr>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=title style='height:14.25pt;border-top:none'>描述:</td>");
hm.push("<td colspan=5 class=content style='border-right:.5pt solid black'>");
hm.push(entities[i].descript);
hm.push("</td>");
hm.push("</tr>");
hm.push("<tr height=19 style='mso-height-source:userset;height:14.25pt'>");
hm.push("<td height=19 class=header width=101 style='height:14.25pt;border-top:");
hm.push("none;width:76pt'>字段名称</td>");
hm.push("<td class=header width=113 style='border-top:none;border-left:none;");
hm.push("width:85pt'>字段代码</td>");
hm.push("<td class=header width=83 style='border-top:none;border-left:none;");
hm.push("width:62pt'>数据类型</td>");
hm.push("<td class=header width=77 style='border-top:none;border-left:none;");
hm.push("width:58pt'>数据长度</td>");
hm.push("<td class=header width=60 style='border-top:none;border-left:none;");
hm.push("width:58pt'>必须字段</td>");
hm.push("<td class=header width=390 style='border-top:none;border-left:none;");
hm.push("width:293pt'>字段备注</td>");
hm.push("</tr>");
hm.push("</thead>");
hm.push("<tbody class='field'>");
hm.push(buildItemCascade(entities[i]));
hm.push("</tbody>");
hm.push("</table>");
hm.push("</div>");
}
$("#tables").html(hm.join(""));
};
var createDataBaseScript=function(){
var hm=[];
for(var i=0;i<entityCount;i++){
hm.push(entities[i].name);
hm.push(entities[i].code);
try{
hm.push(entities[i].pk);
}catch(e){
hm.push(" ");
}
hm.push(entities[i].descript);
hm.push(buildItemCascade(entities[i]));
}
$("#sqlstrs").html(hm.join(""));
};
var readFile=function(path) {
var content = "";
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var reader = fso.openTextFile(path, 1);
while(!reader.AtEndofStream) {
content += reader.readline();
content += "\n";
}
// close the reader
reader.close();
}catch(e){
if(document.implementation && document.implementation.createDocument){
try {
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
var lf = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
lf.initWithPath(path);
if (lf.exists() == false) {
alert("File does not exist");
}
var fis = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream);
fis.init(lf, 0x01, 00004, null);
var sis = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream);
sis.init(fis);
var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
content = converter.ConvertToUnicode(sis.read(sis.available()));
converter.charset = "UTF-8";
//converter.charset = "GB2312";
}
catch (e) {
alert("Mozilla Firefox read local file error: \n" + e);
}
}
}
return content;
};
var writeFile=function(arrstr,path){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fh = fso.CreateTextFile(path, true);
fh.WriteLine(arrstr);
fh.Close();
}catch(e){
try {
var pm = netscape.security.PrivilegeManager;
pm.enablePrivilege('UniversalXPConnect');
}catch(e)
{
alert("!!被浏览器拒绝!\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
}
var file = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
if(file instanceof Components.interfaces.nsILocalFile)
{
file.initWithPath(path);
}else
{
alert("error");
return;
}
var outputStream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream);
var converter = Components.classes["@mozilla.org/intl/converter-output-stream;1"].createInstance(Components.interfaces.nsIConverterOutputStream);
try
{
outputStream.init(file, 0x02 | 0x08 | 0x20, 0666, 0);
}catch(e){
alert(e);
alert(path);
alert(arrstr);
}
converter.init(outputStream, "UTF-8", 0, 0);
try
{
converter.writeString(arrstr);
}catch(e){
alert(e);
alert(path);
alert(arrstr);
};
converter.close();
}
};
$("#modelContent").click(function(){createEntityTable();});
$("#createTable").click(function(){createDatabaseTable();});
$("#createEntity").click(function(){createEntityModel();});
$("#createSql").click(function(){createDataBaseScript();});
});
</script>
</head>
<body>
<div id="handle">
<div>
<label for="packageName">包名:</label><input type="text" style="width:800px" name="packageName" id="packageName" value="com.chameleon.structure.solution"/>
</div>
<div>
<label for="classPath">路径:</label><input type="text" style="width:800px" name="classPath" id="classPath" value="E:/textbook/mis/01.code/structure/src/main/java/com/chameleon/structure/solution"/>
</div>
<input type="button" id="modelContent" value="加载模型"/>
<input type="button" id="createEntity" value="生成实体代码"/>
<input type="button" id="createTable" value="生成表结构"/>
<input type="button" id="createSql" value="生成SQL语句"/>
<input type="button" id="createAction" value="生成Action类">
<input type="button" id="createValidte" value="生成javascript验证"/>
<input type="button" id="createI18n" value="生成国际化配置文件"/>
</div>
<div id="entities" align=center x:publishsource="Excel"></div>
<hr/>
<div id="models" align=center x:publishsource="Excel">
</div>
<hr/>
<div id="tables" align=center x:publishsource="Excel"></div>
<hr/>
<div id="sqlstrs"></div>
<hr/>
<div id="actions"></div>
<hr/>
<div id="javascripts"></div>
<hr/>
<div id="i18n"></div>
</body>
</html>