Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.21 KB | None | 0 0
  1. import se.telavox.tbone.dao.base.*;
  2. import se.telavox.tbone.dao.util.*;
  3. import se.telavox.tbone.dao.*;
  4. import se.telavox.tbone.*;
  5. import se.telavox.commons.util.*;
  6.  
  7. import se.telavox.tbone.ema.*;
  8. import se.telavox.tbone.ema.MobileUtil.*;
  9. import se.telavox.tbone.ema.CAIUtil.*;
  10. import se.telavox.tbone.HibernateUtil.*;
  11. import se.telavox.tbone.service.*;
  12. import se.telavox.constants.CountrySetting;
  13.  
  14. import org.hibernate.criterion.*;
  15. import org.apache.log4j.Logger;
  16.  
  17. import java.util.concurrent.atomic.*;
  18. import java.time.LocalDate;
  19. import org.joda.time.DateTime;
  20. import java.util.*;
  21.  
  22. import se.telavox.partner.web.tvx.ScriptAction.JavaHelper;
  23.  
  24. /**
  25. * Available public methods in JavaHelper:
  26. * getServletContext(), getPartner(), getCore(), getPartnerUser(), getServices(), getDAOProvider(), println().
  27. */
  28. public class DynScript extends JavaHelper {
  29.  
  30. public void run() {
  31. try {
  32. //Name - Prettyname - Parent - Grandparent - Matchers...
  33. String[][] destAndMatchers = {
  34. { "Customer service (0600)", "Customer service", "ROOT", "ROOT", "003580600" },
  35. { "Customer service (075002)", "Customer service", "ROOT", "ROOT", "00358075002" },
  36. { "Customer service (075302)", "Customer service", "ROOT", "ROOT", "00358075302" },
  37. { "Customer service (075322)", "Customer service", "ROOT", "ROOT", "00358075322" },
  38. { "Customer service (075752)", "Customer service", "ROOT", "ROOT", "00358075752" },
  39. { "Customer service (075982)", "Customer service", "ROOT", "ROOT", "00358075982" },
  40. { "Customer service (02098-9)", "Customer service", "ROOT", "ROOT", "0035802098", "0035802099" },
  41. { "Non-profit service (0100)", "Non-profit service", "ROOT", "ROOT", "003580100" },
  42. { "Non-profit service (0200)", "Non-profit service", "ROOT", "ROOT", "003580200"},
  43. { "Non-profit service (02020/2-3)", "Non-profit service", "ROOT", "ROOT", "0035802020", "0035802022", "0035802023" },
  44. { "Non-profit service (0300)", "Non-profit service", "ROOT", "ROOT", "003580300" },
  45. { "Non-profit service (075001)", "Non-profit service", "ROOT", "ROOT", "00358075001" },
  46. { "Non-profit service (075301)", "Non-profit service", "ROOT", "ROOT", "00358075301" },
  47. { "Non-profit service (075321)", "Non-profit service", "ROOT", "ROOT", "00358075321" },
  48. { "Non-profit service (075751)", "Non-profit service", "ROOT", "ROOT", "00358075751" },
  49. { "Non-profit service (075981)", "Non-profit service", "ROOT", "ROOT", "00358075981" },
  50. { "Directory service (0100100)", "Directory service", "Non-profit service (0100)", "ROOT", "003580100100" },
  51. { "Directory service (020200-7/9)", "Directory service", "Non-profit service (02020/2-3)", "ROOT", "00358020200", "00358020201", "00358020202", "00358020203", "00358020204", "00358020205", "00358020206", "00358020207", "00358020209" },
  52. { "Directory service (0751-2)", "Directory service", "ROOT", "ROOT", "003580751" , "003580752" },
  53. { "Directory service (075000)", "Directory service", "ROOT", "ROOT", "00358075000" },
  54. { "Directory service (075300)", "Directory service", "ROOT", "ROOT", "00358075300" },
  55. { "Directory service (075320)", "Directory service", "ROOT", "ROOT", "00358075320" },
  56. { "Directory service (075750)", "Directory service", "ROOT", "ROOT", "00358075750" },
  57. { "Directory service (075980)", "Directory service", "ROOT", "ROOT", "00358075980" },
  58. { "International call connection service (020208)", "International call connection service", "Non-profit service (02020/2-3)", "ROOT", "00358020208" },
  59. { "Entertainment (0700)", "Entertainment", "ROOT", "ROOT", "003580700" },
  60. { "Freephone service (0800)", "Freephone service", "ROOT", "ROOT", "003580600" },
  61. { "Freephone service (116)", "Freephone service", "ROOT", "ROOT", "00358116" },
  62. };
  63. HashMap<String, PLDest> createdDestinations = new HashMap<String, PLDest>();
  64. PLDest finnishSpecialServicesRoot = (PLDest) HibernateUtil.getSession().load(PLDest.class, XXXX);
  65. createdDestinations.put("ROOT", finnishSpecialServicesRoot);
  66. String[] dayOfWeeks = { "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
  67. for (String[] destAndMatcher : destAndMatchers) {
  68. String originalName = destAndMatcher[0];
  69. String prettyName = destAndMatcher[1];
  70. String parent = destAndMatcher[2];
  71. String grandparent = destAndMatcher[3];
  72.  
  73. String rootName = "Finland - Special Services - ";
  74. String name;
  75. if (!grandparent.equals("ROOT")) {
  76. name = rootName + grandparent + " - " + parent + " - " + originalName;
  77. } else if (!parent.equals("ROOT")) {
  78. name = rootName + parent + " - " + originalName;
  79. } else {
  80. name = rootName + originalName;
  81. }
  82.  
  83. println("Skapar destination: " + name);
  84. PLDest destination = new PLDest(name, createdDestinations.get(parent), new PLDestType(0));
  85. destination.setPrettyname(prettyName);
  86. createdDestinations.put(originalName, destination);
  87. HibernateUtil.getSession().saveOrUpdate(destination);
  88. //Has associated matchers
  89. if (destAndMatcher.length > 4) {
  90. for (int i = 4; i < destAndMatcher.length; i++) {
  91. println("Skapar matcher: " + destAndMatcher[i] + ", för: " + name);
  92. for (String dow : dayOfWeeks) {
  93. PLMatcher matcher = new PLMatcher(destAndMatcher[i], destination);
  94. matcher.setDow(dow);
  95. matcher.setState(StateType.ACTIVE);
  96. HibernateUtil.getSession().saveOrUpdate(matcher);
  97. }
  98. }
  99. }
  100. println("");
  101. }
  102.  
  103. } catch (Throwable t) {
  104. throw new RuntimeException(t);
  105. }
  106. }
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement