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