📄 xmlfunctions.java
字号:
package com.icbcsdc.ddlexp.pub.xml.nodeinfo;
import java.io.InputStream;
import java.sql.CallableStatement;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import com.icbcsdc.ddlexp.pub.staticLog.Logger;
import com.icbcsdc.ddlexp.pub.connectionpool.JDBCCnn;
import com.icbcsdc.ddlexp.pub.connectionpool.JDBCException;
import com.icbcsdc.ddlexp.pub.connectionpool.JDBCPool;
import com.icbcsdc.ddlexp.pub.connectionpool.JDBCPoolManager;
/**
* @author zhangyc
*
* To change this generated comment edit the template variable "typecomment":
* Window>Preferences>Java>Templates.
* To enable and disable the creation of type comments go to
* Window>Preferences>Java>Code Generation.
*/
public class XMLFunctions extends XMLNode {
public static String NAME="Functions";
//String sqlFunctions = "select name,line,text from DBA_SOURCE where type='FUNCTION' and owner=? order by name,line";
String sqlFunctions = "select name, MAX(LINE) from DBA_SOURCE where type='FUNCTION' and owner=? GROUP BY NAME";
String sqlFunctionsWrapped = "select name from DBA_SOURCE where type='FUNCTION' and line=1 and owner=? and text like '% wrapped%'";
String crComparedFunctions="SELECT SRC_FUNCTION_NAME,ATTR_NAME,SRC_ATTR_VALUE,DST_FUNCTION_NAME FROM COMPARE_FUNCTIONS WHERE SRC_OWNER=? AND ATTR_NAME='MYSTYLE'";
String upComparedFunctions="SELECT SRC_FUNCTION_NAME,ATTR_NAME,SRC_ATTR_VALUE,DST_ATTR_VALUE FROM COMPARE_FUNCTIONS WHERE SRC_OWNER=? AND ATTR_NAME<>'MYSTYLE'";
private String text = "";
private String funName = "";
//private boolean wrapped = false;
/**
* Constructor for XMLManager.
*/
public XMLFunctions() {
super();
this.name=NAME;
// this.setParent(null);
}
/**
* @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#getType()
*/
public int getType() {
return XMLNode.XML_FUNCTIONS;
}
/**从数据库中获取数据对象比较后的结果*/
public void refreshChangedProperties()throws Exception{
JDBCPool cnn=null;
//try {
//XMLManager.getInstance().
XMLDatabase db=this.getDatabase();
if(db!=null) cnn = db.getConnPool();
else return;
//先创建比较节点
PreparedStatement pStmt=cnn.prepareStatement(crComparedFunctions);
pStmt.setString(1,this.getSchema().getName().toUpperCase());
//pStmt.setString(2,this.getParent().getName().toUpperCase());
ResultSet rsCrFunctions=pStmt.executeQuery();
while(rsCrFunctions.next()){
XMLFunction function=null;
byte status=XMLNode.toCompareStatus(rsCrFunctions.getString("SRC_ATTR_VALUE"));
if(status==XMLNode.SRC_NULL_DST_EXIST)
function=new XMLFunction(rsCrFunctions.getString("DST_FUNCTION_NAME"));
else
function=new XMLFunction(rsCrFunctions.getString("SRC_FUNCTION_NAME"));
function.setCompareStatus(status);
this.addChild(function);
}
rsCrFunctions.close();
//再修改比较节点
pStmt=cnn.prepareStatement(upComparedFunctions);
pStmt.setString(1,this.getSchema().getName().toUpperCase());
ResultSet rsUpFunctions=pStmt.executeQuery();
while(rsUpFunctions.next()){
XMLFunction constaint1=(XMLFunction)this.getDirectChildren(XMLNode.XML_FUNCTION,rsUpFunctions.getString("SRC_FUNCTION_NAME"));
constaint1.putChangedProperty(rsUpFunctions.getString("ATTR_NAME"),rsUpFunctions.getString("SRC_ATTR_VALUE"),rsUpFunctions.getString("DST_ATTR_VALUE"));
}
rsUpFunctions.close();
pStmt.close();
}
/**从数据库中获取数据对象定义*/
public void refreshDDLInfo()throws Exception{
JDBCPool cnn=null;
XMLDatabase db=this.getDatabase();
if(db!=null)
cnn = db.getConnPool();
else return;
/**
if(db.getVersion() == XMLDatabase.VERSION_ORACLE8I){
String sqlGenDDL = "BEGIN GEN_FUNC_DDL(?); END;";
CallableStatement cStmt = cnn.prepareCall(sqlGenDDL);
cStmt.setString(1,this.getSchema().name);
cStmt.execute();
}**/
//获取Function列表
PreparedStatement pStmt=cnn.prepareStatement(this.sqlFunctions);
pStmt.setString(1,this.getParent().getParent().getName().toUpperCase());
ResultSet rsFunctions=pStmt.executeQuery();
while(rsFunctions.next()){
XMLFunction function=new XMLFunction(rsFunctions.getString(1).trim());
if(rsFunctions.getInt(2)>XMLNode.MAX_SOURCE_LINES)
function.setOverflow(true);
this.addChild(function);
}
rsFunctions.close();
pStmt.close();
PreparedStatement pStmt1=cnn.prepareStatement(this.sqlFunctions);
pStmt1.setString(1,this.getParent().getParent().getName().toUpperCase());
ResultSet rsFunctionsWrapped=pStmt1.executeQuery();
while(rsFunctionsWrapped.next()){
XMLFunction function=(XMLFunction)this.getDirectChildren(XMLNode.XML_FUNCTION,rsFunctionsWrapped.getString(1).trim());
function.setWrapped(true);
}
rsFunctionsWrapped.close();
pStmt1.close();
}
/**
* @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#refresh()
*/
public void refresh() throws Exception{
refreshNodeNeedAccessDB();
super.refresh();
}
/**
* @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#chkChildType(XMLNode)
*/
public boolean chkChildType(XMLNode node) {
if(node.getType()==XMLNode.XML_FUNCTION) return true;
return false;
}
/**
* @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#getXmlStream()
public InputStream getXmlStream() {
return null;
}
*/
/**
* @see com.icbcsdc.ddlexp.pub.xml.nodeinfo.XMLNode#getSqlDDL()
*/
public String getSqlDDL() {
return null;
}
public static void main(String[] args) {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -