Пример #1
0
  public static boolean isPrevDisabled(String name) {
    String getStatus = "";
    PropertyDao propDao = (PropertyDao) SpringUtils.getBean("propertyDao");
    List<Property> pList = propDao.findByName("hide_prevention_stop_signs");

    Iterator<Property> i = pList.iterator();

    while (i.hasNext()) {
      Property item = i.next();
      getStatus = item.getValue();
    }

    Pattern pattern = Pattern.compile("(\\[)(.*?)(\\])");
    Matcher matcher = pattern.matcher(getStatus);
    List<String> listMatches = new ArrayList<String>();

    while (matcher.find()) {

      listMatches.add(matcher.group(2));
    }

    int x = 0;
    for (String s : listMatches) {

      if (name.equals(s)) {
        x++;
      }
    }

    if (x > 0) {
      return true;
    } else {
      return false;
    }
  }
Пример #2
0
 /** Retrieve colour for current provider first by querying property table */
 public String getColour() {
   PropertyDao dao = SpringUtils.getBean(PropertyDao.class);
   List<Property> props = dao.findByNameAndProvider(strColName, provider);
   for (Property prop : props) {
     return prop.getValue();
   }
   return "";
 }
Пример #3
0
 public static String getCustomPreventionItems() {
   String itemsToRemove = "";
   PropertyDao propertyDao = (PropertyDao) SpringUtils.getBean("propertyDao");
   Property p = propertyDao.checkByName(HIDE_PREVENTION_ITEM);
   if (p != null && p.getValue() != null) {
     itemsToRemove = p.getValue();
   }
   return itemsToRemove;
 }
Пример #4
0
 public void addCustomPreventionItems(String items) {
   boolean propertyExists = isHidePrevItemExist();
   if (propertyExists) {
     Property p = propertyDao.checkByName(HIDE_PREVENTION_ITEM);
     p.setValue(items);
     propertyDao.merge(p);
   } else {
     Property x = new Property();
     x.setName("hide_prevention_item");
     x.setValue(items);
     propertyDao.persist(x);
   }
 }
Пример #5
0
 public boolean isHidePrevItemExist() {
   List<Property> props = propertyDao.findByName(HIDE_PREVENTION_ITEM);
   if (props.size() > 0) {
     return true;
   }
   return false;
 }
Пример #6
0
  public static boolean isCreated() {
    String getStatus = "";
    PropertyDao propDao = (PropertyDao) SpringUtils.getBean("propertyDao");
    List<Property> pList = propDao.findByName("hide_prevention_stop_signs");

    Iterator<Property> i = pList.iterator();

    while (i.hasNext()) {
      Property item = i.next();
      getStatus = item.getName();
    }

    if (getStatus.equals("hide_prevention_stop_signs")) {
      return true;
    } else {
      return false;
    }
  }
Пример #7
0
  public static boolean isDisabled() {
    String getStatus = "";
    PropertyDao propDao = (PropertyDao) SpringUtils.getBean("propertyDao");
    List<Property> pList = propDao.findByName("hide_prevention_stop_signs");

    Iterator<Property> i = pList.iterator();

    while (i.hasNext()) {
      Property item = i.next();
      getStatus = item.getValue();
    }

    // disable all preventions warnings if result is master
    if (getStatus.equals("master")) {
      return true;
    } else {
      return false;
    }
  }
Пример #8
0
  /** set colour in property table */
  public boolean setColour(String c) {
    PropertyDao dao = SpringUtils.getBean(PropertyDao.class);
    List<Property> props = dao.findByNameAndProvider(strColName, provider);
    Property property = null;
    for (Property p : props) {
      property = p;
      break;
    }

    if (property == null) {
      property = new Property();
    }

    property.setValue(c);
    property.setName(strColName);
    property.setProviderNo(provider);

    dao.saveEntity(property);

    return true;
  }
Пример #9
0
  public boolean hideItem(String item) {
    String itemsToRemove = null;
    Property p = propertyDao.checkByName(HIDE_PREVENTION_ITEM);

    if (p != null && p.getValue() != null) {
      itemsToRemove = p.getValue();
      List<String> items = Arrays.asList(itemsToRemove.split("\\s*,\\s*"));
      for (String i : items) {
        if (i.equals(item)) {
          return true;
        }
      }
    }
    return false;
  }