84f0605061498e042accd3ac2aa44f0c72a0d832
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ServiceProviderPlugin / src / oic / simulator / serviceprovider / resource / SimulatorResource.java
1 package oic.simulator.serviceprovider.resource;
2
3 import java.util.HashMap;
4 import java.util.Iterator;
5 import java.util.Map;
6
7 import org.oic.simulator.AutomationType;
8 import org.oic.simulator.SimulatorResourceModel;
9 import org.oic.simulator.serviceprovider.ObserverInfo;
10 import org.oic.simulator.serviceprovider.SimulatorResourceServer;
11
12 public class SimulatorResource {
13     private String                              resourceURI;
14     private String                              resourceName;
15     private String                              resourceType;
16     private String                              resourceInterface;
17
18     // Native Object references
19     private SimulatorResourceServer             resourceServer;
20     private SimulatorResourceModel              resourceModel;
21
22     private int                                 automationId;
23
24     private boolean                             resourceAutomationInProgress;
25
26     private boolean                             attributeAutomationInProgress;
27
28     private int                                 automationUpdateInterval;
29
30     private AutomationType                      automationType;
31
32     private Map<String, LocalResourceAttribute> resourceAttributesMap;
33
34     private Map<Integer, ObserverDetail>        observers;
35
36     public SimulatorResource() {
37         observers = new HashMap<Integer, ObserverDetail>();
38     }
39
40     public String getResourceURI() {
41         return resourceURI;
42     }
43
44     public void setResourceURI(String resourceURI) {
45         this.resourceURI = resourceURI;
46     }
47
48     public String getResourceName() {
49         return resourceName;
50     }
51
52     public void setResourceName(String resourceName) {
53         this.resourceName = resourceName;
54     }
55
56     public String getResourceType() {
57         return resourceType;
58     }
59
60     public void setResourceType(String resourceType) {
61         this.resourceType = resourceType;
62     }
63
64     public String getResourceInterface() {
65         return resourceInterface;
66     }
67
68     public void setResourceInterface(String resourceInterface) {
69         this.resourceInterface = resourceInterface;
70     }
71
72     public SimulatorResourceServer getResourceServer() {
73         return resourceServer;
74     }
75
76     public void setResourceServer(SimulatorResourceServer resourceServer) {
77         this.resourceServer = resourceServer;
78     }
79
80     public SimulatorResourceModel getResourceModel() {
81         return resourceModel;
82     }
83
84     public void setResourceModel(SimulatorResourceModel resourceModel) {
85         this.resourceModel = resourceModel;
86     }
87
88     public Map<String, LocalResourceAttribute> getResourceAttributesMap() {
89         return resourceAttributesMap;
90     }
91
92     public void setResourceAttributesMap(
93             Map<String, LocalResourceAttribute> resourceAttributesMap) {
94         this.resourceAttributesMap = resourceAttributesMap;
95     }
96
97     public int getAutomationUpdateInterval() {
98         return automationUpdateInterval;
99     }
100
101     public void setAutomationUpdateInterval(int automationUpdateInterval) {
102         this.automationUpdateInterval = automationUpdateInterval;
103     }
104
105     public AutomationType getAutomationType() {
106         return automationType;
107     }
108
109     public void setAutomationType(AutomationType automationType) {
110         this.automationType = automationType;
111     }
112
113     public int getAutomationId() {
114         return automationId;
115     }
116
117     public void setAutomationId(int automationId) {
118         this.automationId = automationId;
119     }
120
121     public boolean isResourceAutomationInProgress() {
122         return resourceAutomationInProgress;
123     }
124
125     public void setResourceAutomationInProgress(
126             boolean resourceAutomationInProgress) {
127         this.resourceAutomationInProgress = resourceAutomationInProgress;
128     }
129
130     public boolean isAttributeAutomationInProgress() {
131         return attributeAutomationInProgress;
132     }
133
134     public void setAttributeAutomationInProgress(
135             boolean attributeAutomationInProgress) {
136         this.attributeAutomationInProgress = attributeAutomationInProgress;
137     }
138
139     public Map<Integer, ObserverDetail> getObserver() {
140         return observers;
141     }
142
143     public void addObserverInfo(ObserverInfo observer) {
144         if (null == observer) {
145             return;
146         }
147         int id = observer.getId();
148         if (!observers.containsKey(id)) {
149             ObserverDetail obsDetail = new ObserverDetail();
150             obsDetail.setObserverInfo(observer);
151             observers.put(id, obsDetail);
152         }
153     }
154
155     public void removeObserverInfo(ObserverInfo observer) {
156         if (null == observer) {
157             return;
158         }
159         observers.remove(observer.getId());
160     }
161
162     public void printResourceInfo() {
163         System.out.println("Resource URI: " + resourceURI);
164         System.out.println("Resource Name: " + resourceName);
165         System.out.println("Resource type: " + resourceType);
166         System.out.println("Resource Interface: " + resourceInterface);
167         System.out.println("Resource Attributes:-");
168         if (null != resourceAttributesMap) {
169             Iterator<String> attItr = resourceAttributesMap.keySet().iterator();
170             while (attItr.hasNext()) {
171                 resourceAttributesMap.get(attItr.next())
172                         .printAttributeDetails();;
173             }
174         }
175     }
176
177     public LocalResourceAttribute getAttribute(String attributeName) {
178         if (null == attributeName || null == resourceAttributesMap
179                 || resourceAttributesMap.size() < 1) {
180             return null;
181         }
182         return resourceAttributesMap.get(attributeName);
183     }
184
185 }