Search in sources :

Example 1 with SearchFieldType

use of org.talend.components.netsuite.client.model.search.SearchFieldType in project components by Talend.

the class BasicMetaDataTest method testGetSearchFieldType.

@Test
public void testGetSearchFieldType() {
    for (SearchFieldType searchFieldType : SearchFieldType.values()) {
        Class<?> clazz = basicMetaData.getSearchFieldClass(searchFieldType.getFieldTypeName());
        assertNotNull(clazz);
    }
}
Also used : SearchFieldType(org.talend.components.netsuite.client.model.search.SearchFieldType) Test(org.junit.Test)

Example 2 with SearchFieldType

use of org.talend.components.netsuite.client.model.search.SearchFieldType in project components by Talend.

the class BasicMetaDataTest method testGetSearchFieldAdapter.

@Test
public void testGetSearchFieldAdapter() {
    for (SearchFieldType searchFieldType : SearchFieldType.values()) {
        SearchFieldAdapter<?> searchFieldAdapter = basicMetaData.getSearchFieldAdapter(searchFieldType);
        assertNotNull(searchFieldAdapter);
        assertEquals(searchFieldType, searchFieldAdapter.getFieldType());
    }
}
Also used : SearchFieldType(org.talend.components.netsuite.client.model.search.SearchFieldType) Test(org.junit.Test)

Example 3 with SearchFieldType

use of org.talend.components.netsuite.client.model.search.SearchFieldType in project components by Talend.

the class BasicMetaDataTest method testGetSearchFieldOperatorByName.

@Test
public void testGetSearchFieldOperatorByName() {
    for (SearchFieldType searchFieldType : SearchFieldType.values()) {
        if (searchFieldType == SearchFieldType.BOOLEAN) {
            Object operatorByName = basicMetaData.getSearchFieldOperatorByName(searchFieldType.getFieldTypeName(), "Boolean");
            assertNotNull(operatorByName);
        } else if (searchFieldType == SearchFieldType.STRING || searchFieldType == SearchFieldType.CUSTOM_STRING) {
            Object operatorByName = basicMetaData.getSearchFieldOperatorByName(searchFieldType.getFieldTypeName(), "String.startsWith");
            assertNotNull(operatorByName);
        } else if (searchFieldType == SearchFieldType.LONG || searchFieldType == SearchFieldType.CUSTOM_LONG) {
            Object operatorByName = basicMetaData.getSearchFieldOperatorByName(searchFieldType.getFieldTypeName(), "Long.greaterThan");
            assertNotNull(operatorByName);
        } else if (searchFieldType == SearchFieldType.DOUBLE || searchFieldType == SearchFieldType.CUSTOM_DOUBLE) {
            Object operatorByName = basicMetaData.getSearchFieldOperatorByName(searchFieldType.getFieldTypeName(), "Double.greaterThanOrEqualTo");
            assertNotNull(operatorByName);
        } else if (searchFieldType == SearchFieldType.DATE || searchFieldType == SearchFieldType.CUSTOM_DATE) {
            Object operatorByName = basicMetaData.getSearchFieldOperatorByName(searchFieldType.getFieldTypeName(), "Date.after");
            assertNotNull(operatorByName);
        } else if (searchFieldType == SearchFieldType.TEXT_NUMBER) {
            Object operatorByName = basicMetaData.getSearchFieldOperatorByName(searchFieldType.getFieldTypeName(), "TextNumber.lessThan");
            assertNotNull(operatorByName);
        } else if (searchFieldType == SearchFieldType.SELECT || searchFieldType == SearchFieldType.CUSTOM_SELECT || searchFieldType == SearchFieldType.MULTI_SELECT || searchFieldType == SearchFieldType.CUSTOM_MULTI_SELECT) {
            Object operatorByName = basicMetaData.getSearchFieldOperatorByName(searchFieldType.getFieldTypeName(), "List.anyOf");
            assertNotNull(operatorByName);
        }
    }
}
Also used : SearchFieldType(org.talend.components.netsuite.client.model.search.SearchFieldType) Test(org.junit.Test)

Example 4 with SearchFieldType

use of org.talend.components.netsuite.client.model.search.SearchFieldType 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 5 with SearchFieldType

use of org.talend.components.netsuite.client.model.search.SearchFieldType in project components by Talend.

the class SearchQuery method processConditionForSearchRecord.

/**
 * Process search condition and update search record.
 *
 * @param searchRecord search record
 * @param condition condition
 * @return search field built for this condition
 * @throws NetSuiteException if an error occurs during processing of condition
 */
private Object processConditionForSearchRecord(Object searchRecord, SearchCondition condition) throws NetSuiteException {
    String fieldName = toInitialLower(condition.getFieldName());
    BeanInfo beanInfo = Beans.getBeanInfo(searchRecord.getClass());
    Class<?> searchFieldClass = beanInfo.getProperty(fieldName).getWriteType();
    SearchFieldType fieldType = SearchFieldType.getByFieldTypeName(searchFieldClass.getSimpleName());
    Object searchField = processCondition(fieldType, condition);
    return searchField;
}
Also used : BeanInfo(org.talend.components.netsuite.client.model.beans.BeanInfo) SearchFieldType(org.talend.components.netsuite.client.model.search.SearchFieldType)

Aggregations

SearchFieldType (org.talend.components.netsuite.client.model.search.SearchFieldType)6 Test (org.junit.Test)3 BeanInfo (org.talend.components.netsuite.client.model.beans.BeanInfo)2 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)1 PropertyInfo (org.talend.components.netsuite.client.model.beans.PropertyInfo)1 SearchFieldOperatorName (org.talend.components.netsuite.client.model.search.SearchFieldOperatorName)1