Search in sources :

Example 1 with ItemModel

use of org.eclipse.smarthome.model.items.ItemModel in project smarthome by eclipse.

the class GenericItemProvider method getItemsFromModel.

private Collection<Item> getItemsFromModel(String modelName) {
    logger.debug("Read items from model '{}'", modelName);
    List<Item> items = new ArrayList<Item>();
    if (modelRepository != null) {
        ItemModel model = (ItemModel) modelRepository.getModel(modelName);
        if (model != null) {
            for (ModelItem modelItem : model.getItems()) {
                Item item = createItemFromModelItem(modelItem);
                if (item != null) {
                    for (String groupName : modelItem.getGroups()) {
                        ((GenericItem) item).addGroupName(groupName);
                    }
                    items.add(item);
                }
            }
        }
    }
    return items;
}
Also used : GroupItem(org.eclipse.smarthome.core.items.GroupItem) ModelGroupItem(org.eclipse.smarthome.model.items.ModelGroupItem) GenericItem(org.eclipse.smarthome.core.items.GenericItem) Item(org.eclipse.smarthome.core.items.Item) ModelItem(org.eclipse.smarthome.model.items.ModelItem) ModelNormalItem(org.eclipse.smarthome.model.items.ModelNormalItem) ItemModel(org.eclipse.smarthome.model.items.ItemModel) GenericItem(org.eclipse.smarthome.core.items.GenericItem) ArrayList(java.util.ArrayList) ModelItem(org.eclipse.smarthome.model.items.ModelItem)

Aggregations

ArrayList (java.util.ArrayList)1 GenericItem (org.eclipse.smarthome.core.items.GenericItem)1 GroupItem (org.eclipse.smarthome.core.items.GroupItem)1 Item (org.eclipse.smarthome.core.items.Item)1 ItemModel (org.eclipse.smarthome.model.items.ItemModel)1 ModelGroupItem (org.eclipse.smarthome.model.items.ModelGroupItem)1 ModelItem (org.eclipse.smarthome.model.items.ModelItem)1 ModelNormalItem (org.eclipse.smarthome.model.items.ModelNormalItem)1