|
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;
|
}
|
}
|