Serge Huber created UNOMI-879:
---------------------------------
Summary: Unified CRUD Command System: Streamlining Shell
Operations with a Consistent Interface
Key: UNOMI-879
URL: https://issues.apache.org/jira/browse/UNOMI-879
Project: Apache Unomi
Issue Type: Sub-task
Affects Versions: unomi-3.0.0
Reporter: Serge Huber
Fix For: unomi-3.0.0
This proposal suggests replacing our current disparate Karaf shell commands
with a unified CRUD command system that would provide a consistent,
maintainable, and extensible interface for all Unomi objects. This
architectural improvement would offer significant benefits for both developers
and operators.
h3. Current Pain Points:
1. Inconsistent command patterns across different object types
2. Significant code duplication in command implementations
3. Varying parameter names and behaviors
4. Scattered documentation and help text
5. High maintenance overhead
6. Steep learning curve for new users
h3. Proposed Solution:
A unified command structure:
{noformat}
unomi:crud <operation> <type> [id] [options]
Operations:
- create: Create new object from JSON file
- read: Display object details
- update: Update existing object from JSON
- delete: Remove an object
- list: Display objects in table format
- help: Show object type documentation
Options:
--file (-f): JSON file for create/update
--csv: Output in CSV format
--max-entries (-n): Maximum items to display
{noformat}
h3. Example Usage Would Be:
{noformat}
# List all rules
unomi:crud list rule
# Show rule details
unomi:crud read rule rule_id
# Create new rule
unomi:crud create rule --file new_rule.json
# Update existing rule
unomi:crud update rule rule_id --file updated_rule.json
# Delete rule
unomi:crud delete rule rule_id
# Get help for rule properties
unomi:crud help rule
{noformat}
h3. Expected Benefits:
1. Consistency and Usability:
* Single command pattern for all object types
* Consistent parameter naming and behavior
* Unified help system and documentation
* Reduced learning curve for new users
2. Code Maintainability:
* Expected ~75% reduction in command-related code
* Centralized error handling
* Shared pagination and filtering logic
* Common JSON handling for all object types
3. Enhanced Features:
* Built-in CSV output support
* Consistent table formatting
* Property auto-completion
* Rich help documentation for each object type
h3. Proposed Implementation:
1. Core Components:
* CrudCommand interface: Would define CRUD operations
* BaseCrudCommand: Would provide common implementation
* UnomiCrudCommand: Would handle main command routing
* Type-specific implementations (e.g., RuleCrudCommand, ProfileCrudCommand)
2. Key Features:
* OSGi service-based architecture
* Dynamic command registration
* JSON-based object serialization
* Flexible output formatting
3. Integration Points:
* Persistence service integration
* Security service integration
* Transaction handling
* Event system integration
h3. Testing Strategy:
1. Unit Tests:
* Core command functionality
* Object serialization/deserialization
* Error handling
* Parameter validation
2. Integration Tests:
* End-to-end command execution
* Service integration
* Transaction handling
* Security integration
h3. Migration Plan:
1. Phase 1:
* Implement core framework
* Convert one object type as proof of concept
* Gather feedback from team
2. Phase 2:
* Convert remaining object types
* Keep old commands temporarily
* Update documentation
3. Phase 3:
* Deprecate old commands
* Remove old command code
* Finalize documentation
h3. Success Metrics:
1. Code Quality:
* Reduction in code lines
* Improved test coverage
* Reduced duplicate code
* Fewer bug reports
2. User Experience:
* Reduced command learning time
* Fewer user errors
* Improved help system usage
* Positive user feedback
h3. Risks and Mitigation:
1. Learning Curve:
* Comprehensive documentation
* Interactive help system
* Example-driven guides
* Gradual migration
2. Migration Challenges:
* Maintain backward compatibility
* Phased approach
* Clear deprecation notices
* Migration guides
This unified approach would significantly improve the maintainability and
usability of Unomi's shell interface while providing a solid foundation for
future extensions.
h3. Next Steps:
1. Review and feedback from team
2. Detailed technical design document
3. Proof of concept implementation
4. User experience testing
5. Full implementation plan
Would you like to proceed with this proposal?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)