Search in sources :

Example 1 with ConditionType

use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.

the class ModuleTypeGSONParser method createMapByType.

private Map<String, List<? extends ModuleType>> createMapByType(Set<ModuleType> dataObjects) {
    Map<String, List<? extends ModuleType>> map = new HashMap<>();
    List<TriggerType> triggers = new ArrayList<>();
    List<ConditionType> conditions = new ArrayList<>();
    List<ActionType> actions = new ArrayList<>();
    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 : TriggerType(org.openhab.core.automation.type.TriggerType) ModuleType(org.openhab.core.automation.type.ModuleType) ActionType(org.openhab.core.automation.type.ActionType) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ConditionType(org.openhab.core.automation.type.ConditionType)

Example 2 with ConditionType

use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.

the class ModuleTypeRegistryImpl method createCopy.

@Nullable
private ModuleType createCopy(@Nullable ModuleType mType) {
    if (mType == null) {
        return null;
    }
    ModuleType result;
    if (mType instanceof CompositeTriggerType) {
        CompositeTriggerType m = (CompositeTriggerType) mType;
        result = new CompositeTriggerType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getOutputs(), new ArrayList<>(m.getChildren()));
    } else if (mType instanceof TriggerType) {
        TriggerType m = (TriggerType) mType;
        result = new TriggerType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getOutputs());
    } else if (mType instanceof CompositeConditionType) {
        CompositeConditionType m = (CompositeConditionType) mType;
        result = new CompositeConditionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), new ArrayList<>(m.getChildren()));
    } else if (mType instanceof ConditionType) {
        ConditionType m = (ConditionType) mType;
        result = new ConditionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs());
    } else if (mType instanceof CompositeActionType) {
        CompositeActionType m = (CompositeActionType) mType;
        result = new CompositeActionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), m.getOutputs(), new ArrayList<>(m.getChildren()));
    } else if (mType instanceof ActionType) {
        ActionType m = (ActionType) mType;
        result = new ActionType(mType.getUID(), mType.getConfigurationDescriptions(), mType.getLabel(), mType.getDescription(), mType.getTags(), mType.getVisibility(), m.getInputs(), m.getOutputs());
    } else {
        throw new IllegalArgumentException("Invalid template type:" + mType);
    }
    return result;
}
Also used : CompositeTriggerType(org.openhab.core.automation.type.CompositeTriggerType) TriggerType(org.openhab.core.automation.type.TriggerType) CompositeTriggerType(org.openhab.core.automation.type.CompositeTriggerType) ModuleType(org.openhab.core.automation.type.ModuleType) ActionType(org.openhab.core.automation.type.ActionType) CompositeActionType(org.openhab.core.automation.type.CompositeActionType) ArrayList(java.util.ArrayList) CompositeConditionType(org.openhab.core.automation.type.CompositeConditionType) CompositeConditionType(org.openhab.core.automation.type.CompositeConditionType) ConditionType(org.openhab.core.automation.type.ConditionType) CompositeActionType(org.openhab.core.automation.type.CompositeActionType) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 3 with ConditionType

use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.

the class ModuleTypeRegistryImpl method getConditions.

@Override
public Collection<ConditionType> getConditions(String... tags) {
    Collection<ModuleType> moduleTypes = getByTags(tags);
    Collection<ConditionType> conditionTypes = new ArrayList<>();
    for (ModuleType mt : moduleTypes) {
        if (mt instanceof ConditionType) {
            conditionTypes.add((ConditionType) mt);
        }
    }
    return conditionTypes;
}
Also used : ModuleType(org.openhab.core.automation.type.ModuleType) ArrayList(java.util.ArrayList) CompositeConditionType(org.openhab.core.automation.type.CompositeConditionType) ConditionType(org.openhab.core.automation.type.ConditionType)

Example 4 with ConditionType

use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.

the class ModuleTypeRegistryImpl method getConditions.

@Override
public Collection<ConditionType> getConditions(@Nullable Locale locale, String... tags) {
    Collection<ModuleType> moduleTypes = getByTags(locale, tags);
    Collection<ConditionType> conditionTypes = new ArrayList<>();
    for (ModuleType mt : moduleTypes) {
        if (mt instanceof ConditionType) {
            conditionTypes.add((ConditionType) mt);
        }
    }
    return conditionTypes;
}
Also used : ModuleType(org.openhab.core.automation.type.ModuleType) ArrayList(java.util.ArrayList) CompositeConditionType(org.openhab.core.automation.type.CompositeConditionType) ConditionType(org.openhab.core.automation.type.ConditionType)

Example 5 with ConditionType

use of org.openhab.core.automation.type.ConditionType in project openhab-core by openhab.

the class TestModuleTypeProvider method createConditionType.

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

Aggregations

ConditionType (org.openhab.core.automation.type.ConditionType)8 ArrayList (java.util.ArrayList)5 CompositeConditionType (org.openhab.core.automation.type.CompositeConditionType)5 Input (org.openhab.core.automation.type.Input)4 ModuleType (org.openhab.core.automation.type.ModuleType)4 HashMap (java.util.HashMap)3 ActionType (org.openhab.core.automation.type.ActionType)3 TriggerType (org.openhab.core.automation.type.TriggerType)3 Nullable (org.eclipse.jdt.annotation.Nullable)2 Condition (org.openhab.core.automation.Condition)2 CompositeActionType (org.openhab.core.automation.type.CompositeActionType)2 CompositeTriggerType (org.openhab.core.automation.type.CompositeTriggerType)2 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 CopyOnWriteArraySet (java.util.concurrent.CopyOnWriteArraySet)1 Action (org.openhab.core.automation.Action)1 Trigger (org.openhab.core.automation.Trigger)1 WrappedAction (org.openhab.core.automation.internal.ruleengine.WrappedAction)1