@Test public void testActivityNoRecentData() { IContextElement[] addrs = { ContextHelper.createCivilAddress(System.currentTimeMillis() - ((15) * 1000), 600, "place1"), ContextHelper.createCivilAddress(System.currentTimeMillis() - ((Defaults.ACTIVITY_PERIOD + Defaults.ACTIVITY_TOLERANCE + 10) * 1000), 600, "place1") }; String activity = activityDetector.getActivity(Constants.ENTITY_ME,addrs); assertFalse((activity == null) || (!activity.equalsIgnoreCase(""))); }
protected String getActivity(IEntity entity, IContextElement[] addrs) { if (addrs.length != 0) { int index = Utility.getFirstSignificativeItem(addrs,Defaults.ACTIVITY_PERIOD,Defaults.ACTIVITY_TOLERANCE); if (index == -1) { logger.debug("Received civil addresses are too recent to infer activity"); return ""; } else { logger.debug("Significative civil address for activity:"); for (int i=0; i<addrs.length; i++) { String prefix = ""; if (i <= index) prefix = "*" + i; else prefix = "" + i; logger.debug(prefix + " - " + (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue() + " " + (String)addrs[i].getMetadata().getMetadatumValue(Factory.createScope(Constants.SCOPE_METADATA_TIMESTAMP)).getValue()); } } String placeName = (String)addrs[0].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); for (int i=1; i<=index; i++) { String currentPlace = (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); if (!currentPlace.equalsIgnoreCase(placeName)) return ""; } return "@" + placeName; } return ""; }
ActivityDetector implements IContextProvider { protected String getActivity(IEntity entity, IContextElement[] addrs) { if (addrs.length != 0) { int index = Utility.getFirstSignificativeItem(addrs,Defaults.ACTIVITY_PERIOD,Defaults.ACTIVITY_TOLERANCE); if (index == -1) { logger.debug("Received civil addresses are too recent to infer activity"); return ""; } else { logger.debug("Significative civil address for activity:"); for (int i=0; i<addrs.length; i++) { String prefix = ""; if (i <= index) prefix = "*" + i; else prefix = "" + i; logger.debug(prefix + " - " + (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue() + " " + (String)addrs[i].getMetadata().getMetadatumValue(Factory.createScope(Constants.SCOPE_METADATA_TIMESTAMP)).getValue()); } } String placeName = (String)addrs[0].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); for (int i=1; i<=index; i++) { String currentPlace = (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); if (!currentPlace.equalsIgnoreCase(placeName)) return ""; } return "@" + placeName; } return ""; } }
ActivityDetector implements IContextProvider { protected String getActivity(IEntity entity, IContextElement[] addrs) { if (addrs.length != 0) { int index = Utility.getFirstSignificativeItem(addrs,Defaults.ACTIVITY_PERIOD,Defaults.ACTIVITY_TOLERANCE); if (index == -1) { logger.debug("Received civil addresses are too recent to infer activity"); return ""; } else { logger.debug("Significative civil address for activity:"); for (int i=0; i<addrs.length; i++) { String prefix = ""; if (i <= index) prefix = "*" + i; else prefix = "" + i; logger.debug(prefix + " - " + (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue() + " " + (String)addrs[i].getMetadata().getMetadatumValue(Factory.createScope(Constants.SCOPE_METADATA_TIMESTAMP)).getValue()); } } String placeName = (String)addrs[0].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); for (int i=1; i<=index; i++) { String currentPlace = (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); if (!currentPlace.equalsIgnoreCase(placeName)) return ""; } return "@" + placeName; } return ""; }  }
ActivityDetector implements IContextProvider { protected String getActivity(IEntity entity, IContextElement[] addrs) { if (addrs.length != 0) { int index = Utility.getFirstSignificativeItem(addrs,Defaults.ACTIVITY_PERIOD,Defaults.ACTIVITY_TOLERANCE); if (index == -1) { logger.debug("Received civil addresses are too recent to infer activity"); return ""; } else { logger.debug("Significative civil address for activity:"); for (int i=0; i<addrs.length; i++) { String prefix = ""; if (i <= index) prefix = "*" + i; else prefix = "" + i; logger.debug(prefix + " - " + (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue() + " " + (String)addrs[i].getMetadata().getMetadatumValue(Factory.createScope(Constants.SCOPE_METADATA_TIMESTAMP)).getValue()); } } String placeName = (String)addrs[0].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); for (int i=1; i<=index; i++) { String currentPlace = (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); if (!currentPlace.equalsIgnoreCase(placeName)) return ""; } return "@" + placeName; } return ""; }  void setContextProcessor(IContextProcessor contextProcessor); void setServiceGateway(ServiceGateway serviceGateway); void setPolicyManager(PolicyManager policyManager); void setProviderManager(IProviderManager providerManager); void setAccountManager(AccountManager accountManager); void setPersonManager(PersonManager personManager); void setPersonGroupManager(PersonGroupManager personGroupManager); void setTenantManager(TenantManager tenantManager); void setUserManager(UserManager userManager); void init(); @Override IContextDataset getContext(Tenant t, IEntity entity, IScope scope,
			IContextDataset inputContextDataset); }
ActivityDetector implements IContextProvider { protected String getActivity(IEntity entity, IContextElement[] addrs) { if (addrs.length != 0) { int index = Utility.getFirstSignificativeItem(addrs,Defaults.ACTIVITY_PERIOD,Defaults.ACTIVITY_TOLERANCE); if (index == -1) { logger.debug("Received civil addresses are too recent to infer activity"); return ""; } else { logger.debug("Significative civil address for activity:"); for (int i=0; i<addrs.length; i++) { String prefix = ""; if (i <= index) prefix = "*" + i; else prefix = "" + i; logger.debug(prefix + " - " + (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue() + " " + (String)addrs[i].getMetadata().getMetadatumValue(Factory.createScope(Constants.SCOPE_METADATA_TIMESTAMP)).getValue()); } } String placeName = (String)addrs[0].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); for (int i=1; i<=index; i++) { String currentPlace = (String)addrs[i].getContextData().getContextValue(Factory.createScope(Constants.SCOPE_LOCATION_CIVILADDRESS_PLACE_NAME)).getValue().getValue(); if (!currentPlace.equalsIgnoreCase(placeName)) return ""; } return "@" + placeName; } return ""; }  void setContextProcessor(IContextProcessor contextProcessor); void setServiceGateway(ServiceGateway serviceGateway); void setPolicyManager(PolicyManager policyManager); void setProviderManager(IProviderManager providerManager); void setAccountManager(AccountManager accountManager); void setPersonManager(PersonManager personManager); void setPersonGroupManager(PersonGroupManager personGroupManager); void setTenantManager(TenantManager tenantManager); void setUserManager(UserManager userManager); void init(); @Override IContextDataset getContext(Tenant t, IEntity entity, IScope scope,
			IContextDataset inputContextDataset);  }