P15GEN2\59518
2025-10-10 9f6890646993d16260d4201d613c092132856127
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
package foundation.icall;
 
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
 
import foundation.dao.DataPackage;
import foundation.dao.DataSource;
import foundation.dao.bizlogic.IActionProvider;
import foundation.data.mapping.Mappings;
import foundation.data.mapping.MappingsRuntime;
import foundation.icall.callout.CallMethod;
import foundation.icall.callout.Fields;
import foundation.icall.callout.IRemoteSource;
import foundation.icall.callout.MethodType;
import foundation.icall.callout.RemoteDBCallProvider;
import foundation.icall.callout.RemoteServerCallProvider;
import foundation.icall.callout.RemoteSourceBucket;
import foundation.io.template.ResponseTemplate;
import foundation.io.template.Template;
import foundation.util.MapList;
import foundation.util.Util;
import foundation.workflow.ActionMeta;
import foundation.workflow.WorkStep;
 
 
public class ICall {
    
    protected static Logger logger;
    private static RemoteSourceBucket sourceBucket;
 
    private ICallMeta meta;
    private IRemoteSource remoteSource;
    private ICallDirection direction;
    
    static {
        logger = LogManager.getLogger(ICall.class);
    }
    
    public ICall(ICallMeta meta) {
        this.meta = meta;
        this.direction = ICallDirection.Unknown;
        
        init();
    }
    
 
    public static ICall getInstance(String name) {
        ICallBucket bucket = ICallBucket.getInstance();
        return bucket.getOne(name);
    }
 
    private void init() {
        //1. remote source
        String sourceName = meta.getSourceName();
        sourceBucket = RemoteSourceBucket.getInstance();
        remoteSource = sourceBucket.getOne(sourceName);
        direction = remoteSource.getDirection();
    }
 
    public void sendRemoteServerCall(WorkStep step, OutboundResult result) throws Exception {
        String actionName = meta.getActionName();
        
        //1. 如果没有配置特定的执行逻辑,使用默认(实现类)执行
        if (Util.isEmpty(actionName)) {
            RemoteServerCallProvider provider = new RemoteServerCallProvider(result, this);
            provider.exec(step, null);
            return;
        }
        
        //2. 如果配置了特定的执行逻辑,用指定的实现类执行
        ActionMeta actionMeta = ActionMeta.getInstance(actionName);
        IActionProvider provider = actionMeta.createProvider();
        
        String method = actionMeta.getMethodName();
        provider.exec(step, method);
    }
 
    public void sendRemoteDBCall(WorkStep step, OutboundResult result) throws Exception {
        String actionName = meta.getActionName();
        
        //1. 如果没有配置特定的执行逻辑,用默认的逻辑(实现类)执行
        if (Util.isEmpty(actionName)) {
            RemoteDBCallProvider provider = new RemoteDBCallProvider(result);
            provider.exec(step, null);
            return;
        }
        
        //2. 如果配置了特定的执行逻辑,用指定的实现类执行
        ActionMeta actionMeta = ActionMeta.getInstance(actionName);
        
        if (actionMeta == null) {
            logger.error("{}不存在", actionName);
            throw new Exception("sendRemoteDBCall 执行错误");
        }
        
        IActionProvider provider = actionMeta.createProvider();
        String method = actionMeta.getMethodName();
        provider.exec(step, method);
    }
    
    @SuppressWarnings("unchecked")
    public <T extends IRemoteSource> T remoteSource() {
        return (T)remoteSource;
    }
    
    public String getId() {
        return meta.getId();
    }
 
    public ICallMeta getMeta() {
        return meta;
    }
 
    public String getURL() {
        return meta.getURL();
    }
    
    public String getRemoteFilter() {
        return meta.getRemoteFilter();
    }
    
    public String getDataName() {
        return meta.getDataName();
    }
 
    public String getName() {
        return meta.getName();
    }
 
    public ICallDirection getType() {
        return direction;
    }
 
    public Mappings getMappings() {
        return null;
    }
 
    public MappingsRuntime getMappingsRuntime(DataPackage dataPackage) {
        return null;
    }
 
    public CallMethod getCallMethod() {
        return null;
    }
 
    public IRemoteSource getRemoteSource() { 
        return remoteSource;
    }
 
    public String getSourceName() { 
        return meta.getSourceName();
    }
 
    public boolean isPermitEmptyStamp() {
        return meta.isPermitEmptyStamp();
    }
 
    public String getHistoryTableName() {
        return meta.getHistoryTableName();
    }
 
    public Fields getIdFields() {
        return meta.getIdFields();
    }
    
    public String getStampField() {
        return meta.getStampField();
    }
    
    public String getOrderByField() {
        return meta.getOrderByField();
    }
 
    public String getIOTaskName() {
        return meta.getIOTaskName();
    }
 
    public boolean isPageActive() {
        return meta.isPageActive();
    }
 
    public String getRoute() {
        return meta.getRoute();
    }
    
    public String getMonitorId() {
        return meta.getMonitorId();
    }
 
    public String getTitle() {
        return meta.getTitle();
    }
 
    public ContentType getContentType() {
        return meta.getContentType();
    }
    
    public MapList<String, Template> getRequestTemplateList() {
        return meta.getRequestTemplateList();
    }
 
    public ResponseTemplate getResponseTemplate() {
        return meta.getResponseTemplate();
    }
 
 
    public DataSource[] getRequestDataSources() {
        return meta.getRequestDataSources();
    }
 
 
    public MethodType getMethodType() {
        return meta.getMethodType();
    }
}