ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
package com.vci.client.portal.custom;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
 
import com.vci.omd.constants.FileObjectType;
import com.vci.omd.utils.ObjectTool;
import com.vci.client.portal.custom.CommonFileUI;
import com.vci.client.portal.custom.ICommonFileUI;
import com.vci.client.portal.custom.ICustomDefine;
import com.vci.client.portal.utility.PRMItem;
import com.vci.corba.common.VCIError;
import com.vci.corba.omd.data.BusinessObject;
 
public class CustomFileInterceptor implements ICustomDefine{
 
    @Override
    public void getCustomValue(String key, Map<String, PRMItem> customMap, List<Map<String, String>> datas) throws VCIError {
        Iterator<String> itor = customMap.keySet().iterator();
        while (itor.hasNext()) {
            String ckey = itor.next();
            PRMItem prm = customMap.get(ckey);
            String fieldType = prm.getItemType();
            List<String> fileIds = new ArrayList<String>();
            for (Map<String, String> data : datas) {
                String value = data.get(ckey);
                if (value == null || value.trim().equals("")) {
                    continue;
                }
                fileIds.add(value);
            }
            ICommonFileUI fileUI = new CommonFileUI();
            BusinessObject[] bos = fileUI.getMultiObjectFiles((String[]) fileIds
                    .toArray(new String[0]));
            Map<String, List<BusinessObject>> idsMap = new HashMap<String, List<BusinessObject>>();
            for (BusinessObject bo : bos) {
                String fileId = ObjectTool.getBOAttributeValue(bo, FileObjectType.SELECT_DOCUMENT_ID);
                List<BusinessObject> idList = idsMap.get(fileId);
                if (idList == null) {
                    idList = new ArrayList<BusinessObject>();
                }
                idList.add(bo);
                idsMap.put(fileId, idList);
            }
            for (Map<String, String> data : datas) {
                String value = data.get(ckey);
                if (value == null || value.trim().equals("")) {
                    data.put(fieldType + ":" + ckey.toLowerCase(), "");
                    continue;
                }
                List<BusinessObject> idList = idsMap.get(value);
                if (idList == null || idList.size() == 0) {
                    data.put(fieldType + ":" + ckey.toLowerCase(), "");
                    continue;
                }
                StringBuffer idBuffer = new StringBuffer();
                for (int i = 0; i < bos.length; ++i) {
                    if (i != 0) {
                        idBuffer.append(",");
                    }
                    idBuffer.append(bos[i].oid).append(":").append(bos[i].name);
                }
                data.put(fieldType + ":" + ckey.toLowerCase(), idBuffer.toString());
            }
        }
    }
 
}