98 lines
1.8 KiB
Markdown
98 lines
1.8 KiB
Markdown
|
```xscript
|
||
|
|
||
|
var useDataTypeAsName = false;
|
||
|
var useExistDomains = true;
|
||
|
var showReport = true;
|
||
|
var encoding = "EUC_KR";
|
||
|
|
||
|
var updateCnt = 0;
|
||
|
|
||
|
var domainMap = newMap();
|
||
|
var newDomains = newSet();
|
||
|
|
||
|
plugins.addGetter("cname", function(it){
|
||
|
return it.get("name")
|
||
|
});
|
||
|
|
||
|
|
||
|
|
||
|
var logFile = newFile("domain-reverse.log", encoding);
|
||
|
|
||
|
|
||
|
console.setLogFile(logFile, true);
|
||
|
|
||
|
log(newDate());
|
||
|
|
||
|
if(useExistDomains){
|
||
|
select(function(it){
|
||
|
//log("type" + it.get("type"));
|
||
|
return it.get("type") == "domain";
|
||
|
}).each(function(it){
|
||
|
//log("data-type" + it.get("data-type"));
|
||
|
domainMap.put(it.get("cname"), it);
|
||
|
});
|
||
|
}
|
||
|
|
||
|
//log(domainMap);
|
||
|
|
||
|
var allColumns = select(function(it){
|
||
|
return it.get("type") == "column";
|
||
|
});
|
||
|
|
||
|
updateCnt = allColumns.size();
|
||
|
|
||
|
monitor.beginTask("컬럼 처리중", updateCnt);
|
||
|
logf("%-20s | %-20s | %-20s\n", "테이블", "컬럼", "지정된 도메인(* : 새로 생성)");
|
||
|
logf("==========================================================================\n")
|
||
|
|
||
|
|
||
|
allColumns.each(function(it){
|
||
|
|
||
|
var domain = domainMap.get(it.get("cname"));
|
||
|
var dataType = domainMap.get(it.get("data-type"));
|
||
|
var domainName;
|
||
|
//log("domain" + domain);
|
||
|
|
||
|
|
||
|
try{
|
||
|
|
||
|
it.set("domain", domain);
|
||
|
|
||
|
if(domain == null ){
|
||
|
updateCnt --;
|
||
|
|
||
|
it.set("data-type", it.get("data-type"));
|
||
|
domainName = "도메인List에 없음";
|
||
|
}else{
|
||
|
it.set("data-type", dataType);
|
||
|
domainName = domain.get("name")
|
||
|
}
|
||
|
|
||
|
}
|
||
|
catch(e){
|
||
|
log("e" + e);
|
||
|
}
|
||
|
|
||
|
logf(
|
||
|
"%-20s | %-20s | %-20s\n", it.get("table").get("name"),
|
||
|
it.get("name"),
|
||
|
domainName
|
||
|
);
|
||
|
|
||
|
monitor.worked(1);
|
||
|
if(monitor.isCanceled()){
|
||
|
exit();
|
||
|
}
|
||
|
});
|
||
|
logf("==========================================================================\n")
|
||
|
logf("%d 개의 도메인이 업데이트 되었습니다.\n", updateCnt);
|
||
|
|
||
|
monitor.done();
|
||
|
|
||
|
views.showDomainView();
|
||
|
|
||
|
if(showReport){
|
||
|
logFile.openInEditor();
|
||
|
}
|
||
|
|
||
|
```
|