1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet.announcements.service.impl;
16  
17  import com.liferay.portal.kernel.exception.PortalException;
18  import com.liferay.portal.kernel.exception.SystemException;
19  import com.liferay.portlet.announcements.model.AnnouncementsFlag;
20  import com.liferay.portlet.announcements.service.base.AnnouncementsFlagLocalServiceBaseImpl;
21  
22  import java.util.Date;
23  
24  /**
25   * <a href="AnnouncementsFlagLocalServiceImpl.java.html"><b><i>View Source</i>
26   * </b></a>
27   *
28   * @author Thiago Moreira
29   * @author Raymond Augé
30   */
31  public class AnnouncementsFlagLocalServiceImpl
32      extends AnnouncementsFlagLocalServiceBaseImpl {
33  
34      public AnnouncementsFlag addFlag(long userId, long entryId, int value)
35          throws SystemException {
36  
37          long flagId = counterLocalService.increment();
38  
39          AnnouncementsFlag flag = announcementsFlagPersistence.create(flagId);
40  
41          flag.setUserId(userId);
42          flag.setCreateDate(new Date());
43          flag.setEntryId(entryId);
44          flag.setValue(value);
45  
46          announcementsFlagPersistence.update(flag, false);
47  
48          return flag;
49      }
50  
51      public void deleteFlag(long flagId)
52          throws PortalException, SystemException {
53  
54          announcementsFlagPersistence.remove(flagId);
55      }
56  
57      public void deleteFlags(long entryId) throws SystemException {
58          announcementsFlagPersistence.removeByEntryId(entryId);
59      }
60  
61      public AnnouncementsFlag getFlag(long userId, long entryId, int value)
62          throws PortalException, SystemException {
63  
64          return announcementsFlagPersistence.findByU_E_V(
65              userId, entryId, value);
66      }
67  
68  }