Commit 8be5f5e1 authored by José Soares's avatar José Soares

Implemented I - Similarity

parent 5efd1cc3
......@@ -6,10 +6,6 @@ package com.senception.contextualmanager.aidl;
* */
interface CManagerInterface {
//double [] getAvailability(in String [] peerList);
//double [] getCentrality(in String [] peerList);
//Map getA(in String [] peerList); //String [] to ArrayList<String>
//Map getC(in String [] peerList); //String [] to ArrayList<String>
Map getAvailability(in List<String> peerList);
Map getCentrality(in List<String> peerList);
Map getSimilarity(in List<String> peerList);
......
......@@ -47,23 +47,22 @@ public class ContextualManagerReceive implements WifiP2pListener.TxtRecordAvaila
@Override
public void onTxtRecordAvailable(String fullDomainName, Map<String, String> txtRecordMap, WifiP2pDevice srcDevice) {
//TODO resolve error: getting txtrecord with a and c null
if(txtRecordMap != null && txtRecordMap.size() != 0) {
Log.d("teste", "txtRecord: " + txtRecordMap.toString());
Log.d("teste", "received from" + srcDevice.deviceName);
String a = txtRecordMap.get(Identity.AVAILABILITY);
String c = txtRecordMap.get(Identity.CENTRALITY);
Log.d("teste", "a: " + a + " c : " + c);
double A = 0;
double C = 0;
Log.d("teste", "Received a: " + a + "\t c : " + c);
//if(a != null && c != null ) {
A = Double.parseDouble(a);
C = Double.parseDouble(txtRecordMap.get(Identity.CENTRALITY));
//double A = 0;
//double C = 0;
//else{
Log.d("teste", "Device Name: " + srcDevice.deviceName);
//todo add if(a != null && c != null ) {
double A = Double.parseDouble(a);
double C = Double.parseDouble(c);
//}
//double I = Double.parseDouble(txtRecordMap.get(Identity.SIMILARITY));
String hashSrcDeviceBSSID = MacSecurity.md5Hash(srcDevice.deviceAddress);
//if it's the first time we see this peer we save it
......@@ -75,7 +74,6 @@ public class ContextualManagerReceive implements WifiP2pListener.TxtRecordAvaila
//TODO peer.setLongitude(longitude);
peer.setAvailability(A);
peer.setCentrality(C);
//peer.setSimilarity(I);
peer.setNumEncounters(1);
peer.setStartEncounter((int)(System.currentTimeMillis()/1000)); //time in seconds System.currentTimeMillis()/1000
dataSource.registerNewPeers(peer, ContextualManagerService.checkWeek("peers"));
......@@ -85,7 +83,6 @@ public class ContextualManagerReceive implements WifiP2pListener.TxtRecordAvaila
peer.setBSSID(hashSrcDeviceBSSID);
peer.setAvailability(A);
peer.setCentrality(C);
//peer.setSimilarity(I);
//TODO peer.setLatitude(latitude);
//TODO peer.setLongitude(longitude);
dataSource.updatePeer(peer, ContextualManagerService.checkWeek("peers"));
......
......@@ -36,6 +36,7 @@ public class ContextualManagerSend {
* @param context
*/
public ContextualManagerSend(Context context) {
//TODO resolve error: getting txtrecord with a and c null
mContext = context;
new Timer().scheduleAtFixedRate(new TimerTask() {
......@@ -44,22 +45,16 @@ public class ContextualManagerSend {
ContextualManagerDataSource dataSource = new ContextualManagerDataSource(mContext);
dataSource.openDB(true);
if (dataSource.hasPeer(MacSecurity.md5Hash("self"), ContextualManagerService.checkWeek("peers"))) {
ContextualManagerAP self = dataSource.getPeer(MacSecurity.md5Hash("self"), ContextualManagerService.checkWeek("peers"));
double A = self.getAvailability();
double C = self.getCentrality();
Log.d("teste", "A: " + A + " C: " + C);
//double I = self.getSimilarity();
Log.d("teste", "Sending A: " + A + "\t C: " + C);
String AToSend = String.valueOf(A);
String CToSend = String.valueOf(C);
Log.d("teste", "AToSend :" + AToSend + "CToSend: " + CToSend );
//String IToSend = String.valueOf(I); //Todo: Find bug - Find out when can A,C or I be null
Log.d("teste", "AToSend :" + AToSend + "\t CToSend: " + CToSend);//Todo: Find bug - Find out when can A or C null
WifiP2pTxtRecord.setRecord(mContext, Identity.AVAILABILITY, AToSend);
WifiP2pTxtRecord.setRecord(mContext, Identity.CENTRALITY, CToSend);
//WifiP2pTxtRecord.setRecord(mContext, Identity.SIMILARITY, IToSend);
Log.d(TAG, "Sent A, C and I.");
Log.d("teste", "Sent A and C");
}
else{
Log.d(TAG, "Table is still empty so we can't send the availability and centrality.");
......
......@@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -27,10 +26,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.database.*;
import android.database.sqlite.SQLiteDatabase;
import com.senception.contextualmanager.modals.ContextualManagerAP;
import com.senception.contextualmanager.modals.ContextualManagerVisit;
import com.senception.contextualmanager.modals.ContextualManagerWeight;
import com.senception.contextualmanager.modals.ContextualManagerAppUsage;
import com.senception.contextualmanager.modals.ContextualManagerPhysicalUsage;
......@@ -104,7 +100,6 @@ public class ContextualManagerDataSource {
db.execSQL("DELETE FROM "+ ContextualManagerSQLiteHelper.TABLE_SUNDAY_PEERS);
db.execSQL("DELETE FROM "+ ContextualManagerSQLiteHelper.TABLE_RESOURCE_USAGE);
db.execSQL("DELETE FROM "+ ContextualManagerSQLiteHelper.TABLE_APPS_USAGE);
db.execSQL("DELETE FROM "+ ContextualManagerSQLiteHelper.TABLE_WEIGHTS);
}
/**
......@@ -264,21 +259,6 @@ public class ContextualManagerDataSource {
return app;
}
/**
* Function cursorWeight
* Converts a cursor pointing to a record in the Weights table to a Contextual Manager object.
* @param cursor Cursor pointing to a record of the Weight table.
* @return the Contextual Manager object
*/
private ContextualManagerWeight cursorWeight(Cursor cursor){
ContextualManagerWeight weight = new ContextualManagerWeight();
weight.setDateTime(cursor.getString(1));
weight.setA(cursor.getString(2));
weight.setC(cursor.getString(3));
weight.setDayOfTheWeek(cursor.getString(4));
return weight;
}
/**
* Function registerNewAP
* Register a new AP in the application. It creates a new record on the AP table, with the information passed as ContextualManagerAP.
......@@ -366,22 +346,6 @@ public class ContextualManagerDataSource {
return db.insertOrThrow(ContextualManagerSQLiteHelper.TABLE_APPS_USAGE, null, values);
}
/**
* Method that registers a new wheight on the wheight table
* this table will save the wheight of the device (A,C and I)
* @param weight - the wheight to be stored
* @return the row ID of the newly inserted row, or -1 if an error occurred
*/
public long registerWeight(ContextualManagerWeight weight){
ContentValues values = new ContentValues();
values.put(ContextualManagerSQLiteHelper.COLUMN_DATETIME, weight.getDateTime());
values.put(ContextualManagerSQLiteHelper.COLUMN_AVAILABILITY, weight.getA());
values.put(ContextualManagerSQLiteHelper.COLUMN_CENTRALITY, weight.getC());
values.put(ContextualManagerSQLiteHelper.COLUMN_DAYOFTHEWEEK, weight.getDayOfTheWeek());
return db.insertOrThrow(ContextualManagerSQLiteHelper.TABLE_WEIGHTS, null, values);
}
/**
* Function updateAP
* Update an AP already registered by the application. This modifies the corresponding record to the AP in the AP table.
......@@ -482,24 +446,6 @@ public class ContextualManagerDataSource {
return rows != 0 ? true : false;
}
/**
* Function that updates the Weights table
* Update a weight already registered by the application.
* @param weight the weight
* @return true, if successful.
*/
public boolean updateWeight(ContextualManagerWeight weight){
String identifier = ContextualManagerSQLiteHelper.COLUMN_DAYOFTHEWEEK + "='" + String.valueOf(weight.getDayOfTheWeek()) + "'" +" COLLATE NOCASE ";
ContentValues values = new ContentValues();
values.put(ContextualManagerSQLiteHelper.COLUMN_DATETIME, weight.getDateTime());
values.put(ContextualManagerSQLiteHelper.COLUMN_AVAILABILITY, weight.getA());
values.put(ContextualManagerSQLiteHelper.COLUMN_CENTRALITY, weight.getC());
values.put(ContextualManagerSQLiteHelper.COLUMN_DAYOFTHEWEEK, String.valueOf(weight.getDayOfTheWeek()));
int rows = db.update(ContextualManagerSQLiteHelper.TABLE_WEIGHTS, values, identifier, null);
return rows != 0 ? true : false;
}
/**
* Function getAP
* Gets an AP already registered by the application.
......@@ -553,21 +499,6 @@ public class ContextualManagerDataSource {
return pru;
}
/**
* Method to get the device's weight
* @return weight the weight of the device (A,C,I)
*/
public ContextualManagerWeight getWeight (){
ContextualManagerWeight weight = null;
// query to get last row of the weight's table
String selectQuery = "SELECT * FROM " + ContextualManagerSQLiteHelper.TABLE_WEIGHTS + " ORDER BY " + ContextualManagerSQLiteHelper.COLUMN_DATETIME + " DESC LIMIT 1";
Cursor cursor = db.rawQuery(selectQuery, null);
if (cursor.moveToFirst() && cursor.getCount()>0) {
weight = cursorWeight(cursor);
}
return weight;
}
/**
* Function getAllAP
* Gets the all the Peers recorded by the application on the Peers table.
......
......@@ -53,7 +53,6 @@ public class ContextualManagerSQLiteHelper extends SQLiteOpenHelper {
public static final String TABLE_SUNDAY_PEERS = "sundaypeers";
public static final String TABLE_RESOURCE_USAGE = "resourceusage";
public static final String TABLE_APPS_USAGE = "appsusage";
public static final String TABLE_WEIGHTS = "weights";
// IDENTIFICATION
public static final String COLUMN_ID = "_id";
......@@ -68,12 +67,16 @@ public class ContextualManagerSQLiteHelper extends SQLiteOpenHelper {
public static final String COLUMN_LATITUDE = "latitude";
public static final String COLUMN_LONGITUDE = "longitude";
//PEERS
//1)PEERS
public static final String COLUMN_START_ENCOUNTER = "startencounter";
public static final String COLUMN_END_ENCOUNTER = "endencounter";
public static final String COLUMN_NUM_ENCOUNTERS = "encounters";
public static final String COLUMN_AVG_ENCOUNTER_DURATION = "avgduration";
public static final String COLUMN_IS_CONNECTED = "connected";
public static final String COLUMN_SIMILARITY = "i"; // Similarity of a node (measures the node's similarity).
//2)PEER (SELF)
public static final String COLUMN_AVAILABILITY = "a"; // Internal Usage weight of a node (measures the availability of the node)
public static final String COLUMN_CENTRALITY = "c"; // Affinity network level of a node (measures node's centrality/popularity).
// VISITS
public static final String COLUMN_TIMEON = "timeon";
......@@ -88,11 +91,6 @@ public class ContextualManagerSQLiteHelper extends SQLiteOpenHelper {
public static final String COLUMN_APP_NAME = "appname";
public static final String COLUMN_APP_CATEGORY = "appcategory";
//WEIGHTS
public static final String COLUMN_AVAILABILITY = "a"; // Internal Usage weight of a node (measures the availability of the node)
public static final String COLUMN_CENTRALITY = "c"; // Affinity network level of a node (measures node's centrality/popularity).
public static final String COLUMN_SIMILARITY = "i"; // Similarity of a node (measures the node's similarity).
/* Measures the (eigenvector) similarity between the selected resource of node I and j.
For instance, I can provide a measure of battery similarity over time between nodes.
Or, it can provide a measure of similarity between category of applications.*/
......@@ -329,15 +327,6 @@ public class ContextualManagerSQLiteHelper extends SQLiteOpenHelper {
+ COLUMN_DAYOFTHEWEEK + " integer "
+ ");";
private static final String CREATE_WEIGHTS_TABLE = "create table "
+ TABLE_WEIGHTS + "("
+ COLUMN_ID + " integer primary key autoincrement, "
+ COLUMN_DATETIME + " text, "
+ COLUMN_AVAILABILITY + " text not null, "
+ COLUMN_CENTRALITY + " text not null, "
+ COLUMN_DAYOFTHEWEEK + " integer "
+ ");";
public ContextualManagerSQLiteHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
......@@ -362,7 +351,6 @@ public class ContextualManagerSQLiteHelper extends SQLiteOpenHelper {
dataBase.execSQL(CREATE_SUNDAY_PEERS_TABLE);
dataBase.execSQL(CREATE_RESOURCE_USAGE_TABLE);
dataBase.execSQL(CREATE_APPS_USAGE_TABLE);
dataBase.execSQL(CREATE_WEIGHTS_TABLE);
}
@Override
......@@ -385,7 +373,6 @@ public class ContextualManagerSQLiteHelper extends SQLiteOpenHelper {
dataBase.execSQL("DROP TABLE IF EXISTS " + TABLE_SUNDAY_PEERS);
dataBase.execSQL("DROP TABLE IF EXISTS " + TABLE_RESOURCE_USAGE);
dataBase.execSQL("DROP TABLE IF EXISTS " + TABLE_APPS_USAGE);
dataBase.execSQL("DROP TABLE IF EXISTS " + TABLE_WEIGHTS);
onCreate(dataBase);
}
......
package com.senception.contextualmanager.inference;
import android.util.Log;
import java.util.ArrayList;
import java.util.Calendar;
/**
* Copyright (C) 2016 Senception Lda
......
package com.senception.contextualmanager.inference;
import android.util.Log;
import com.senception.contextualmanager.databases.ContextualManagerDataSource;
import com.senception.contextualmanager.modals.ContextualManagerAP;
import com.senception.contextualmanager.modals.ContextualManagerWeight;
import java.lang.reflect.Array;
import java.util.ArrayList;
import static com.senception.contextualmanager.services.ContextualManagerService.checkWeek;
/**
......@@ -45,8 +39,9 @@ public class ContextualManagerCentrality {
* @param dataSource
* @return centrality - the centrality of the device
*/
//NOTE: In the beggining the calculated C will present often as 0.0
public static double calculateC(ContextualManagerDataSource dataSource){
//double degree;
//double degree; --> to use later
int numEncounters;
double avgEncDur;
double distance = 1; // we're not taking into consideration the distance in this implementation -> only in the future
......@@ -59,7 +54,7 @@ public class ContextualManagerCentrality {
peerList = dataSource.getAllPeers(checkWeek("peers"));
for (ContextualManagerAP peer : peerList) {
//Todo only if peer is connected (future)
//if peer is connected (future) --> to use later
numEncounters = peer.getNumEncounters();
avgEncDur = peer.getAvgEncounterDuration();
centrality += numEncounters*avgEncDur/distance;
......
package com.senception.contextualmanager.inference;
import com.senception.contextualmanager.databases.ContextualManagerDataSource;
import com.senception.contextualmanager.modals.ContextualManagerAP;
import java.util.ArrayList;
import static com.senception.contextualmanager.services.ContextualManagerService.checkWeek;
/**
* Copyright (C) 2016 Senception Lda
* Author(s): Igor dos Santos - [email protected] *
* José Soares - jos[email protected]
* Update to Contextual Manager 2017
* @author Igor dos Santos
* @author José Soares
* @version 0.1
*
* @file Contains ContextualManagerSimilarity. Class that handles the inference of the similarity.
*
*/
// TODO I: similarity
public class ContextualManagerSimilarity {
//I = numEnc*AvgDuration
public static double calculateI(ContextualManagerDataSource dataSource) {
double similarity = 0;
//get peer list
ArrayList<ContextualManagerAP> peerList;
if(!dataSource.isTableEmpty(checkWeek("peers"))) {
peerList = dataSource.getAllPeers(checkWeek("peers"));
for (ContextualManagerAP peer : peerList) {
double numEncounters = peer.getNumEncounters();
double avgEncDur = peer.getAvgEncounterDuration();
similarity = numEncounters*avgEncDur;
}
}
return similarity;
}
}
package com.senception.contextualmanager.modals;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
/**
* Copyright (C) 2016 Senception Lda
* Author(s): Igor dos Santos - [email protected] *
* José Soares - [email protected]
* Update to Contextual Manager 2017
* @author Igor dos Santos
* @author José Soares
* @version 0.1
*
* @file Contains ContextualManagerWeight. This class represents an object that will
* save the weights A (Availability) and C (Centrality).
*
*/
public class ContextualManagerWeight {
private int id;
private SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy 'at' HH:mm:ss");
public void setDateTime(String dateTime) {
this.dateTime = dateTime;
}
private String dateTime;
private double A;
private double C;
private int dayOfTheWeek;
/**
* Contextual Manager Weight Constructor.
*/
public ContextualManagerWeight() { super();}
/**
* Contextual Manager Weight Constructor.
* @param dayOfTheWeek the date time.
*/
public ContextualManagerWeight(int dayOfTheWeek) {
A = -1;
C = -1;
this.dayOfTheWeek = dayOfTheWeek;
dateTime = dateFormat.format(System.currentTimeMillis());
}
/**
* Get the id of this weight
* @return the id
*/
public int getId() {
return id;
}
/**
* Set he id of this weight.
* @param id the id to set.
*/
public void setId(int id) {
this.id = id;
}
/**
* Get the date time.
* @return the dateTime.
*/
public String getDateTime() {
return dateTime;
}
/**
* Updates the date time.
*/
public void updateDateTime() {
this.dateTime = dateFormat.format(System.currentTimeMillis());
}
/**
* Get availability.
* @return the availability.
*/
public double getA() {
return A;
}
/**
* Set the availability.
* @param A the availability to be set as double.
*/
public void setA(double A){
this.A = A;
}
/**
* Set the availability.
* @param A the availability to be set as string.
*/
public void setA(String A){
this.A = Double.parseDouble(A);
}
/**
* Get the centrality.
* @return the centrality
*/
public double getC() {
return C;
}
/**
* Set the centrality.
* @param C the centrality to set as double.
*/
public void setC(double C){
this.C = C;
}
/**
* Set the centrality.
* @param C the centrality to set as string.
*/
public void setC(String C){
this.C = Double.parseDouble(C);
}
/**
* Get the day of the week.
* @return the day of the week.
*/
public int getDayOfTheWeek() {
return dayOfTheWeek;
}
/**
* Set the day of the week.
* @param dayOfTheWeek The day of the week to set as integer.
*/
public void setDayOfTheWeek(int dayOfTheWeek){
this.dayOfTheWeek = dayOfTheWeek;
}
/**
* Set the day of the week.
* @param dayOfTheWeek the day of the week to set as string.
*/
public void setDayOfTheWeek(String dayOfTheWeek) {
this.dayOfTheWeek = Integer.parseInt(dayOfTheWeek);
}
}
......@@ -25,7 +25,6 @@ import com.senception.contextualmanager.databases.ContextualManagerDataSource;
import com.senception.contextualmanager.databases.ContextualManagerSQLiteHelper;
import com.senception.contextualmanager.inference.ContextualManagerCentrality;
import com.senception.contextualmanager.inference.ContextualManagerAvailability;
import com.senception.contextualmanager.inference.ContextualManagerSimilarity;
import com.senception.contextualmanager.modals.ContextualManagerAP;
import com.senception.contextualmanager.modals.ContextualManagerAppUsage;
import com.senception.contextualmanager.modals.ContextualManagerPhysicalUsage;
......@@ -35,18 +34,13 @@ import com.senception.contextualmanager.physical_usage.ContextualManagerMemory;
import com.senception.contextualmanager.physical_usage.ContextualManagerPhysicalResourceType;
import com.senception.contextualmanager.physical_usage.ContextualManagerStorage;
import com.senception.contextualmanager.security.MacSecurity;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import static com.senception.contextualmanager.services.ContextualManagerService.checkWeek;
/**
* Copyright (C) 2016 Senception Lda
......@@ -269,16 +263,12 @@ public class ContextualManagerCaptureService extends Service {
/*Centrality Calculation:*/
double C = ContextualManagerCentrality.calculateC(dataSource);
/*Similarity Calculation*/
double I = ContextualManagerSimilarity.calculateI(dataSource);
/* Saves A and C into the database */
ContextualManagerAP mySelf = new ContextualManagerAP();
mySelf.setSSID("self");
mySelf.setBSSID(MacSecurity.md5Hash("self"));
mySelf.setAvailability(A);
mySelf.setCentrality(C);
mySelf.setSimilarity(I);
if(!dataSource.hasPeer(mySelf.getBSSID(), ContextualManagerService.checkWeek("peers"))) {
dataSource.registerNewPeers(mySelf, ContextualManagerService.checkWeek("peers"));
}
......@@ -286,19 +276,20 @@ public class ContextualManagerCaptureService extends Service {
dataSource.updatePeer(mySelf, ContextualManagerService.checkWeek("peers"));
}
/*
ContextualManagerWeight weight = new ContextualManagerWeight(dayOfTheWeek);
double A = availability.get(currentMinute);
weight.setA(A);
weight.setC(C);
weight.updateDateTime();
weight.setDayOfTheWeek(newDayOfTheWeek);
if (dataSource.isTableEmpty(ContextualManagerSQLiteHelper.TABLE_WEIGHTS)){
dataSource.registerWeight(weight);
/*Similarity Calculation*/
//get peer list, and foreach one updates its similarity
ArrayList<ContextualManagerAP> peerList;
if(!dataSource.isTableEmpty(checkWeek("peers"))) {
peerList = dataSource.getAllPeers(checkWeek("peers"));
for (ContextualManagerAP peer : peerList) {
double numEncounters = peer.getNumEncounters();
double avgEncDur = peer.getAvgEncounterDuration();
double similarity = numEncounters*avgEncDur;
peer.setSimilarity(similarity);
dataSource.updatePeer(peer, checkWeek("peers"));
}
}
else {
dataSource.updateWeight(weight);
}*/
/* Captures the apps usage */
captureAppsUsage();
......
package com.senception.contextualmanager.services;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.p2p.WifiP2pManager;
import android.os.Binder;
import android.os.IBinder;
import android.os.RemoteException;
import android.util.Log;
import com.senception.contextualmanager.aidl.CManagerInterface;
import com.senception.contextualmanager.databases.ContextualManagerDataSource;
import com.senception.contextualmanager.databases.ContextualManagerSQLiteHelper;
import com.senception.contextualmanager.modals.ContextualManagerAP;
import android.net.wifi.p2p.WifiP2pManager.Channel;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.senception.contextualmanager.services.ContextualManagerService.checkWeek;
/**
* Copyright (C) 2016 Senception Lda
......@@ -43,64 +32,18 @@ public class ContextualManagerInterfaceService extends Service {
final CManagerInterface.Stub mBinder = new CManagerInterface.Stub(){
/*@Override
public double[] getAvailability(String[] peerList) throws RemoteException {
double [] availability = new double [peerList.length];
for (int i = 0; i < peerList.length; i++){
if(dataSource.hasPeer(peerList[i], ContextualManagerService.checkWeek("peers"))){
ContextualManagerAP peer = dataSource.getPeer(peerList[i], ContextualManagerService.checkWeek("peers"));
availability[i] = peer.getAvailability();
}
else
availability[i] = -1; //if the peer id given was not found on the db then we can't provide it's availability
}
return availability;
}
@Override
public double[] getCentrality(String[] peerList) throws RemoteException {
double [] centrality = new double [peerList.length];
for (int i = 0; i < peerList.length; i++){
//peerList[i] == peerId
if(dataSource.hasPeer(String.valueOf(peerList[i]), ContextualManagerService.checkWeek("peers"))){
ContextualManagerAP peer = dataSource.getPeer(String.valueOf(peerList[i]), ContextualManagerService.checkWeek("peers"));
centrality[i] = peer.getCentrality();
}
else
centrality[i] = -1; //if the peer id given was not found on the db then we can't provide it's centrality
}
return centrality;
}
@Override