@Override public int getDistinctCountByPeriodUser( List<WAPrimaryKey> primaryKeys, int action, String objectType, Date startDate, Date endDate, List<String> userIds) { int nb = 0; Connection con = getConnection(); if (userIds != null && !userIds.isEmpty()) { Set<String> distinctObjectIds = new HashSet<>(userIds.size()); try { for (String userId : userIds) { List<String> objectIds = HistoryObjectDAO.getListObjectAccessByPeriodAndUser( con, primaryKeys, objectType, startDate, endDate, userId); distinctObjectIds.addAll(objectIds); } nb = distinctObjectIds.size(); } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().getDistinctCountByPeriod()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_GET_HISTORY_STATISTICS_PUBLICATION", e); } finally { DBUtil.close(con); } } return nb; }
@Override public int getCountByPeriodAndUser( List<WAPrimaryKey> primaryKeys, String objectType, Date startDate, Date endDate, List<String> userIds) { int nb = 0; Connection con = getConnection(); try { if (!userIds.isEmpty()) { for (String userId : userIds) { for (WAPrimaryKey primaryKey : primaryKeys) { nb += HistoryObjectDAO.getCountByPeriodAndUser( con, primaryKey, objectType, startDate, endDate, userId); } } } } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().getCountByPeriodAndUser()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_GET_HISTORY_STATISTICS_PUBLICATION", e); } finally { DBUtil.close(con); } return nb; }
@Override public int getCount(List<ForeignPK> foreignPKs, int action, String objectType) { Connection con = getConnection(); try { return HistoryObjectDAO.getCount(con, foreignPKs, objectType); } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().getCount()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_GET_HISTORY_STATISTICS_PUBLICATION", e); } finally { DBUtil.close(con); } }
/** * Deletes the resources belonging to the specified component instance. This method is invoked by * Silverpeas when a component instance is being deleted. * * @param componentInstanceId the unique identifier of a component instance. */ @Override @Transactional public void delete(final String componentInstanceId) { Connection con = getConnection(); try { HistoryObjectDAO.deleteStatsOfComponent(con, componentInstanceId); } catch (Exception e) { throw new RuntimeException( "A failure occurred when deleting the statistics relative to the component instance " + componentInstanceId, e); } finally { DBUtil.close(con); } }
@Override public void addStat(String userId, ForeignPK foreignPK, int actionType, String objectType) { Connection con = getConnection(); try { HistoryObjectDAO.add(con, userId, foreignPK, actionType, objectType); } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().addStat()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_ADD_VISITE_NODE", e); } finally { DBUtil.close(con); } }
@Override public void deleteStats(ForeignPK foreignPK, String objectType) { Connection con = getConnection(); try { HistoryObjectDAO.deleteHistoryByObject(con, foreignPK, objectType); } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().deleteHistoryByAction", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_DELETE_HISTORY_STATISTICS_PUBLICATION", e); } finally { DBUtil.close(con); } }
public boolean isRead(SilverpeasContent content, String userId) { Connection con = getConnection(); try { int numberOfReading = HistoryObjectDAO.getCountByPeriodAndUser( con, getForeignPK(content), content.getContributionType(), null, null, userId); return numberOfReading > 0; } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().isRead()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_GET_HISTORY_STATISTICS_PUBLICATION", e); } finally { DBUtil.close(con); } }
@Override public void moveStat(ForeignPK toForeignPK, int actionType, String objectType) { SilverTrace.info( "statistic", "DefaultStatisticService.deleteHistoryByAction", "root.MSG_GEN_ENTER_METHOD"); Connection con = getConnection(); try { HistoryObjectDAO.move(con, toForeignPK, actionType, objectType); } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().addObjectToHistory()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_ADD_VISITE_NODE", e); } finally { DBUtil.close(con); } }
@Override public Collection<HistoryObjectDetail> getLastHistoryOfObjectsForUser( String userId, int actionType, String objectType, int nbObjects) { Connection con = getConnection(); try { return HistoryObjectDAO.getLastHistoryDetailOfObjectsForUser( con, userId, actionType, objectType, nbObjects); } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().getLastHistoryOfObjectsForUser()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_GET_HISTORY_STATISTICS_PUBLICATION", e); } finally { DBUtil.close(con); } }
@Override public Collection<HistoryObjectDetail> getHistoryByObjectAndUser( ForeignPK foreignPK, int action, String objectType, String userId) { SilverTrace.info( "statistic", "DefaultStatisticService.getHistoryByObjectAndUser", "root.MSG_GEN_ENTER_METHOD"); Connection con = getConnection(); try { return HistoryObjectDAO.getHistoryDetailByObjectAndUser(con, foreignPK, objectType, userId); } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().getHistoryByObjectAndUser()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_GET_HISTORY_STATISTICS_PUBLICATION", e); } finally { DBUtil.close(con); } }
@Override public int getDistinctCountByPeriod( List<WAPrimaryKey> primaryKeys, int action, String objectType, Date startDate, Date endDate) { int nb = 0; Connection con = getConnection(); try { List<String> objectIds = HistoryObjectDAO.getListObjectAccessByPeriod( con, primaryKeys, objectType, startDate, endDate); Set<String> distinctObjectIds = new HashSet<String>(objectIds); nb = distinctObjectIds.size(); } catch (Exception e) { throw new StatisticRuntimeException( "DefaultStatisticService().getDistinctCountByPeriod()", SilverpeasRuntimeException.ERROR, "statistic.CANNOT_GET_HISTORY_STATISTICS_PUBLICATION", e); } finally { DBUtil.close(con); } return nb; }