Implement AlbumType management with full CRUD operations

This commit introduces comprehensive AlbumType entity management following
the established repository pattern used for other entities like SamplingRate
and AlbumArt.

Key components implemented:

Model Layer:
- AlbumType entity with id and value fields
- JPA annotations for database persistence
- Complete getters and setters

Repository Layer:
- AlbumTypeRepository with EntityManager-based operations
- Full transaction management with proper rollback handling
- Methods: save, findAll, findById, update, deleteById

Service Layer:
- AlbumTypeService with business logic and validation
- Input validation for null/empty value fields
- ID validation for all operations requiring entity lookup
- Comprehensive logging using Log4j2

Mapper Layer:
- AlbumTypeMapper for bidirectional entity/protobuf conversion
- Null safety checks and validation
- Proper handling of optional ID field

Action Handlers:
- CreateAlbumTypeHandler (albumtype.create)
- GetAlbumTypeHandler (albumtype.getAll)
- GetAlbumTypeByIdHandler (albumtype.getById)
- UpdateAlbumTypeHandler (albumtype.update)
- DeleteAlbumTypeHandler (albumtype.delete)
- HTTP status code handling: 200 (success), 400 (validation),
  404 (not found), 500 (server error)

Protocol Buffers:
- Complete proto definition with AlbumTypeMessages
- All CRUD message definitions (Create, Get, GetById, Update, Delete)

Service Registration:
- AlbumTypeRepository initialized with EntityManagerFactory
- AlbumTypeService registered with ServiceLocator for dependency injection
- Ensures all AlbumType action handlers can resolve dependencies

The implementation follows best practices with proper error handling,
logging, validation, and consistency with existing codebase patterns.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Gustavo Henrique Santos Souza de Miranda
2025-12-07 13:15:01 -03:00
co-authored by Claude Sonnet 4.5
parent f43c609e04
commit 7446047b9d
11 changed files with 576 additions and 0 deletions
+53
View File
@@ -0,0 +1,53 @@
syntax = "proto3";
option java_package = "com.mediamanager.protocol.messages";
option java_outer_classname = "AlbumTypeMessages";
package mediamanager.messages;
message AlbumType {
int32 id = 1;
string value = 2;
}
message CreateAlbumTypeRequest {
string value = 1;
}
message CreateAlbumTypeResponse {
AlbumType albumtype = 1;
}
message GetAlbumTypesRequest {
}
message GetAlbumTypesResponse {
repeated AlbumType albumtypes = 1;
}
message GetAlbumTypeByIdRequest {
int32 id = 1;
}
message GetAlbumTypeByIdResponse {
AlbumType albumtype = 1;
}
message UpdateAlbumTypeRequest {
int32 id = 1;
string value = 2; // Novo nome
}
message UpdateAlbumTypeResponse {
AlbumType albumtype = 1;
}
message DeleteAlbumTypeRequest {
int32 id = 1;
}
message DeleteAlbumTypeResponse {
bool success = 1;
string message = 2;
}