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);
}
}
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);
}
}
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());
}
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;
}
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);
}
}
Aggregations