Class GroupService

java.lang.Object
com.plannaplan.services.GroupService

@Service
public class GroupService
extends java.lang.Object
Service of GroupService which can find(optional), get(By Course, Groups Ammount, Group By Id, find Not Existing Group), save, delete group.
  • Constructor Summary

    Constructors 
    Constructor Description
    GroupService()  
  • Method Summary

    Modifier and Type Method Description
    void delete​(Groups groups)
    delete from database
    java.util.Optional<Groups> find​(int time, int capacity, java.lang.String room)
    find group with given properties
    java.util.Optional<Groups> find​(java.lang.Integer zajCykId, java.lang.Integer nrGr)
    find group with given properties
    java.util.Optional<java.lang.Long> findNotExistingGroup​(java.util.List<java.lang.Long> ids)
    get wich of provided id is not existind groups
    java.lang.Integer getFullgroupsAmmount()  
    java.util.Optional<Groups> getGroupById​(java.lang.Long id)
    find group with given properties
    int getGroupsAmmount()
    get hom manyh groups are in database in general
    java.util.List<Groups> getGroupsByCourse​(java.lang.Long id)
    find group with given properties
    java.util.HashMap<java.lang.Long,​java.lang.Integer> getTakenPlaces​(java.util.List<Groups> groups)  
    java.util.HashMap<java.lang.Long,​java.lang.Integer> getTakenPlacesOfAssignments​(java.util.List<Assignment> assignments)  
    Groups save​(Groups group)
    save group to database

    Methods inherited from class java.lang.Object

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

  • Method Details

    • find

      public java.util.Optional<Groups> find​(int time, int capacity, java.lang.String room)
      find group with given properties
      Parameters:
      time - scheduled time for group as int of minutes passed from 00:00
      capacity - capacity of group
      room - class room
      Returns:
      optional with Groups instance if found
    • find

      public java.util.Optional<Groups> find​(java.lang.Integer zajCykId, java.lang.Integer nrGr)
      find group with given properties
      Parameters:
      zajCykId - proteprty from usos
      nrGr - group number
      Returns:
      optional with Groups instance if found
    • getGroupsByCourse

      public java.util.List<Groups> getGroupsByCourse​(java.lang.Long id)
      find group with given properties
      Parameters:
      id - course id of groups belogns to
      Returns:
      list of found groups
    • save

      public Groups save​(Groups group)
      save group to database
      Parameters:
      group - insatnce to be saved
      Returns:
      new instance that has id form database
    • delete

      public void delete​(Groups groups)
      delete from database
      Parameters:
      groups - isntance to delete
    • getGroupsAmmount

      public int getGroupsAmmount()
      get hom manyh groups are in database in general
      Returns:
      int - groups ammount
    • getGroupById

      public java.util.Optional<Groups> getGroupById​(java.lang.Long id)
      find group with given properties
      Parameters:
      id - group id
      Returns:
      optional with group if found
    • findNotExistingGroup

      public java.util.Optional<java.lang.Long> findNotExistingGroup​(java.util.List<java.lang.Long> ids)
      get wich of provided id is not existind groups
      Parameters:
      ids - list of ids to check
      Returns:
      optional with id that is not group if found. If there is multiple will be returned first found
    • getTakenPlacesOfAssignments

      public java.util.HashMap<java.lang.Long,​java.lang.Integer> getTakenPlacesOfAssignments​(java.util.List<Assignment> assignments)
      Parameters:
      assignments - list of assignments you want to get taken places ammount
      Returns:
      HashMap of Long to Integer where Long is group id and Integer is how many places in gorup is already taken
    • getTakenPlaces

      public java.util.HashMap<java.lang.Long,​java.lang.Integer> getTakenPlaces​(java.util.List<Groups> groups)
      Parameters:
      groups - list of groups you want to get taken places ammount
      Returns:
      HashMap of Long to Integer where Long is group id and Integer is how many places in gorup is already taken
    • getFullgroupsAmmount

      public java.lang.Integer getFullgroupsAmmount()
      Returns:
      amount of groups with full capacity taken