PageRenderTime 21ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/src/mpv5/db/objects/ProductList.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 105 lines | 59 code | 14 blank | 32 comment | 3 complexity | aa93433809762cf1c24adfb2fd9b43fa MD5 | raw file
Possible License(s): LGPL-3.0, Apache-2.0, GPL-3.0, GPL-2.0, AGPL-3.0, JSON, BSD-3-Clause
  1. /*
  2. * This file is part of YaBS.
  3. *
  4. * YaBS is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * YaBS is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with YaBS. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. package mpv5.db.objects;
  18. import java.math.BigDecimal;
  19. import java.util.ArrayList;
  20. import java.util.logging.Level;
  21. import java.util.logging.Logger;
  22. import javax.swing.JComponent;
  23. import mpv5.db.common.Context;
  24. import mpv5.db.common.DatabaseObject;
  25. import mpv5.db.common.QueryCriteria;
  26. import mpv5.db.common.QueryHandler;
  27. import mpv5.logging.Log;
  28. import mpv5.ui.panels.ProductListsPanel;
  29. import mpv5.utils.images.MPIcon;
  30. /**
  31. *
  32. *
  33. */
  34. public class ProductList extends DatabaseObject {
  35. private String description;
  36. private boolean asproduct = false;
  37. public ProductList() {
  38. setContext(Context.getProductlist());
  39. }
  40. @Override
  41. public JComponent getView() {
  42. return new ProductListsPanel();
  43. }
  44. @Override
  45. public mpv5.utils.images.MPIcon getIcon() {
  46. return new MPIcon("/mpv5/resources/images/22/playlist.png");
  47. }
  48. /**
  49. * @return the description
  50. */
  51. public String __getDescription() {
  52. return description;
  53. }
  54. /**
  55. * @param description the description to set
  56. */
  57. public void setDescription(String description) {
  58. this.description = description;
  59. }
  60. /**
  61. * @return the asproduct
  62. */
  63. public boolean __isAsproduct() {
  64. return asproduct;
  65. }
  66. /**
  67. * @param asproduct the asproduct to set
  68. */
  69. public void setAsproduct(boolean asproduct) {
  70. this.asproduct = asproduct;
  71. }
  72. @Override
  73. public boolean delete() {
  74. QueryCriteria c = new QueryCriteria("productlistsids", __getIDS());
  75. if (asproduct) {
  76. try {
  77. QueryHandler.instanceOf().clone(Context.getProduct()).delete(c);
  78. } catch (Exception ex) {
  79. Log.Debug(ex);
  80. }
  81. }
  82. return super.delete();
  83. }
  84. @Override
  85. public boolean save(boolean b) {
  86. if (getCname().length() == 0) {
  87. setCname("<unnamed>");
  88. }
  89. return super.save(b);
  90. }
  91. }