Commit 4c8a7824 authored by helene ortiz's avatar helene ortiz
Browse files

Changes for NomadServerGUI

parent 2c6e94e2
......@@ -792,8 +792,8 @@ public class PropertyManager {
/**
* Returns a sorted set containing all property names for given controller.
* @param controllerType controller type
* @return a set containing all property names for given controller type
* @param controllerName controller name
* @return a set containing all property names for given controller name
*/
public Set<String> getPropertiesForController(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName);
......@@ -809,6 +809,25 @@ public class PropertyManager {
return properties;
}
/**
* Returns a sorted set containing all dynamic property names for given controller.
* @param controllerName controller name
* @return a set containing all dynamic property names for given controller name
*/
public Set<String> getDynamicPropertiesForController(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName);
SortedSet<String> properties = new TreeSet<String>();
Map<String, String> namesAndTypes = PropertyDatabase.getInstance().getDynamicPropertyNamesAndTypes(servantId);
if (namesAndTypes != null) {
properties.addAll(namesAndTypes.keySet());
} else {
System.out.println("property map has no entries for " + controllerName);
}
return properties;
}
/**
*
* @param controller
......
......@@ -41,7 +41,7 @@ public class PropertyDatabase {
private Map<Integer, Set<DynamicPropertyDescriptor>> dynamicPropertiesByServant; // KEY=Servant id VALUE=Set of associated DynamicPropertyDescriptor
private Map<Integer, Set<SpyPropertyDescriptor>> spyPropertiesByServant; // KEY=Servant id VALUE=Set of associated SpyPropertyDescriptor
private static PropertyDatabase instance = null;
public static PropertyDatabase getInstance() {
......@@ -75,9 +75,9 @@ public class PropertyDatabase {
* @param standardPropertyDescriptor
*/
public void addStandardPropertyDescriptor(int servantId, StandardPropertyDescriptor standardPropertyDescriptor) {
//System.out.println("added property " + standardPropertyDescriptor.getName() + " to servant " + servantId);
properties.put(standardPropertyDescriptor.getId(), standardPropertyDescriptor);
if (!propertiesByServant.containsKey(servantId)) {
Set<Integer> set = new HashSet<Integer>();
......@@ -110,13 +110,13 @@ public class PropertyDatabase {
Set<SpyPropertyDescriptor> set = new TreeSet<SpyPropertyDescriptor>(new SpyPropertyDescriptorComparator());
spyPropertiesByServant.put(servantId, set);
}
spyPropertiesByServant.get(servantId).add(descriptor);
// System.out.println("spy property for servant " + servantId);
// System.out.println(descriptor);
// System.out.println("spy property for servant " + servantId);
// System.out.println(descriptor);
}
/**
*
* @param id
......@@ -125,12 +125,12 @@ public class PropertyDatabase {
public DynamicPropertyDescriptor getDynamicPropertyDescriptor(int id) {
return dynamicProperties.get(id);
}
public StandardPropertyDescriptor getStandardPropertyDescriptor(int id) {
return properties.get(id);
}
public void removeDynamicPropertyDescriptors(int servantId) {
// only clearing the set for the servant ID
......@@ -138,7 +138,7 @@ public class PropertyDatabase {
dynamicPropertiesByServant.get(servantId).clear();
}
}
/**
*
* @param id
......@@ -147,7 +147,7 @@ public class PropertyDatabase {
public Set<SpyPropertyDescriptor> getSpyPropertyDescriptors(int servantId) {
return spyPropertiesByServant.get(servantId);
}
/**
*
* @param servantId
......@@ -166,6 +166,26 @@ public class PropertyDatabase {
}
return namesAndTypes;
}
/**
*
* @param servantId
* @return
*/
public Map<String, String> getDynamicPropertyNamesAndTypes(int servantId) {
Map<String, String> namesAndTypes = new HashMap<String, String>();
Set<DynamicPropertyDescriptor> propertyDescriptors = dynamicPropertiesByServant.get(servantId);
if (propertyDescriptors != null) {
Iterator<DynamicPropertyDescriptor> it = propertyDescriptors.iterator();
while (it.hasNext()) {
DynamicPropertyDescriptor descriptor = it.next();
namesAndTypes.put(descriptor.getName(), descriptor.getType());
}
}
return namesAndTypes;
}
/**
......@@ -198,25 +218,25 @@ public class PropertyDatabase {
* @return
*/
public String getPropertyType(int id) {
StandardPropertyDescriptor descriptor = properties.get(id);
if (descriptor != null) {
return descriptor.getType();
}
DynamicPropertyDescriptor dynamicDescriptor = dynamicProperties.get(id);
if (dynamicDescriptor != null) {
return dynamicDescriptor.getType();
}
// searching in the dynamic properties
Iterator<Entry<Integer, DynamicPropertyDescriptor>> dit = dynamicProperties.entrySet().iterator();
while (dit.hasNext()) {
Entry<Integer, DynamicPropertyDescriptor> entry = dit.next();
dynamicDescriptor = entry.getValue();
Iterator<Integer> iit = dynamicDescriptor.getIds().iterator();
while (iit.hasNext()) {
Integer index = iit.next();
......@@ -224,9 +244,9 @@ public class PropertyDatabase {
return dynamicDescriptor.getType();
}
}
}
return null;
}
......@@ -252,7 +272,7 @@ public class PropertyDatabase {
if (propertyName.indexOf(".") != -1) {
String parentPropertyName = propertyName.substring(0, propertyName.indexOf("."));
String indexString = propertyName.substring(propertyName.indexOf(".")+1);
Set<DynamicPropertyDescriptor> dynamicPropertyIdsForServant = dynamicPropertiesByServant.get(servantId);
if (dynamicPropertyIdsForServant != null) {
Iterator<DynamicPropertyDescriptor> it = dynamicPropertyIdsForServant.iterator();
......@@ -265,11 +285,11 @@ public class PropertyDatabase {
return ids.get(index);
}
}
}
}
}
return -1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment