2 * Copyright 2015 Samsung Electronics All Rights Reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 package oic.simulator.clientcontroller.remoteresource;
19 import oic.simulator.clientcontroller.utils.Constants;
21 import org.oic.simulator.SimulatorResourceModel;
22 import org.oic.simulator.client.SimulatorRemoteResource;
25 * This class represents a remote resource. It maintains all the necessary
26 * information about the resource.
28 public class RemoteResource {
30 private boolean observed;
32 // Native object references
33 private SimulatorRemoteResource remoteResourceRef;
34 private SimulatorResourceModel resourceModelRef;
35 private ResourceRepresentation mResourceRepresentation;
36 // private Map<String, RemoteResourceAttribute> resourceAttributesMap;
38 private boolean configUploaded;
40 private boolean getAutomtnInProgress;
41 private boolean putAutomtnInProgress;
42 private boolean postAutomtnInProgress;
44 private int getAutomtnId;
45 private int putAutomtnId;
46 private int postAutomtnId;
48 private boolean isFavorite;
50 public SimulatorResourceModel getResourceModelRef() {
51 return resourceModelRef;
54 public void setResourceModelRef(SimulatorResourceModel resourceModel) {
55 this.resourceModelRef = resourceModel;
59 * public Map<String, RemoteResourceAttribute> getResourceAttributesMap() {
60 * return resourceAttributesMap; }
62 * public void setResourceAttributesMap( Map<String,
63 * RemoteResourceAttribute> resourceAttributesMap) {
64 * this.resourceAttributesMap = resourceAttributesMap; }
66 public int getGetAutomtnId() {
70 public void setGetAutomtnId(int getAutomtnId) {
71 this.getAutomtnId = getAutomtnId;
74 public int getPutAutomtnId() {
78 public void setPutAutomtnId(int putAutomtnId) {
79 this.putAutomtnId = putAutomtnId;
82 public int getPostAutomtnId() {
86 public void setPostAutomtnId(int postAutomtnId) {
87 this.postAutomtnId = postAutomtnId;
90 public boolean isGetAutomtnInProgress() {
91 return getAutomtnInProgress;
94 public void setGetAutomtnInProgress(boolean getAutomtnInProgress) {
95 this.getAutomtnInProgress = getAutomtnInProgress;
98 public boolean isPutAutomtnInProgress() {
99 return putAutomtnInProgress;
102 public void setPutAutomtnInProgress(boolean putAutomtnInProgress) {
103 this.putAutomtnInProgress = putAutomtnInProgress;
106 public boolean isPostAutomtnInProgress() {
107 return postAutomtnInProgress;
110 public void setPostAutomtnInProgress(boolean postAutomtnInProgress) {
111 this.postAutomtnInProgress = postAutomtnInProgress;
114 public boolean isConfigUploaded() {
115 return configUploaded;
118 public void setConfigUploaded(boolean configUploaded) {
119 this.configUploaded = configUploaded;
122 public SimulatorRemoteResource getRemoteResourceRef() {
123 return remoteResourceRef;
126 public void setRemoteResourceRef(SimulatorRemoteResource resource) {
127 this.remoteResourceRef = resource;
130 public boolean isObserved() {
134 public void setObserved(boolean observed) {
135 this.observed = observed;
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; }
150 * public String getAttributeValue(String attName) { RemoteResourceAttribute
151 * attribute = resourceAttributesMap.get(attName); if (null == attribute) {
152 * return null; } return String.valueOf(attribute.getAttributeValue()); }
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;
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;
174 public boolean isFavorite() {
178 public void setFavorite(boolean isFavorite) {
179 this.isFavorite = isFavorite;
182 public void setResourceRepresentation(SimulatorResourceModel resModel,
183 boolean ramlUploaded) {
184 if (mResourceRepresentation == null)
185 mResourceRepresentation = new ResourceRepresentation(resModel);
187 mResourceRepresentation.update(resModel, ramlUploaded);
190 public ResourceRepresentation getResourceRepresentation() {
191 return mResourceRepresentation;