Package energy.eddie.dataneeds.services
Class DataNeedsConfigService
java.lang.Object
energy.eddie.dataneeds.services.DataNeedsConfigService
- All Implemented Interfaces:
DataNeedsService
@Service
@ConditionalOnProperty(value="eddie.data-needs-config.data-need-source",
havingValue="CONFIG")
public class DataNeedsConfigService
extends Object
implements DataNeedsService
DataNeedService that reads data needs from a JSON file. It only stores the data needs in memory.
-
Constructor Summary
ConstructorsConstructorDescriptionDataNeedsConfigService(String dataNeedsFilePath, com.fasterxml.jackson.databind.ObjectMapper mapper, org.springframework.context.ApplicationContext context) -
Method Summary
Modifier and TypeMethodDescriptionFetches the data need with the passed ID from the underlying persistence layer.Gets a data need by its id.Returns a list of all data needs with only their name and ID.
-
Constructor Details
-
DataNeedsConfigService
public DataNeedsConfigService(@Value("${eddie.data-needs-config.file}") String dataNeedsFilePath, com.fasterxml.jackson.databind.ObjectMapper mapper, org.springframework.context.ApplicationContext context) throws DataNeedAlreadyExistsException, IOException
-
-
Method Details
-
getDataNeedIdsAndNames
Description copied from interface:DataNeedsServiceReturns a list of all data needs with only their name and ID.- Specified by:
getDataNeedIdsAndNamesin interfaceDataNeedsService
-
findById
Description copied from interface:DataNeedsServiceFetches the data need with the passed ID from the underlying persistence layer.- Specified by:
findByIdin interfaceDataNeedsService- Parameters:
id- The ID of the data need to get.- Returns:
- The data need or an empty Optional if there is no data need with the given ID.
-
getById
Description copied from interface:DataNeedsServiceGets a data need by its id. If it cannot be found throwsEntityNotFoundException. Should only be used when sure that the data need exists- Specified by:
getByIdin interfaceDataNeedsService- Parameters:
id- The ID of the data need to get.- Returns:
- the data need
-