Package com.vst.model.ext

Examples of com.vst.model.ext.GeoClassificator


    } else if (code == 2) {
      item = new GeoProvince();
    } else if (code == 3) {
      item = new GeoCity();
    } else {
      item = new GeoClassificator();
    }
    children = new ArrayList<GeoTreeItemDto>();
  }
View Full Code Here


    Map<Integer, GeoTreeItemDto> idxCountry = new HashMap<Integer, GeoTreeItemDto>();
    Map<Integer, GeoTreeItemDto> idxMacroReg = new HashMap<Integer, GeoTreeItemDto>();
    Map<Integer, GeoTreeItemDto> idxProvince = new HashMap<Integer, GeoTreeItemDto>();
    Map<Integer, GeoTreeItemDto> idxCity = new HashMap<Integer, GeoTreeItemDto>();

    GeoClassificator russia = null;
    GeoTreeItemDto res = null;
    for (GeoClassificator item : geolist) {
      if (item instanceof GeoCountry) {
        idxCountry.put(item.getId(), new GeoTreeItemDto(item));
        if (item.getLatinName().equalsIgnoreCase("russia")) {
          russia = item;
        }
      } else if (item instanceof GeoMacroRegion) {
        idxMacroReg.put(item.getId(), new GeoTreeItemDto(item));
      } else if (item instanceof GeoProvince) {
        idxProvince.put(item.getId(), new GeoTreeItemDto(item));
      } else if (item instanceof GeoCity) {
        idxCity.put(item.getId(), new GeoTreeItemDto(item));
      }
    }

    for (GeoTreeItemDto item : idxCity.values()){
      GeoClassificator dbitem = item.getGeoItem();
      GeoTreeItemDto parent = idxProvince.get(dbitem.getParent().getId());
      if (parent != null){
        parent.addChild(item);
      }
    }

    for (GeoTreeItemDto item : idxProvince.values()){
      GeoClassificator dbitem = item.getGeoItem();
      GeoTreeItemDto parent = idxMacroReg.get(dbitem.getParent().getId());
      if (parent != null){
        parent.addChild(item);
      }
    }

    for (GeoTreeItemDto item : idxMacroReg.values()){
      GeoClassificator dbitem = item.getGeoItem();
      GeoTreeItemDto parent = idxCountry.get(dbitem.getParent().getId());
      if (parent != null){
        parent.addChild(item);
      }
    }
View Full Code Here

    if (org==null){
      throw new IllegalArgumentException("Customer with id=" + customerKey +" not found.");
    }
    List<?> countries = getCountryList();
    List<?> provinces = getProvinceListForCountry();
    GeoClassificator ancestor = new GeoClassificator();
    ancestor.setId(org.getAddress().getProvince().getId());
    List<?> cities = getCityListForAncestor(ancestor);
    List<?> contacts = getContactsList(extractKeys(org.getContacts()));

    CustomerFormDto dto = new CustomerFormDto();
    dto.setCities((List<GeoClassificator>) cities);
View Full Code Here

    if (building==null){
      throw new IllegalArgumentException("Building with id=" + buildingKey +" not found.");
    }
    List<?> countries = getCountryList();
    List<?> provinces = getProvinceListForCountry();
    GeoClassificator ancestor = new GeoClassificator();
    ancestor.setId(building.getAddress().getProvince().getId());
    List<?> cities = getCityListForAncestor(ancestor);

    List<?> objectTypes = getObjectTypesList();
    List<?> dangerCategories = getDangerCategoriesList();
    Organization org = getOrganization(building.getBuildingowner().getId());
View Full Code Here

    return dto;
  }

    //========
  public List<?> getProvinceListForCountry(){
    GeoClassificator russia = new GeoCountry();
    russia.setId(2);
    return gatewayDao.getGeoListForAncestor(GeoProvince.class, russia);
  }
View Full Code Here

      Node child = childs.item(i);
      if ((child.getNodeType() == Node.ELEMENT_NODE) || (child
          .getNodeType() == Node.DOCUMENT_NODE)){
        RTreeItem r = getRegionTagCode(child);
        if (r != null) {
          GeoClassificator rparent = parent.item;
          r.item.setParent(rparent);
          r.item.setHierarchyLevel(parent.item.getHierarchyLevel() + 1);
          while (rparent != null) {
            r.item.addAncestor(rparent);
            rparent = rparent.getParent();
          }
          String name = getAttrVal(child,"name");
          r.item.setRegionName(name);
          r.item.setLatinName(toTranslit(name));
          parent.children.add(r);
View Full Code Here

  class RTreeItem {
    GeoClassificator item;
    List<RTreeItem> children;

    public RTreeItem() {
      item = new GeoClassificator();
      children = new ArrayList<RTreeItem>();
    }
View Full Code Here

      } else if (code == 2){
        item = new GeoProvince();
      } else if (code == 3){
        item = new GeoCity();
      }else{
        item = new GeoClassificator();
      }
      children = new ArrayList<RTreeItem>();
    }
View Full Code Here

      @Override
      public Object doInTransaction(TransactionStatus arg0) {
        long start = System.currentTimeMillis();
        //manager.getGeoTree();
                GeoClassificator ancestor = new GeoClassificator();
                ancestor.setId(2);
        List<?> qList = manager.getCityListForAncestor(ancestor);

            long end = System.currentTimeMillis();
          System.out.println("Work time:" + (end - start) );
        return qList;
View Full Code Here

  }

  public List<GeoClassificator> getGeoListForAncestor(
      Class<? extends GeoClassificator> clazz, GeoClassificator parent) {
    final Class<?> lclazz = clazz;
    final GeoClassificator lparent = parent;
    List<GeoClassificator> res = (List<GeoClassificator>) getHibernateTemplate()
        .execute(new HibernateCallback() {

          public List<GeoClassificator> doInHibernate(Session arg0)
              throws HibernateException, SQLException {
            Query q = getSession().createQuery(
                "select p  from " + lclazz.getName() + " as p "
                    + " where (select n from  "
                    + GeoClassificator.class.getName()
                    + " as n where n.id=" + lparent.getId()
                    + ") in elements (p.ancestors)");
            List<GeoClassificator> qlist = q.list();

            return qlist;
          }
View Full Code Here

TOP

Related Classes of com.vst.model.ext.GeoClassificator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.