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