use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class RuleUtils method getTriggersCopy.
/**
* This method creates deep copy of list of triggers
*
* @param triggers list of triggers
* @return deep copy of list of triggers or empty list when parameter is null.
*/
public static List<Trigger> getTriggersCopy(List<Trigger> triggers) {
List<Trigger> res = new ArrayList<Trigger>();
if (triggers != null) {
for (Trigger t : triggers) {
Trigger trigger = new Trigger(t.getId(), t.getTypeUID(), new Configuration(t.getConfiguration().getProperties()));
trigger.setLabel(t.getLabel());
trigger.setDescription(t.getDescription());
res.add(trigger);
}
}
return res;
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class TriggerDTOMapper method mapDto.
public static Trigger mapDto(final TriggerDTO triggerDto) {
final Trigger trigger = new Trigger(triggerDto.id, triggerDto.type, new Configuration(triggerDto.configuration));
trigger.setLabel(triggerDto.label);
trigger.setDescription(triggerDto.description);
return trigger;
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class ConditionDTOMapper method mapDto.
public static Condition mapDto(final ConditionDTO conditionDto) {
final Condition condition = new Condition(conditionDto.id, conditionDto.type, new Configuration(conditionDto.configuration), conditionDto.inputs);
condition.setLabel(conditionDto.label);
condition.setDescription(conditionDto.description);
return condition;
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class RuleDTOMapper method map.
public static Rule map(final RuleDTO ruleDto) {
final Rule rule = new Rule(ruleDto.uid, TriggerDTOMapper.mapDto(ruleDto.triggers), ConditionDTOMapper.mapDto(ruleDto.conditions), ActionDTOMapper.mapDto(ruleDto.actions), ConfigDescriptionDTOMapper.map(ruleDto.configDescriptions), new Configuration(ruleDto.configuration), ruleDto.templateUID, ruleDto.visibility);
rule.setTags(ruleDto.tags);
rule.setName(ruleDto.name);
rule.setDescription(ruleDto.description);
return rule;
}
use of org.eclipse.smarthome.config.core.Configuration in project smarthome by eclipse.
the class ThingFactoryHelper method createChannelBuilder.
static ChannelBuilder createChannelBuilder(ChannelUID channelUID, ChannelType channelType, ConfigDescriptionRegistry configDescriptionRegistry) {
ChannelBuilder channelBuilder = //
ChannelBuilder.create(channelUID, channelType.getItemType()).withType(//
channelType.getUID()).withDefaultTags(//
channelType.getTags()).withKind(//
channelType.getKind()).withLabel(channelType.getLabel());
String description = channelType.getDescription();
if (description != null) {
channelBuilder = channelBuilder.withDescription(description);
}
// Initialize channel configuration with default-values
URI channelConfigDescriptionURI = channelType.getConfigDescriptionURI();
if (configDescriptionRegistry != null && channelConfigDescriptionURI != null) {
ConfigDescription cd = configDescriptionRegistry.getConfigDescription(channelConfigDescriptionURI);
if (cd != null) {
Configuration config = new Configuration();
for (ConfigDescriptionParameter param : cd.getParameters()) {
String defaultValue = param.getDefault();
if (defaultValue != null) {
Object value = getDefaultValueAsCorrectType(param.getType(), defaultValue);
if (value != null) {
config.put(param.getName(), value);
}
}
}
channelBuilder = channelBuilder.withConfiguration(config);
}
}
return channelBuilder;
}
Aggregations