ludc
2024-09-14 36c2449aec5b51e5ed4e5c6841154b746060e09a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
package com.vci.client.omd.inter.impl;
 
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
 
import com.vci.corba.omd.atm.AttribItem;
import com.vci.corba.omd.ltm.LinkType;
import com.vci.client.omd.attribpool.ui.APClient;
import com.vci.client.omd.linktype.LinkTypeStart;
import com.vci.client.omd.linktype.util.Tool;
import com.vci.corba.common.VCIError;
 
/**
 * 实现属性池提供的接口, 实现属性池的查看使用范围功能
 * @author Administrator
 *
 */
public class InterAPForLTImpl implements InterAPForLinkType{
    
    /**
     * 返回使用指定属性的业务类型名列表
     */
    @Override
    public ArrayList<String> getUsedNameList(String abItemName){
        String[] ltNameArray = null;
        try {
            ltNameArray = LinkTypeStart.getService().getLTNamesByAPName(abItemName);
        } catch (VCIError e) {
            e.printStackTrace();
        }
        return convertArrayToList(ltNameArray);
    }
 
    /**
     * 
     * @param objArray
     * @return
     */
    private ArrayList<String> convertArrayToList(String[] objArray){
        if(objArray == null){
            return null;
        }
        ArrayList<String> objList = new ArrayList<String>();
        for(int i = 0; i < objArray.length; i++){
            String obj = objArray[i];
            objList.add(obj);
        }
        return objList;
    }
 
 
    /**
     * 修改属性, 对应的修改业务类型和链接类型中该属性字段
     */
    @Override
    public boolean alterAp(String apName) {
        String[] ltNames = null;
        ArrayList<String> ltNameList = new ArrayList<String>();
        AttribItem abItem = null;
        try {
            abItem = APClient.getService().getAttribItemByName(apName);
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if(abItem == null || abItem.equals("")){
            return true;
        }
        try {
            ltNames = LinkTypeStart.getService().getLTNamesByAPName(apName);
        } catch (VCIError e) {
            e.printStackTrace();
        }
        if(ltNames == null || ltNames.length <= 0){
            return true;
        }
        String abSql = Tool.getInstance().getAbSql(abItem);
        abSql = abSql.substring(0, abSql.lastIndexOf(","));
        ltNameList = Tool.getInstance().convertArrayToList(ltNames);
        for(Iterator<String> i = ltNameList.iterator(); i.hasNext();){
            String linkName = i.next();
            
            try {
                boolean success = LinkTypeStart.getService().modifyLTAttribute(linkName, apName);
                if (!success)
                    return false;
                
            } catch (VCIError e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
//            String sql = "alter table " + OmdTools.getLTTableName(linkName) + " modify( " + abSql + " )";
//            DDLToolClient.getService().executeUpdateOracle(sql);
//            DDLToolClient.getService().alterTableDDLOracle(sql + ";");
        }
        
        return true;
    }
 
    /**
     * 判断在业务类型和连接类型中, 该属性是否已生成数据
     * 当使用该属性的业务类型有数据, 即判定该属性有数据
     */
    @Override
    public boolean hasInstance(String apName) {
        String[] ltNames = null;
        try {
            ltNames = LinkTypeStart.getService().getLTNamesByAPName(apName);
        } catch (VCIError e) {
            e.printStackTrace();
        }
        
        if(ltNames == null || ltNames.length == 0){
            return false;
        }
        
        for(int i = 0; i < ltNames.length; i++){
            String ltName = ltNames[i];
            
            boolean flag;
            try {
                flag = LinkTypeStart.getService().hasData(ltName);
                if(flag){
                    return flag;
                }
            } catch (VCIError e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            //boolean flag = DDLToolClient.getService().hasInstanceOralce(ltName);
        }
        
        return false;
    }
 
    /**
     * 返回所有的链接类型名
     */
    @Override
    public List<String> getAllLtName() {
        try {
            LinkType[] objs = LinkTypeStart.getService().getLinkTypes();
            List<String> list = new ArrayList<String>();
            for(LinkType obj : objs){
                list.add(obj.name);
            }
            return list;
        } catch (VCIError e) {
            e.printStackTrace();
        }
        return null;
    }
    
}