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
216
217
218
219
package foundation.icall;
 
import foundation.dao.DataPackageMeta;
import foundation.dao.DataSource;
import foundation.data.entity.Entity;
import foundation.icall.callout.Fields;
import foundation.icall.callout.MethodType;
import foundation.io.template.ResponseTemplate;
import foundation.io.template.Template;
import foundation.json.IJSONProvider;
import foundation.json.IJSONWriter;
import foundation.util.MapList;
import foundation.util.Util;
 
 
public class ICallMeta implements IJSONProvider {
 
    private String id;
    private String name;
    private String route;
    private String sourceName;
    private String url;
    private String remoteFilter;
    private DataPackageMeta packageMeta;
    private String dataName;
    private String actionName;
    private boolean permitEmptyStamp;
    private String historyTableName;
    private Fields idFields;
    private String stampField;
    private String orderByField;
    private boolean pageActive;
    private String ioTaskName;
    private String monitorId;
    private String title;
    private ContentType contentType;
    private MethodType methodType;
    private ResponseTemplate responseTemplate;
    private MapList<String, Template> requestTemplates;
    private DataSource[] requestDataSources;
    
    public ICallMeta() {
 
    }
    
    public void load(Entity entity) throws Exception {
        id = entity.getString("id");
        name = entity.getString("name");
        title = entity.getString("title"); 
        sourceName = entity.getString("source_name");
        dataName = entity.getString("dataname");
 
        url = entity.getString("url");
        remoteFilter = entity.getString("remote_filter");
        historyTableName = entity.getString("history_table_name");
        idFields = new Fields(entity.getString("id_field"));
        stampField = entity.getString("stamp_field");
        orderByField = entity.getString("orderby_field");
        pageActive = entity.getBoolean("is_page_active", true);
        
        ioTaskName = entity.getString("io_task_name");
        actionName = entity.getString("action_name"); 
        monitorId = entity.getString("sys_interface_step__monitor_id"); 
        
        if (Util.isEmpty(remoteFilter)) {
            remoteFilter = " 1=1 ";
        }
        
        contentType = ContentType.parse(entity.getString("content_type"));
        methodType = MethodType.parse(entity.getString("method_type"));
        
        parseDataSource(entity.getString("request_datasources"));
    }
 
    private void parseDataSource(String datasourceValues) {
        if (Util.isEmpty(datasourceValues)) {
            requestDataSources = new DataSource[] {DataSource.DB};
            return ;
        }
        
        String[] datasourceValueList = datasourceValues.split(",");
        requestDataSources = new DataSource[datasourceValueList.length];
        String datasourceValue;
        
        for (int i = 0; i < datasourceValueList.length; i++) {
            datasourceValue = datasourceValueList[i];
            requestDataSources[i] = DataSource.valueOf(datasourceValue);
        }
    }
 
    public void addOneRequestTemplate(String code, Template template) {
        if (requestTemplates == null) {
            requestTemplates = new MapList<String, Template>();
        }
        
        requestTemplates.add(code, template);
    }
 
    public MapList<String, Template> getRequestTemplateList() {
        return requestTemplates;
    }
 
    public void setResponseTemplate(ResponseTemplate template) {
        this.responseTemplate = template;
    }
 
    public ResponseTemplate getResponseTemplate() {
        return responseTemplate;
    }
    
    public String getDataName() {
        return dataName;
    }
    
    public String getId() {
        return id;
    }
 
    public String getName() {
        return name;
    }
 
    public String getSourceName() {
        return sourceName;
    }
 
    public String getURL() {
        return url;
    }
    
    public String getRemoteFilter() {
        return remoteFilter;
    }
 
    public String getRoute() {
        return route;
    }
 
    public String getActionName() {
        return actionName;
    }
 
    public String getHistoryTableName() {
        return historyTableName;
    }
 
    public DataPackageMeta getPackageMeta() {
        return packageMeta;
    }
 
    public boolean isPermitEmptyStamp() {
        return permitEmptyStamp;
    }
 
    public Fields getIdFields() {
        return idFields;
    }
    
    public String getStampField() {
        return stampField;
    }
 
    public String getOrderByField() {
        if (!Util.isEmpty(orderByField)) {
            return orderByField;
        }
        
        return stampField;
    }
 
    public String getIOTaskName() {
        return ioTaskName;
    }
 
    public boolean isPageActive() {
        return pageActive;
    }
    
    public String getMonitorId() {
        return monitorId;
    }
 
    public String getTitle() {
        return title;
    }
    
    public ContentType getContentType() {
        return contentType;
    }
 
    public DataSource[] getRequestDataSources() {
        return requestDataSources;
    }
 
    public MethodType getMethodType() {
        return methodType;
    }
    
    @Override
    public void writeJSON(IJSONWriter writer) {
        writer.beginObject("jcall");
        writeJSONBody(writer);
        writer.endObject();
    }
 
    private void writeJSONBody(IJSONWriter writer) {
        //1. body
        writer.write("name", name);
        
        //2. mappings
        writer.beginArray("fields");
        
//        for (FieldMapping fieldMapping: mappings) {
//            fieldMapping.writeOnProvider(writer);
//        }
        
        writer.endArray();
    }
}