田源
2024-03-07 4b4083fd73dc27ece42f4835483565eef0e4f608
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
156
package com.vci.client.omd.linktype.itf;
 
import java.util.ArrayList;
import java.util.List;
 
import com.vci.client.omd.attribpool.ui.APClient;
import com.vci.client.omd.linktype.LinkTypeStart;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.atm.AttribItem;
import com.vci.corba.omd.ltm.LinkType;
 
public class LinkTypeInterfaceImpl implements LinkTypeInterface {
    String[] allAttributes = null;
 
    @Override
    public String[] getDetailAttributesByLinkTypeName(String name) {
 
        // 获取系统属性
        String[] sysAttibutes = { "OID", "Creator", "CreateTime", "LastModifier", "LASTMODIFYTIME", "F_OID",
                "F_REVISIONOID", "F_NAMEOID", "F_BtwName", "T_OID", "T_REVISIONOID", "T_NAMEOID", "T_BtwName", "TS" };
        String[] nonAttibutes = null;
        List<String> list = new ArrayList<String>();
        LinkType[] linkTypes;
 
        linkTypes = getLinkTypes();
        for (LinkType linkType : linkTypes) {
            if (linkType.name.equals(name)) {
                String[] attributes = linkType.attributes;
                for (String attrbute : attributes) {
                    list.add(attrbute);
                }
            }
        }
        nonAttibutes = list.toArray(new String[0]);
        allAttributes = arraycat(sysAttibutes, nonAttibutes);
 
        return allAttributes;
    }
 
    /**
     * 合并数组
     * 
     * @param dgc1
     * @param dgc2
     * @return
     */
    public String[] arraycat(String[] dgc1, String[] dgc2) {
        try {
            int len1 = 0;
            int len2 = 0;
            if (dgc1 != null)
                len1 = dgc1.length;
            if (dgc2 != null)
                len2 = dgc2.length;
            if (len1 + len2 > 0)
                allAttributes = new String[len1 + len2];
            if (len1 > 0)
                System.arraycopy(dgc1, 0, allAttributes, 0, len1);
            if (len2 > 0)
                System.arraycopy(dgc2, 0, allAttributes, len1, len2);
            return allAttributes;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
 
    @Override
    public String[] getSystemAttributes() {
        String[] sysAttibutes = { "OID", "Creator", "CreateTime", "LastModifier", "LASTMODIFYTIME", "F_OID",
                "F_REVISIONOID", "F_NAMEOID", "F_BtwName", "T_OID", "T_REVISIONOID", "T_NAMEOID", "T_BtwName", "TS" };
        return sysAttibutes;
    }
 
    @Override
    public AttribItem[] getNonSystemAttributesByLinkTypeName(String name) {
 
        try {
            com.vci.corba.omd.atm.AttribItem[] abItems = null;
            List<String> abNames = new ArrayList<String>();
            LinkType[] linkTypes = LinkTypeStart.getService().getLinkTypes();
            for (LinkType linkType : linkTypes) {
                if (linkType.name.equals(name)) {
                    String[] attributes = linkType.attributes;
                    for (String attribute : attributes) {
                        abNames.add(attribute);
                    }
                    abItems = APClient.getService().getAttribItemsByNames(abNames.toArray(new String[0]));
                }
            }
            return abItems;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new AttribItem[0];
    }
 
    @Override
    public LinkType getLinkTypeByName(String name) {
 
        LinkType[] linkTypes = getLinkTypes();
        for (LinkType linkType : linkTypes) {
            if (linkType.name.equals(name)) {
                return linkType;
            }
 
        }
        return null;
    }
 
    @Override
    public String getRelationByLtName(String ltName) {
 
        LinkType[] linkTypes = getLinkTypes();
        for (LinkType lt : linkTypes) {
            if (lt.name.equals(ltName)) {
                return lt.relation;
            }
        }
        return null;
    }
    
    private LinkType[] getLinkTypes() {
        try {
            return LinkTypeStart.getService().getLinkTypes();
        } catch (VCIError e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        
        return new LinkType[0];
    }
 
//    public String[] getNonSystemAttributesByLinkTypeName(String name) {
//        try {
//            String[] nonAttibutes = null;
//            List<String> list = new ArrayList<String>();
//            LinkType[] linkTypes = LinkTypeStart.getService().getLinkTypes();
//            for(LinkType linkType:linkTypes){
//                if(linkType.name.equals(name)){
//                    AttribItem[] attribItems = linkType.attribNameArray;
//                    for(AttribItem attrbute:attribItems){
//                        list.add(attrbute.name);
//                    }
//                }
//            }
//            nonAttibutes = list.toArray(new String[0]);
//            return nonAttibutes;
//        } catch (PlmLinkTypeError e) {
//            // TODO Auto-generated catch block
//            e.printStackTrace();
//        }
//        return null;
//    } 
 
}