use of org.openhab.core.persistence.config.PersistenceAllConfig in project openhab-core by openhab.
the class PersistenceManagerImpl method getDefaultConfig.
@Nullable
private PersistenceServiceConfiguration getDefaultConfig(PersistenceService persistenceService) {
List<PersistenceStrategy> strategies = persistenceService.getDefaultStrategies();
List<PersistenceItemConfiguration> configs = List.of(new PersistenceItemConfiguration(List.of(new PersistenceAllConfig()), null, strategies, null));
return new PersistenceServiceConfiguration(configs, strategies, strategies);
}
use of org.openhab.core.persistence.config.PersistenceAllConfig in project openhab-core by openhab.
the class PersistenceManagerImpl method getAllItems.
/**
* Retrieves all items for which the persistence configuration applies to.
*
* @param config the persistence configuration entry
* @return all items that this configuration applies to
*/
Iterable<Item> getAllItems(PersistenceItemConfiguration config) {
// first check, if we should return them all
for (Object itemCfg : config.getItems()) {
if (itemCfg instanceof PersistenceAllConfig) {
return itemRegistry.getItems();
}
}
// otherwise, go through the detailed definitions
Set<Item> items = new HashSet<>();
for (Object itemCfg : config.getItems()) {
if (itemCfg instanceof PersistenceItemConfig) {
PersistenceItemConfig singleItemConfig = (PersistenceItemConfig) itemCfg;
String itemName = singleItemConfig.getItem();
try {
items.add(itemRegistry.getItem(itemName));
} catch (ItemNotFoundException e) {
logger.debug("Item '{}' does not exist.", itemName);
}
}
if (itemCfg instanceof PersistenceGroupConfig) {
PersistenceGroupConfig groupItemConfig = (PersistenceGroupConfig) itemCfg;
String groupName = groupItemConfig.getGroup();
try {
Item gItem = itemRegistry.getItem(groupName);
if (gItem instanceof GroupItem) {
GroupItem groupItem = (GroupItem) gItem;
items.addAll(groupItem.getAllMembers());
}
} catch (ItemNotFoundException e) {
logger.debug("Item group '{}' does not exist.", groupName);
}
}
}
return items;
}
Aggregations