Map<String, ManagedProperty> managedProperties = mc.getProperties();
for (ManagedProperty mp: managedProperties.values()) {
MetaValue value = mp.getValue();
if (value != null) {
MetaType type = value.getMetaType();
if (type.isSimple()) {
PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((SimpleValue)value).getValue());
}
else if (type.isPrimitive()) {
PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((SimpleValue)value).getValue());
}
else if (type.isEnum()) {
PropertiesUtils.setBeanProperty(t, mp.getMappedName(), ((org.jboss.metatype.api.values.EnumValue)value).getValue());
}
else if (type.isProperties()) {
}
else if (type.isComposite()) {
if (value instanceof MapCompositeValueSupport) {
HashMap<String, String> myValue = (HashMap<String, String>)MetaValueFactory.getInstance().unwrap(value);
if (mp.getMappedName().equals("JAXBProperties")) { //$NON-NLS-1$
List<PropertyMetadata> props = new ArrayList<PropertyMetadata>();
for (String key:myValue.keySet()) {
props.add(new PropertyMetadata(key, myValue.get(key)));
}
PropertiesUtils.setBeanProperty(t, mp.getMappedName(), props);
}
else {
PropertiesUtils.setBeanProperty(t, mp.getMappedName(), myValue);
}
}
}
else if (type.isCollection()) {
List list = new ArrayList();
MetaType elementType = ((CollectionMetaType) type).getElementType();
if (elementType == AbstractManagedObjectFactory.MANAGED_OBJECT_META_TYPE) {
List<ManagedObject> managedObjects = (List<ManagedObject>) MetaValueFactory.getInstance().unwrap(value);
for (ManagedObject mo : managedObjects) {
list.add(buildAO(mo, mo.getAttachment().getClass()));
}
}
else if (elementType == SimpleMetaType.STRING) {
list.addAll((List<String>) MetaValueFactory.getInstance().unwrap(value));
}
else if (elementType.isComposite()) {
list.addAll((List)MetaValueFactory.getInstance().unwrap(value));
}
else {
throw new TeiidRuntimeException("unsupported type"); //$NON-NLS-1$
}