Search in sources :

Example 11 with BeanInfo

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);
}
Also used : BeanInfo(org.talend.components.netsuite.client.model.beans.BeanInfo) ArrayList(java.util.ArrayList) SearchFieldOperatorTypeDesc(org.talend.components.netsuite.client.model.search.SearchFieldOperatorTypeDesc) PropertyInfo(org.talend.components.netsuite.client.model.beans.PropertyInfo)

Example 12 with BeanInfo

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;
}
Also used : HashMap(java.util.HashMap) BeanInfo(org.talend.components.netsuite.client.model.beans.BeanInfo) CustomFieldSpec(org.talend.components.netsuite.CustomFieldSpec) CustomFieldRef(com.netsuite.webservices.v2016_2.platform.core.CustomFieldRef) PropertyInfo(org.talend.components.netsuite.client.model.beans.PropertyInfo)

Aggregations

BeanInfo (org.talend.components.netsuite.client.model.beans.BeanInfo)12 PropertyInfo (org.talend.components.netsuite.client.model.beans.PropertyInfo)6 HashMap (java.util.HashMap)4 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Schema (org.apache.avro.Schema)2 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)2 FieldDesc (org.talend.components.netsuite.client.model.FieldDesc)2 SearchFieldType (org.talend.components.netsuite.client.model.search.SearchFieldType)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 CustomFieldRef (com.netsuite.webservices.test.platform.core.CustomFieldRef)1 CustomFieldRef (com.netsuite.webservices.v2014_2.platform.core.CustomFieldRef)1 RecordType (com.netsuite.webservices.v2014_2.platform.core.types.RecordType)1 CustomizationFieldType (com.netsuite.webservices.v2014_2.setup.customization.types.CustomizationFieldType)1 CustomFieldRef (com.netsuite.webservices.v2016_2.platform.core.CustomFieldRef)1 HashSet (java.util.HashSet)1 CustomFieldSpec (org.talend.components.netsuite.CustomFieldSpec)1 NsRef (org.talend.components.netsuite.client.NsRef)1 CustomFieldDesc (org.talend.components.netsuite.client.model.CustomFieldDesc)1 CustomRecordTypeInfo (org.talend.components.netsuite.client.model.CustomRecordTypeInfo)1