dangsn
2024-12-26 4e9ff2ce6a830bb2340d7c8612c72eea0c5a553e
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
 
package com.vci.client.framework.delegate;
 
import com.vci.client.ClientSession;
import com.vci.client.common.objects.UserEntityObject;
import com.vci.client.common.providers.ServiceProvider;
import com.vci.client.framework.systemConfig.volumn.object.PvolumeObject;
import com.vci.client.ui.exception.VCIException;
import com.vci.corba.common.VCIError;
import com.vci.corba.framework.data.PvolumeInfo;
 
/**
 * 卷ClientDelegateo
 * @author wangxl
 *
 */
public class PvolumeClientDelegate extends ClientBaseDelegate{
 
    public PvolumeClientDelegate(UserEntityObject userEntityObject) {
        super(userEntityObject);
    }
 
    /**
     * 添加卷
     * @param pvolumeObject
     * @param userEntityObject
     * @return
     * @throws VCIError
     */
    public String savePvolume(PvolumeObject pvolumeObject) throws VCIException{
        String id = "";
        try {
            PvolumeInfo pvolumeInfo = changePvolumeObjectToPvolumeInfo(pvolumeObject);    
            id= ServiceProvider.getFrameService().savePvolume(pvolumeInfo, userEntityInfo);
        } catch ( VCIError e) {
            throw convertVCIErrorToVCIException(e);
        }
        return id;
    }
    
    /**
     * 查询所有的卷数目
     * @return
     * @throws VCIError
     */
    public PvolumeObject[] getAllPvolumes() throws VCIException {
        PvolumeObject[] pvolumeObjs = {};
        try {
            PvolumeInfo[] pvoInfos = ServiceProvider.getFrameService().getAllPvolumes();
            int len = pvoInfos.length;
            pvolumeObjs = new PvolumeObject[len];
            for (int i = 0; i < len; i++) {
                pvolumeObjs[i] = tranferCorbaObjToPvolume(pvoInfos[i]);
            }
        } catch ( VCIError e) {
            throw convertVCIErrorToVCIException(e);
        }
 
        return pvolumeObjs;
    }
    
    /**
     * 分页查询卷
     * <p>Description: </p>
     * 
     * @author llb
     * @time 2013-1-3
     * @param pageSize
     * @param pageIndex
     * @return
     * @throws VCIException
     */
    public PvolumeObject[] getPvolumesPage(short pageSize, short pageIndex) throws VCIException {
        PvolumeObject[] pvolumeObjs = {};
        try {
            PvolumeInfo[] pvoInfos = ServiceProvider.getFrameService().getPvolumesPage(pageSize, pageIndex);
            int len = pvoInfos.length;
            pvolumeObjs = new PvolumeObject[len];
            for (int i = 0; i < len; i++) {
                pvolumeObjs[i] = tranferCorbaObjToPvolume(pvoInfos[i]);
            }
        } catch ( VCIError e) {
            throw convertVCIErrorToVCIException(e);
        }
 
        return pvolumeObjs;
    }
    /**
     * 获得指定文档所在的卷
     * @param id, 文档所在文件发放区的id
     * @return
     * @throws VCIError
     */
//    public PvolumeObject getDocumentVolumn(String id) throws VCIException {
//        PvolumeObject pvolumeObj = null;
//        try {
//            PvolumeInfo pvoInfo = ServiceProvider.getFrameService().getDocumentVolume(id);
//            pvolumeObj = tranferCorbaObjToPvolume(pvoInfo);
//        } catch ( VCIError e) {
//            throw convertVCIErrorToVCIException(e);
//        }
//        return pvolumeObj;
//    }
    
    /**
     * 修改卷
     * @param pvoObject
     * @param userEntityObj
     * @return
     * @throws VCIError
     */
    public boolean updatePvolume(PvolumeObject pvoObject) throws VCIException {
        boolean rs = false;
        try {
            PvolumeInfo pvoInfo = changePvolumeObjectToPvolumeInfo(pvoObject);
            rs = ServiceProvider.getFrameService().updatePvolume(pvoInfo, userEntityInfo);
        } catch ( VCIError e) {
            throw convertVCIErrorToVCIException(e);
        }
        return rs;
        
    }
    /**
     * 删除卷
     * @throws VCIException 
     */
    public boolean deletePvolume(String[] ids) throws VCIException{
        boolean rs = false;
        try {
            rs = ServiceProvider.getFrameService().deletePvolume(ids, userEntityInfo);
        } catch ( VCIError e) {
            throw convertVCIErrorToVCIException(e);
        }
        return rs;
    }
    
