Search in sources :

Example 6 with ConditionType

use of org.eclipse.smarthome.automation.type.ConditionType in project smarthome by eclipse.

the class ModuleTypeRegistryMockup method createConditionType.

private ConditionType createConditionType() {
    List<Input> inputs = new ArrayList<Input>(3);
    // no connection, missing condition tag
    inputs.add(createInput("in0", new String[] { "tagE" }));
    // conflict in2 -> out1 or in2 -> out3
    inputs.add(createInput("in1", new String[] { "tagA" }));
    // in2 -> out3
    inputs.add(createInput("in2", new String[] { "tagA", "tagB" }));
    ConditionType t = new ConditionType(CONDITION_TYPE, null, inputs);
    return t;
}
Also used : Input(org.eclipse.smarthome.automation.type.Input) ArrayList(java.util.ArrayList) ConditionType(org.eclipse.smarthome.automation.type.ConditionType)

Example 7 with ConditionType

use of org.eclipse.smarthome.automation.type.ConditionType in project smarthome by eclipse.

the class ModuleTypeResourceBundleProvider method createLocalizedConditionType.

/**
 * Utility method for localization of ConditionTypes.
 *
 * @param ct is a ConditionType for localization.
 * @param bundle the bundle providing localization resources.
 * @param moduleTypeUID is a ConditionType uid.
 * @param locale represents a specific geographical, political, or cultural region.
 * @param lconfigDescriptions are ConditionType localized config descriptions.
 * @param llabel is a ConditionType localized label.
 * @param ldescription is a ConditionType localized description.
 * @return localized ConditionType.
 */
private ConditionType createLocalizedConditionType(ConditionType ct, Bundle bundle, String moduleTypeUID, Locale locale, List<ConfigDescriptionParameter> lconfigDescriptions, String llabel, String ldescription) {
    List<Input> inputs = ModuleTypeI18nUtil.getLocalizedInputs(i18nProvider, ct.getInputs(), bundle, moduleTypeUID, locale);
    ConditionType lct = null;
    if (ct instanceof CompositeConditionType) {
        List<Condition> modules = ModuleI18nUtil.getLocalizedModules(i18nProvider, ((CompositeConditionType) ct).getChildren(), bundle, moduleTypeUID, ModuleTypeI18nUtil.MODULE_TYPE, locale);
        lct = new CompositeConditionType(moduleTypeUID, lconfigDescriptions, llabel, ldescription, ct.getTags(), ct.getVisibility(), inputs, modules);
    } else {
        lct = new ConditionType(moduleTypeUID, lconfigDescriptions, llabel, ldescription, ct.getTags(), ct.getVisibility(), inputs);
    }
    return lct;
}
Also used : Condition(org.eclipse.smarthome.automation.Condition) Input(org.eclipse.smarthome.automation.type.Input) CompositeConditionType(org.eclipse.smarthome.automation.type.CompositeConditionType) CompositeConditionType(org.eclipse.smarthome.automation.type.CompositeConditionType) ConditionType(org.eclipse.smarthome.automation.type.ConditionType)

Example 8 with ConditionType

use of org.eclipse.smarthome.automation.type.ConditionType in project smarthome by eclipse.

the class ModuleTypeResourceBundleProvider method getPerLocale.

/**
 * This method is used to localize the {@link ModuleType}s.
 *
 * @param element is the {@link ModuleType} that must be localized.
 * @param locale represents a specific geographical, political, or cultural region.
 * @return the localized {@link ModuleType}.
 */
private ModuleType getPerLocale(ModuleType defModuleType, Locale locale) {
    if (locale == null || defModuleType == null || i18nProvider == null) {
        return defModuleType;
    }
    String uid = defModuleType.getUID();
    Bundle bundle = getBundle(uid);
    String llabel = ModuleTypeI18nUtil.getLocalizedModuleTypeLabel(i18nProvider, bundle, uid, defModuleType.getLabel(), locale);
    String ldescription = ModuleTypeI18nUtil.getLocalizedModuleTypeDescription(i18nProvider, bundle, uid, defModuleType.getDescription(), locale);
    List<ConfigDescriptionParameter> lconfigDescriptions = getLocalizedConfigurationDescription(i18nProvider, defModuleType.getConfigurationDescriptions(), bundle, uid, ModuleTypeI18nUtil.MODULE_TYPE, locale);
    if (defModuleType instanceof ActionType) {
        return createLocalizedActionType((ActionType) defModuleType, bundle, uid, locale, lconfigDescriptions, llabel, ldescription);
    }
    if (defModuleType instanceof ConditionType) {
        return createLocalizedConditionType((ConditionType) defModuleType, bundle, uid, locale, lconfigDescriptions, llabel, ldescription);
    }
    if (defModuleType instanceof TriggerType) {
        return createLocalizedTriggerType((TriggerType) defModuleType, bundle, uid, locale, lconfigDescriptions, llabel, ldescription);
    }
    return null;
}
Also used : CompositeTriggerType(org.eclipse.smarthome.automation.type.CompositeTriggerType) TriggerType(org.eclipse.smarthome.automation.type.TriggerType) CompositeActionType(org.eclipse.smarthome.automation.type.CompositeActionType) ActionType(org.eclipse.smarthome.automation.type.ActionType) Bundle(org.osgi.framework.Bundle) ConfigDescriptionParameter(org.eclipse.smarthome.config.core.ConfigDescriptionParameter) CompositeConditionType(org.eclipse.smarthome.automation.type.CompositeConditionType) ConditionType(org.eclipse.smarthome.automation.type.ConditionType)

Example 9 with ConditionType

use of org.eclipse.smarthome.automation.type.ConditionType 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;
}
Also used : CompositeTriggerType(org.eclipse.smarthome.automation.type.CompositeTriggerType) TriggerType(org.eclipse.smarthome.automation.type.TriggerType) ModuleType(org.eclipse.smarthome.automation.type.ModuleType) ActionType(org.eclipse.smarthome.automation.type.ActionType) CompositeActionType(org.eclipse.smarthome.automation.type.CompositeActionType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CompositeConditionType(org.eclipse.smarthome.automation.type.CompositeConditionType) ConditionType(org.eclipse.smarthome.automation.type.ConditionType)

Aggregations

ConditionType (org.eclipse.smarthome.automation.type.ConditionType)9 CompositeConditionType (org.eclipse.smarthome.automation.type.CompositeConditionType)7 ArrayList (java.util.ArrayList)4 ActionType (org.eclipse.smarthome.automation.type.ActionType)4 CompositeActionType (org.eclipse.smarthome.automation.type.CompositeActionType)4 CompositeTriggerType (org.eclipse.smarthome.automation.type.CompositeTriggerType)4 Input (org.eclipse.smarthome.automation.type.Input)4 ModuleType (org.eclipse.smarthome.automation.type.ModuleType)4 TriggerType (org.eclipse.smarthome.automation.type.TriggerType)4 HashMap (java.util.HashMap)3 Condition (org.eclipse.smarthome.automation.Condition)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 Action (org.eclipse.smarthome.automation.Action)1 Trigger (org.eclipse.smarthome.automation.Trigger)1 Connection (org.eclipse.smarthome.automation.core.internal.Connection)1 ConfigDescriptionParameter (org.eclipse.smarthome.config.core.ConfigDescriptionParameter)1 Bundle (org.osgi.framework.Bundle)1