IT-KIMI_SHI\SINOIT.KIMI
2018-06-04 b12dfac6e495d6cf38df6b7e5222191f59762900
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
package frame.file;
 
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
public class IOMappingRuntime {
      
    private List<IOMappingItemRuntime> InsertMappingRuntimeList;
    private Map<String, IOMappingItemRuntime> InsertfromMap;
    private Map<String, IOMappingItemRuntime> InserttoMap;
    private List<IOMappingItemRuntime> UpdateMappingRuntimeList;
    private Map<String, IOMappingItemRuntime> UpdatefromMap;
    private Map<String, IOMappingItemRuntime> UpdatetoMap;
      
    public IOMappingRuntime(List<IOMappingItemRuntime> insertMappingRuntime, List<IOMappingItemRuntime> updateMappingRuntime) {
        InsertMappingRuntimeList = new ArrayList<IOMappingItemRuntime>();
        InsertfromMap = new HashMap<String, IOMappingItemRuntime>();
        InserttoMap = new HashMap<String, IOMappingItemRuntime>();
        UpdateMappingRuntimeList = new ArrayList<IOMappingItemRuntime>();
        UpdatefromMap = new HashMap<String, IOMappingItemRuntime>();
        UpdatetoMap = new HashMap<String, IOMappingItemRuntime>();
        
        for (IOMappingItemRuntime ioMappingItemRuntime : insertMappingRuntime) {
            addItem(ioMappingItemRuntime, "insert");
        }
        
        for (IOMappingItemRuntime ioMappingItemRuntime : updateMappingRuntime) {
            addItem(ioMappingItemRuntime, "update");
        }
    }
 
    private void addItem(IOMappingItemRuntime ioMappingItemRuntime, String type) {
        // base,add
        if ("insert".equalsIgnoreCase(type)) {
            InsertMappingRuntimeList.add(ioMappingItemRuntime);
            InsertfromMap.put(ioMappingItemRuntime.getFromField(), ioMappingItemRuntime);
            InserttoMap.put(ioMappingItemRuntime.getToField(), ioMappingItemRuntime);
        }
        else if ("update".equalsIgnoreCase(type)) {
            UpdateMappingRuntimeList.add(ioMappingItemRuntime);
            UpdatefromMap.put(ioMappingItemRuntime.getFromField(), ioMappingItemRuntime);
            UpdatetoMap.put(ioMappingItemRuntime.getToField(), ioMappingItemRuntime);
        }
        
    }
    
    public boolean contaisFromField(String fromField, String type) {
        boolean containsField = containsField(fromField, "from", type);
        return containsField;
    }
    
    public boolean contaisToField(String toField, String type) {
        boolean containsField = containsField(toField, "to", type);
        return containsField;
    }
    
    private boolean containsField(String field, String directionType, String dataType) {
        if (field == null) {
            return false;
        }
        if ("insert".equalsIgnoreCase(dataType)) {
            
        }
        if ("from".equalsIgnoreCase(type)) {
            return fromMap.containsKey(field.toLowerCase());
        }
        else if ("to".equalsIgnoreCase(type)) {
            return toMap.containsKey(field.toLowerCase());
        }
        return false;
    }
 
    public List<IOMappingItemRuntime> getUpdateMappingRuntime() {
        
        return null;
    }
}