ludc
2024-04-08 bcb1aaaadad892fe02e4de9a1fdb10cb99fea9bc
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package com.vci.web.util;
 
import com.vci.corba.logon.method.LogonFactory;
import com.vci.corba.logon.method.LogonFactoryHelper;
import com.vci.corba.volumn.method.VolumnFactory;
import com.vci.corba.volumn.method.VolumnFactoryHelper;
import com.vci.starter.corba.connector.JacorbClientConnector;
import com.vci.starter.web.exception.VciBaseException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import plm.bs.bom.common.BOFactoryService;
import plm.bs.bom.common.BOFactoryServiceHelper;
import plm.corba.attribpool.AttPoolServiceHelper;
import plm.corba.attribpool.AttPoolServiceOperations;
import plm.corba.btm.BTMServiceHelper;
import plm.corba.btm.BTMServiceOperations;
import plm.corba.enumManager.EnumServiceHelper;
import plm.corba.enumManager.EnumServiceOperations;
import plm.corba.lifecycle.LifeCyleServiceHelper;
import plm.corba.lifecycle.LifeCyleServiceOperations;
import plm.corba.linkTypeManager.LinkTypeServiceHelper;
import plm.corba.linkTypeManager.LinkTypeServiceOperations;
import plm.corba.portal.PortalServiceHelper;
import plm.corba.portal.PortalServiceOperations;
import plm.corba.qt.QTServiceHelper;
import plm.corba.qt.QTServiceOperations;
import plm.corba.statePoolManager.StatePoolServiceHelper;
import plm.corba.statePoolManager.StatePoolServiceOperations;
import plm.corba.versionRuleManager.VersionRuleServiceHelper;
import plm.corba.versionRuleManager.VersionRuleServiceOperations;
 
/**
 * 平台的客户端调用工具类
 * @author weidy
 * @date 2021-2-14
 */
@Component
public class PlatformClientUtil {
 
    /**
     * 业务类型工厂的服务
     */
    private static final String BO_FACTORY_SERVICE_NAME = "bofFactoryService";
 
    /**
     * 登录服务
     */
    public static final String LOGON_FACTORY_SERVICE_NAME = "LogonFactoryService";
 
    /**
     * 状态池服务名字
     */
    public static final String STATE_POOL_SERVICE_NAME = "statePoolService";
 
    /**
     * 生命周期服务
     */
    public static final String LIFE_CYCLE_SERVICE_NAME = "lifeCycleService";
 
    /**
     * 枚举的服务
     */
    public static final String ENUM_SERVICE_NAME = "enumService";
 
    /**
     * 版本规则的服务
     */
    private static final String VERSION_SERVICE_NAME = "versionRuleService";
 
    /**
     * 属性的服务
     */
    private static final String ATTRIBUTE_SERVICE_NAME = "apService";
 
    /**
     * 业务类型的服务
     */
    private static final String BTM_SERVICE_NAME = "btmService";
 
    /**
     * 链接类型的服务
     */
    public static final String LINK_SERVICE_NAME = "linkTypeService";
    /**
     * UI上下文服务
     */
    private static final String PORTAL_SERVICE_NAME = "portalService";
    /**
     * 查询服务
     */
    private static final String QUERY_SERVICE_NAME = "qtService";
 
    /**
    * corba的客户端调用
    */
    @Autowired
    private JacorbClientConnector jacorbClientConnector;
 
    /**
     * 获取业务类型工厂的服务
     * @return 服务的对象
     */
    public BOFactoryService getBOFactoryService(){
       return BOFactoryServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(BO_FACTORY_SERVICE_NAME));
    }
 
    /**
     * 获取登录主服务
     * @return 服务的对象
     */
    public LogonFactory getLogonFactoryService(){
        return LogonFactoryHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(LOGON_FACTORY_SERVICE_NAME));
    }
 
    /**
     * 获取状态池的服务
     * @return 服务的对象
     */
    public StatePoolServiceOperations getStatePoolService(){
        return StatePoolServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(STATE_POOL_SERVICE_NAME));
    }
 
    /**
     * 获取生命周期的服务
     * @return 生命周期的服务对象
     */
    public LifeCyleServiceOperations getLifeCycleService(){
        return LifeCyleServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(LIFE_CYCLE_SERVICE_NAME));
    }
 
    /**
     * 获取枚举的服务
     * @return 枚举的服务对象
     */
    public EnumServiceOperations getEnumService(){
        return EnumServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(ENUM_SERVICE_NAME));
    }
 
    /**
     * 获取版本规则的服务
     * @return 版本规则的服务
     */
    public VersionRuleServiceOperations getVersionService(){
        return VersionRuleServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(VERSION_SERVICE_NAME));
    }
 
    /**
     * 属性服务
     * @return 服务的对象
     */
    public AttPoolServiceOperations getAttributeService(){
        return AttPoolServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(ATTRIBUTE_SERVICE_NAME));
    }
 
    /**
     * 获取业务类型
     * @return 服务的对象
     */
    public BTMServiceOperations getBtmService(){
        return BTMServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(BTM_SERVICE_NAME));
    }
 
    /**
     * 获取链接类型
     * @return 服务的对象
     */
    public LinkTypeServiceOperations getLinkTypeService(){
        return LinkTypeServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(LINK_SERVICE_NAME));
    }
 
    /**
     * 获取UI上下文服务
     * @return 服务的对象
     */
    public PortalServiceOperations getPortalService(){
        return PortalServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(PORTAL_SERVICE_NAME));
    }
 
    /**
     * 获取查询服务
     * @return 服务的对象
     */
    public QTServiceOperations getQueryService(){
        return QTServiceHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByServiceName(QUERY_SERVICE_NAME));
    }
 
    /**
     * 卷服务
     * @param serverUrl 命名服务
     * @param volumeName 卷的名称
     * @return 卷服务的的对象
     */
    public VolumnFactory getVolumeService(String serverUrl,String volumeName){
        if(StringUtils.isNotBlank(serverUrl)){
            if(StringUtils.countMatches(serverUrl,":") < 2){
                throw new VciBaseException("卷服务的配置错误,需要主机名:端口:服务前缀这种形式");
            }
            String[] split = serverUrl.split(":");
            serverUrl = "corbaloc::" + split[0] + ":" +split[1] + "/NameService:" +split[2];
        }
        return VolumnFactoryHelper.narrow(jacorbClientConnector.getCorbaServiceObjectByUrlAndServiceName(serverUrl,volumeName));
    }
 
}