@Test public void testUpdateActivity() { try { List<Node> activities = new ArrayList<Node>(); RawContextNotification notification = createNotification(user1,currentActivity); rawContextUpdater.contextChanged(notification); State state = liveContextService.get(State.class); ClosableIterator<Statement> currentIt = state.getModel().findStatements(state, DCON.currentActivity, Variable.ANY); while (currentIt.hasNext()) { Node object = currentIt.next().getObject(); if (object instanceof URI) { activities.add(object); } } currentIt.close(); assertTrue(activities.size() == 1); } catch (Exception e) { fail(e.getMessage()); } }
@Override public void contextChanged(RawContextNotification notification) throws Exception { String name = notification.getName(); logger.debug("Raw Activity Context notification received: " + name); StringTokenizer tok = new StringTokenizer(name,","); IEntity entity = Factory.createEntity(tok.nextToken()); IScope scope = Factory.createScope(tok.nextToken()); Tenant t = new Tenant(); t.setId(notification.getTenant()); IContextDataset dataset; try { dataset = this.contextProcessor.getContext(t,entity, scope); if (!dataset.equals(IContextDataset.EMPTY_CONTEXT_DATASET)) { IContextElement[] ces = dataset.getContextElements(scope); if (ces != null && ces.length == 1) { this.rawContextQueue.add(ces[0]); update(); } } } catch (ContextException e) { logger.error(e.toString()); } }
ActivityContextUpdater implements LiveContextUpdater, IContextListener { @Override public void contextChanged(RawContextNotification notification) throws Exception { String name = notification.getName(); logger.debug("Raw Activity Context notification received: " + name); StringTokenizer tok = new StringTokenizer(name,","); IEntity entity = Factory.createEntity(tok.nextToken()); IScope scope = Factory.createScope(tok.nextToken()); Tenant t = new Tenant(); t.setId(notification.getTenant()); IContextDataset dataset; try { dataset = this.contextProcessor.getContext(t,entity, scope); if (!dataset.equals(IContextDataset.EMPTY_CONTEXT_DATASET)) { IContextElement[] ces = dataset.getContextElements(scope); if (ces != null && ces.length == 1) { this.rawContextQueue.add(ces[0]); update(); } } } catch (ContextException e) { logger.error(e.toString()); } } }
ActivityContextUpdater implements LiveContextUpdater, IContextListener { @Override public void contextChanged(RawContextNotification notification) throws Exception { String name = notification.getName(); logger.debug("Raw Activity Context notification received: " + name); StringTokenizer tok = new StringTokenizer(name,","); IEntity entity = Factory.createEntity(tok.nextToken()); IScope scope = Factory.createScope(tok.nextToken()); Tenant t = new Tenant(); t.setId(notification.getTenant()); IContextDataset dataset; try { dataset = this.contextProcessor.getContext(t,entity, scope); if (!dataset.equals(IContextDataset.EMPTY_CONTEXT_DATASET)) { IContextElement[] ces = dataset.getContextElements(scope); if (ces != null && ces.length == 1) { this.rawContextQueue.add(ces[0]); update(); } } } catch (ContextException e) { logger.error(e.toString()); } }  }
ActivityContextUpdater implements LiveContextUpdater, IContextListener { @Override public void contextChanged(RawContextNotification notification) throws Exception { String name = notification.getName(); logger.debug("Raw Activity Context notification received: " + name); StringTokenizer tok = new StringTokenizer(name,","); IEntity entity = Factory.createEntity(tok.nextToken()); IScope scope = Factory.createScope(tok.nextToken()); Tenant t = new Tenant(); t.setId(notification.getTenant()); IContextDataset dataset; try { dataset = this.contextProcessor.getContext(t,entity, scope); if (!dataset.equals(IContextDataset.EMPTY_CONTEXT_DATASET)) { IContextElement[] ces = dataset.getContextElements(scope); if (ces != null && ces.length == 1) { this.rawContextQueue.add(ces[0]); update(); } } } catch (ContextException e) { logger.error(e.toString()); } }  void setContextProcessor(IContextProcessor contextProcessor); void setConnectionProvider(ConnectionProvider connectionProvider); void setTenantManager(TenantManager tenantManager); void init(); @Override void contextChanged(RawContextNotification notification); @Override void update(); }
ActivityContextUpdater implements LiveContextUpdater, IContextListener { @Override public void contextChanged(RawContextNotification notification) throws Exception { String name = notification.getName(); logger.debug("Raw Activity Context notification received: " + name); StringTokenizer tok = new StringTokenizer(name,","); IEntity entity = Factory.createEntity(tok.nextToken()); IScope scope = Factory.createScope(tok.nextToken()); Tenant t = new Tenant(); t.setId(notification.getTenant()); IContextDataset dataset; try { dataset = this.contextProcessor.getContext(t,entity, scope); if (!dataset.equals(IContextDataset.EMPTY_CONTEXT_DATASET)) { IContextElement[] ces = dataset.getContextElements(scope); if (ces != null && ces.length == 1) { this.rawContextQueue.add(ces[0]); update(); } } } catch (ContextException e) { logger.error(e.toString()); } }  void setContextProcessor(IContextProcessor contextProcessor); void setConnectionProvider(ConnectionProvider connectionProvider); void setTenantManager(TenantManager tenantManager); void init(); @Override void contextChanged(RawContextNotification notification); @Override void update();  }