Class SampleService
java.lang.Object
ai.nervemind.app.service.SampleService
- All Implemented Interfaces:
ai.nervemind.common.service.SampleServiceInterface
@Service
public class SampleService
extends Object
implements ai.nervemind.common.service.SampleServiceInterface
Service for loading, searching, and managing sample workflows.
Samples are loaded from classpath resources and user's samples directory.
-
Constructor Summary
ConstructorsConstructorDescriptionSampleService(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates a new SampleService with the given ObjectMapper. -
Method Summary
Modifier and TypeMethodDescriptionOptional<ai.nervemind.common.domain.SampleWorkflow> Find a sample by ID.List<ai.nervemind.common.domain.SampleWorkflow> Get all available samples.Get unique categories from all samples.List<ai.nervemind.common.domain.SampleWorkflow> getFeaturedSamples(int limit) Get featured/recommended samples (e.g., for home screen).Get unique languages from all samples.Get sample count by difficulty level.List<ai.nervemind.common.domain.SampleWorkflow> getSamplesByCategory(String category) Get samples by category.ai.nervemind.common.domain.WorkflowgetWorkflowFromSample(String sampleId) Get the workflow from a sample (for importing).voidLoads sample workflows from both user directory and classpath.voidReload all samples (e.g., after user adds new samples).List<ai.nervemind.common.domain.SampleWorkflow> searchSamples(String query, String category, String language, ai.nervemind.common.domain.SampleWorkflow.Difficulty difficulty) Search samples with filters.
-
Constructor Details
-
SampleService
public SampleService(com.fasterxml.jackson.databind.ObjectMapper objectMapper) Creates a new SampleService with the given ObjectMapper.- Parameters:
objectMapper- the ObjectMapper for JSON processing
-
-
Method Details
-
loadSamples
@PostConstruct public void loadSamples()Loads sample workflows from both user directory and classpath. User samples take priority over bundled samples. -
reloadSamples
public void reloadSamples()Reload all samples (e.g., after user adds new samples).- Specified by:
reloadSamplesin interfaceai.nervemind.common.service.SampleServiceInterface
-
getAllSamples
Get all available samples.- Specified by:
getAllSamplesin interfaceai.nervemind.common.service.SampleServiceInterface
-
searchSamples
public List<ai.nervemind.common.domain.SampleWorkflow> searchSamples(String query, String category, String language, ai.nervemind.common.domain.SampleWorkflow.Difficulty difficulty) Search samples with filters.- Specified by:
searchSamplesin interfaceai.nervemind.common.service.SampleServiceInterface- Parameters:
query- Search query (matches name, description, tags)category- Filter by category (null for all)language- Filter by language (null for all)difficulty- Filter by difficulty (null for all)- Returns:
- Filtered list of samples
-
getCategories
-
getLanguages
-
findById
-
getWorkflowFromSample
Get the workflow from a sample (for importing).- Specified by:
getWorkflowFromSamplein interfaceai.nervemind.common.service.SampleServiceInterface
-
getSamplesByCategory
-
getSampleCountByDifficulty
-
getFeaturedSamples
Get featured/recommended samples (e.g., for home screen).- Specified by:
getFeaturedSamplesin interfaceai.nervemind.common.service.SampleServiceInterface
-