Search in sources :

Example 1 with SearchRecordTypeDesc

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

the class NetSuiteClientServiceIT method testGetSearchableTypes.

@Test
public void testGetSearchableTypes() throws Exception {
    NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
    connection.login();
    Collection<NamedThing> searches = connection.getMetaDataSource().getSearchableTypes();
    for (NamedThing search : searches) {
        assertNotNull(search);
        assertNotNull(search.getName());
        assertNotNull(search.getDisplayName());
        SearchRecordTypeDesc searchRecordInfo = connection.getMetaDataSource().getSearchRecordType(search.getName());
        assertNotNull("Search record def found: " + search.getName(), searchRecordInfo);
    }
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) NamedThing(org.talend.daikon.NamedThing) Test(org.junit.Test)

Example 2 with SearchRecordTypeDesc

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

the class NetSuiteClientServiceTest method testStandardMetaData.

@Test
public void testStandardMetaData() 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("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()));
    Set<String> recordTypeNameSet = new HashSet<>();
    for (RecordType recordType : recordTypeSet) {
        recordTypeNameSet.add(toInitialUpper(recordType.value()));
    }
    recordTypeNameSet.add("InventoryDetail");
    recordTypeNameSet.add("TimeEntry");
    for (String recordType : recordTypeNameSet) {
        RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType(recordType);
        assertNotNull("Record type def found: " + recordType, recordTypeInfo);
    }
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) SearchRecordType(com.netsuite.webservices.v2014_2.platform.core.types.SearchRecordType) RecordType(com.netsuite.webservices.v2014_2.platform.core.types.RecordType) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) SearchRecordType(com.netsuite.webservices.v2014_2.platform.core.types.SearchRecordType) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 3 with SearchRecordTypeDesc

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

the class SearchResultSetTest method testEmptyResult.

@Test
public void testEmptyResult() throws Exception {
    NetSuiteClientService<?> conn = mock(NetSuiteClientService.class);
    SearchResult result1 = new SearchResult();
    Status status = new Status();
    status.setIsSuccess(true);
    result1.setStatus(status);
    result1.setSearchId("abc123");
    result1.setPageIndex(1);
    result1.setTotalRecords(0);
    result1.setTotalPages(0);
    SearchResponse response1 = new SearchResponse();
    response1.setSearchResult(result1);
    AccountSearch nsSearchRecord1 = new AccountSearch();
    NsSearchResult nsSearchResult1 = TestNetSuiteClientService.toNsSearchResult(result1);
    when(conn.search(eq(nsSearchRecord1))).thenReturn(nsSearchResult1);
    NetSuiteClientService<?> clientService = new TestNetSuiteClientService();
    RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType("Account");
    SearchRecordTypeDesc searchRecordTypeDesc = clientService.getMetaDataSource().getSearchRecordType(recordTypeInfo.getRecordType().getSearchRecordType());
    SearchResultSet<Record> resultSet = new SearchResultSet<>(conn, recordTypeInfo.getRecordType(), searchRecordTypeDesc, nsSearchResult1);
    assertFalse(resultSet.next());
}
Also used : Status(com.netsuite.webservices.test.platform.core.Status) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) TestNetSuiteClientService(org.talend.components.netsuite.test.client.TestNetSuiteClientService) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) SearchResultSet(org.talend.components.netsuite.client.search.SearchResultSet) SearchResult(com.netsuite.webservices.test.platform.core.SearchResult) Record(com.netsuite.webservices.test.platform.core.Record) SearchResponse(com.netsuite.webservices.test.platform.messages.SearchResponse) AccountSearch(com.netsuite.webservices.test.lists.accounting.AccountSearch) Test(org.junit.Test)

Example 4 with SearchRecordTypeDesc

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

the class DefaultMetaDataSource method getSearchableTypes.

/**
 * {@inheritDoc}
 */
