Commit 2a50aa83 authored by yannick legoc's avatar yannick legoc
Browse files

Added the function copyValues to DynamicProperty's classes, format values...

Added the function copyValues to DynamicProperty's classes, format values improved, implicit property declaration in NomadCommandSystem
parent 3b79fbe1
......@@ -404,23 +404,33 @@ public class PropertyManager {
*/
private Property createPropertyForServant(CorbaServant servant, String propertyName) {
Map properties = propertyMap.get(servant.getId());
Map<String, Property> properties = propertyMap.get(servant.getId());
XMLPropertyDescriptor propertyDescriptor = getPropertyDescriptor(servant.getType(), propertyName);
if (propertyDescriptor != null) {
int id = PropertyDatabase.getInstance().getPropertyIdForServant(servant.getId(), propertyName);
if (id < 0) {
System.err.println("Cannot get property " + propertyName + " from " + servant.getName());
ConfigManager.CONFIGURATION_ERROR = true;
return null;
}
int id = PropertyDatabase.getInstance().getPropertyIdForServant(servant.getId(), propertyName);
if (id < 0) {
System.err.println("Cannot get property " + propertyName + " from " + servant.getName());
ConfigManager.CONFIGURATION_ERROR = true;
return null;
}
if (propertyDescriptor != null) {
Property property = PropertyFactory.getInstance().createProperty(servant.getDatabaseId(), id, getPropertyDescriptor(servant.getType(), propertyName), false);
properties.put(propertyName, property);
return property;
}
// create the property from database
Property property = PropertyFactory.getInstance().createProperty(servant.getDatabaseId(), id, "unknown", false);
properties.put(propertyName, property);
}
LOGGER.log(Level.SEVERE, "Unable to find description of property " + propertyName + " for controller " + servant.getType());
return null;
// System.out.println("created property for servant " + propertyName + " from database");
return property;
// LOGGER.log(Level.SEVERE, "Unable to find description of property " + propertyName + " for controller " + servant.getType());
// return null;
}
/**
......@@ -433,23 +443,34 @@ public class PropertyManager {
CommandBoxKey key = new CommandBoxKey(command.getServerId(), command.getId());
Map properties = commandBoxPropertyMap.get(key);
Map<String, Property> properties = commandBoxPropertyMap.get(key);
XMLPropertyDescriptor propertyDescriptor = getPropertyDescriptor(command.getType(), propertyName);
int propertyId = PropertyDatabase.getInstance().getPropertyIdForServant(command.getServantId(), propertyName);
if (propertyId < 0) {
System.err.println("Cannot get property " + propertyName + " from servant " + command.getServantId());
ConfigManager.CONFIGURATION_ERROR = true;
return null;
}
if (propertyDescriptor != null) {
int propertyId = PropertyDatabase.getInstance().getPropertyIdForServant(command.getServantId(), propertyName);
if (propertyId < 0) {
System.err.println("Cannot get property " + propertyName + " from servant " + command.getServantId());
ConfigManager.CONFIGURATION_ERROR = true;
return null;
}
Property property = PropertyFactory.getInstance().createProperty(command.getId(), propertyId, getPropertyDescriptor(command.getType(), propertyName), true);
property.setServerId(command.getServerId());
properties.put(propertyName, property);
return property;
}
LOGGER.log(Level.SEVERE, "Unable to find description of property " + propertyName + " for atomic command " + command.getType());
return null;
}
// create the property from database
Property property = PropertyFactory.getInstance().createProperty(command.getId(), propertyId, "unknown", true);
properties.put(propertyName, property);
//System.out.println("created property for command " + propertyName + " from database");
return property;
// LOGGER.log(Level.SEVERE, "Unable to find description of property " + propertyName + " for atomic command " + command.getType());
// return null;
}
......@@ -478,7 +499,7 @@ public class PropertyManager {
return null;
}
List ids = dynamicPropertyDescriptor.getIds();
List<Integer> ids = dynamicPropertyDescriptor.getIds();
for (int i = 0; i < ids.size(); i++) {
Property childProperty = PropertyFactory.getInstance().createProperty(command.getId(), (Integer)ids.get(i), xmlDynamicPropertyDescriptor, true);
childProperty.setServerId(command.getServerId());
......@@ -779,7 +800,25 @@ public class PropertyManager {
* @return
*/
public Property getProperty(int servantId, String propertyName) {
return propertyMap.get(servantId).get(propertyName);
Property property = propertyMap.get(servantId).get(propertyName);
if (property == null) {
int propertyId = PropertyDatabase.getInstance().getPropertyIdForServant(servantId, propertyName);
// create the property from database
// container id should not be important unless for properties of command box that should already have been created
// should we test is command box?
//System.out.println("creating property " + propertyName + " from database");
property = PropertyFactory.getInstance().createProperty(0, propertyId, "unknown", false);
propertyMap.get(servantId).put(propertyName, property);
//System.out.println("created property " + propertyName + " from database");
}
return property;
}
public void removeDynamicProperties(int servantId) {
......
......@@ -73,6 +73,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>();
......
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