Skip to content

Commit

Permalink
Merge pull request #163 from lucasponce/import-export-triggers
Browse files Browse the repository at this point in the history
Import export triggers
  • Loading branch information
jshaughn committed Feb 9, 2016
2 parents 9b9f9b6 + ce2f607 commit 6e321a4
Show file tree
Hide file tree
Showing 34 changed files with 1,928 additions and 1,181 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 Red Hat, Inc. and/or its affiliates
* Copyright 2015-2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -56,7 +56,6 @@ public void testConnection() throws Exception {

/* Wait to receive some response */
for (int i = 0; i < 15; i++) {
System.out.printf("[%s] Waiting response... \n", i);
Thread.sleep(1000);
}
conn.doQuit();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 Red Hat, Inc. and/or its affiliates
* Copyright 2015-2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,12 +16,16 @@
*/
package org.hawkular.alerts.api.json;

import static com.fasterxml.jackson.annotation.JsonInclude.*;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;

import org.hawkular.alerts.api.model.condition.Condition;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* A convenience class used in the REST API to POST a new Group Condition.
* <p>
Expand All @@ -35,7 +39,11 @@
* @author lucas ponce
*/
public class GroupConditionsInfo {

@JsonInclude(Include.NON_EMPTY)
private Collection<Condition> conditions;

@JsonInclude(Include.NON_EMPTY)
private Map<String, Map<String, String>> dataIdMemberMap;

public GroupConditionsInfo() {
Expand Down

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2015 Red Hat, Inc. and/or its affiliates
* Copyright 2015-2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -20,17 +20,20 @@
import java.util.HashMap;
import java.util.Map;

import org.hawkular.alerts.api.json.JacksonDeserializer;
import org.hawkular.alerts.api.model.trigger.Mode;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;

/**
* A base class for condition definition.
*
* @author Jay Shaughnessy
* @author Lucas Ponce
*/
@JsonDeserialize(using = JacksonDeserializer.ConditionDeserializer.class)
public abstract class Condition implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2015-2016 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.hawkular.alerts.api.model.export;

import static com.fasterxml.jackson.annotation.JsonInclude.Include;

import java.util.List;

import org.hawkular.alerts.api.model.action.ActionDefinition;
import org.hawkular.alerts.api.model.trigger.FullTrigger;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
* Representation of a list of full triggers (trigger, dampenings and conditions) and actions definitions.
*
* @author Jay Shaughnessy
* @author Lucas Ponce
*/
public class Definitions {

@JsonInclude(Include.NON_EMPTY)
private List<FullTrigger> triggers;

@JsonInclude(Include.NON_EMPTY)
private List<ActionDefinition> actions;

public Definitions() {
}

public Definitions(List<FullTrigger> triggers,
List<ActionDefinition> actions) {
this.triggers = triggers;
this.actions = actions;
}

public List<FullTrigger> getTriggers() {
return triggers;
}

public void setTriggers(List<FullTrigger> triggers) {
this.triggers = triggers;
}

public List<ActionDefinition> getActions() {
return actions;
}

public void setActions(List<ActionDefinition> actions) {
this.actions = actions;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;

Definitions that = (Definitions) o;

if (triggers != null ? !triggers.equals(that.triggers) : that.triggers != null) return false;
return actions != null ? actions.equals(that.actions) : that.actions == null;
}

@Override
public int hashCode() {
int result = triggers != null ? triggers.hashCode() : 0;
result = 31 * result + (actions != null ? actions.hashCode() : 0);
return result;
}

@Override
public String toString() {
return "Definitions" + '[' +
"triggers=" + triggers +
", actions=" + actions +
']';
}
}

0 comments on commit 6e321a4

Please sign in to comment.