Feature uses features-parent as parent
[groupbasedpolicy.git] / renderers / opflex / src / main / java / org / opendaylight / groupbasedpolicy / renderer / opflex / lib / messages / PolicyUpdateRequest.java
1 /*
2  * Copyright (C) 2014 Cisco Systems, Inc.
3  * 
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  * 
8  * Authors : Thomas Bachman
9  */
10 package org.opendaylight.groupbasedpolicy.renderer.opflex.lib.messages;
11
12 import java.util.List;
13
14 import org.opendaylight.groupbasedpolicy.renderer.opflex.jsonrpc.RpcMessage;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
16
17 import com.fasterxml.jackson.annotation.JsonIgnore;
18 import com.fasterxml.jackson.databind.JsonNode;
19 import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
20 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
21
22 @JsonSerialize
23 @JsonDeserialize
24 public class PolicyUpdateRequest extends RpcMessage {
25
26     public static final String UPDATE_MESSAGE = "policy_update";
27
28     static public class Params {
29
30         private List<ManagedObject> replace;
31         private List<ManagedObject> merge_children;
32         private List<Uri> delete_uri;
33
34         public List<ManagedObject> getReplace() {
35             return replace;
36         }
37
38         public void setReplace(List<ManagedObject> replace) {
39             this.replace = replace;
40         }
41
42         public List<ManagedObject> getMerge_children() {
43             return merge_children;
44         }
45
46         public void setMerge_children(List<ManagedObject> merge_children) {
47             this.merge_children = merge_children;
48         }
49
50         public List<Uri> getDelete_uri() {
51             return delete_uri;
52         }
53
54         public void setDelete_uri(List<Uri> delete_uri) {
55             this.delete_uri = delete_uri;
56         }
57     }
58
59     private JsonNode id;
60     private String method;
61     private List<Params> params;
62
63     @JsonIgnore
64     private String name;
65
66     @Override
67     public JsonNode getId() {
68         return id;
69     }
70
71     @Override
72     public void setId(JsonNode id) {
73         this.id = id;
74     }
75
76     @Override
77     public String getMethod() {
78         return method;
79     }
80
81     @Override
82     public void setMethod(String method) {
83         this.method = method;
84     }
85
86     public List<Params> getParams() {
87         return this.params;
88     }
89
90     public void setParams(List<Params> params) {
91         this.params = params;
92     }
93
94     @Override
95     public String getName() {
96         return this.name;
97     }
98
99     @Override
100     public void setName(String name) {
101         this.name = name;
102     }
103
104     public PolicyUpdateRequest(String name) {
105         this.name = name;
106     }
107
108     public PolicyUpdateRequest() {
109         this.name = UPDATE_MESSAGE;
110         this.method = UPDATE_MESSAGE;
111     }
112
113     /**
114      * Minimal check on validity of message
115      * 
116      * @return true if message has passed validity check
117      */
118     @JsonIgnore
119     @Override
120     public boolean valid() {
121         if (params == null)
122             return false;
123         if (params.get(0) == null)
124             return false;
125         return true;
126     }
127 }