    /**
     * 将其他卷设置为非首选卷 0
     * @throws VCIError
     */
    public void updatePvolumeInvalid() throws VCIException {
        try{
            ServiceProvider.getFrameService().updatePvolumeInvalid(userEntityInfo);
        } catch ( VCIError e) {
            throw convertVCIErrorToVCIException(e);
        }
    }
    
    /**
     * 查看卷是否被引用
     * @param ids
     * @return
     * @throws VCIError
     */
//    public int fetchVolumnInfoByIds(String id) throws VCIException {
//        int count = 0;
//        try{
//            count = ServiceProvider.getFrameService().fetchVolumeInfoByIds(id);
//        } catch ( VCIError e) {
//            throw convertVCIErrorToVCIException(e);
//        }
//        return (int)count;
//    }
//    
    public boolean checkDelIsvalid(String id ) throws VCIException {
        boolean isValid = false;
        try{
            isValid = ServiceProvider.getFrameService().checkIsvalid(id);
 
        } catch ( VCIError e) {
            throw convertVCIErrorToVCIException(e);
        }
        return isValid;
    }
    
    /**
     * 获取当前首选卷
     * <p>Description: </p>
     * @author xchao
     * @time 2013-8-6
     * @return
     * @throws VCIException
     */
    public PvolumeObject getIsvalidVolumeName()throws VCIException{
        PvolumeInfo  info =null;
        try {
             info =  ServiceProvider.getFrameService().getDefaultVolume();
        } catch ( VCIError e) {
            throw convertVCIErrorToVCIException(e);
        }
        return this.tranferCorbaObjToPvolume(info);
    }
 
    /**
     * 返回一个在服务器端有效的卷对象
     * <p>此卷对象只有卷路径值,其它值均为空,其卷路径值是 ${user.dir}\attachments\</p>
     * <p>其中${user.dir}将用System.getProperty("user.dir")的值替换</p>
     * <p>Description: </p>
     * @author xchao
     * @time 2013-8-6
     * @return
     * @throws VCIException
     */
//    public PvolumeObject getIsvalidVolumeNameInServerEnv()throws VCIException{
//        PvolumeInfo  info =null;
//        try {
//             info =  ServiceProvider.getFrameService().getIsvalidVolumeNameInServerEnv();
//        } catch ( VCIError e) {
//            throw convertVCIErrorToVCIException(e);
//        }
//        return this.tranferCorbaObjToPvolume(info);
//    }
    /***
     *   卷对象从客户端对象到corba对象
     * @param systemCfgObject
     * @return
     */
    private PvolumeInfo changePvolumeObjectToPvolumeInfo(PvolumeObject pvolumeObject) {
        PvolumeInfo pvolumeInfo = new PvolumeInfo();
        pvolumeInfo.id = pvolumeObject.getId() == null ?  "" : pvolumeObject.getId();
        pvolumeInfo.name = pvolumeObject.getName() == null ? "" : pvolumeObject.getName();
        pvolumeInfo.host = pvolumeObject.getHost() == null ? "" : pvolumeObject.getHost();
        pvolumeInfo.service = pvolumeObject.getService() == null ? "" : pvolumeObject.getService();
        pvolumeInfo.type = pvolumeObject.getType();
        pvolumeInfo.path = pvolumeObject.getPath() == null ? "" : pvolumeObject.getPath(); 
        pvolumeInfo.isvalid = pvolumeObject.getIsvalid();
        return pvolumeInfo;
    }
    
    /**
     * 卷 从Corba端转到Hibernate对象端
     * @param pvoInfo
     * @return
     */
    private PvolumeObject tranferCorbaObjToPvolume(PvolumeInfo pvoInfo) {
        PvolumeObject obj = new PvolumeObject();
        obj.setId(pvoInfo.id);
        obj.setName(pvoInfo.name);
        obj.setHost(pvoInfo.host);
        obj.setService(pvoInfo.service);
        obj.setType(pvoInfo.type);
        obj.setPath(pvoInfo.path);
        obj.setIsvalid(pvoInfo.isvalid);
        return obj;
    }
}