use of org.talend.components.netsuite.client.model.beans.BeanInfo in project components by Talend.
the class BasicMetaData method getTypeInfo.
/**
* Get type descriptor for given type class.
*
* @param clazz class of type
* @return type descriptor
*/
public TypeDesc getTypeInfo(Class<?> clazz) {
BeanInfo beanInfo = Beans.getBeanInfo(clazz);
List<PropertyInfo> propertyInfos = beanInfo.getProperties();
List<FieldDesc> fields = new ArrayList<>(propertyInfos.size());
for (PropertyInfo propertyInfo : propertyInfos) {
String fieldName = propertyInfo.getName();
Class fieldValueType = propertyInfo.getReadType();
// Skip 'class' property
if ((propertyInfo.getName().equals("class") && fieldValueType == Class.class)) {
continue;
}
boolean isKey = isKeyField(propertyInfo);
SimpleFieldDesc fieldDesc = new SimpleFieldDesc(fieldName, fieldValueType, isKey, true);
fieldDesc.setPropertyName(propertyInfo.getName());
fields.add(fieldDesc);
}
return new TypeDesc(clazz.getSimpleName(), clazz, fields);
}
use of org.talend.components.netsuite.client.model.beans.BeanInfo in project components by Talend.
the class NetSuiteMockTestBase method createCustomFieldRefs.
protected Map<String, CustomFieldRef> createCustomFieldRefs(Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customFieldSpecs) throws Exception {
NetSuiteClientService<?> clientService = webServiceMockTestFixture.getClientService();
Map<String, CustomFieldRef> map = new HashMap<>();
for (CustomFieldSpec spec : customFieldSpecs.values()) {
CustomFieldRef fieldRef = clientService.getBasicMetaData().createInstance(spec.getFieldRefType().getTypeName());
fieldRef.setScriptId(spec.getScriptId());
fieldRef.setInternalId(spec.getInternalId());
BeanInfo beanInfo = Beans.getBeanInfo(fieldRef.getClass());
PropertyInfo valuePropInfo = beanInfo.getProperty("value");
Object value = composeValue(valuePropInfo.getWriteType());
if (value != null) {
Beans.setProperty(fieldRef, "value", value);
}
map.put(fieldRef.getScriptId(), fieldRef);
}
return map;
}
Aggregations