Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import se.telavox.tbone.dao.base.*;
- import se.telavox.tbone.dao.util.*;
- import se.telavox.tbone.dao.*;
- import se.telavox.tbone.*;
- import se.telavox.commons.util.*;
- import se.telavox.tbone.ema.*;
- import se.telavox.tbone.ema.MobileUtil.*;
- import se.telavox.tbone.ema.CAIUtil.*;
- import se.telavox.tbone.HibernateUtil.*;
- import se.telavox.tbone.service.*;
- import se.telavox.constants.CountrySetting;
- import org.hibernate.criterion.*;
- import org.apache.log4j.Logger;
- import java.util.concurrent.atomic.*;
- import java.time.LocalDate;
- import org.joda.time.DateTime;
- import java.util.*;
- import se.telavox.partner.web.tvx.ScriptAction.JavaHelper;
- /**
- * Available public methods in JavaHelper:
- * getServletContext(), getPartner(), getCore(), getPartnerUser(), getServices(), getDAOProvider(), println().
- */
- public class DynScript extends JavaHelper {
- public void run() {
- try {
- //Name - Prettyname - Parent - Grandparent - Matchers...
- String[][] destAndMatchers = {
- { "Customer service (0600)", "Customer service", "ROOT", "ROOT", "003580600" },
- { "Customer service (075002)", "Customer service", "ROOT", "ROOT", "00358075002" },
- { "Customer service (075302)", "Customer service", "ROOT", "ROOT", "00358075302" },
- { "Customer service (075322)", "Customer service", "ROOT", "ROOT", "00358075322" },
- { "Customer service (075752)", "Customer service", "ROOT", "ROOT", "00358075752" },
- { "Customer service (075982)", "Customer service", "ROOT", "ROOT", "00358075982" },
- { "Customer service (02098-9)", "Customer service", "ROOT", "ROOT", "0035802098", "0035802099" },
- { "Non-profit service (0100)", "Non-profit service", "ROOT", "ROOT", "003580100" },
- { "Non-profit service (0200)", "Non-profit service", "ROOT", "ROOT", "003580200"},
- { "Non-profit service (02020/2-3)", "Non-profit service", "ROOT", "ROOT", "0035802020", "0035802022", "0035802023" },
- { "Non-profit service (0300)", "Non-profit service", "ROOT", "ROOT", "003580300" },
- { "Non-profit service (075001)", "Non-profit service", "ROOT", "ROOT", "00358075001" },
- { "Non-profit service (075301)", "Non-profit service", "ROOT", "ROOT", "00358075301" },
- { "Non-profit service (075321)", "Non-profit service", "ROOT", "ROOT", "00358075321" },
- { "Non-profit service (075751)", "Non-profit service", "ROOT", "ROOT", "00358075751" },
- { "Non-profit service (075981)", "Non-profit service", "ROOT", "ROOT", "00358075981" },
- { "Directory service (0100100)", "Directory service", "Non-profit service (0100)", "ROOT", "003580100100" },
- { "Directory service (020200-7/9)", "Directory service", "Non-profit service (02020/2-3)", "ROOT", "00358020200", "00358020201", "00358020202", "00358020203", "00358020204", "00358020205", "00358020206", "00358020207", "00358020209" },
- { "Directory service (0751-2)", "Directory service", "ROOT", "ROOT", "003580751" , "003580752" },
- { "Directory service (075000)", "Directory service", "ROOT", "ROOT", "00358075000" },
- { "Directory service (075300)", "Directory service", "ROOT", "ROOT", "00358075300" },
- { "Directory service (075320)", "Directory service", "ROOT", "ROOT", "00358075320" },
- { "Directory service (075750)", "Directory service", "ROOT", "ROOT", "00358075750" },
- { "Directory service (075980)", "Directory service", "ROOT", "ROOT", "00358075980" },
- { "International call connection service (020208)", "International call connection service", "Non-profit service (02020/2-3)", "ROOT", "00358020208" },
- { "Entertainment (0700)", "Entertainment", "ROOT", "ROOT", "003580700" },
- { "Freephone service (0800)", "Freephone service", "ROOT", "ROOT", "003580600" },
- { "Freephone service (116)", "Freephone service", "ROOT", "ROOT", "00358116" },
- };
- HashMap<String, PLDest> createdDestinations = new HashMap<String, PLDest>();
- PLDest finnishSpecialServicesRoot = (PLDest) HibernateUtil.getSession().load(PLDest.class, XXXX);
- createdDestinations.put("ROOT", finnishSpecialServicesRoot);
- String[] dayOfWeeks = { "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };
- for (String[] destAndMatcher : destAndMatchers) {
- String originalName = destAndMatcher[0];
- String prettyName = destAndMatcher[1];
- String parent = destAndMatcher[2];
- String grandparent = destAndMatcher[3];
- String rootName = "Finland - Special Services - ";
- String name;
- if (!grandparent.equals("ROOT")) {
- name = rootName + grandparent + " - " + parent + " - " + originalName;
- } else if (!parent.equals("ROOT")) {
- name = rootName + parent + " - " + originalName;
- } else {
- name = rootName + originalName;
- }
- println("Skapar destination: " + name);
- PLDest destination = new PLDest(name, createdDestinations.get(parent), new PLDestType(0));
- destination.setPrettyname(prettyName);
- createdDestinations.put(originalName, destination);
- HibernateUtil.getSession().saveOrUpdate(destination);
- //Has associated matchers
- if (destAndMatcher.length > 4) {
- for (int i = 4; i < destAndMatcher.length; i++) {
- println("Skapar matcher: " + destAndMatcher[i] + ", för: " + name);
- for (String dow : dayOfWeeks) {
- PLMatcher matcher = new PLMatcher(destAndMatcher[i], destination);
- matcher.setDow(dow);
- matcher.setState(StateType.ACTIVE);
- HibernateUtil.getSession().saveOrUpdate(matcher);
- }
- }
- }
- println("");
- }
- } catch (Throwable t) {
- throw new RuntimeException(t);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement