View Javadoc

1   /*
2   Copyright 2011-2014 AGH-UST, http://www.agh.edu.pl
3   Faculty of Computer Science, Electronics and Telecommunications
4   Department of Computer Science 
5   
6   See the NOTICE file distributed with this work for additional
7   information regarding copyright ownership
8   
9   Licensed under the Apache License, Version 2.0 (the "License");
10  you may not use this file except in compliance with the License.
11  You may obtain a copy of the License at
12  
13    http://www.apache.org/licenses/LICENSE-2.0
14  
15  Unless required by applicable law or agreed to in writing, software
16  distributed under the License is distributed on an "AS IS" BASIS,
17  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  See the License for the specific language governing permissions and
19  limitations under the License.
20  */
21  package org.universAAL.ri.gateway.eimanager.impl.importing;
22  
23  import java.io.IOException;
24  import java.util.HashSet;
25  import java.util.Set;
26  
27  import org.universAAL.middleware.container.ModuleContext;
28  import org.universAAL.middleware.rdf.Resource;
29  import org.universAAL.middleware.service.owls.profile.ServiceProfile;
30  import org.universAAL.middleware.ui.UIHandler;
31  import org.universAAL.middleware.ui.UIHandlerProfile;
32  import org.universAAL.middleware.ui.UIRequest;
33  import org.universAAL.ri.gateway.eimanager.impl.ProxyBusMember;
34  
35  public class ProxyUIHandler extends ProxyBusMember {
36  
37  	private UIHandler handler;
38  	private Set<ServiceProfile> profilesSet;
39  	
40  	public ProxyUIHandler(UIHandlerProfile[] handlerProfiles,
41  			ImportedProxyManager manager, final String targetId,
42  			ModuleContext mc) {
43  		super(manager, targetId,"", mc);
44  		
45  		profilesSet = new HashSet<ServiceProfile>();
46  		
47  		handler = new UIHandler(mc, handlerProfiles) {
48  
49  			public void handleUICall(UIRequest uicall) {
50  				try {
51  					((ImportedProxyManager) getManager())
52  							.realizeRemoteUIRequest(targetId, uicall);
53  				} catch (IOException e) {
54  					// TODO Auto-generated catch block
55  					e.printStackTrace();
56  				}
57  			}
58  
59  			public Resource cutDialog(String dialogID) {
60  				return null;
61  			}
62  
63  			public void communicationChannelBroken() {
64  			}
65  
66  			public void adaptationParametersChanged(String dialogID,
67  					String changedProp, Object newVal) {
68  			}
69  		};
70  	}
71  
72  	public void removeProxy() {
73  		handler.close();
74  	}
75  
76  	public String getId() {
77  		return handler.getMyID();
78  	}
79  	
80  	public Set<ServiceProfile> getProfilesSet() {
81  		return profilesSet;
82  	}
83  
84  	public void setProfilesSet(Set<ServiceProfile> profilesSet) {
85  		this.profilesSet = profilesSet;
86  	}
87  }