001package gudusoft.gsqlparser.dlineage.dataflow.model;
002
003import gudusoft.gsqlparser.EDbVendor;
004import gudusoft.gsqlparser.ESqlStatementType;
005import gudusoft.gsqlparser.ETableSource;
006import gudusoft.gsqlparser.TCustomSqlStatement;
007import gudusoft.gsqlparser.TSourceToken;
008import gudusoft.gsqlparser.dlineage.util.DlineageUtil;
009import gudusoft.gsqlparser.dlineage.util.Pair3;
010import gudusoft.gsqlparser.nodes.TFunctionCall;
011import gudusoft.gsqlparser.nodes.TObjectName;
012import gudusoft.gsqlparser.nodes.TParseTreeNode;
013import gudusoft.gsqlparser.sqlenv.TSQLCatalog;
014import gudusoft.gsqlparser.sqlenv.TSQLEnv;
015import gudusoft.gsqlparser.sqlenv.TSQLSchema;
016import gudusoft.gsqlparser.sqlenv.TSQLSchemaObject;
017import gudusoft.gsqlparser.sqlenv.TSQLTable;
018import gudusoft.gsqlparser.stmt.TStoredProcedureSqlStatement;
019import gudusoft.gsqlparser.stmt.teradata.TTeradataCreateProcedure;
020import gudusoft.gsqlparser.util.Logger;
021import gudusoft.gsqlparser.util.LoggerFactory;
022import gudusoft.gsqlparser.util.SQLUtil;
023
024import java.io.ByteArrayInputStream;
025import java.io.IOException;
026import java.util.ArrayList;
027import java.util.HashMap;
028import java.util.List;
029import java.util.Map;
030import java.util.Properties;
031
032public class Procedure {
033    private static final Logger logger = LoggerFactory.getLogger(Procedure.class);
034    private long id;
035    private String server;
036    private String database;
037    private String schema;
038    private String name;
039    private String fullName;
040    private Pair3<Long, Long, String> startPosition;
041    private Pair3<Long, Long, String> endPosition;
042    private List<Argument> arguments = new ArrayList<Argument>();
043    private ESqlStatementType type;
044    private TParseTreeNode procedureObject;
045    private OraclePackage parentPackage;
046
047    public Procedure(TStoredProcedureSqlStatement procedure) {
048        if (procedure == null) {
049            throw new IllegalArgumentException("Procedure arguments can't be null.");
050        } else {
051            this.id = ++ModelBindingManager.get().TABLE_COLUMN_ID;
052            this.procedureObject = procedure;
053            TObjectName procedureName = getProcedureName();
054            TSourceToken startToken = procedure.getStartToken();
055            TSourceToken endToken = procedure.getEndToken();
056            this.startPosition = new Pair3<Long, Long, String>(startToken.lineNo, startToken.columnNo, ModelBindingManager.getGlobalHash());
057            this.endPosition = new Pair3<Long, Long, String>(endToken.lineNo,
058                    endToken.columnNo + (long) SQLUtil.endTrim(endToken.getAstext()).length(), ModelBindingManager.getGlobalHash());
059            this.fullName = procedureName.toString();
060            this.name = procedureName.toString();
061
062            EDbVendor vendor = ModelBindingManager.getGlobalOption().getVendor();
063            boolean supportCatalog = TSQLEnv.supportCatalog(vendor);
064            boolean supportSchema = TSQLEnv.supportSchema(vendor);
065
066            fillSchemaInfo();
067
068            if (SQLUtil.isEmpty(this.database)) {
069                        this.database = DlineageUtil.getTableDatabase(procedureName.toString());
070                        if (SQLUtil.isEmpty(this.database) && ModelBindingManager.getGlobalOption().isShowImplicitSchema()
071                                        && !SQLUtil.isEmpty(procedureName.getImplictDatabaseString())) {
072                                this.database = procedureName.getImplictDatabaseString();
073                        }
074                }
075
076                if (SQLUtil.isEmpty(this.schema)) {
077                        this.schema = DlineageUtil.getTableSchema(procedureName.toString());
078                        if (SQLUtil.isEmpty(this.schema) && ModelBindingManager.getGlobalOption().isShowImplicitSchema()
079                                        && !SQLUtil.isEmpty(procedureName.getImplictSchemaString())) {
080                                this.schema = procedureName.getImplictSchemaString();
081                        }
082                }
083
084                if (!SQLUtil.isEmpty(this.database) && SQLUtil.isEmpty(this.schema)) {
085                        if (!SQLUtil.isEmpty(procedureName.getImplictSchemaString())) {
086                                this.schema = procedureName.getImplictSchemaString();
087                        }
088                }
089
090                if (!supportCatalog) {
091                        this.database = null;
092                } else if (this.database == null && !TSQLEnv.DEFAULT_DB_NAME.equals(getDefaultDatabase())) {
093                        this.database = getDefaultDatabase();
094                }
095
096                if (!supportSchema) {
097                        this.schema = null;
098                } else if (this.schema == null && !TSQLEnv.DEFAULT_SCHEMA_NAME.equals(getDefaultSchema())) {
099                        this.schema = getDefaultSchema();
100                }
101
102            updateProcedureName(supportCatalog, supportSchema);
103
104            this.type = procedure.sqlstatementtype;
105
106            if (this.server == null && !TSQLEnv.DEFAULT_SERVER_NAME.equals(getDefaultServer())) {
107                this.server = getDefaultServer();
108            }
109        }
110    }
111
112    public Procedure(TObjectName procedureName) {
113        if (procedureName == null) {
114            throw new IllegalArgumentException("Procedure arguments can't be null.");
115        } else {
116            this.id = ++ModelBindingManager.get().TABLE_COLUMN_ID;
117            this.procedureObject = procedureName;
118            TSourceToken startToken = procedureName.getStartToken();
119            TSourceToken endToken = procedureName.getEndToken();
120            this.startPosition = new Pair3<Long, Long, String>(startToken.lineNo, startToken.columnNo, ModelBindingManager.getGlobalHash());
121            this.endPosition = new Pair3<Long, Long, String>(endToken.lineNo,
122                    endToken.columnNo + (long) SQLUtil.endTrim(endToken.getAstext()).length(), ModelBindingManager.getGlobalHash());
123            this.fullName = procedureName.toString();
124            this.name = procedureName.toString();
125
126            EDbVendor vendor = ModelBindingManager.getGlobalOption().getVendor();
127            boolean supportCatalog = TSQLEnv.supportCatalog(vendor);
128            boolean supportSchema = TSQLEnv.supportSchema(vendor);
129
130            fillSchemaInfo();
131
132            if (SQLUtil.isEmpty(this.database)) {
133                        this.database = DlineageUtil.getTableDatabase(procedureName.toString());
134                        if (SQLUtil.isEmpty(this.database) && ModelBindingManager.getGlobalOption().isShowImplicitSchema()
135                                        && !SQLUtil.isEmpty(procedureName.getImplictDatabaseString())) {
136                                this.database = procedureName.getImplictDatabaseString();
137                        }
138                }
139
140                if (SQLUtil.isEmpty(this.schema)) {
141                        this.schema = DlineageUtil.getTableSchema(procedureName.toString());
142                        if (SQLUtil.isEmpty(this.schema) && ModelBindingManager.getGlobalOption().isShowImplicitSchema()
143                                        && !SQLUtil.isEmpty(procedureName.getImplictSchemaString())) {
144                                this.schema = procedureName.getImplictSchemaString();
145                        }
146                }
147
148                if (!SQLUtil.isEmpty(this.database) && SQLUtil.isEmpty(this.schema)) {
149                        if (!SQLUtil.isEmpty(procedureName.getImplictSchemaString())) {
150                                this.schema = procedureName.getImplictSchemaString();
151                        }
152                }
153
154                if (!supportCatalog) {
155                        this.database = null;
156                } else if (this.database == null && !TSQLEnv.DEFAULT_DB_NAME.equals(getDefaultDatabase())) {
157                        this.database = getDefaultDatabase();
158                }
159
160                if (!supportSchema) {
161                        this.schema = null;
162                } else if (this.schema == null && !TSQLEnv.DEFAULT_SCHEMA_NAME.equals(getDefaultSchema())) {
163                        this.schema = getDefaultSchema();
164                }
165
166            updateProcedureName(supportCatalog, supportSchema);
167
168            if (this.server == null && !TSQLEnv.DEFAULT_SERVER_NAME.equals(getDefaultServer())) {
169                this.server = getDefaultServer();
170            }
171        }
172    }
173    
174    public Procedure(TFunctionCall function) {
175        if (function == null) {
176            throw new IllegalArgumentException("Procedure arguments can't be null.");
177        } else {
178            this.id = ++ModelBindingManager.get().TABLE_COLUMN_ID;
179            this.procedureObject = function;
180            TObjectName procedureName = getProcedureName();
181            TSourceToken startToken = procedureName.getStartToken();
182            TSourceToken endToken = procedureName.getEndToken();
183            this.startPosition = new Pair3<Long, Long, String>(startToken.lineNo, startToken.columnNo, ModelBindingManager.getGlobalHash());
184            this.endPosition = new Pair3<Long, Long, String>(endToken.lineNo,
185                    endToken.columnNo + (long) SQLUtil.endTrim(endToken.getAstext()).length(), ModelBindingManager.getGlobalHash());
186            this.fullName = procedureName.toString();
187            this.name = procedureName.toString();
188
189            EDbVendor vendor = ModelBindingManager.getGlobalOption().getVendor();
190            boolean supportCatalog = TSQLEnv.supportCatalog(vendor);
191            boolean supportSchema = TSQLEnv.supportSchema(vendor);
192
193            fillSchemaInfo();
194
195            if (SQLUtil.isEmpty(this.database)) {
196                        this.database = DlineageUtil.getTableDatabase(procedureName.toString());
197                        if (SQLUtil.isEmpty(this.database) && ModelBindingManager.getGlobalOption().isShowImplicitSchema()
198                                        && !SQLUtil.isEmpty(procedureName.getImplictDatabaseString())) {
199                                this.database = procedureName.getImplictDatabaseString();
200                        }
201                }
202
203                if (SQLUtil.isEmpty(this.schema)) {
204                        this.schema = DlineageUtil.getTableSchema(procedureName.toString());
205                        if (SQLUtil.isEmpty(this.schema) && ModelBindingManager.getGlobalOption().isShowImplicitSchema()
206                                        && !SQLUtil.isEmpty(procedureName.getImplictSchemaString())) {
207                                this.schema = procedureName.getImplictSchemaString();
208                        }
209                }
210
211                if (!SQLUtil.isEmpty(this.database) && SQLUtil.isEmpty(this.schema)) {
212                        if (!SQLUtil.isEmpty(procedureName.getImplictSchemaString())) {
213                                this.schema = procedureName.getImplictSchemaString();
214                        }
215                }
216
217                if (!supportCatalog) {
218                        this.database = null;
219                } else if (this.database == null && !TSQLEnv.DEFAULT_DB_NAME.equals(getDefaultDatabase())) {
220                        this.database = getDefaultDatabase();
221                }
222
223                if (!supportSchema) {
224                        this.schema = null;
225                } else if (this.schema == null && !TSQLEnv.DEFAULT_SCHEMA_NAME.equals(getDefaultSchema())) {
226                        this.schema = getDefaultSchema();
227                }
228
229            updateProcedureName(supportCatalog, supportSchema);
230
231            if (this.server == null && !TSQLEnv.DEFAULT_SERVER_NAME.equals(getDefaultServer())) {
232                this.server = getDefaultServer();
233            }
234        }
235    }
236    
237    private void fillSchemaInfo() {
238                TCustomSqlStatement stmt = DlineageUtil.getTopStmt(ModelBindingManager.getGlobalStmtStack().peek());
239                String sqlComment = null;
240                try {
241                        sqlComment = stmt.getCommentBeforeNode();
242                } catch (Exception e) {
243                }
244                if (!SQLUtil.isEmpty(sqlComment) && (sqlComment.indexOf("db") != -1 || sqlComment.indexOf("schema") != -1)) {
245                        Properties properties = new Properties();
246                        try {
247                                properties.load(
248                                                new ByteArrayInputStream(sqlComment.replace("--", "").trim().replace(",", "\n").getBytes()));
249                                if (SQLUtil.isEmpty(this.server) && properties.containsKey("db-instance")) {
250                                        this.server = properties.getProperty("db-instance");
251                                }
252                                if (SQLUtil.isEmpty(this.database) && properties.containsKey("db")) {
253                                        this.database = properties.getProperty("db");
254                                        if(this.database.indexOf(".")!=-1) {
255                                                String delimitedChar = TSQLEnv.delimitedChar(ModelBindingManager.getGlobalOption().getVendor());
256                                                this.database = delimitedChar + SQLUtil.trimColumnStringQuote(this.database) + delimitedChar;
257                                        }
258                                }
259                                if (SQLUtil.isEmpty(this.schema) && properties.containsKey("schema")) {
260                                        this.schema = properties.getProperty("schema");
261                                        if(this.schema.indexOf(".")!=-1) {
262                                                String delimitedChar = TSQLEnv.delimitedChar(ModelBindingManager.getGlobalOption().getVendor());
263                                                this.schema = delimitedChar + SQLUtil.trimColumnStringQuote(this.schema) + delimitedChar;
264                                        }
265                                }
266                        } catch (IOException e) {
267                logger.error("load sql comment properties failed.", e);
268                        }
269                }
270                
271                if (SQLUtil.isEmpty(this.database) || this.database.equals(ModelBindingManager.getGlobalDatabase())) {
272                        TSQLEnv sqlEnv = ModelBindingManager.getGlobalSQLEnv();
273                        if (sqlEnv == null) {
274                                return;
275                        }
276                        int occurrence = 0;
277                        int maxPriority = -1;
278                        String tableDatabase = null;
279                        String tableSchema = null;
280                        Map<Integer, List<String>> databaseSchemasMap = new HashMap<Integer, List<String>>();
281                        for (TSQLCatalog catalog : sqlEnv.getCatalogList()) {
282                                if (SQLUtil.isEmpty(schema) || this.schema.equals(ModelBindingManager.getGlobalSchema())) {
283                                        for (TSQLSchema schema : catalog.getSchemaList()) {
284                                                TSQLSchemaObject tsqlTable = schema.findSchemaObject(DlineageUtil.getSimpleTableName(this.name));
285                                                if (tsqlTable != null) {
286                                                        occurrence += 1;
287                                                        if (tsqlTable.getPriority() > maxPriority
288                                                                        || (maxPriority > 0 && tsqlTable.getPriority() == maxPriority)) {
289                                                                tableDatabase = catalog.getName();
290                                                                if(tableDatabase.indexOf(".")!=-1) {
291                                                                        String delimitedChar = TSQLEnv.delimitedChar(ModelBindingManager.getGlobalOption().getVendor());
292                                                                        tableDatabase = delimitedChar + SQLUtil.trimColumnStringQuote(tableDatabase) + delimitedChar;
293                                                                }
294                                                                tableSchema = schema.getName();
295                                                                if(tableSchema.indexOf(".")!=-1) {
296                                                                        String delimitedChar = TSQLEnv.delimitedChar(ModelBindingManager.getGlobalOption().getVendor());
297                                                                        tableSchema = delimitedChar + SQLUtil.trimColumnStringQuote(tableSchema) + delimitedChar;
298                                                                }
299                                                                maxPriority = tsqlTable.getPriority();
300                                                                if(!databaseSchemasMap.containsKey(maxPriority)) {
301                                                                        databaseSchemasMap.put(maxPriority, new ArrayList<String>());
302                                                                }
303                                                                databaseSchemasMap.get(maxPriority).add(tableDatabase + "___" + tableSchema);
304                                                        }
305                                                }
306                                        }
307                                } else {
308                                        TSQLSchema schema = catalog.getSchema(this.schema, false);
309                                        if (schema != null) {
310                                                TSQLSchemaObject tsqlTable = schema.findSchemaObject(DlineageUtil.getSimpleTableName(this.name));
311                                                if (tsqlTable != null) {
312                                                        occurrence += 1;
313                                                        if (tsqlTable.getPriority() > maxPriority
314                                                                        || (maxPriority > 0 && tsqlTable.getPriority() == maxPriority)) {
315                                                                tableDatabase = catalog.getName();
316                                                                if(tableDatabase.indexOf(".")!=-1) {
317                                                                        String delimitedChar = TSQLEnv.delimitedChar(ModelBindingManager.getGlobalOption().getVendor());
318                                                                        tableDatabase = delimitedChar + SQLUtil.trimColumnStringQuote(tableDatabase) + delimitedChar;
319                                                                }
320                                                                tableSchema = schema.getName();
321                                                                if(tableSchema.indexOf(".")!=-1) {
322                                                                        String delimitedChar = TSQLEnv.delimitedChar(ModelBindingManager.getGlobalOption().getVendor());
323                                                                        tableSchema = delimitedChar + SQLUtil.trimColumnStringQuote(tableSchema) + delimitedChar;
324                                                                }
325                                                                maxPriority = tsqlTable.getPriority();
326                                                                if(!databaseSchemasMap.containsKey(maxPriority)) {
327                                                                        databaseSchemasMap.put(maxPriority, new ArrayList<String>());
328                                                                }
329                                                                databaseSchemasMap.get(maxPriority).add(tableDatabase + "___" + tableSchema);
330                                                        }
331                                                }
332                                        }
333                                }
334                        }
335                        if (occurrence == 1 || (maxPriority > 0 && databaseSchemasMap.get(maxPriority).size() == 1)) {
336                                if (this.database == null && tableDatabase != null && !TSQLEnv.DEFAULT_DB_NAME.equalsIgnoreCase(tableDatabase)) {
337                                        this.database = tableDatabase;
338                                }
339                                if (this.schema == null && tableSchema != null && !TSQLEnv.DEFAULT_SCHEMA_NAME.equalsIgnoreCase(tableSchema)) {
340                                        this.schema = tableSchema;
341                                }
342                        }
343                } else if (SQLUtil.isEmpty(this.schema) || this.schema.equals(ModelBindingManager.getGlobalSchema())) {
344                        TSQLEnv sqlEnv = ModelBindingManager.getGlobalSQLEnv();
345                        if (sqlEnv == null) {
346                                return;
347                        }
348                        int occurrence = 0;
349                        int maxPriority = -1;
350                        String tableDatabase = null;
351                        String tableSchema = null;
352                        Map<Integer, List<String>> databaseSchemasMap = new HashMap<Integer, List<String>>();
353                        TSQLCatalog catalog = sqlEnv.searchCatalog(this.database);
354                        if (catalog != null) {
355                                for (TSQLSchema schema : catalog.getSchemaList()) {
356                                        TSQLSchemaObject tsqlTable = schema.findSchemaObject(DlineageUtil.getSimpleTableName(this.name));
357                                        if (tsqlTable != null) {
358                                                occurrence += 1;
359                                                if (tsqlTable.getPriority() > maxPriority
360                                                                || (maxPriority > 0 && tsqlTable.getPriority() == maxPriority)) {
361                                                        tableDatabase = catalog.getName();
362                                                        if (tableDatabase.indexOf(".") != -1) {
363                                                                String delimitedChar = TSQLEnv
364                                                                                .delimitedChar(ModelBindingManager.getGlobalOption().getVendor());
365                                                                tableDatabase = delimitedChar + SQLUtil.trimColumnStringQuote(tableDatabase)
366                                                                                + delimitedChar;
367                                                        }
368                                                        tableSchema = schema.getName();
369                                                        if (tableSchema.indexOf(".") != -1) {
370                                                                String delimitedChar = TSQLEnv
371                                                                                .delimitedChar(ModelBindingManager.getGlobalOption().getVendor());
372                                                                tableSchema = delimitedChar + SQLUtil.trimColumnStringQuote(tableSchema)
373                                                                                + delimitedChar;
374                                                        }
375                                                        maxPriority = tsqlTable.getPriority();
376                                                        if(!databaseSchemasMap.containsKey(maxPriority)) {
377                                                                databaseSchemasMap.put(maxPriority, new ArrayList<String>());
378                                                        }
379                                                        databaseSchemasMap.get(maxPriority).add(tableDatabase + "___" + tableSchema);
380                                                }
381                                        }
382                                }
383                        }
384
385                        if (occurrence == 1 || (maxPriority > 0 && databaseSchemasMap.get(maxPriority).size() == 1)) {
386                                if (this.database == null && tableDatabase != null && !TSQLEnv.DEFAULT_DB_NAME.equalsIgnoreCase(tableDatabase)) {
387                                        this.database = tableDatabase;
388                                }
389                                if (this.schema == null && tableSchema != null && !TSQLEnv.DEFAULT_SCHEMA_NAME.equalsIgnoreCase(tableSchema)) {
390                                        this.schema = tableSchema;
391                                }
392                        }
393
394                        if (SQLUtil.isEmpty(this.schema) && !SQLUtil.isEmpty(this.database)) {
395                                this.schema = getDefaultSchema();
396                        }
397                }
398        }
399
400        protected void updateProcedureName(boolean supportCatalog, boolean supportSchema) {
401                List<String> segments = SQLUtil.parseNames(this.name);
402                this.name = segments.get(segments.size() - 1);
403                if (supportCatalog && supportSchema) {
404                        StringBuilder builder = new StringBuilder();
405                        if (segments.size() > 2) {
406                                builder.append(segments.get(segments.size() - 3)).append(".");
407                        } else {
408                                if (!SQLUtil.isEmpty(this.database) && !TSQLEnv.DEFAULT_DB_NAME.equalsIgnoreCase(this.database)) {
409                                        builder.append(this.database).append(".");
410                                }
411                        }
412                        if (segments.size() > 1) {
413                                builder.append(segments.get(segments.size() - 2)).append(".");
414                        } else {
415                                if (builder.length() > 0) {
416                                        if (this.schema == null) {
417                                                if (ModelBindingManager.getGlobalVendor() == EDbVendor.dbvmssql) {
418                                                        this.schema = "dbo";
419                                                } else {
420                                                        this.schema = getDefaultSchema();
421                                                }
422                                        }
423                                        else if (TSQLEnv.DEFAULT_SCHEMA_NAME.equalsIgnoreCase(this.schema)
424                                                        && ModelBindingManager.getGlobalVendor() == EDbVendor.dbvmssql) {
425                                                this.schema = "dbo";
426                                        }
427                                        builder.append(this.schema).append(".");
428                                } else {
429                                        if (!SQLUtil.isEmpty(this.schema) && !TSQLEnv.DEFAULT_SCHEMA_NAME.equalsIgnoreCase(this.schema)) {
430                                                builder.append(this.schema).append(".");
431                                        }
432                                }
433                        }
434                        builder.append(this.name);
435                        this.name = builder.toString();
436                } else if (supportCatalog) {
437                        if (segments.size() > 1) {
438                                this.name = segments.get(segments.size() - 2) + "." + this.name;
439                        }
440                        else {
441                                if (!SQLUtil.isEmpty(this.database) && !TSQLEnv.DEFAULT_DB_NAME.equalsIgnoreCase(this.database)) {
442                                        this.name = this.database + "." + this.name;
443                                }
444                        }
445                } else if (supportSchema) {
446                        if (segments.size() > 1) {
447                                this.name = segments.get(segments.size() - 2) + "." + this.name;
448                        } else {
449                                if (!SQLUtil.isEmpty(this.schema) && !TSQLEnv.DEFAULT_SCHEMA_NAME.equalsIgnoreCase(this.schema)) {
450                                        this.name = this.schema + "." + this.name;
451                                }
452                        }
453                }
454        }
455
456    protected String getDefaultServer() {
457        String defaultServer = null;
458        if (ModelBindingManager.getGlobalSQLEnv() != null) {
459            defaultServer = ModelBindingManager.getGlobalSQLEnv().getDefaultServerName();
460        }
461        if (!SQLUtil.isEmpty(defaultServer))
462            return defaultServer;
463        return TSQLEnv.DEFAULT_SERVER_NAME;
464    }
465
466    protected String getDefaultSchema() {
467        String defaultSchema = null;
468        if (ModelBindingManager.getGlobalSQLEnv() != null) {
469            defaultSchema = ModelBindingManager.getGlobalSQLEnv().getDefaultSchemaName();
470        }
471        if (!SQLUtil.isEmpty(defaultSchema))
472            return defaultSchema;
473        return TSQLEnv.DEFAULT_SCHEMA_NAME;
474    }
475
476    protected String getDefaultDatabase() {
477        String defaultDatabase = null;
478        if (ModelBindingManager.getGlobalSQLEnv() != null) {
479            defaultDatabase = ModelBindingManager.getGlobalSQLEnv().getDefaultCatalogName();
480        }
481        if (!SQLUtil.isEmpty(defaultDatabase))
482            return defaultDatabase;
483        return TSQLEnv.DEFAULT_DB_NAME;
484    }
485
486    private TObjectName getProcedureName() {
487        if (procedureObject instanceof TTeradataCreateProcedure) {
488            return ((TTeradataCreateProcedure) procedureObject).getProcedureName();
489        }
490        if (procedureObject instanceof TStoredProcedureSqlStatement) {
491            return ((TStoredProcedureSqlStatement) procedureObject).getStoredProcedureName();
492        }
493        if (procedureObject instanceof TFunctionCall) {
494            return ((TFunctionCall) procedureObject).getFunctionName();
495        }
496        return null;
497    }
498
499    public long getId() {
500        return this.id;
501    }
502
503    public String getName() {
504        return this.name;
505    }
506
507    public void setName(String name) {
508        this.name = name;
509    }
510
511    public Pair3<Long, Long, String> getStartPosition() {
512        return this.startPosition;
513    }
514
515    public Pair3<Long, Long, String> getEndPosition() {
516        return this.endPosition;
517    }
518
519    public String getFullName() {
520        return this.fullName;
521    }
522
523    public void setFullName(String fullName) {
524        this.fullName = fullName;
525    }
526
527    public List<Argument> getArguments() {
528        return this.arguments;
529    }
530
531    public void setArguments(List<Argument> arguments) {
532        this.arguments = arguments;
533    }
534
535    public void addArgument(Argument argument) {
536        if (argument != null && !this.arguments.contains(argument)) {
537            this.arguments.add(argument);
538        }
539
540    }
541
542    public ESqlStatementType getType() {
543        return this.type;
544    }
545
546    public void setType(ESqlStatementType type) {
547        this.type = type;
548    }
549
550    public TParseTreeNode getProcedureObject() {
551        return this.procedureObject;
552    }
553
554    public void setProcedureObject(TParseTreeNode procedureObject) {
555        this.procedureObject = procedureObject;
556    }
557
558    public void setId(int id) {
559        this.id = id;
560    }
561
562    public void setStartPosition(Pair3<Long, Long, String> startPosition) {
563        this.startPosition = startPosition;
564    }
565
566    public void setEndPosition(Pair3<Long, Long, String> endPosition) {
567        this.endPosition = endPosition;
568    }
569
570    public String getDatabase() {
571        return database;
572    }
573
574    public String getSchema() {
575        return schema;
576    }
577
578    public OraclePackage getParentPackage() {
579        return parentPackage;
580    }
581
582    public void setParentPackage(OraclePackage parentPackage) {
583        this.parentPackage = parentPackage;
584    }
585
586    public String getServer() {
587        return server;
588    }
589}