Class StatNewDB

java.lang.Object
sk.iway.iwcm.stat.StatNewDB

public class StatNewDB extends Object
StatNewDB.java
  • Constructor Details

    • StatNewDB

      protected StatNewDB()
  • Method Details

    • getTableSuffix

      public static String[] getTableSuffix(long dateFrom, long dateTo)
      Vytvori pole suffixov tabuliek v rozsahu zadanych datumov
      Parameters:
      dateFrom -
      dateTo -
      Returns:
    • getTableSuffix

      public static String[] getTableSuffix(String tableName, long dateFrom, long dateTo)
      Vytvori pole suffixov tabuliek v rozsahu zadanych datumov pre zadanu tabulku
      Parameters:
      tableName -
      dateFrom -
      dateTo -
      Returns:
    • getTableSuffix

      public static String getTableSuffix(String tableName)
    • createStatTablesFromError

      public static boolean createStatTablesFromError(String errorMessage, String suffix)
      Skontroluje v popise chyby ci nastala chyba, ze neexistuje partitioning tabulka ak ano vytvori ju a vrati true, inak vrati false. Takato chyba nastava v statistike ked je nastavene obdobie, pre ktore este neexistuje vytvorena tabulka.
      Parameters:
      errorMessage -
      suffix -
      Returns:
    • createStatTablesFromError

      public static boolean createStatTablesFromError(String errorMessage, String suffix, String tableName)
    • prepareStatement

      public static PreparedStatement prepareStatement(Connection dbConn, String sql) throws SQLException
      Vytvori a nastavi default parametre pre PS - cursor a fetch size (setri pamat)
      Parameters:
      dbConn -
      sql -
      Returns:
      Throws:
      SQLException
    • createStatTable

      public static void createStatTable(String tableName, String suffix)
      Vytvori tabulku stat_views_X_Y (ak treba)
      Parameters:
      tableName -
      suffix - - suffix tabulky, alebo null (vytvori sa suffix pre aktualny mesiac)
    • getDMYSelect

      public static String getDMYSelect(String fieldName)
      Vrati SQL volanie pre vypis vt_day, vt_month a vt_year pre jednotlive DB
      Parameters:
      fieldName -
      Returns:
    • getYWSelect

      public static String getYWSelect(String fieldName)
      Vrati SQL volanie do SELECTU pre vypis vt_year a vt_week
      Parameters:
      fieldName -
      Returns:
    • getYMSelect

      public static String getYMSelect(String fieldName)
    • getDateSelect

      public static String getDateSelect(String type, String fieldName, String as)
      Vrati SQL pre datum pre rozne DB
      Parameters:
      type -
      fieldName -
      as -
      Returns:
    • getDateGroupBy

      public static String getDateGroupBy(String type, String fieldName, String as)
    • getDMYGroupBy

      public static String getDMYGroupBy(String fieldName)
    • getYWGroupBy

      public static String getYWGroupBy(String fieldName)
    • getYMGroupBy

      public static String getYMGroupBy(String fieldName)
    • getTopPages

      public static List<Column> getTopPages(int max_size, Date from, Date to, int rootGroupId, String skipDocIds)
    • getTopPages

      public static List<Column> getTopPages(int max_size, Date from, Date to, int rootGroupId, String skipDocIds, boolean withoutBots)
      Vygeneruje tabulku videni, sedeni, roznych userov pre top stranky za zvolene obdobie
      Parameters:
      max_size -
      from -
      to -
      rootGroupId -
      skipDocIds -
      Returns:
    • getTopPagesIn

      public static List<Column> getTopPagesIn(int max_size, Date from, Date to, int rootGroupId, String skipDocIds)
    • getTopPagesIn

      public static List<Column> getTopPagesIn(int max_size, Date from, Date to, int rootGroupId, String skipDocIds, boolean withoutBots)
      Vrati zoznam nanavstevovanejsich vstupnych stranok
      Parameters:
      max_size -
      from -
      to -
      rootGroupId -
      skipDocIds -
      Returns:
    • getTopPagesOut

      public static List<Column> getTopPagesOut(int max_size, Date from, Date to, int rootGroupId, String skipDocIds)
    • getTopPagesOut

      public static List<Column> getTopPagesOut(int max_size, Date from, Date to, int rootGroupId, String skipDocIds, boolean withoutBots)
      Ziska z databazy zoznam stranok, ktore boli posledne vramci session
      Parameters:
      max_size -
      from -
      to -
      rootGroupId -
      skipDocIds -
      Returns:
    • getPageViews

      public static List<Column> getPageViews(int docId, Date from, Date to)
      Vygeneruje pre zvolene docID tabulku videni, sedeni, roznych userov za zvolene obdobie podla DNI
      Parameters:
      docId -
      from -
      to -
      Returns:
    • getPageViews

      public static List<Column> getPageViews(int docId, Date from, Date to, int lastDocId)
      Vygeneruje pre zvolene docID tabulku videni, sedeni, roznych userov za zvolene obdobie podla DNI a podla referera
      Parameters:
      docId -
      from -
      to -
      lastDocId - - referer, ak je nastavene na -1, neberie sa do uvahy
      Returns:
    • getWeekViews

      public static List<Column> getWeekViews(Date from, Date to, int rootGroupId)
      Vrati statistiku podla tyzdnov za dane obdobie a adresar
      Parameters:
      from -
      to -
      rootGroupId -
      Returns:
    • getWeekViews

      public static List<Column> getWeekViews(Date from, Date to, int rootGroupId, boolean withoutBots)
    • getWeekViews

      public static List<Column> getWeekViews(Date from, Date to, String groupIds)
    • getWeekViews

      public static List<Column> getWeekViews(Date from, Date to, String groupIds, boolean withoutBots)
      Vrati statistiku podla tyzdnov za dane obdobie a adresar
      Parameters:
      from -
      to -
      groupIds -
      withoutBots -
      Returns:
    • getDayViews

      public static List<Column> getDayViews(Date from, Date to, int rootGroupId)
      Vrati statistiku podla dni za dane obdobie
      Parameters:
      from -
      to -
      rootGroupId -
      Returns:
    • getDayViews

      public static List<Column> getDayViews(Date from, Date to, int rootGroupId, boolean filterBotsOut)
    • getDayViews

      public static List<Column> getDayViews(Date from, Date to, String groupIds)
    • getDayViews

      public static List<Column> getDayViews(Date from, Date to, String groupIds, boolean withoutBots)
      Vrati statistiku podla dni za dane obdobie
      Parameters:
      from -
      to -
      groupIds -
      withoutBots -
      Returns:
    • getHours

      public static List<Column> getHours(Date from, Date to, int rootGroupId)
      Vrati statistiku podla hodin za dane obdobie
      Parameters:
      from -
      to -
      rootGroupId -
      Returns:
    • getHours

      public static List<Column> getHours(Date from, Date to, int rootGroupId, boolean withoutBots)
    • getHours

      public static List<Column> getHours(Date from, Date to, String groupIds)
    • getHours

      public static List<Column> getHours(Date from, Date to, String groupIds, boolean withoutBots)
      Vrati statistiku podla hodin za dane obdobie
      Parameters:
      from -
      to -
      groupIds -
      withoutBots -
      Returns:
    • getMonthViews

      public static List<Column> getMonthViews(Date from, Date to, int rootGroupId)
      Vrati statistiku podla dni za dane obdobie
      Parameters:
      from -
      to -
      rootGroupId -
      Returns:
    • getMonthViews

      public static List<Column> getMonthViews(Date from, Date to, int rootGroupId, boolean withoutBots)
    • getMonthViews

      public static List<Column> getMonthViews(Date from, Date to, String groupIds)
    • getMonthViews

      public static List<Column> getMonthViews(Date from, Date to, String groupIds, boolean withoutBots)
      Vrati statistiku podla dni za dane obdobie
      Parameters:
      from -
      to -
      groupIds - - id adresarov oddelenych ciarkou
      withoutBots -
      Returns:
    • getStatReferer

      public static List<Column> getStatReferer(Date from, Date to, int maxRows, String groupIdsQuery)
      Parameters:
      from -
      to -
      maxRows -
      groupIdsQuery -
      Returns:
    • getUniqueUsersFromStatViews

      public static int getUniqueUsersFromStatViews(Date from, Date to, int rootGroupId)
      Vrati pocet unikatnych pouzivatelov za stanovene obdobie z tab. stat_ views
      Parameters:
      from -
      to -
      rootGroupId -
      Returns:
    • getUniqueUsersFromStatViews

      public static int getUniqueUsersFromStatViews(Date from, Date to, int rootGroupId, boolean withoutBots)
    • getUniqueUsersFromStatViews

      public static int getUniqueUsersFromStatViews(Date from, Date to, String groupIds)
    • getUniqueUsersFromStatViews

      public static int getUniqueUsersFromStatViews(Date from, Date to, String groupIds, boolean withoutBots)
      Vrati pocet unikatnych pouzivatelov za stanovene obdobie z tab. stat_ views
      Parameters:
      from -
      to -
      groupIds -
      withoutBots -
      Returns:
    • getViewsForDoc

      public static List<Column> getViewsForDoc(Date from, Date to, int docId)
      Vygeneruje pre zvolene docID tabulku videni, sedeni, roznych userov za zvolene obdobie podla TYZDNOV
      Parameters:
      from -
      to -
      docId -
      Returns:
    • getMonthViewsForDoc

      public static List<Column> getMonthViewsForDoc(int backInterval, int docId)
      Vygeneruje pre zvolenu rootGroupID tabulku videni, sedeni, roznych userov za zvolene obdobie
      Parameters:
      backInterval - - pocet mesiacov spat, za ktore sa ma vygenerovat statistika
      docId -
      Returns:
    • getIncomingStats

      public static List<Column> getIncomingStats(int docId, Date from, Date to, String groupIdsQuery, javax.servlet.http.HttpServletRequest request)
      Vygeneruje pre zvolene docID tabulku kolko na dane docId prislo navstev z ktoreho docId
      Parameters:
      docId -
      from -
      to -
      Returns:
    • getOutgoingStats

      public static List<Column> getOutgoingStats(int docId, Date from, Date to)
      Vygeneruje pre zvolene docID tabulku kolko z docId navstev islo na ktore docId
      Parameters:
      docId -
      from -
      to -
      Returns:
    • getUserStatViews

      public static List<Column> getUserStatViews(int userId, Date from, Date to, int rootGroupId)
      Funkcia, ktora vrati zoznam vsetkych pristupov daneho registrovaneho pouzivatela zoradenych od najnovsieho po najstarsi.
      Zoznam obshauje identifikacne cislo prihlasenia (intColumn1), prehliadany dokument (column1), posledne prehliadany dokument (last_doc), nazov skupiny, do ktorej patri prehliadana stranka (column3) a cas pristupu (dateColumn1)
      Parameters:
      from - datetime, od ktoreho chceme vyhladavat zobrazenia stranok
      to - datetime, do ktoreho chceme vyhladavat zobrazenia stranok
      rootGroupId - identifikator skupiny, ktoru chceme filtrovat. Ak sa rovna -1, tak to znamena, ze chceme vyhladavat vo vsetkych skupinach
      Returns:
      List naplneny jednotlivymi zobrazeniami stranok pre urceneho registrovaneho pouzivatela s roznymi vlastnostami
    • grantRightsToUser

      public static boolean grantRightsToUser(String tableName, String suffix, String publicWebDbUserName)
      Grants SELECT, UPDATE, INSERT, DELETE on specified table to supplied username
      Parameters:
      tableName - name of table (ie stat_error)
      suffix - suffix for partitioning (ie _2012_10) _YYYY_MM
      publicWebDbUserName - name of user to whom will be granted priviledges
      Returns:
      true if grant was successful, otherwise false
      Throws:
      IllegalArgumentException - if suffix, tableName od udername is null
      IllegalStateException - if there is exception while granting permissions
    • tableExists

      public static boolean tableExists(String tablename)
      Checks if there exists table with spacified name in DB method ignores case
      Parameters:
      tablename - name of the table
      Returns:
      true if table with specified name exists in DB
      Throws:
      IllegalArgumentException - if tablename is null or empty
    • amChartsData

      public static String amChartsData(Map<String,Map<Date,Number>> data)
    • amChartsData

      public static String amChartsData(Map<String,Map<Date,Number>> data, boolean monitoring)
    • getWhiteListedUAQuery

      public static String getWhiteListedUAQuery()
      vrati " AND browser_ua_id IN [povolene prehliadace]", alebo prazdny string
      Returns: