Issue 15: Reorganize source files
[remote/remote-gui.git] / src / remote / service / motedata / client / MoteDataWrapper.java
bloba7d45290e95d8dfd05fe19da94950f9faefb9c8d
1 package remote.service.motedata.client;
3 import java.util.Hashtable;
4 import diku.distlab.remote.motedata.*;
5 import remote.motecontrol.client.Session;
7 public class MoteDataWrapper {
8 private static MoteDataServiceLocator motedataLocator = new MoteDataServiceLocator();
10 private static SimpleTable moteList = null;
11 private static SimpleTableWrapper moteTable = null;
12 private static Hashtable moteIndex = null;
13 private static Session session = null;
15 public static Table getMoteTable() {
16 if (moteTable == null)
18 moteTable = new SimpleTableWrapper(getMoteList());
20 return moteTable;
23 public static Hashtable getMoteIndex() {
24 return moteIndex;
27 public static void updateMoteList() {
28 try
30 moteList = motedataLocator.getmotedata().getMoteData(session.getSessionId());
31 ((SimpleTableWrapper)getMoteTable()).updateTable(moteList);
32 moteIndex = createIndex(moteList,0);
34 catch (Exception e)
36 e.printStackTrace();
40 private static SimpleTable getMoteList()
42 if (moteList == null)
44 try
46 moteList = motedataLocator.getmotedata().getMoteData(session.getSessionId());
48 catch (Exception e)
50 e.printStackTrace();
53 return moteList;
56 static Hashtable createIndex(SimpleTable table, int col)
58 Hashtable index = new Hashtable();
59 for (int i = 0 ; i < table.getData().length ; i ++ )
61 index.put(table.getData()[i][col], table.getData()[i]);
63 return index;
66 public static void setSession(Session session) {
67 MoteDataWrapper.session = session;
68 String url ="http://"+session.getServerConnection().getConnectionInfo().getServerName()+":8080/axis/services/motedata";
69 motedataLocator.setmotedataEndpointAddress(url);