- Created extensible BaseQueryParadigm interface with standardized QueryResult format - Implemented QueryParadigmRegistry for paradigm discovery and management - Added 5 working paradigms: SQL, FTS, GraphQL, JSONPath, Natural Language - Documented 9 additional paradigms: QBE, Batch Manipulation, Visual Query Builder, REST API, NoSQL, UNIX Pipeline, XPath/XQuery, RAG, Data Transformation - Integrated full CLI interface: list, search, show, exec, categories commands - Added comprehensive test suite with 23 test cases covering all components - Auto-registration system enables easy addition of new paradigms - Organized paradigms by category (structural, textual, semantic, visual, procedural, network) and complexity (beginner, intermediate, advanced) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
68 lines
2.4 KiB
Python
68 lines
2.4 KiB
Python
"""
|
|
Registry for managing query paradigms.
|
|
"""
|
|
|
|
from typing import Dict, List, Optional
|
|
from .base import BaseQueryParadigm
|
|
|
|
|
|
class QueryParadigmRegistry:
|
|
"""Registry for managing and discovering query paradigms."""
|
|
|
|
def __init__(self):
|
|
self._paradigms: Dict[str, BaseQueryParadigm] = {}
|
|
|
|
def register(self, paradigm: BaseQueryParadigm) -> None:
|
|
"""Register a new query paradigm."""
|
|
self._paradigms[paradigm.name.lower()] = paradigm
|
|
|
|
def get(self, name: str) -> Optional[BaseQueryParadigm]:
|
|
"""Get a paradigm by name."""
|
|
return self._paradigms.get(name.lower())
|
|
|
|
def list_all(self) -> List[BaseQueryParadigm]:
|
|
"""Get all registered paradigms."""
|
|
return list(self._paradigms.values())
|
|
|
|
def list_by_category(self, category: str) -> List[BaseQueryParadigm]:
|
|
"""Get paradigms by category."""
|
|
return [p for p in self._paradigms.values() if p.category == category]
|
|
|
|
def list_by_complexity(self, complexity: str) -> List[BaseQueryParadigm]:
|
|
"""Get paradigms by complexity level."""
|
|
return [p for p in self._paradigms.values() if p.complexity == complexity]
|
|
|
|
def get_categories(self) -> List[str]:
|
|
"""Get all available categories."""
|
|
return list(set(p.category for p in self._paradigms.values()))
|
|
|
|
def get_complexity_levels(self) -> List[str]:
|
|
"""Get all available complexity levels."""
|
|
return list(set(p.complexity for p in self._paradigms.values()))
|
|
|
|
def search_paradigms(self, query: str) -> List[BaseQueryParadigm]:
|
|
"""Search paradigms by name or description."""
|
|
query_lower = query.lower()
|
|
results = []
|
|
|
|
for paradigm in self._paradigms.values():
|
|
if (query_lower in paradigm.name.lower() or
|
|
query_lower in paradigm.description.lower()):
|
|
results.append(paradigm)
|
|
|
|
return results
|
|
|
|
def get_translation_matrix(self) -> Dict[str, List[str]]:
|
|
"""Get matrix of which paradigms can translate to which others."""
|
|
matrix = {}
|
|
for paradigm in self._paradigms.values():
|
|
targets = []
|
|
for other in self._paradigms.values():
|
|
if other.can_translate_from(paradigm.name):
|
|
targets.append(other.name)
|
|
matrix[paradigm.name] = targets
|
|
return matrix
|
|
|
|
|
|
# Global registry instance
|
|
registry = QueryParadigmRegistry() |