Search in sources :

Example 6 with RuleDTO

use of org.eclipse.smarthome.automation.dto.RuleDTO in project smarthome by eclipse.

the class RuleDTOMapper method map.

public static RuleDTO map(final Rule rule) {
    final RuleDTO ruleDto = new RuleDTO();
    fillProperties(rule, ruleDto);
    return ruleDto;
}
Also used : RuleDTO(org.eclipse.smarthome.automation.dto.RuleDTO)

Example 7 with RuleDTO

use of org.eclipse.smarthome.automation.dto.RuleDTO in project smarthome by eclipse.

the class RuleEventFactory method createRuleUpdatedEvent.

/**
 * Creates a rule updated event
 *
 * @param rule the new rule
 * @param oldRule the rule that has been updated
 * @param source the source of the event
 * @return {@link RuleUpdatedEvent} instance
 */
public static RuleUpdatedEvent createRuleUpdatedEvent(Rule rule, Rule oldRule, String source) {
    String topic = buildTopic(RULE_UPDATED_EVENT_TOPIC, rule);
    final RuleDTO ruleDto = RuleDTOMapper.map(rule);
    final RuleDTO oldRuleDto = RuleDTOMapper.map(oldRule);
    List<RuleDTO> rules = new LinkedList<RuleDTO>();
    rules.add(ruleDto);
    rules.add(oldRuleDto);
    String payload = serializePayload(rules);
    return new RuleUpdatedEvent(topic, payload, source, ruleDto, oldRuleDto);
}
Also used : RuleDTO(org.eclipse.smarthome.automation.dto.RuleDTO) LinkedList(java.util.LinkedList)

Example 8 with RuleDTO

use of org.eclipse.smarthome.automation.dto.RuleDTO in project smarthome by eclipse.

the class RuleEventFactory method createRuleUpdatedEvent.

/**
 * Creates a rule updated event.
 *
 * @param rule    the new rule.
 * @param oldRule the rule that has been updated.
 * @param source  the source of the event.
 * @return {@link RuleUpdatedEvent} instance.
 */
public static RuleUpdatedEvent createRuleUpdatedEvent(Rule rule, Rule oldRule, String source) {
    String topic = buildTopic(RULE_UPDATED_EVENT_TOPIC, rule);
    final RuleDTO ruleDto = RuleDTOMapper.map(rule);
    final RuleDTO oldRuleDto = RuleDTOMapper.map(oldRule);
    List<RuleDTO> rules = new LinkedList<>();
    rules.add(ruleDto);
    rules.add(oldRuleDto);
    String payload = serializePayload(rules);
    return new RuleUpdatedEvent(topic, payload, source, ruleDto, oldRuleDto);
}
Also used : RuleDTO(org.eclipse.smarthome.automation.dto.RuleDTO) RuleUpdatedEvent(org.eclipse.smarthome.automation.events.RuleUpdatedEvent) LinkedList(java.util.LinkedList)

Aggregations

RuleDTO (org.eclipse.smarthome.automation.dto.RuleDTO)8 LinkedList (java.util.LinkedList)2 TypeToken (com.google.gson.reflect.TypeToken)1 JsonReader (com.google.gson.stream.JsonReader)1 JsonToken (com.google.gson.stream.JsonToken)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Rule (org.eclipse.smarthome.automation.Rule)1 RuleAddedEvent (org.eclipse.smarthome.automation.events.RuleAddedEvent)1 RuleRemovedEvent (org.eclipse.smarthome.automation.events.RuleRemovedEvent)1 RuleUpdatedEvent (org.eclipse.smarthome.automation.events.RuleUpdatedEvent)1 ParsingException (org.eclipse.smarthome.automation.parser.ParsingException)1 ParsingNestedException (org.eclipse.smarthome.automation.parser.ParsingNestedException)1