Class EquipmentService
java.lang.Object
de.gustavblass.fsu.fmi.roombooking.service.EquipmentService
Provides functionality to manage
RoomEquipment, namely to create, modify and delete them.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final EquipmentRepositoryProvides database access to actually create, modify and deleteRoomEquipment.private final EquipmentTypeRepositoryProvides database access to actually create, modify and delete EquipmentTypes. -
Constructor Summary
ConstructorsConstructorDescriptionEquipmentService(@NonNull EquipmentRepository equipmentRepository, @NonNull EquipmentTypeRepository equipmentTypeRepository) Constructs a newEquipmentService. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateType(@NonNull EquipmentType equipmentType) Adds the givenEquipmentTypeto the database if no type with the sameEquipmentType.nameexists already.voiddeleteByName(@NonNull String name) Removes theEquipmentTypewith the givenEquipmentType.namefrom the database if existent.@NonNull LinkedHashSet<RoomEquipment> findAll()A subset of allRoomEquipmentin the database table.@NonNull LinkedHashSet<EquipmentType> Fetches all EquipmentTypes from the database.@NonNull LinkedHashSet<CommonEquipmentType> @NonNull LinkedHashSet<IndividualEquipmentType> @NonNull Optional<EquipmentType> findTypeByName(@NonNull String name) Fetches theEquipmentTypewith the givenEquipmentType.namefrom the database table.voidAdds theDefaultIndividualEquipmentTypeandDefaultCommonEquipmentTypeto the database if there is noRoomEquipmentyet.
-
Field Details
-
equipmentRepository
Provides database access to actually create, modify and deleteRoomEquipment. -
equipmentTypeRepository
Provides database access to actually create, modify and delete EquipmentTypes.
-
-
Constructor Details
-
EquipmentService
public EquipmentService(@NonNull @NonNull EquipmentRepository equipmentRepository, @NonNull @NonNull EquipmentTypeRepository equipmentTypeRepository) Constructs a newEquipmentService.- Parameters:
equipmentRepository- TheequipmentRepositoryto be used for database access.equipmentTypeRepository- TheequipmentTypeRepositoryto be used for database access.
-
-
Method Details
-
initialise
@PostConstruct public void initialise()Adds theDefaultIndividualEquipmentTypeandDefaultCommonEquipmentTypeto the database if there is noRoomEquipmentyet. -
findAll
A subset of allRoomEquipmentin the database table.- Returns:
- All RoomEquipment entries.
-
findTypeByName
Fetches theEquipmentTypewith the givenEquipmentType.namefrom the database table.- Parameters:
name- The title of the EquipmentType to be returned.- Returns:
- The EquipmentType with the given name.
-
findAllTypes
Fetches all EquipmentTypes from the database.- Returns:
- All EquipmentTypes already existing.
-
findIndividualEquipmentTypes
- Returns:
- All IndividualEquipmentTypes currently present in the database.
-
findCommonEquipmentTypes
- Returns:
- All
CommonEquipmentTypecurrently present in the database.
-
createType
@PreAuthorize("hasRole('FACULTY_ADMINISTRATION')") public void createType(@NonNull @NonNull EquipmentType equipmentType) throws AlreadyExistsException Adds the givenEquipmentTypeto the database if no type with the sameEquipmentType.nameexists already.- Parameters:
equipmentType- The new EquipmentType to add.- Throws:
AlreadyExistsException- If the EquipmentType's name is already taken.
-
deleteByName
@PreAuthorize("hasRole('FACULTY_ADMINISTRATION')") public void deleteByName(@NonNull @NonNull String name) throws NotFoundException Removes theEquipmentTypewith the givenEquipmentType.namefrom the database if existent. Also removes allRoomEquipmentthat has theRoomEquipment.typethat shall be deleted.- Parameters:
name- The title of the EquipmentType to delete.- Throws:
NotFoundException- If no EquipmentType with the given name exists.
-