1. package service;
  2. /**
  3.  * @author Julija
  4.  */
  5. import model.Alarm;
  6. import model.Location;
  7. import model.Product;
  8. import model.Stack;
  9. import model.Stack.DryState;
  10. import dao.AlarmDao;
  11. import dao.LocationDao;
  12. import dao.ProductDao;
  13.  
  14. public class Service {
  15. private static final Service INSTANCE = new Service();
  16.  
  17. private Service() {
  18. }
  19.  
  20. public static Service getInstance() {
  21. return INSTANCE;
  22. }
  23.  
  24.  
  25. public boolean isNumber(String input) {
  26. boolean isNumber = false;
  27. for (int i = 0; i < input.length(); i++) { // Goes through the string char by char
  28. if(isCharNumber(input.charAt(i))){
  29. isNumber = true;
  30. } else {
  31. return false;
  32. }
  33. }
  34. return isNumber;
  35. }
  36.  
  37. boolean isCharNumber(char cha){
  38. char[] number = {'0','1','2','3','4','5','6','7','8','9'};
  39. for (int i = 0; i < 10; i++){ // Compares specific char in the string with every number as a char to test wether it is a number
  40. if (cha == number[i]){
  41. return true;
  42. }
  43. }
  44. return false;
  45. }
  46.  
  47.  
  48. public void createObjects() {
  49.  
  50. Location area1 = new Location("Area1", "AR1");
  51. LocationDao.storeLocation(area1);
  52.  
  53. Location area2 = new Location("Area2", "AR2");
  54. LocationDao.storeLocation(area2);
  55.  
  56. Location area3 = new Location("Area3", "AR3");
  57. LocationDao.storeLocation(area3);
  58.  
  59. Alarm alarm1 = new Alarm(5, 5);
  60. AlarmDao.storeAlarm(alarm1);
  61.  
  62. Alarm alarm2 = new Alarm(5, 5);
  63. AlarmDao.storeAlarm(alarm2);
  64.  
  65. Alarm alarm3 = new Alarm(0, 0);
  66. AlarmDao.storeAlarm(alarm3);
  67.  
  68. for (int i=0;i<=20;i++)
  69. {
  70. ProductDao.storeProduct(new Product("SK"+i, "Candy made of liqorice in the middle with "+i+" coatings of colored sugar.", null));
  71. ProductDao.storeProduct(new Product("AB"+i, "Candy made of liqorice in the middle with "+i+" coatings of colored sugar.", null));
  72. ProductDao.storeProduct(new Product("ZF"+i, "Candy made of liqorice in the middle with "+i+" coatings of colored sugar.", null));
  73. }
  74. System.out.println(ProductDao.getAllProducts());
  75.  
  76.  
  77.  
  78. }
  79.  
  80. }
  81.