Search in sources :

Example 1 with PropertyInfo

use of org.talend.components.netsuite.client.model.beans.PropertyInfo 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<RecordType, CustomizationFieldType> 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 : CustomizationFieldType(com.netsuite.webservices.v2014_2.setup.customization.types.CustomizationFieldType) RecordType(com.netsuite.webservices.v2014_2.platform.core.types.RecordType) HashMap(java.util.HashMap) BeanInfo(org.talend.components.netsuite.client.model.beans.BeanInfo) CustomFieldRef(com.netsuite.webservices.v2014_2.platform.core.CustomFieldRef) PropertyInfo(org.talend.components.netsuite.client.model.beans.PropertyInfo)

Example 2 with PropertyInfo

use of org.talend.components.netsuite.client.model.beans.PropertyInfo in project components by Talend.

the class SearchQuery method condition.

/**
 * Add condition for search query.
 *
 * @param condition condition to be added
 * @return
 * @throws NetSuiteException if an error occurs during adding of condition
 */
public SearchQuery condition(SearchCondition condition) throws NetSuiteException {
    initSearch();
    BeanInfo searchMetaData = Beans.getBeanInfo(searchRecordTypeDesc.getSearchBasicClass());
    String fieldName = toInitialLower(condition.getFieldName());
    PropertyInfo propertyInfo = searchMetaData.getProperty(fieldName);
    SearchFieldOperatorName operatorQName = new SearchFieldOperatorName(condition.getOperatorName());
    if (propertyInfo != null) {
        Object searchField = processConditionForSearchRecord(searchBasic, condition);
        setProperty(searchBasic, fieldName, searchField);
    } else {
        String dataType = operatorQName.getDataType();
        SearchFieldType searchFieldType = null;
        if (SearchFieldOperatorType.STRING.dataTypeEquals(dataType)) {
            searchFieldType = SearchFieldType.CUSTOM_STRING;
        } else if (SearchFieldOperatorType.BOOLEAN.dataTypeEquals(dataType)) {
            searchFieldType = SearchFieldType.CUSTOM_BOOLEAN;
        } else if (SearchFieldOperatorType.LONG.dataTypeEquals(dataType)) {
            searchFieldType = SearchFieldType.CUSTOM_LONG;
        } else if (SearchFieldOperatorType.DOUBLE.dataTypeEquals(dataType)) {
            searchFieldType = SearchFieldType.CUSTOM_DOUBLE;
        } else if (SearchFieldOperatorType.DATE.dataTypeEquals(dataType) || SearchFieldOperatorType.PREDEFINED_DATE.dataTypeEquals(dataType)) {
            searchFieldType = SearchFieldType.CUSTOM_DATE;
        } else if (SearchFieldOperatorType.MULTI_SELECT.dataTypeEquals(dataType)) {
            searchFieldType = SearchFieldType.CUSTOM_MULTI_SELECT;
        } else if (SearchFieldOperatorType.ENUM_MULTI_SELECT.dataTypeEquals(dataType)) {
            searchFieldType = SearchFieldType.CUSTOM_SELECT;
        } else {
            throw new NetSuiteException("Invalid data type: " + searchFieldType);
        }
        Object searchField = processCondition(searchFieldType, condition);
        customFieldList.add(searchField);
    }
    return this;
}
Also used : BeanInfo(org.talend.components.netsuite.client.model.beans.BeanInfo) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) SearchFieldOperatorName(org.talend.components.netsuite.client.model.search.SearchFieldOperatorName) SearchFieldType(org.talend.components.netsuite.client.model.search.SearchFieldType) PropertyInfo(org.talend.components.netsuite.client.model.beans.PropertyInfo)

Example 3 with PropertyInfo

use of org.talend.components.netsuite.client.model.beans.PropertyInfo 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) CustomFieldRef(com.netsuite.webservices.test.platform.core.CustomFieldRef) PropertyInfo(org.talend.components.netsuite.client.model.beans.PropertyInfo)

Example 4 with PropertyInfo

use of org.talend.components.netsuite.client.model.beans.PropertyInfo in project components by Talend.

the class AbstractNetSuiteTestBase method composeObject.

protected static <T> T composeObject(Class<T> clazz) throws Exception {
    BeanInfo beanInfo = Beans.getBeanInfo(clazz);
    List<PropertyInfo> propertyInfoList = beanInfo.getProperties();
    T obj = clazz.newInstance();
    for (PropertyInfo propertyInfo : propertyInfoList) {
        if (propertyInfo.getWriteType() != null) {
            Object value;
            if (propertyInfo.getName().equals("internalId")) {
                value = composeValue(Integer.class).toString();
            } else {
                value = composeValue(propertyInfo.getWriteType());
            }
            setProperty(obj, propertyInfo.getName(), value);
        }
    }
    return obj;
}
Also used : BeanInfo(org.talend.components.netsuite.client.model.beans.BeanInfo) PropertyInfo(org.talend.components.netsuite.client.model.beans.PropertyInfo)

Example 5 with PropertyInfo

use of org.talend.components.netsuite.client.model.beans.PropertyInfo 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)

Aggregations

BeanInfo (org.talend.components.netsuite.client.model.beans.BeanInfo)6 PropertyInfo (org.talend.components.netsuite.client.model.beans.PropertyInfo)6 HashMap (java.util.HashMap)3 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 ArrayList (java.util.ArrayList)1 CustomFieldSpec (org.talend.components.netsuite.CustomFieldSpec)1 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)1 SearchFieldOperatorName (org.talend.components.netsuite.client.model.search.SearchFieldOperatorName)1 SearchFieldOperatorTypeDesc (org.talend.components.netsuite.client.model.search.SearchFieldOperatorTypeDesc)1 SearchFieldType (org.talend.components.netsuite.client.model.search.SearchFieldType)1