1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
13   */
14  
15  package com.liferay.portlet.announcements.service.impl;
16  
17  import com.liferay.portal.PortalException;
18  import com.liferay.portal.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  }