}
Collections.addAll(channelSet, channelNames);
}
private void addApiDataUpdate(DataUpdate update, GuestService guestService, final SettingsService settingsService){
ApiKey api = guestService.getApiKey(update.apiKeyId);
if (api == null || api.getConnector() == null){
//This means the specific apikeyid was removed
return;
}
String apiName = api.getConnector().getName();
List<String> facetNames = new ArrayList<String>();
if (update.objectTypeId == null){ //TODO: determine if this is ever reached
System.err.println("Unhandled: objectType = null for DataUpdate");
}
else{
ObjectType[] objectTypes = api.getConnector().getObjectTypesForValue(update.objectTypeId.intValue());
for(ObjectType objectType : objectTypes){
facetNames.add(objectType.getName());
}
}
if (facetNames.size() == 0){ //TODO: determine if this is ever reached
System.err.println("ApiDataUpdate with no facetNames!");
return;
}
if (apiData == null){
apiData = new HashMap<String,Map<String,TimeBoundariesModel>>();
}
Map<String,TimeBoundariesModel> connectorMap = apiData.get(apiName);
if (connectorMap == null){
connectorMap = new HashMap<String,TimeBoundariesModel>();
apiData.put(apiName,connectorMap);
}
for (String facetName : facetNames){
connectorMap.put(facetName,new TimeBoundariesModel(update.startTime,update.endTime));
}
if (connectorInfo == null){
connectorInfo = new HashMap<String,ConnectorDigestModel>();
}
if (connectorInfo.get(apiName) == null){
ConnectorDigestModel model = new ConnectorDigestModel();
model.apiKeyId = update.apiKeyId;
model.channelNames = settingsService.getChannelsForConnector(api.getGuestId(),api.getConnector());
model.prettyName = api.getConnector().getPrettyName();
model.connectorName = api.getConnector().getName();
for (ObjectType objectType : api.getConnector().objectTypes())
model.facetTypes.add(model.connectorName + "-" + objectType.getName());
connectorInfo.put(apiName,model);
}
}