use of org.eclipse.smarthome.automation.type.ModuleType in project smarthome by eclipse.
the class ModuleTypeRegistryImpl method getActions.
@Override
public Collection<ActionType> getActions(String... tags) {
Collection<ModuleType> moduleTypes = getByTags(tags);
Collection<ActionType> actionTypes = new ArrayList<ActionType>();
for (ModuleType mt : moduleTypes) {
if (mt instanceof ActionType) {
actionTypes.add((ActionType) mt);
}
}
return actionTypes;
}
use of org.eclipse.smarthome.automation.type.ModuleType in project smarthome by eclipse.
the class CompositeModuleHandlerFactory method internalCreate.
@Override
public ModuleHandler internalCreate(Module module, String ruleUID) {
ModuleHandler handler = null;
if (module != null) {
String moduleType = module.getTypeUID();
ModuleType mt = mtRegistry.get(moduleType);
if (mt instanceof CompositeTriggerType) {
List<Trigger> childModules = ((CompositeTriggerType) mt).getChildren();
LinkedHashMap<Trigger, TriggerHandler> mapModuleToHandler = getChildHandlers(module.getId(), module.getConfiguration(), childModules, ruleUID);
if (mapModuleToHandler != null) {
handler = new CompositeTriggerHandler((Trigger) module, (CompositeTriggerType) mt, mapModuleToHandler, ruleUID);
}
} else if (mt instanceof CompositeConditionType) {
List<Condition> childModules = ((CompositeConditionType) mt).getChildren();
LinkedHashMap<Condition, ConditionHandler> mapModuleToHandler = getChildHandlers(module.getId(), module.getConfiguration(), childModules, ruleUID);
if (mapModuleToHandler != null) {
handler = new CompositeConditionHandler((Condition) module, (CompositeConditionType) mt, mapModuleToHandler, ruleUID);
}
} else if (mt instanceof CompositeActionType) {
List<Action> childModules = ((CompositeActionType) mt).getChildren();
LinkedHashMap<Action, ActionHandler> mapModuleToHandler = getChildHandlers(module.getId(), module.getConfiguration(), childModules, ruleUID);
if (mapModuleToHandler != null) {
handler = new CompositeActionHandler((Action) module, (CompositeActionType) mt, mapModuleToHandler, ruleUID);
}
}
if (handler != null) {
logger.debug("Set module handler: {} -> {} of rule {}.", module.getId(), handler.getClass().getSimpleName() + "(" + moduleType + ")", ruleUID);
} else {
logger.debug("Not found module handler {} for moduleType {} of rule {}.", module.getId(), moduleType, ruleUID);
}
}
return handler;
}
use of org.eclipse.smarthome.automation.type.ModuleType in project smarthome by eclipse.
the class ModuleTypeGSONParser method createMapByType.
private Map<String, List<? extends ModuleType>> createMapByType(Set<ModuleType> dataObjects) {
Map<String, List<? extends ModuleType>> map = new HashMap<String, List<? extends ModuleType>>();
List<TriggerType> triggers = new ArrayList<TriggerType>();
List<ConditionType> conditions = new ArrayList<ConditionType>();
List<ActionType> actions = new ArrayList<ActionType>();
for (ModuleType moduleType : dataObjects) {
if (moduleType instanceof TriggerType) {
triggers.add((TriggerType) moduleType);
} else if (moduleType instanceof ConditionType) {
conditions.add((ConditionType) moduleType);
} else if (moduleType instanceof ActionType) {
actions.add((ActionType) moduleType);
}
}
map.put("triggers", triggers);
map.put("conditions", conditions);
map.put("actions", actions);
return map;
}
Aggregations