@Override
public Collection<NamedThing> getSearchableTypes() {
    List<NamedThing> searchableTypes = new ArrayList<>(256);
    Collection<RecordTypeInfo> recordTypes = getRecordTypes();
    for (RecordTypeInfo recordTypeInfo : recordTypes) {
        RecordTypeDesc recordTypeDesc = recordTypeInfo.getRecordType();
        if (recordTypeDesc.getSearchRecordType() != null) {
            SearchRecordTypeDesc searchRecordType = clientService.getBasicMetaData().getSearchRecordType(recordTypeDesc);
            if (searchRecordType != null) {
                searchableTypes.add(new SimpleNamedThing(recordTypeInfo.getName(), recordTypeInfo.getDisplayName()));
            }
        }
    }
    return searchableTypes;
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo) RecordTypeInfo(org.talend.components.netsuite.client.model.RecordTypeInfo) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) SimpleNamedThing(org.talend.daikon.SimpleNamedThing) ArrayList(java.util.ArrayList) NamedThing(org.talend.daikon.NamedThing) SimpleNamedThing(org.talend.daikon.SimpleNamedThing)

Example 5 with SearchRecordTypeDesc

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

the class NetSuiteDatasetRuntimeImpl method getSearchInfo.

@Override
public SearchInfo getSearchInfo(String typeName) {
    try {
        final SearchRecordTypeDesc searchInfo = metaDataSource.getSearchRecordType(typeName);
        final TypeDesc searchRecordInfo = metaDataSource.getBasicMetaData().getTypeInfo(searchInfo.getSearchBasicClass());
        List<FieldDesc> fieldDescList = searchRecordInfo.getFields();
        List<SearchFieldInfo> fields = new ArrayList<>(fieldDescList.size());
        for (FieldDesc fieldDesc : fieldDescList) {
            SearchFieldInfo field = new SearchFieldInfo(fieldDesc.getName(), fieldDesc.getValueType());
            fields.add(field);
        }
        // Sort by display name in alphabetical order
        Collections.sort(fields, new Comparator<SearchFieldInfo>() {

            @Override
            public int compare(SearchFieldInfo o1, SearchFieldInfo o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });
        return new SearchInfo(searchRecordInfo.getTypeName(), fields);
    } catch (NetSuiteException e) {
        throw new ComponentException(e);
    }
}
Also used : SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) SearchFieldInfo(org.talend.components.netsuite.schema.SearchFieldInfo) SearchInfo(org.talend.components.netsuite.schema.SearchInfo) SearchRecordTypeDesc(org.talend.components.netsuite.client.model.SearchRecordTypeDesc) RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) TypeDesc(org.talend.components.netsuite.client.model.TypeDesc) ArrayList(java.util.ArrayList) ComponentException(org.talend.components.api.exception.ComponentException) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) CustomFieldDesc(org.talend.components.netsuite.client.model.CustomFieldDesc) FieldDesc(org.talend.components.netsuite.client.model.FieldDesc)

Aggregations

SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)11 Test (org.junit.Test)8 RecordTypeInfo (org.talend.components.netsuite.client.model.RecordTypeInfo)7 ArrayList (java.util.ArrayList)5 Record (com.netsuite.webservices.test.platform.core.Record)3 SearchResult (com.netsuite.webservices.test.platform.core.SearchResult)3 Status (com.netsuite.webservices.test.platform.core.Status)3 SearchResponse (com.netsuite.webservices.test.platform.messages.SearchResponse)3 SearchResultSet (org.talend.components.netsuite.client.search.SearchResultSet)3 TestNetSuiteClientService (org.talend.components.netsuite.test.client.TestNetSuiteClientService)3 NamedThing (org.talend.daikon.NamedThing)3 AccountSearch (com.netsuite.webservices.test.lists.accounting.AccountSearch)2 RecordList (com.netsuite.webservices.test.platform.core.RecordList)2 SearchMoreWithIdResponse (com.netsuite.webservices.test.platform.messages.SearchMoreWithIdResponse)2 HashSet (java.util.HashSet)2 CustomRecordTypeInfo (org.talend.components.netsuite.client.model.CustomRecordTypeInfo)2 RecordTypeDesc (org.talend.components.netsuite.client.model.RecordTypeDesc)2 Account (com.netsuite.webservices.test.lists.accounting.Account)1 InventoryItem (com.netsuite.webservices.test.lists.accounting.InventoryItem)1 ItemSearch (com.netsuite.webservices.test.lists.accounting.ItemSearch)1