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
/**
 * 
 */
package com.vci.client.framework.delegate;
 
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
 
import com.vci.corba.common.VCIError;
import com.vci.corba.workflow.data.QueryParamInfo;
import com.vci.corba.common.data.UserEntityInfo;
import com.vci.client.common.objects.UserEntityObject;
import com.vci.client.ui.exception.VCIException;
import com.vci.common.objects.QueryParam;
 
/**
 * 客户端登录的用户信息转换
 * @author 刘迪
 *
 */
public class ClientBaseDelegate  implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = -6808139609741384733L;
    protected UserEntityObject userEntityObject;
    protected UserEntityInfo userEntityInfo;
    
    public ClientBaseDelegate() {
        
    }
    
    public ClientBaseDelegate(UserEntityObject userEntityObject){
        this.userEntityObject = userEntityObject;
        this.userEntityInfo = UserEntityClientDelegate.changeUserEntityToInfo(userEntityObject);
    }
    public UserEntityObject getUserEntityObject() {
        return userEntityObject;
    }
    public void setUserEntityObject(UserEntityObject userEntityObject) {
        this.userEntityObject = userEntityObject;
        this.userEntityInfo = UserEntityClientDelegate.changeUserEntityToInfo(userEntityObject);
    }
    public void setUserEntityInfo(UserEntityInfo userEntityInfo) {
        this.userEntityInfo = userEntityInfo;
    }
    public UserEntityInfo getUserEntityInfo(){
        return this.userEntityInfo;
    }
    
    public final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";
    private SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT);
    private String defaultDateString = "1977-01-01 00:00:00";
    
    public final String DATE_FORMAT_OLD = "yyyyMMdd HH:mm:ss";
    private SimpleDateFormat sdf_old = new SimpleDateFormat(DATE_FORMAT_OLD);
 
    public String getStringFromDate(Date date){
        String res = defaultDateString;
        try{
            if(date != null){
                res = sdf.format(date);
            }
        }catch(Exception ex){
            ex.printStackTrace();
        }
        return res;
    }
    public Date getDateFromString(String string){
        Date res = new Date();
        try {
            res = sdf.parse(defaultDateString);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        try{
            res = sdf.parse(string);
        }catch(Exception ex){
            try{
                res = sdf_old.parse(string);
            } catch (Exception ex1){
                ex1.printStackTrace();
            }
        }
        return res;
    }
    
    /**
     * 
     * <p>Description: 将Corba的异常转换为客户端异常</p>
     * 
     * @author Administrator
     * @time 2011-7-18
     * @param e
     * @return
     */
    public VCIException convertVCIErrorToVCIException(VCIError e) {
        return new VCIException(String.valueOf(e.code), e.messages);
    }
    
//    protected QueryParamInfo convertQueryParam(QueryParam obj){
//        QueryParamInfo info = new QueryParamInfo();
//        info.customQueryString = obj.getCustomQueryString();
//        info.pageIndex = obj.getPageIndex();
//        info.pageSize = obj.getPageSize();
//        return info;
//    }
//    protected QueryParam convertQueryParam(QueryParamInfo info){
//        QueryParam obj = new QueryParam();
//        obj.setCustomQueryString(info.customQueryString);
//        obj.setPageIndex(info.pageIndex);
//        obj.setPageSize(info.pageSize);
//        return obj;
//    }
}