Commit 104fbfa0 authored by yannick legoc's avatar yannick legoc
Browse files

Changed implementation of getting the list of properties of a controller (to...

Changed implementation of getting the list of properties of a controller (to get the properties that are not defined in XML)
parent c4f6c5dd
...@@ -424,13 +424,8 @@ public class PropertyManager { ...@@ -424,13 +424,8 @@ public class PropertyManager {
// create the property from database // create the property from database
Property property = PropertyFactory.getInstance().createProperty(servant.getDatabaseId(), id, "unknown", false); Property property = PropertyFactory.getInstance().createProperty(servant.getDatabaseId(), id, "unknown", false);
properties.put(propertyName, property); properties.put(propertyName, property);
// System.out.println("created property for servant " + propertyName + " from database");
return property; return property;
// LOGGER.log(Level.SEVERE, "Unable to find description of property " + propertyName + " for controller " + servant.getType());
// return null;
} }
/** /**
...@@ -464,13 +459,8 @@ public class PropertyManager { ...@@ -464,13 +459,8 @@ public class PropertyManager {
// create the property from database // create the property from database
Property property = PropertyFactory.getInstance().createProperty(command.getId(), propertyId, "unknown", true); Property property = PropertyFactory.getInstance().createProperty(command.getId(), propertyId, "unknown", true);
properties.put(propertyName, property); properties.put(propertyName, property);
//System.out.println("created property for command " + propertyName + " from database");
return property; return property;
// LOGGER.log(Level.SEVERE, "Unable to find description of property " + propertyName + " for atomic command " + command.getType());
// return null;
} }
...@@ -772,6 +762,7 @@ public class PropertyManager { ...@@ -772,6 +762,7 @@ public class PropertyManager {
* @return a set containing all property names for given controller type * @return a set containing all property names for given controller type
*/ */
public Set getPropertiesForControllersType(String controllerType) { public Set getPropertiesForControllersType(String controllerType) {
SortedSet properties = new TreeSet(); SortedSet properties = new TreeSet();
if (propertiesByControllerType.get(controllerType) != null) { if (propertiesByControllerType.get(controllerType) != null) {
properties.addAll(propertiesByControllerType.get(controllerType).keySet()); properties.addAll(propertiesByControllerType.get(controllerType).keySet());
...@@ -779,6 +770,24 @@ public class PropertyManager { ...@@ -779,6 +770,24 @@ public class PropertyManager {
return properties; return properties;
} }
/**
* 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
*/
public Set<String> getPropertiesForController(String controllerName) {
int servantId = ServantDatabase.getInstance().getServantId(controllerName);
SortedSet<String> properties = new TreeSet<String>();
Map<String, String> namesAndTypes = PropertyDatabase.getInstance().getPropertyNamesAndTypes(servantId);
if (namesAndTypes != null) {
properties.addAll(namesAndTypes.keySet());
} else {
System.out.println("property map has no entries for " + controllerName);
}
return properties;
}
/** /**
* *
...@@ -810,12 +819,8 @@ public class PropertyManager { ...@@ -810,12 +819,8 @@ public class PropertyManager {
// create the property from database // create the property from database
// container id should not be important unless for properties of command box that should already have been created // container id should not be important unless for properties of command box that should already have been created
// should we test is command box? // should we test is command box?
//System.out.println("creating property " + propertyName + " from database");
property = PropertyFactory.getInstance().createProperty(0, propertyId, "unknown", false); property = PropertyFactory.getInstance().createProperty(0, propertyId, "unknown", false);
propertyMap.get(servantId).put(propertyName, property); propertyMap.get(servantId).put(propertyName, property);
//System.out.println("created property " + propertyName + " from database");
} }
return property; return property;
......
...@@ -150,9 +150,9 @@ public class PropertyDatabase { ...@@ -150,9 +150,9 @@ public class PropertyDatabase {
* @param servantId * @param servantId
* @return * @return
*/ */
public Map getPropertyNamesAndTypes(int servantId) { public Map<String, String> getPropertyNamesAndTypes(int servantId) {
Map namesAndTypes = new HashMap(); Map<String, String> namesAndTypes = new HashMap<String, String>();
Set<Integer> propertyIds = propertiesByServant.get(servantId); Set<Integer> propertyIds = propertiesByServant.get(servantId);
if (propertyIds != null) { if (propertyIds != null) {
Iterator<Integer> it = propertyIds.iterator(); Iterator<Integer> it = propertyIds.iterator();
......
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