001package gudusoft.gsqlparser.dlineage.dataflow.model;
002
003import java.util.Arrays;
004import java.util.HashSet;
005import java.util.Set;
006
007import gudusoft.gsqlparser.EDbVendor;
008import gudusoft.gsqlparser.dlineage.dataflow.listener.DataFlowHandleListener;
009
010public class Option implements Cloneable {
011
012    private EDbVendor vendor;
013    private DataFlowHandleListener handleListener;
014    private boolean simpleOutput;
015    private boolean textFormat = false;
016    private boolean showJoin = false;
017    private boolean ignoreRecordSet = false;
018    private boolean ignoreTemporaryTable = false;
019    private boolean ignoreTopSelect = false;
020    private boolean ignoreUnusedSynonym = true;
021    private boolean showCallRelation = false;
022    private boolean simpleShowFunction = false;
023    private boolean simpleShowSynonym = false;
024    private boolean simpleShowUdfFunctionOnly = false;
025    private boolean simpleShowCursor = false;
026    private boolean simpleShowVariable = false;
027    private boolean simpleShowTopSelectResultSet = false;
028    private boolean linkOrphanColumnToFirstTable = false;
029    private boolean ignoreCoordinate = false;
030    private boolean transform = false;
031    private boolean transformCoordinate = false;
032    private boolean showImplicitSchema = false;
033    private boolean showCountTableColumn = true;
034    private boolean showConstantTable = false;
035    private boolean showCaseWhenAsDirect = true;
036    private String filePathDatabase;
037    private String filePathSchema;
038    private long startId = 0;
039    private boolean output = true;
040    private boolean traceSQL = false;
041    private boolean traceProcedure = false;
042    private int parallel = Runtime.getRuntime().availableProcessors() / 2;
043    private String defaultServer;
044    private String defaultDatabase;
045    private String defaultSchema;
046    private boolean showERDiagram = false;
047    private Set<ResultSetType> targetResultSetTypes = new HashSet<ResultSetType>(); 
048    private Set<String> filterRelationTypes = new HashSet<String>();
049    private Set<String> simpleShowRelationTypes = new HashSet<String>();
050    private boolean sqlflowIgnoreFunction = false;
051    private boolean showCandidateTable = true;
052    private boolean ignoreInsertIntoValues = true;
053    private boolean normalizeOutput = false;
054    /*
055     * Whether to trace all table positions. Default is false.
056     */
057    private boolean traceTablePosition = false;
058
059    private boolean enablePipelinedStitching = true;
060    private int maxPipelinedExpansionDepth = 8;
061    private int maxStitchedSourcesPerColumn = 64;
062
063    private AnalyzeMode analyzeMode;
064
065    public EDbVendor getVendor() {
066        return vendor;
067    }
068
069    public void setVendor(EDbVendor vendor) {
070        this.vendor = vendor;
071    }
072
073    public DataFlowHandleListener getHandleListener() {
074        return handleListener;
075    }
076
077    public void setHandleListener(DataFlowHandleListener handleListener) {
078        this.handleListener = handleListener;
079    }
080
081    public boolean isSimpleOutput() {
082        return simpleOutput;
083    }
084
085    public void setSimpleOutput(boolean simpleOutput) {
086        this.simpleOutput = simpleOutput;
087    }
088
089    public boolean isTextFormat() {
090        return textFormat;
091    }
092
093    public void setTextFormat(boolean textFormat) {
094        this.textFormat = textFormat;
095    }
096
097    public boolean isShowJoin() {
098        return showJoin;
099    }
100
101    public void setShowJoin(boolean showJoin) {
102        this.showJoin = showJoin;
103    }
104
105    public boolean isIgnoreRecordSet() {
106        return ignoreRecordSet;
107    }
108
109    public void setIgnoreRecordSet(boolean ignoreRecordSet) {
110        this.ignoreRecordSet = ignoreRecordSet;
111    }
112
113    public boolean isLinkOrphanColumnToFirstTable() {
114        return linkOrphanColumnToFirstTable;
115    }
116
117    public void setLinkOrphanColumnToFirstTable(boolean linkOrphanColumnToFirstTable) {
118        this.linkOrphanColumnToFirstTable = linkOrphanColumnToFirstTable;
119    }
120
121    public boolean isIgnoreCoordinate() {
122        return ignoreCoordinate;
123    }
124
125    public void setIgnoreCoordinate(boolean ignoreCoordinate) {
126        this.ignoreCoordinate = ignoreCoordinate;
127    }
128
129    public boolean isTransform() {
130        return transform;
131    }
132
133    public void setTransform(boolean transform) {
134        this.transform = transform;
135    }
136
137    public boolean isTransformCoordinate() {
138        return transformCoordinate;
139    }
140
141    public void setTransformCoordinate(boolean transformCoordinate) {
142        this.transformCoordinate = transformCoordinate;
143    }
144
145    public boolean isSimpleShowFunction() {
146        return simpleShowFunction;
147    }
148
149    public void setSimpleShowFunction(boolean simpleShowFunction) {
150        this.simpleShowFunction = simpleShowFunction;
151    }
152
153    public boolean isSimpleShowSynonym() {
154        return simpleShowSynonym;
155    }
156
157    public void setSimpleShowSynonym(boolean simpleShowSynonym) {
158        this.simpleShowSynonym = simpleShowSynonym;
159    }
160
161    public boolean isSimpleShowTopSelectResultSet() {
162        return simpleShowTopSelectResultSet;
163    }
164
165    public void setSimpleShowTopSelectResultSet(boolean simpleShowTopSelectResultSet) {
166        this.simpleShowTopSelectResultSet = simpleShowTopSelectResultSet;
167    }
168
169    public boolean isShowImplicitSchema() {
170        return showImplicitSchema;
171    }
172
173    public void setShowImplicitSchema(boolean showImplicitSchema) {
174        this.showImplicitSchema = showImplicitSchema;
175    }
176
177    public boolean isShowCountTableColumn() {
178        return showCountTableColumn;
179    }
180
181    public void setShowCountTableColumn(boolean showCountTableColumn) {
182        this.showCountTableColumn = showCountTableColumn;
183    }
184
185    public boolean isShowConstantTable() {
186        return showConstantTable;
187    }
188
189    public void setShowConstantTable(boolean showConstantTable) {
190        this.showConstantTable = showConstantTable;
191    }
192
193    public long getStartId() {
194        return startId;
195    }
196
197    public void setStartId(long startId) {
198        this.startId = startId;
199    }
200
201    public boolean isOutput() {
202        return output;
203    }
204
205    public void setOutput(boolean output) {
206        this.output = output;
207    }
208
209    public int getParallel() {
210        return parallel;
211    }
212
213    public void setParallel(int parallel) {
214        this.parallel = parallel;
215    }
216
217    public boolean isTraceSQL() {
218        return traceSQL;
219    }
220
221    public void setTraceSQL(boolean traceSQL) {
222        this.traceSQL = traceSQL;
223    }
224
225    public boolean isIgnoreTopSelect() {
226                return ignoreTopSelect;
227        }
228
229        public void setIgnoreTopSelect(boolean ignoreTopSelect) {
230                this.ignoreTopSelect = ignoreTopSelect;
231        }
232        
233        public void setShowCallRelation(boolean showCallRelation) {
234                this.showCallRelation = showCallRelation;
235        }
236        
237        public boolean isShowCallRelation() {
238                return showCallRelation;
239        }
240
241        public String getFilePathDatabase() {
242                return filePathDatabase;
243        }
244
245        public void setFilePathDatabase(String filePathDatabase) {
246                this.filePathDatabase = filePathDatabase;
247        }
248
249        public String getFilePathSchema() {
250                return filePathSchema;
251        }
252
253        public void setFilePathSchema(String filePathSchema) {
254                this.filePathSchema = filePathSchema;
255        }
256
257        public String getDefaultServer() {
258                return defaultServer;
259        }
260
261        public void setDefaultServer(String defaultServer) {
262                this.defaultServer = defaultServer;
263        }
264
265        public String getDefaultDatabase() {
266                return defaultDatabase;
267        }
268
269        public void setDefaultDatabase(String defaultDatabase) {
270                this.defaultDatabase = defaultDatabase;
271        }
272
273        public String getDefaultSchema() {
274                return defaultSchema;
275        }
276
277        public void setDefaultSchema(String defaultSchema) {
278                this.defaultSchema = defaultSchema;
279        }
280
281    public boolean isShowERDiagram() {
282        return showERDiagram;
283    }
284
285    public void setShowERDiagram(boolean showERDiagram) {
286        this.showERDiagram = showERDiagram;
287    }
288
289    public boolean isIgnoreTemporaryTable() {
290        return ignoreTemporaryTable;
291    }
292
293    public void setIgnoreTemporaryTable(boolean ignoreTemporaryTable) {
294        this.ignoreTemporaryTable = ignoreTemporaryTable;
295    }
296    
297    public void showResultSetTypes(ResultSetType... types) {
298        if(types!=null) {
299                targetResultSetTypes.addAll(Arrays.asList(types));
300        }
301    }
302    
303        public void showResultSetTypes(String... types) {
304                if (types != null) {
305                        for (String type : types) {
306                                ResultSetType resultSetType = ResultSetType.of(type);
307                                if (resultSetType != null) {
308                                        targetResultSetTypes.add(resultSetType);
309                                }
310                        }
311                }
312        }
313    
314    public boolean containsResultSetType(ResultSetType type) {
315        return targetResultSetTypes.contains(type);
316    }
317
318    @Override
319    public Object clone() throws CloneNotSupportedException {
320        return super.clone();
321    }
322    
323        public void filterRelationTypes(String... types) {
324                if (types != null) {
325                        for (String type : types) {
326                                RelationshipType relationshipType = RelationshipType.of(type);
327                                if (relationshipType != null) {
328                                        filterRelationTypes.add(relationshipType.name());
329                                }
330                        }
331                }
332        }
333
334        public Set<String> getFilterRelationTypes() {
335                return filterRelationTypes;
336        }
337
338    public boolean isSimpleShowCursor() {
339        return simpleShowCursor;
340    }
341
342    public void setSimpleShowCursor(boolean simpleShowCursor) {
343        this.simpleShowCursor = simpleShowCursor;
344    }
345
346    public boolean isSimpleShowVariable() {
347        return simpleShowVariable;
348    }
349
350    public void setSimpleShowVariable(boolean simpleShowVariable) {
351        this.simpleShowVariable = simpleShowVariable;
352    }
353
354    public boolean isSimpleShowUdfFunctionOnly() {
355        return simpleShowUdfFunctionOnly;
356    }
357
358    public void setSimpleShowUdfFunctionOnly(boolean simpleShowUdfFunctionOnly) {
359        this.simpleShowUdfFunctionOnly = simpleShowUdfFunctionOnly;
360    }
361
362        public boolean isTraceProcedure() {
363                return traceProcedure;
364        }
365
366        public void setTraceProcedure(boolean traceProcedure) {
367                this.traceProcedure = traceProcedure;
368        }
369
370    public boolean isSqlflowIgnoreFunction() {
371        return sqlflowIgnoreFunction;
372    }
373
374    public void setSqlflowIgnoreFunction(boolean sqlflowIgnoreFunction) {
375        this.sqlflowIgnoreFunction = sqlflowIgnoreFunction;
376    }
377
378    public boolean isShowCaseWhenAsDirect() {
379        return showCaseWhenAsDirect;
380    }
381
382    public void setShowCaseWhenAsDirect(boolean showCaseWhenAsDirect) {
383        this.showCaseWhenAsDirect = showCaseWhenAsDirect;
384    }
385
386        public boolean isIgnoreUnusedSynonym() {
387                return ignoreUnusedSynonym;
388        }
389
390        public void setIgnoreUnusedSynonym(boolean ignoreUnusedSynonym) {
391                this.ignoreUnusedSynonym = ignoreUnusedSynonym;
392        }
393
394        public boolean isShowCandidateTable() {
395                return showCandidateTable;
396        }
397
398        public void setShowCandidateTable(boolean showCandidateTable) {
399                this.showCandidateTable = showCandidateTable;
400        }
401
402        public Set<String> getSimpleShowRelationTypes() {
403                return simpleShowRelationTypes;
404        }
405
406        public void setSimpleShowRelationTypes(String... types) {
407                if (types != null) {
408                        for (String type : types) {
409                                RelationshipType relationshipType = RelationshipType.of(type);
410                                if (relationshipType != null) {
411                                        simpleShowRelationTypes.add(relationshipType.name());
412                                }
413                        }
414                }
415        }
416        
417        public void setSimpleShowRelationTypes(RelationshipType... types) {
418                if (types != null) {
419                        for (RelationshipType relationshipType : types) {
420                                simpleShowRelationTypes.add(relationshipType.name());
421                        }
422                }
423        }
424
425        public AnalyzeMode getAnalyzeMode() {
426                return analyzeMode;
427        }
428
429        public void setAnalyzeMode(AnalyzeMode analyzeMode) {
430                this.analyzeMode = analyzeMode;
431        }
432
433        public boolean isIgnoreInsertIntoValues() {
434                return ignoreInsertIntoValues;
435        }
436
437        public void setIgnoreInsertIntoValues(boolean ignoreInsertIntoValues) {
438                this.ignoreInsertIntoValues = ignoreInsertIntoValues;
439        }
440
441    public boolean isNormalizeOutput() {
442        return normalizeOutput;
443    }
444
445    public void setNormalizeOutput(boolean normalizeOutput) {
446        this.normalizeOutput = normalizeOutput;
447    }
448
449        public boolean isTraceTablePosition() {
450                return traceTablePosition;
451        }
452
453        public void setTraceTablePosition(boolean traceTablePosition) {
454                this.traceTablePosition = traceTablePosition;
455        }
456
457        public boolean isEnablePipelinedStitching() {
458                return enablePipelinedStitching;
459        }
460
461        public void setEnablePipelinedStitching(boolean enablePipelinedStitching) {
462                this.enablePipelinedStitching = enablePipelinedStitching;
463        }
464
465        public int getMaxPipelinedExpansionDepth() {
466                return maxPipelinedExpansionDepth;
467        }
468
469        public void setMaxPipelinedExpansionDepth(int maxPipelinedExpansionDepth) {
470                this.maxPipelinedExpansionDepth = maxPipelinedExpansionDepth;
471        }
472
473        public int getMaxStitchedSourcesPerColumn() {
474                return maxStitchedSourcesPerColumn;
475        }
476
477        public void setMaxStitchedSourcesPerColumn(int maxStitchedSourcesPerColumn) {
478                this.maxStitchedSourcesPerColumn = maxStitchedSourcesPerColumn;
479        }
480
481}