Class CodesService


  • public class CodesService
    extends java.lang.Object
    A Service to access and store Activities
    Version:
    $Id: $Id
    Author:
    medamine
    • Constructor Detail

      • CodesService

        public CodesService​(CodesStorage codesStorage)

        Constructor for CodesService.

        Parameters:
        codesStorage - a CodesStorage object.
    • Method Detail

      • createActivityCode

        public ActivityCode createActivityCode​(ActivityCode activityCode)
                                        throws java.lang.Exception
        Create new ActivityCode. If the ActivityCode already exits an EntityExistsException will be thrown.
        Parameters:
        activityCode - ActivityCode to create
        Returns:
        stored ActivityCode in datasource
        Throws:
        java.lang.Exception - when ActivityCode already exists or an error occurs while creating ActivityCode or its attached image
      • updateActivityCode

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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