Advertisement
Samsul8908

My View Model

Apr 3rd, 2019
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.17 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package com.eksad.ddms.gigr.h3.web.viewmodel.checkarea;
  7.  
  8. import com.eksad.ddms.Gmarkers;
  9. import com.eksad.ddms.gigr.h3.dto.AhassDTO;
  10. import com.eksad.ddms.gigr.h3.dto.StockDTO;
  11. import com.eksad.ddms.gigr.h3.dto.checkarea.CheckAreaDTO;
  12. import com.eksad.ddms.gigr.h3.web.service.checkarea.CheckAreaService;
  13. import java.util.ArrayList;
  14. import java.util.List;
  15. import java.util.Map;
  16. import org.zkoss.bind.annotation.AfterCompose;
  17. import org.zkoss.bind.annotation.Command;
  18. import org.zkoss.bind.annotation.Init;
  19. import org.zkoss.bind.annotation.NotifyChange;
  20. import org.zkoss.gmaps.Gmaps;
  21. import org.zkoss.gmaps.Gmarker;
  22. import org.zkoss.gmaps.Mapitem;
  23. import org.zkoss.xel.VariableResolver;
  24. import org.zkoss.zk.ui.Component;
  25. import org.zkoss.zk.ui.select.annotation.Wire;
  26. import org.zkoss.zk.ui.util.Composer;
  27. import org.zkoss.zk.ui.util.Template;
  28.  
  29. /**
  30.  *
  31.  * @author eksad
  32.  */
  33. public class CheckAvailabilityOnAreaVM {
  34.    @Wire
  35.    Gmaps gmaps;
  36.     private Double lat;
  37.     private Double lng;
  38.     List<CheckAreaDTO> areaList=new ArrayList<>();
  39.     CheckAreaService serv;
  40.     @Init
  41.     public void init() {  
  42.         gmaps=new Gmaps();
  43.         gmaps.enableBindingAnnotation();    
  44.         serv=new CheckAreaService();
  45.         lat=-6.206040;
  46.         lng=106.818771;
  47.         areaList= serv.findNearBy(lat, lng);
  48.         for(CheckAreaDTO area : areaList){
  49.             if(area.getLatitude()!=null && area.getLongitute()!=null){
  50.                 Gmarker marker=new Gmarker();
  51.                 marker.setLat(area.getLatitude());
  52.                 marker.setLng(area.getLongitute());
  53.                 marker.setOpen(true);
  54.                 marker.setParent(gmaps);
  55.             }            
  56.         }
  57.         gmaps.focus();    
  58.     }
  59.    @AfterCompose
  60.    @NotifyChange("areaList")
  61.    public void aftercomp(){
  62.         CheckAreaService serv=new CheckAreaService();
  63.         areaList= serv.findNearBy(lat, lng);  
  64.         lat=-6.206040;
  65.         lng=106.818771;        
  66.         areaList= serv.findNearBy(lat, lng);  
  67.         for(CheckAreaDTO area : areaList){
  68.             if(area.getLatitude()!=null && area.getLongitute()!=null){
  69.                 Gmarker marker=new Gmarker();
  70.                 marker.setLat(area.getLatitude());
  71.                 marker.setLng(area.getLongitute());
  72.                 marker.setOpen(true);
  73.                 marker.setParent(gmaps);
  74.             }            
  75.         }
  76.        
  77.     }
  78.    
  79.     public Double getLat() {
  80.         return lat;
  81.     }
  82.  
  83.     public void setLat(Double lat) {
  84.         this.lat = lat;
  85.     }
  86.  
  87.     public Double getLng() {
  88.         return lng;
  89.     }
  90.  
  91.     public void setLng(Double lng) {
  92.         this.lng = lng;
  93.     }
  94.  
  95.     public Gmaps getGmaps() {
  96.         return gmaps;
  97.     }
  98.  
  99.     public void setGmaps(Gmaps gmaps) {
  100.         this.gmaps = gmaps;
  101.     }
  102.  
  103.     public List<CheckAreaDTO> getAreaList() {
  104.         return areaList;
  105.     }
  106.  
  107.     public void setAreaList(List<CheckAreaDTO> areaList) {
  108.         this.areaList = areaList;
  109.     }
  110.    
  111. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement