Class ActivityService


  • public class ActivityService
    extends java.lang.Object
    A Service to access and store Activities
    Version:
    $Id: $Id
    Author:
    medamine
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Activity createActivity​(Activity activity)
      Create new Activity that will be available for all users.
      void deleteActivity​(java.lang.Long activityId, java.lang.String username)
      Delete Activity identified by its id and check if username has permission to delete it.
      java.util.List<Activity> getActivitiesforUser​(java.util.List<java.lang.String> teams)
      Retrieves the list of Activities with offset, limit and a keyword that can be empty
      java.util.List<Activity> getActivitiesList()
      Retrieves the list of Activities with offset, limit and a keyword that can be empty
      Activity updateActivity​(Activity Activity, java.lang.String username)
      Update an existing Activity on datasource.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ActivityService

        public ActivityService​(ActivityStorage activitiestorage)

        Constructor for ActivityService.

        Parameters:
        activitiestorage - a ActivityStorage object.
    • Method Detail

      • createActivity

        public Activity createActivity​(Activity activity)
                                throws java.lang.Exception
        Create new Activity that will be available for all users. If the Activity already exits an EntityExistsException will be thrown.
        Parameters:
        activity - Activity to create
        Returns:
        stored Activity in datasource
        Throws:
        java.lang.Exception - when Activity already exists or an error occurs while creating Activity or its attached image
      • updateActivity

        public Activity updateActivity​(Activity Activity,
                                       java.lang.String username)
                                throws java.lang.Exception
        Update an existing Activity on datasource. If the Activity doesn't exit an EntityNotFoundException will be thrown.
        Parameters:
        Activity - dto to update on store
        username - username storing Activity
        Returns:
        stored Activity in datasource
        Throws:
        java.lang.Exception - when Exception is thrown or an error occurs while saving Activity
      • deleteActivity

        public void deleteActivity​(java.lang.Long activityId,
                                   java.lang.String username)
                            throws javax.persistence.EntityNotFoundException,
                                   java.lang.IllegalAccessException
        Delete Activity identified by its id and check if username has permission to delete it.
        Parameters:
        activityId - technical identifier of Activity
        username - user currently deleting Activity
        Throws:
        javax.persistence.EntityNotFoundException - if Activity wasn't found
        java.lang.IllegalAccessException - if user is not allowed to delete Activity
      • getActivitiesList

        public java.util.List<Activity> getActivitiesList()
        Retrieves the list of Activities with offset, limit and a keyword that can be empty
        Returns:
        List of Activity that contains the list of Activities
      • getActivitiesforUser

        public java.util.List<Activity> getActivitiesforUser​(java.util.List<java.lang.String> teams)
        Retrieves the list of Activities with offset, limit and a keyword that can be empty
        Parameters:
        teams - a List object.
        Returns:
        List of Activity that contains the list of Activities