Displaying and editing the complex value types for attributes.
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ClientControllerPlugin / src / oic / simulator / clientcontroller / remoteresource / RemoteResource.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package oic.simulator.clientcontroller.remoteresource;
18
19 import oic.simulator.clientcontroller.utils.Constants;
20
21 import org.oic.simulator.SimulatorResourceModel;
22 import org.oic.simulator.client.SimulatorRemoteResource;
23
24 /**
25  * This class represents a remote resource. It maintains all the necessary
26  * information about the resource.
27  */
28 public class RemoteResource {
29
30     private boolean                 observed;
31
32     // Native object references
33     private SimulatorRemoteResource remoteResourceRef;
34     private SimulatorResourceModel  resourceModelRef;
35     private ResourceRepresentation  mResourceRepresentation;
36     // private Map<String, RemoteResourceAttribute> resourceAttributesMap;
37
38     private boolean                 configUploaded;
39
40     private boolean                 getAutomtnInProgress;
41     private boolean                 putAutomtnInProgress;
42     private boolean                 postAutomtnInProgress;
43
44     private int                     getAutomtnId;
45     private int                     putAutomtnId;
46     private int                     postAutomtnId;
47
48     private boolean                 isFavorite;
49
50     public SimulatorResourceModel getResourceModelRef() {
51         return resourceModelRef;
52     }
53
54     public void setResourceModelRef(SimulatorResourceModel resourceModel) {
55         this.resourceModelRef = resourceModel;
56     }
57
58     /*
59      * public Map<String, RemoteResourceAttribute> getResourceAttributesMap() {
60      * return resourceAttributesMap; }
61      * 
62      * public void setResourceAttributesMap( Map<String,
63      * RemoteResourceAttribute> resourceAttributesMap) {
64      * this.resourceAttributesMap = resourceAttributesMap; }
65      */
66     public int getGetAutomtnId() {
67         return getAutomtnId;
68     }
69
70     public void setGetAutomtnId(int getAutomtnId) {
71         this.getAutomtnId = getAutomtnId;
72     }
73
74     public int getPutAutomtnId() {
75         return putAutomtnId;
76     }
77
78     public void setPutAutomtnId(int putAutomtnId) {
79         this.putAutomtnId = putAutomtnId;
80     }
81
82     public int getPostAutomtnId() {
83         return postAutomtnId;
84     }
85
86     public void setPostAutomtnId(int postAutomtnId) {
87         this.postAutomtnId = postAutomtnId;
88     }
89
90     public boolean isGetAutomtnInProgress() {
91         return getAutomtnInProgress;
92     }
93
94     public void setGetAutomtnInProgress(boolean getAutomtnInProgress) {
95         this.getAutomtnInProgress = getAutomtnInProgress;
96     }
97
98     public boolean isPutAutomtnInProgress() {
99         return putAutomtnInProgress;
100     }
101
102     public void setPutAutomtnInProgress(boolean putAutomtnInProgress) {
103         this.putAutomtnInProgress = putAutomtnInProgress;
104     }
105
106     public boolean isPostAutomtnInProgress() {
107         return postAutomtnInProgress;
108     }
109
110     public void setPostAutomtnInProgress(boolean postAutomtnInProgress) {
111         this.postAutomtnInProgress = postAutomtnInProgress;
112     }
113
114     public boolean isConfigUploaded() {
115         return configUploaded;
116     }
117
118     public void setConfigUploaded(boolean configUploaded) {
119         this.configUploaded = configUploaded;
120     }
121
122     public SimulatorRemoteResource getRemoteResourceRef() {
123         return remoteResourceRef;
124     }
125
126     public void setRemoteResourceRef(SimulatorRemoteResource resource) {
127         this.remoteResourceRef = resource;
128     }
129
130     public boolean isObserved() {
131         return observed;
132     }
133
134     public void setObserved(boolean observed) {
135         this.observed = observed;
136     }
137
138     /*
139      * public List<PutPostAttributeModel> getPutPostModel() { Map<String,
140      * RemoteResourceAttribute> attMap = getResourceAttributesMap(); if (null ==
141      * attMap || attMap.size() < 1) { return null; } List<PutPostAttributeModel>
142      * putPostModelList = new ArrayList<PutPostAttributeModel>(); String
143      * attName; RemoteResourceAttribute attribute; PutPostAttributeModel
144      * putPostModel; Iterator<String> attItr = attMap.keySet().iterator(); while
145      * (attItr.hasNext()) { attName = attItr.next(); attribute =
146      * attMap.get(attName); putPostModel =
147      * PutPostAttributeModel.getModel(attribute); if (null != putPostModel) {
148      * putPostModelList.add(putPostModel); } } return putPostModelList; }
149      * 
150      * public String getAttributeValue(String attName) { RemoteResourceAttribute
151      * attribute = resourceAttributesMap.get(attName); if (null == attribute) {
152      * return null; } return String.valueOf(attribute.getAttributeValue()); }
153      */
154     public int getAutomationtype(int autoId) {
155         if (getAutomtnId == autoId) {
156             return Constants.GET_AUTOMATION_INDEX;
157         } else if (putAutomtnId == autoId) {
158             return Constants.PUT_AUTOMATION_INDEX;
159         } else {// if(postAutomtnId == autoId) {
160             return Constants.POST_AUTOMATION_INDEX;
161         }
162     }
163
164     public void updateAutomationStatus(int autoId, boolean status) {
165         if (getAutomtnId == autoId) {
166             getAutomtnInProgress = status;
167         } else if (putAutomtnId == autoId) {
168             putAutomtnInProgress = status;
169         } else {// if(postAutomtnId == autoId) {
170             postAutomtnInProgress = status;
171         }
172     }
173
174     public boolean isFavorite() {
175         return isFavorite;
176     }
177
178     public void setFavorite(boolean isFavorite) {
179         this.isFavorite = isFavorite;
180     }
181
182     public void setResourceRepresentation(SimulatorResourceModel resModel,
183             boolean ramlUploaded) {
184         if (mResourceRepresentation == null)
185             mResourceRepresentation = new ResourceRepresentation(resModel);
186         else
187             mResourceRepresentation.update(resModel, ramlUploaded);
188     }
189
190     public ResourceRepresentation getResourceRepresentation() {
191         return mResourceRepresentation;
192     }
193 }