}
@Transactional
public void evaluate(long pieceId, Long userId, boolean positive, String ip) {
if (dao.getEvaluation(pieceId, userId, ip) == null) {
PieceEvaluation evaluation = new PieceEvaluation();
evaluation.setDateTime(new DateTime());
if (userId != null) {
evaluation.setUser(dao.getById(User.class, userId));
}
Piece piece = dao.getById(Piece.class, pieceId);
evaluation.setPiece(piece);
evaluation.setPositive(positive);
evaluation.setIp(ip);
dao.persist(evaluation);
// not exact due to race condition - a job should count likes every
// X minutes
if (positive) {