package com.rthoni.intellij.codefromds.dbo.template;

import java.util.List;
import java.util.Vector;

/**
 * Created by robin on 11/18/16.
 */
public class DataSourceDbo {

    private String _name;

    private List<TableDataSourceDbo> _tables = new Vector<>();

    private List<StoredProcedureDbo> _storedProcedures = new Vector<>();

    public List<StoredProcedureDbo> getStoredProcedures() {
        return _storedProcedures;
    }

    public void addStoredProcedure(StoredProcedureDbo storedProcedures) {
        _storedProcedures.add(storedProcedures);
    }

    public String getName() {
        return _name;
    }

    public void setName(String name) {
        _name = name;
    }

    public List<TableDataSourceDbo> getTables() {
        return _tables;
    }

    public void addTable(TableDataSourceDbo table) {
        _tables.add(table);
    }

    public TableDataSourceDbo findTable(String name)
    {
        for (TableDataSourceDbo table : _tables) {
            if (table.getName().equals(name)) {
                return table;
            }
        }
        return null;
    }

    public StoredProcedureDbo findStoredProcedure(String name)
    {
        for (StoredProcedureDbo sp : _storedProcedures) {
            if (sp.getFullName().equals(name)) {
                return sp;
            }
        }
        return null;
    }
}
