Advertisement
luizarruda_gapso

GPVWSLog 1.0

Dec 19th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.53 KB | None | 0 0
  1. package com.gapso.dashboard.engine;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8.  
  9. import com.gapso.dashboard.utils.DateUtil;
  10.  
  11. public class GPVWSLog {
  12.     String kpi;
  13.     String porto;
  14.     Date data;
  15.  
  16.     public GPVWSLog(String kpi, String Porto, Date data) {
  17.         this.kpi = kpi;
  18.         this.porto = porto;
  19.         this.data = data;
  20.     }
  21.  
  22.     public GPVWSLog(String kpi) {
  23.         this(kpi, "", new Date());
  24.     }
  25.  
  26.     static List<GPVWSLog> lista = new ArrayList<GPVWSLog>();
  27.     static Map<String, List<GPVWSLog>> mapa = new HashMap<String, List<GPVWSLog>>();
  28.     static Map<Date, List<GPVWSLog>> mapaHora = new HashMap<Date, List<GPVWSLog>>();
  29.     static Map<Date, List<GPVWSLog>> mapaDia = new HashMap<Date, List<GPVWSLog>>();
  30.  
  31.     public void logarBuscaGPVWS(String kpi) {
  32.         logarBuscaGPVWS(kpi, "");
  33.     }
  34.  
  35.     public void logarBuscaGPVWS(String kpi, String porto) {
  36.         Date agora = new Date();
  37.         Date agoraHora = DateUtil.getInicioDaHora(agora);
  38.         Date agoraDia = DateUtil.getInicioDoDia(agora);
  39.         GPVWSLog gpvLogEntry = new GPVWSLog(kpi, porto, agora);
  40.         lista.add(gpvLogEntry);
  41.         if (mapa.get(kpi) == null) {
  42.             mapa.put(kpi, new ArrayList<GPVWSLog>());
  43.             mapa.get(kpi).add(gpvLogEntry);
  44.         }
  45.         if (mapaHora.get(agoraHora) == null) {
  46.             mapaHora.put(agoraHora, new ArrayList<GPVWSLog>());
  47.             mapaHora.get(agoraHora).add(gpvLogEntry);
  48.         }
  49.         if (mapaDia.get(agoraDia) == null) {
  50.             mapaDia.put(agoraDia, new ArrayList<GPVWSLog>());
  51.             mapaDia.get(agoraDia).add(gpvLogEntry);
  52.         }
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement