@SuppressWarnings({ "unchecked", "deprecation" })
@Override
public Object mapList(AutoDataMap autoDataMap, LabelMap labelMap, MapNodeList node) {
IAttribute a = node.getAttribute();
try {
RArray list = null;
RName rname = null;
Object object = autoDataMap.getCurrentObject();
if(object instanceof IREntity){
IREntity entity = (IREntity) object;
rname = mapName(autoDataMap, labelMap, node.getLabel());
IRObject olist = entity.get(rname);
if(olist != null && olist.type().getId() == IRObject.iArray){
list = olist.rArrayValue();
}
}
node.setTargetList(list);
// Handle Arrays of primitives ... We just keep a link to the list
// from our data source in this case.
if(a.getSubType().isPrimitive()){
if(list == null) return null;
if(node.getData()!=null) for (Object d : (List<Object>) node.getData()){
list.add(iconvert(d));
}
return list;
}else{
List<IMapNode> children = node.getChildren();
for(IMapNode c : children){
autoDataMap.pushMark(); // Make sure no children try and update our list's parent
Object o = c.mapNode(autoDataMap, labelMap);
if(o instanceof List && ((List)o).size()==1){ // Mostly we are going to get an array of length
o = ((List)o).get(0); // one of the object we want. If that's the
} // case, get the object we want from the List.
autoDataMap.pop(); // Remove the mark.
if(list!=null // If we have a list, and
&& o != null // a rules engine object
&& o instanceof IRObject){ // then add it to our list.
list.add((IRObject)o); // then add it to the list.
}
}
}
} catch (RulesException e) {}