Imported Upstream version 1.1.0
[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 java.util.Map;
20
21 import org.oic.simulator.SimulatorResourceModel;
22 import org.oic.simulator.client.SimulatorRemoteResource;
23 import org.oic.simulator.client.SimulatorRemoteResource.RequestType;
24 import org.oic.simulator.client.SimulatorRequestModel;
25
26 /**
27  * This class represents a remote resource. It maintains all the necessary
28  * information about the resource.
29  */
30 public class RemoteResource {
31
32     private boolean                                 observed;
33
34     // Native object references
35     private SimulatorRemoteResource                 remoteResourceRef;
36     private SimulatorResourceModel                  resourceModelRef;
37     private Map<RequestType, SimulatorRequestModel> requestModels;
38     private ResourceRepresentation                  mResourceRepresentation;
39
40     private boolean                                 configUploaded;
41
42     private boolean                                 getAutomtnInProgress;
43     private boolean                                 putAutomtnInProgress;
44     private boolean                                 postAutomtnInProgress;
45
46     private int                                     getAutomtnId;
47     private int                                     putAutomtnId;
48     private int                                     postAutomtnId;
49
50     private boolean                                 isFavorite;
51
52     public SimulatorResourceModel getResourceModelRef() {
53         return resourceModelRef;
54     }
55
56     public void setResourceModelRef(SimulatorResourceModel resourceModel) {
57         this.resourceModelRef = resourceModel;
58     }
59
60     public Map<RequestType, SimulatorRequestModel> getRequestModels() {
61         return requestModels;
62     }
63
64     public void setRequestModels(
65             Map<RequestType, SimulatorRequestModel> requestModels) {
66         this.requestModels = requestModels;
67     }
68
69     public int getGetAutomtnId() {
70         return getAutomtnId;
71     }
72
73     public void setGetAutomtnId(int getAutomtnId) {
74         this.getAutomtnId = getAutomtnId;
75     }
76
77     public int getPutAutomtnId() {
78         return putAutomtnId;
79     }
80
81     public void setPutAutomtnId(int putAutomtnId) {
82         this.putAutomtnId = putAutomtnId;
83     }
84
85     public int getPostAutomtnId() {
86         return postAutomtnId;
87     }
88
89     public void setPostAutomtnId(int postAutomtnId) {
90         this.postAutomtnId = postAutomtnId;
91     }
92
93     public boolean isGetAutomtnInProgress() {
94         return getAutomtnInProgress;
95     }
96
97     public void setGetAutomtnInProgress(boolean getAutomtnInProgress) {
98         this.getAutomtnInProgress = getAutomtnInProgress;
99     }
100
101     public boolean isPutAutomtnInProgress() {
102         return putAutomtnInProgress;
103     }
104
105     public void setPutAutomtnInProgress(boolean putAutomtnInProgress) {
106         this.putAutomtnInProgress = putAutomtnInProgress;
107     }
108
109     public boolean isPostAutomtnInProgress() {
110         return postAutomtnInProgress;
111     }
112
113     public void setPostAutomtnInProgress(boolean postAutomtnInProgress) {
114         this.postAutomtnInProgress = postAutomtnInProgress;
115     }
116
117     public boolean isConfigUploaded() {
118         return configUploaded;
119     }
120
121     public void setConfigUploaded(boolean configUploaded) {
122         this.configUploaded = configUploaded;
123     }
124
125     public SimulatorRemoteResource getRemoteResourceRef() {
126         return remoteResourceRef;
127     }
128
129     public void setRemoteResourceRef(SimulatorRemoteResource resource) {
130         this.remoteResourceRef = resource;
131     }
132
133     public boolean isObserved() {
134         return observed;
135     }
136
137     public void setObserved(boolean observed) {
138         this.observed = observed;
139     }
140
141     public RequestType getAutomationtype(int autoId) {
142         if (getAutomtnId == autoId) {
143             return RequestType.GET;
144         } else if (putAutomtnId == autoId) {
145             return RequestType.PUT;
146         } else {
147             return RequestType.POST;
148         }
149     }
150
151     public void updateAutomationStatus(int autoId, boolean status) {
152         if (getAutomtnId == autoId) {
153             getAutomtnInProgress = status;
154         } else if (putAutomtnId == autoId) {
155             putAutomtnInProgress = status;
156         } else {
157             postAutomtnInProgress = status;
158         }
159     }
160
161     public boolean isFavorite() {
162         return isFavorite;
163     }
164
165     public void setFavorite(boolean isFavorite) {
166         this.isFavorite = isFavorite;
167     }
168
169     public void setResourceRepresentation(SimulatorResourceModel resModel) {
170         mResourceRepresentation = new ResourceRepresentation(resModel);
171     }
172
173     public ResourceRepresentation getResourceRepresentation() {
174         return mResourceRepresentation;
175     }
176 }