Commit b3bf8aae authored by Cristina Cocho's avatar Cristina Cocho
Browse files

Modifications in relation to mutiplot functionality

parent 75f991ad
......@@ -27,6 +27,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
......@@ -272,41 +273,64 @@ public class PropertyFactory {
} else {
// trying with "double" dynamic properties
String genericPropertyName = xmlDynamicPropertyDescriptor.getPropertyName();
int index = 0;
boolean hasNext = true;
while (hasNext) {
String indexPropertyName = genericPropertyName + "." + index;
Set<DynamicPropertyDescriptor> doubleDynamicPropertyDescriptors = PropertyDatabase.getInstance().getDoubleDynamicPropertyDescriptor(servantId, genericPropertyName);
if (doubleDynamicPropertyDescriptors != null) {
Iterator<DynamicPropertyDescriptor> iter = doubleDynamicPropertyDescriptors.iterator();
while (iter.hasNext()) {
DynamicPropertyDescriptor descriptor = iter.next();
String dynamicPropertyName = descriptor.getName();
dynamicPropertyDescriptor = PropertyDatabase.getInstance().getDynamicPropertyDescriptor(servantId, indexPropertyName);
if (dynamicPropertyDescriptor != null) {
LinkedHashSet<Property> childProperties = new LinkedHashSet<Property>();
DynamicProperty dynamicProperty = new DynamicProperty(databaseId, dynamicPropertyDescriptor.getId(), false);
List<Integer> ids = dynamicPropertyDescriptor.getIds();
DynamicProperty dynamicProperty = new DynamicProperty(databaseId, descriptor.getId(), false);
List<Integer> ids = descriptor.getIds();
for (int i = 0; i < ids.size(); i++) {
childProperties.add(createProperty(databaseId, ids.get(i), xmlDynamicPropertyDescriptor, false));
}
dynamicProperty.setProperties(childProperties);
dynamicProperties.put(xmlDynamicPropertyDescriptor.getPropertyName() + "." + index, dynamicProperty);
index++;
} else {
hasNext = false;
/*
if (index == 0) {
System.err.println("Dynamic property " + genericPropertyName + " from " + servantId + " not found in server");
} else {
//System.out.println("Dynamic property " + indexPropertyName + " added from " + servantId);
}*/
dynamicProperties.put(dynamicPropertyName, dynamicProperty);
}
}
}
//
// int index = 0;
// boolean hasNext = true;
// while (hasNext) {
// String indexPropertyName = genericPropertyName + "." + index;
//
// dynamicPropertyDescriptor = PropertyDatabase.getInstance().getDynamicPropertyDescriptor(servantId, indexPropertyName);
//
// if (dynamicPropertyDescriptor != null) {
//
// LinkedHashSet<Property> childProperties = new LinkedHashSet<Property>();
// DynamicProperty dynamicProperty = new DynamicProperty(databaseId, dynamicPropertyDescriptor.getId(), false);
// List<Integer> ids = dynamicPropertyDescriptor.getIds();
//
// for (int i = 0; i < ids.size(); i++) {
// childProperties.add(createProperty(databaseId, ids.get(i), xmlDynamicPropertyDescriptor, false));
// }
//
// dynamicProperty.setProperties(childProperties);
// dynamicProperties.put(xmlDynamicPropertyDescriptor.getPropertyName() + "." + index, dynamicProperty);
//
//
// index++;
//
// } else {
// hasNext = false;
// /*
// if (index == 0) {
// System.err.println("Dynamic property " + genericPropertyName + " from " + servantId + " not found in server");
// } else {
// //System.out.println("Dynamic property " + indexPropertyName + " added from " + servantId);
// }*/
// }
// }
// }
}
return dynamicProperties;
}
......
......@@ -851,7 +851,10 @@ public class PropertyManager {
*/
public int getNumberOfChildrenForDynamicProperty(Controller controller, String dynamicPropertyName) {
int propertyId = PropertyDatabase.getInstance().getDynamicPropertyIdForServant(((CorbaServant)controller).getId(), dynamicPropertyName);
return PropertyDatabase.getInstance().getNumberOfChildProperties(propertyId);
if (propertyId > 0) {
return PropertyDatabase.getInstance().getNumberOfChildProperties(propertyId);
}
return -1;
}
public int getNumberOfDecimalPlaces(Controller controller, String propertyName) {
......
......@@ -112,9 +112,6 @@ public class PropertyDatabase {
}
spyPropertiesByServant.get(servantId).add(descriptor);
// System.out.println("spy property for servant " + servantId);
// System.out.println(descriptor);
}
/**
......@@ -349,6 +346,30 @@ public class PropertyDatabase {
return null;
}
/**
* Get all "double dynamic" properties that have the same "genericPropertyName"
* Important detail: for a double dynamic property, the name of the propertyDescriptor contains the father index, that is, it is sth like: nameOfDoubleDynamicProperty.i
* @param servantId
* @param genericPropertyName
* @return
*/
public Set<DynamicPropertyDescriptor> getDoubleDynamicPropertyDescriptor(int servantId, String genericPropertyName) {
//Iterate through dynamicPropertiesbyServant to find all the properties that has the same genericPropertyName
Set<DynamicPropertyDescriptor> descriptors = dynamicPropertiesByServant.get(servantId);
Set<DynamicPropertyDescriptor> doubleDynamicDescriptors = new HashSet<DynamicPropertyDescriptor>();
if (descriptors != null) {
Iterator<DynamicPropertyDescriptor> it = descriptors.iterator();
while (it.hasNext()) {
DynamicPropertyDescriptor descriptor = it.next();
if (descriptor.getName().contains(".") && descriptor.getName().contains(genericPropertyName)) {
doubleDynamicDescriptors.add(descriptor);
}
}
}
return doubleDynamicDescriptors;
}
/**
*
......
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