use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.
the class LivenessMgmtService method incLiveness.
/**
* Increments a field of the specified liveness.
*
* @param userId the specified user id
* @param field the specified field
*/
@Transactional
public void incLiveness(final String userId, final String field) {
Stopwatchs.start("Inc liveness");
final String date = DateFormatUtils.format(System.currentTimeMillis(), "yyyyMMdd");
try {
JSONObject liveness = livenessRepository.getByUserAndDate(userId, date);
if (null == liveness) {
liveness = new JSONObject();
liveness.put(Liveness.LIVENESS_USER_ID, userId);
liveness.put(Liveness.LIVENESS_DATE, date);
liveness.put(Liveness.LIVENESS_POINT, 0);
liveness.put(Liveness.LIVENESS_ACTIVITY, 0);
liveness.put(Liveness.LIVENESS_ARTICLE, 0);
liveness.put(Liveness.LIVENESS_COMMENT, 0);
liveness.put(Liveness.LIVENESS_PV, 0);
liveness.put(Liveness.LIVENESS_REWARD, 0);
liveness.put(Liveness.LIVENESS_THANK, 0);
liveness.put(Liveness.LIVENESS_VOTE, 0);
liveness.put(Liveness.LIVENESS_VOTE, 0);
livenessRepository.add(liveness);
}
liveness.put(field, liveness.optInt(field) + 1);
livenessRepository.update(liveness.optString(Keys.OBJECT_ID), liveness);
} catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Updates a liveness [" + date + "] field [" + field + "] failed", e);
} finally {
Stopwatchs.end();
}
}
use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.
the class NotificationMgmtService method addNewFollowerNotification.
/**
* Adds a 'new follower' type notification with the specified request json object.
*
* @param requestJSONObject the specified request json object, for example,
* "userId": "",
* "dataId": "" // new follower id
* @throws ServiceException service exception
*/
@Transactional
public void addNewFollowerNotification(final JSONObject requestJSONObject) throws ServiceException {
try {
requestJSONObject.put(Notification.NOTIFICATION_DATA_TYPE, Notification.DATA_TYPE_C_NEW_FOLLOWER);
addNotification(requestJSONObject);
} catch (final RepositoryException e) {
final String msg = "Adds notification [type=new_follower] failed";
LOGGER.log(Level.ERROR, msg, e);
throw new ServiceException(msg);
}
}
use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.
the class NotificationMgmtService method addSysAnnounceArticleNotification.
/**
* Adds a 'sys announce - article' type notification with the specified request json object.
*
* @param requestJSONObject the specified request json object, for example,
* "userId"; "",
* "dataId": "" // article id
* @throws ServiceException service exception
*/
@Transactional
public void addSysAnnounceArticleNotification(final JSONObject requestJSONObject) throws ServiceException {
try {
requestJSONObject.put(Notification.NOTIFICATION_DATA_TYPE, Notification.DATA_TYPE_C_SYS_ANNOUNCE_ARTICLE);
addNotification(requestJSONObject);
} catch (final RepositoryException e) {
final String msg = "Adds notification [type=sys_announce_article] failed";
LOGGER.log(Level.ERROR, msg, e);
throw new ServiceException(msg);
}
}
use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.
the class NotificationMgmtService method addCommentVoteDownNotification.
/**
* Adds a 'comment vote down' type notification with the specified request json object.
*
* @param requestJSONObject the specified request json object, for example,
* "userId": "",
* "dataId": "" // comment id-vote user id
* @throws ServiceException service exception
*/
@Transactional
public void addCommentVoteDownNotification(final JSONObject requestJSONObject) throws ServiceException {
try {
requestJSONObject.put(Notification.NOTIFICATION_DATA_TYPE, Notification.DATA_TYPE_C_COMMENT_VOTE_DOWN);
addNotification(requestJSONObject);
} catch (final RepositoryException e) {
final String msg = "Adds notification [type=comment_vote_down] failed";
LOGGER.log(Level.ERROR, msg, e);
throw new ServiceException(msg);
}
}
use of org.b3log.latke.repository.annotation.Transactional in project symphony by b3log.
the class NotificationMgmtService method addAbusePointDeductNotification.
/**
* Adds a 'abuse point deduct' type notification with the specified request json object.
*
* @param requestJSONObject the specified request json object, for example,
* "userId"; "",
* "dataId": "" // transfer record id
* @throws ServiceException service exception
*/
@Transactional
public void addAbusePointDeductNotification(final JSONObject requestJSONObject) throws ServiceException {
try {
requestJSONObject.put(Notification.NOTIFICATION_DATA_TYPE, Notification.DATA_TYPE_C_ABUSE_POINT_DEDUCT);
addNotification(requestJSONObject);
} catch (final RepositoryException e) {
final String msg = "Adds notification [type=abuse_point_deduct] failed";
LOGGER.log(Level.ERROR, msg, e);
throw new ServiceException(msg);
}
}
Aggregations