Search in sources :

Example 1 with SearchFieldOperatorName

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

the class BasicMetaDataTest method testGetSearchOperatorNames.

@Test
public void testGetSearchOperatorNames() {
    Collection<SearchFieldOperatorName> operatorNames = basicMetaData.getSearchOperatorNames();
    Collection<String> dataTypes = new HashSet<>();
    for (SearchFieldOperatorName operatorName : operatorNames) {
        dataTypes.add(operatorName.getDataType());
    }
    assertThat(dataTypes, containsInAnyOrder("Boolean", "String", "Long", "Double", "TextNumber", "Date", "PredefinedDate", "List"));
}
Also used : SearchFieldOperatorName(org.talend.components.netsuite.client.model.search.SearchFieldOperatorName) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with SearchFieldOperatorName

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

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

the class NetSuiteDatasetRuntimeImpl method getSearchFieldOperators.

@Override
public List<String> getSearchFieldOperators() {
    List<SearchFieldOperatorName> operatorList = new ArrayList<>(metaDataSource.getBasicMetaData().getSearchOperatorNames());
    List<String> operatorNames = new ArrayList<>(operatorList.size());
    for (SearchFieldOperatorName operatorName : operatorList) {
        operatorNames.add(operatorName.getQualifiedName());
    }
    // Sort in alphabetical order
    Collections.sort(operatorNames);
    return operatorNames;
}
Also used : ArrayList(java.util.ArrayList) SearchFieldOperatorName(org.talend.components.netsuite.client.model.search.SearchFieldOperatorName)

Example 4 with SearchFieldOperatorName

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

the class BasicMetaData method getSearchFieldOperator.

/**
 * Get search field operator for given search field type and operator name.
 *
 * @see SearchFieldOperatorType
 * @see SearchFieldOperatorName
 *
 * @param fieldType search field type
 * @param operatorName operator name
 * @return search field operator
 */
public Object getSearchFieldOperator(SearchFieldType fieldType, String operatorName) {
    SearchFieldOperatorName operatorQName = new SearchFieldOperatorName(operatorName);
    SearchFieldOperatorType operatorType = SearchFieldType.getOperatorType(fieldType);
    if (operatorType != null) {
        SearchFieldOperatorTypeDesc def = searchFieldOperatorTypeMap.get(operatorType);
        return def.getOperator(operatorName);
    }
    for (SearchFieldOperatorTypeDesc def : searchFieldOperatorTypeMap.values()) {
        if (def.hasOperator(operatorQName)) {
            return def.getOperator(operatorName);
        }
    }
    throw new IllegalArgumentException("Unknown search field operator: " + fieldType + ", " + operatorName);
}
Also used : SearchFieldOperatorName(org.talend.components.netsuite.client.model.search.SearchFieldOperatorName) SearchFieldOperatorTypeDesc(org.talend.components.netsuite.client.model.search.SearchFieldOperatorTypeDesc) SearchFieldOperatorType(org.talend.components.netsuite.client.model.search.SearchFieldOperatorType)

Example 5 with SearchFieldOperatorName

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

the class NetSuiteClientServiceTest method testBasicMetaData.

@Test
public void testBasicMetaData() throws Exception {
    NetSuiteClientService<?> clientService = webServiceMockTestFixture.getClientService();
    Set<SearchRecordType> searchRecordTypeSet = new HashSet<>(Arrays.asList(SearchRecordType.values()));
    Set<String> searchRecordTypeNameSet = new HashSet<>();
    for (SearchRecordType searchRecordType : searchRecordTypeSet) {
        searchRecordTypeNameSet.add(toInitialUpper(searchRecordType.value()));
    }
    searchRecordTypeNameSet.add("Address");
    searchRecordTypeNameSet.add("InventoryDetail");
    searchRecordTypeNameSet.add("TimeEntry");
    for (String searchRecordType : searchRecordTypeNameSet) {
        try {
            SearchRecordTypeDesc searchRecordInfo = clientService.getMetaDataSource().getSearchRecordType(searchRecordType);
            assertNotNull("Search record def found: " + searchRecordType, searchRecordInfo);
        } catch (Exception e) {
            throw new AssertionError("Search record type: " + searchRecordType, e);
        }
    }
    Set<RecordType> recordTypeSet = new HashSet<>(Arrays.asList(RecordType.values()));
    recordTypeSet.remove(RecordType.CUSTOM_TRANSACTION_TYPE);
    Set<String> recordTypeNameSet = new HashSet<>();
    for (RecordType recordType : recordTypeSet) {
        recordTypeNameSet.add(toInitialUpper(recordType.value()));
    }
    recordTypeNameSet.add("Address");
    recordTypeNameSet.add("InventoryDetail");
    recordTypeNameSet.add("TimeEntry");
    for (String recordType : recordTypeNameSet) {
        RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType(recordType);
        assertNotNull("Record type def found: " + recordType, recordTypeInfo);
    }
    Collection<SearchFieldOperatorName> searchOperatorNames = clientService.getBasicMetaData().getSearchOperatorNames();
    List<SearchFieldOperatorName> searchFieldOperatorNameList = new ArrayList<>(searchOperatorNames);
    Collections.sort(searchFieldOperatorNameList, new Comparator<SearchFieldOperatorName>() {

        @Override
        public int compare(SearchFieldOperatorName o1, SearchFieldOperatorName o2) {
            return o1.getQualifiedName().compareTo(o2.getQualifiedName());
        }
    });
    for (SearchFieldOperatorName operatorName : searchFieldOperatorNameList) {
        assertNotNull(operatorName.getDataType());
        if (!SearchFieldOperatorType.BOOLEAN.dataTypeEquals(operatorName.getDataType())) {
            assertNotNull(operatorName.getName());
        }
    }
}
Also used : ArrayList(java.util.ArrayList) SearchRecordType(com.netsuite.webservices.v2016_2.platform.core.types.SearchRecordType) SearchFieldOperatorName(org.talend.components.netsuite.client.model.search.SearchFieldOperatorName) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) SearchRecordType(com.netsuite.webservices.v2016_2.platform.core.types.SearchRecordType) RecordType(com.netsuite.webservices.v2016_2.platform.core.types.RecordType) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

SearchFieldOperatorName (org.talend.components.netsuite.client.model.search.SearchFieldOperatorName)5 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 RecordType (com.netsuite.webservices.v2016_2.platform.core.types.RecordType)1 SearchRecordType (com.netsuite.webservices.v2016_2.platform.core.types.SearchRecordType)1 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)1 RecordTypeInfo (org.talend.components.netsuite.client.model.RecordTypeInfo)1 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)1 BeanInfo (org.talend.components.netsuite.client.model.beans.BeanInfo)1 PropertyInfo (org.talend.components.netsuite.client.model.beans.PropertyInfo)1 SearchFieldOperatorType (org.talend.components.netsuite.client.model.search.SearchFieldOperatorType)1 SearchFieldOperatorTypeDesc (org.talend.components.netsuite.client.model.search.SearchFieldOperatorTypeDesc)1 SearchFieldType (org.talend.components.netsuite.client.model.search.SearchFieldType)1