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 = false;
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    private AnalyzeMode analyzeMode;
056
057    public EDbVendor getVendor() {
058        return vendor;
059    }
060
061    public void setVendor(EDbVendor vendor) {
062        this.vendor = vendor;
063    }
064
065    public DataFlowHandleListener getHandleListener() {
066        return handleListener;
067    }
068
069    public void setHandleListener(DataFlowHandleListener handleListener) {
070        this.handleListener = handleListener;
071    }
072
073    public boolean isSimpleOutput() {
074        return simpleOutput;
075    }
076
077    public void setSimpleOutput(boolean simpleOutput) {
078        this.simpleOutput = simpleOutput;
079    }
080
081    public boolean isTextFormat() {
082        return textFormat;
083    }
084
085    public void setTextFormat(boolean textFormat) {
086        this.textFormat = textFormat;
087    }
088
089    public boolean isShowJoin() {
090        return showJoin;
091    }
092
093    public void setShowJoin(boolean showJoin) {
094        this.showJoin = showJoin;
095    }
096
097    public boolean isIgnoreRecordSet() {
098        return ignoreRecordSet;
099    }
100
101    public void setIgnoreRecordSet(boolean ignoreRecordSet) {
102        this.ignoreRecordSet = ignoreRecordSet;
103    }
104
105    public boolean isLinkOrphanColumnToFirstTable() {
106        return linkOrphanColumnToFirstTable;
107    }
108
109    public void setLinkOrphanColumnToFirstTable(boolean linkOrphanColumnToFirstTable) {
110        this.linkOrphanColumnToFirstTable = linkOrphanColumnToFirstTable;
111    }
112
113    public boolean isIgnoreCoordinate() {
114        return ignoreCoordinate;
115    }
116
117    public void setIgnoreCoordinate(boolean ignoreCoordinate) {
118        this.ignoreCoordinate = ignoreCoordinate;
119    }
120
121    public boolean isTransform() {
122        return transform;
123    }
124
125    public void setTransform(boolean transform) {
126        this.transform = transform;
127    }
128
129    public boolean isTransformCoordinate() {
130        return transformCoordinate;
131    }
132
133    public void setTransformCoordinate(boolean transformCoordinate) {
134        this.transformCoordinate = transformCoordinate;
135    }
136
137    public boolean isSimpleShowFunction() {
138        return simpleShowFunction;
139    }
140
141    public void setSimpleShowFunction(boolean simpleShowFunction) {
142        this.simpleShowFunction = simpleShowFunction;
143    }
144
145    public boolean isSimpleShowSynonym() {
146        return simpleShowSynonym;
147    }
148
149    public void setSimpleShowSynonym(boolean simpleShowSynonym) {
150        this.simpleShowSynonym = simpleShowSynonym;
151    }
152
153    public boolean isSimpleShowTopSelectResultSet() {
154        return simpleShowTopSelectResultSet;
155    }
156
157    public void setSimpleShowTopSelectResultSet(boolean simpleShowTopSelectResultSet) {
158        this.simpleShowTopSelectResultSet = simpleShowTopSelectResultSet;
159    }
160
161    public boolean isShowImplicitSchema() {
162        return showImplicitSchema;
163    }
164
165    public void setShowImplicitSchema(boolean showImplicitSchema) {
166        this.showImplicitSchema = showImplicitSchema;
167    }
168
169    public boolean isShowCountTableColumn() {
170        return showCountTableColumn;
171    }
172
173    public void setShowCountTableColumn(boolean showCountTableColumn) {
174        this.showCountTableColumn = showCountTableColumn;
175    }
176
177    public boolean isShowConstantTable() {
178        return showConstantTable;
179    }
180
181    public void setShowConstantTable(boolean showConstantTable) {
182        this.showConstantTable = showConstantTable;
183    }
184
185    public long getStartId() {
186        return startId;
187    }
188
189    public void setStartId(long startId) {
190        this.startId = startId;
191    }
192
193    public boolean isOutput() {
194        return output;
195    }
196
197    public void setOutput(boolean output) {
198        this.output = output;
199    }
200
201    public int getParallel() {
202        return parallel;
203    }
204
205    public void setParallel(int parallel) {
206        this.parallel = parallel;
207    }
208
209    public boolean isTraceSQL() {
210        return traceSQL;
211    }
212
213    public void setTraceSQL(boolean traceSQL) {
214        this.traceSQL = traceSQL;
215    }
216
217    public boolean isIgnoreTopSelect() {
218                return ignoreTopSelect;
219        }
220
221        public void setIgnoreTopSelect(boolean ignoreTopSelect) {
222                this.ignoreTopSelect = ignoreTopSelect;
223        }
224        
225        public void setShowCallRelation(boolean showCallRelation) {
226                this.showCallRelation = showCallRelation;
227        }
228        
229        public boolean isShowCallRelation() {
230                return showCallRelation;
231        }
232
233        public String getFilePathDatabase() {
234                return filePathDatabase;
235        }
236
237        public void setFilePathDatabase(String filePathDatabase) {
238                this.filePathDatabase = filePathDatabase;
239        }
240
241        public String getFilePathSchema() {
242                return filePathSchema;
243        }
244
245        public void setFilePathSchema(String filePathSchema) {
246                this.filePathSchema = filePathSchema;
247        }
248
249        public String getDefaultServer() {
250                return defaultServer;
251        }
252
253        public void setDefaultServer(String defaultServer) {
254                this.defaultServer = defaultServer;
255        }
256
257        public String getDefaultDatabase() {
258                return defaultDatabase;
259        }
260
261        public void setDefaultDatabase(String defaultDatabase) {
262                this.defaultDatabase = defaultDatabase;
263        }
264
265        public String getDefaultSchema() {
266                return defaultSchema;
267        }
268
269        public void setDefaultSchema(String defaultSchema) {
270                this.defaultSchema = defaultSchema;
271        }
272
273    public boolean isShowERDiagram() {
274        return showERDiagram;
275    }
276
277    public void setShowERDiagram(boolean showERDiagram) {
278        this.showERDiagram = showERDiagram;
279    }
280
281    public boolean isIgnoreTemporaryTable() {
282        return ignoreTemporaryTable;
283    }
284
285    public void setIgnoreTemporaryTable(boolean ignoreTemporaryTable) {
286        this.ignoreTemporaryTable = ignoreTemporaryTable;
287    }
288    
289    public void showResultSetTypes(ResultSetType... types) {
290        if(types!=null) {
291                targetResultSetTypes.addAll(Arrays.asList(types));
292        }
293    }
294    
295        public void showResultSetTypes(String... types) {
296                if (types != null) {
297                        for (String type : types) {
298                                ResultSetType resultSetType = ResultSetType.of(type);
299                                if (resultSetType != null) {
300                                        targetResultSetTypes.add(resultSetType);
301                                }
302                        }
303                }
304        }
305    
306    public boolean containsResultSetType(ResultSetType type) {
307        return targetResultSetTypes.contains(type);
308    }
309
310    @Override
311    public Object clone() throws CloneNotSupportedException {
312        return super.clone();
313    }
314    
315        public void filterRelationTypes(String... types) {
316                if (types != null) {
317                        for (String type : types) {
318                                RelationshipType relationshipType = RelationshipType.of(type);
319                                if (relationshipType != null) {
320                                        filterRelationTypes.add(relationshipType.name());
321                                }
322                        }
323                }
324        }
325
326        public Set<String> getFilterRelationTypes() {
327                return filterRelationTypes;
328        }
329
330    public boolean isSimpleShowCursor() {
331        return simpleShowCursor;
332    }
333
334    public void setSimpleShowCursor(boolean simpleShowCursor) {
335        this.simpleShowCursor = simpleShowCursor;
336    }
337
338    public boolean isSimpleShowVariable() {
339        return simpleShowVariable;
340    }
341
342    public void setSimpleShowVariable(boolean simpleShowVariable) {
343        this.simpleShowVariable = simpleShowVariable;
344    }
345
346    public boolean isSimpleShowUdfFunctionOnly() {
347        return simpleShowUdfFunctionOnly;
348    }
349
350    public void setSimpleShowUdfFunctionOnly(boolean simpleShowUdfFunctionOnly) {
351        this.simpleShowUdfFunctionOnly = simpleShowUdfFunctionOnly;
352    }
353
354        public boolean isTraceProcedure() {
355                return traceProcedure;
356        }
357
358        public void setTraceProcedure(boolean traceProcedure) {
359                this.traceProcedure = traceProcedure;
360        }
361
362    public boolean isSqlflowIgnoreFunction() {
363        return sqlflowIgnoreFunction;
364    }
365
366    public void setSqlflowIgnoreFunction(boolean sqlflowIgnoreFunction) {
367        this.sqlflowIgnoreFunction = sqlflowIgnoreFunction;
368    }
369
370    public boolean isShowCaseWhenAsDirect() {
371        return showCaseWhenAsDirect;
372    }
373
374    public void setShowCaseWhenAsDirect(boolean showCaseWhenAsDirect) {
375        this.showCaseWhenAsDirect = showCaseWhenAsDirect;
376    }
377
378        public boolean isIgnoreUnusedSynonym() {
379                return ignoreUnusedSynonym;
380        }
381
382        public void setIgnoreUnusedSynonym(boolean ignoreUnusedSynonym) {
383                this.ignoreUnusedSynonym = ignoreUnusedSynonym;
384        }
385
386        public boolean isShowCandidateTable() {
387                return showCandidateTable;
388        }
389
390        public void setShowCandidateTable(boolean showCandidateTable) {
391                this.showCandidateTable = showCandidateTable;
392        }
393
394        public Set<String> getSimpleShowRelationTypes() {
395                return simpleShowRelationTypes;
396        }
397
398        public void setSimpleShowRelationTypes(String... types) {
399                if (types != null) {
400                        for (String type : types) {
401                                RelationshipType relationshipType = RelationshipType.of(type);
402                                if (relationshipType != null) {
403                                        simpleShowRelationTypes.add(relationshipType.name());
404                                }
405                        }
406                }
407        }
408        
409        public void setSimpleShowRelationTypes(RelationshipType... types) {
410                if (types != null) {
411                        for (RelationshipType relationshipType : types) {
412                                simpleShowRelationTypes.add(relationshipType.name());
413                        }
414                }
415        }
416
417        public AnalyzeMode getAnalyzeMode() {
418                return analyzeMode;
419        }
420
421        public void setAnalyzeMode(AnalyzeMode analyzeMode) {
422                this.analyzeMode = analyzeMode;
423        }
424
425        public boolean isIgnoreInsertIntoValues() {
426                return ignoreInsertIntoValues;
427        }
428
429        public void setIgnoreInsertIntoValues(boolean ignoreInsertIntoValues) {
430                this.ignoreInsertIntoValues = ignoreInsertIntoValues;
431        }
432
433    public boolean isNormalizeOutput() {
434        return normalizeOutput;
435    }
436
437    public void setNormalizeOutput(boolean normalizeOutput) {
438        this.normalizeOutput = normalizeOutput;
439    }
440}