You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DataSourceDbo.java 2.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package com.rthoni.intellij.codefromds.dbo.template;
  2. import java.util.List;
  3. import java.util.Vector;
  4. /**
  5. * Created by robin on 11/18/16.
  6. */
  7. public class DataSourceDbo {
  8. private String _name;
  9. private List<TableDataSourceDbo> _tables = new Vector<>();
  10. private List<TableDataSourceDbo> _types = new Vector<>();
  11. private List<StoredProcedureDbo> _storedProcedures = new Vector<>();
  12. public List<StoredProcedureDbo> getStoredProcedures() {
  13. return _storedProcedures;
  14. }
  15. public void addStoredProcedure(StoredProcedureDbo storedProcedures) {
  16. _storedProcedures.add(storedProcedures);
  17. }
  18. public String getName() {
  19. return _name;
  20. }
  21. public void setName(String name) {
  22. _name = name;
  23. }
  24. public List<TableDataSourceDbo> getTables() {
  25. return _tables;
  26. }
  27. public void addTable(TableDataSourceDbo table) {
  28. _tables.add(table);
  29. }
  30. public List<TableDataSourceDbo> getTypes() {
  31. return _types;
  32. }
  33. public List<TableDataSourceDbo> getTablesAndTypes() {
  34. List<TableDataSourceDbo> all = new Vector<>();
  35. all.addAll(_tables);
  36. all.addAll(_types);
  37. return all;
  38. }
  39. public void addType(TableDataSourceDbo types) {
  40. _types.add(types);
  41. }
  42. public TableDataSourceDbo findTable(String name)
  43. {
  44. for (TableDataSourceDbo table : _tables) {
  45. if (table.getName().equals(name)) {
  46. return table;
  47. }
  48. }
  49. return null;
  50. }
  51. public TableDataSourceDbo findType(String name)
  52. {
  53. for (TableDataSourceDbo table : _types) {
  54. if (table.getName().equals(name)) {
  55. return table;
  56. }
  57. }
  58. return null;
  59. }
  60. public TableDataSourceDbo findTypeOrTable(String name)
  61. {
  62. TableDataSourceDbo type = findType(name);
  63. if (type == null) {
  64. return findTable(name);
  65. }
  66. return type;
  67. }
  68. public StoredProcedureDbo findStoredProcedure(String name)
  69. {
  70. for (StoredProcedureDbo sp : _storedProcedures) {
  71. if (sp.getFullName().equals(name)) {
  72. return sp;
  73. }
  74. }
  75. return null;
  76. }
  77. }