use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.
the class DefaultMetaDataSource method getTypeInfo.
/**
* {@inheritDoc}
*/
@Override
public TypeDesc getTypeInfo(final String typeName) {
TypeDesc baseTypeDesc;
String targetTypeName = null;
Class<?> targetTypeClass;
List<FieldDesc> baseFieldDescList;
RecordTypeInfo recordTypeInfo = getRecordType(typeName);
if (recordTypeInfo != null) {
if (recordTypeInfo instanceof CustomRecordTypeInfo) {
CustomRecordTypeInfo customRecordTypeInfo = (CustomRecordTypeInfo) recordTypeInfo;
baseTypeDesc = clientService.getBasicMetaData().getTypeInfo(customRecordTypeInfo.getRecordType().getTypeName());
targetTypeName = customRecordTypeInfo.getName();
} else {
baseTypeDesc = clientService.getBasicMetaData().getTypeInfo(typeName);
}
} else {
baseTypeDesc = clientService.getBasicMetaData().getTypeInfo(typeName);
}
if (targetTypeName == null) {
targetTypeName = baseTypeDesc.getTypeName();
}
targetTypeClass = baseTypeDesc.getTypeClass();
baseFieldDescList = baseTypeDesc.getFields();
List<FieldDesc> resultFieldDescList = new ArrayList<>(baseFieldDescList.size() + 10);
// Add basic fields except field list containers (custom field list, null field list)
for (FieldDesc fieldDesc : baseFieldDescList) {
String fieldName = fieldDesc.getName();
if (fieldName.equals("customFieldList") || fieldName.equals("nullFieldList")) {
continue;
}
resultFieldDescList.add(fieldDesc);
}
if (recordTypeInfo != null) {
if (customizationEnabled) {
// Add custom fields
Map<String, CustomFieldDesc> customFieldMap = customMetaDataSource.getCustomFields(recordTypeInfo);
for (CustomFieldDesc fieldInfo : customFieldMap.values()) {
resultFieldDescList.add(fieldInfo);
}
}
}
return new TypeDesc(targetTypeName, targetTypeClass, resultFieldDescList);
}
use of org.talend.components.netsuite.client.model.RecordTypeInfo 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());
}
}
}
use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.
the class NetSuiteClientServiceIT method testSearchCustomRecord.
@Test
public void testSearchCustomRecord() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
Collection<RecordTypeInfo> recordTypes = connection.getMetaDataSource().getRecordTypes();
RecordTypeInfo recordType = getCustomRecordType(recordTypes, "customrecord_campaign_revenue");
SearchQuery searchQuery = connection.newSearch();
searchQuery.target(recordType.getName());
SearchResultSet<Record> rs = searchQuery.search();
int count = 10;
while (rs.next() && count-- > 0) {
Record record = rs.get();
assertNotNull(record);
}
}
use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.
the class NetSuiteClientServiceIT method testRetrieveCustomRecordCustomFields.
@Test
public void testRetrieveCustomRecordCustomFields() throws Exception {
NetSuiteClientService<?> connection = webServiceTestFixture.getClientService();
connection.login();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
RecordTypeInfo recordType = connection.getMetaDataSource().getRecordType("customrecord_campaign_revenue");
TypeDesc typeDesc = connection.getMetaDataSource().getTypeInfo(recordType.getName());
logger.debug("Record type desc: {}", typeDesc.getTypeName());
stopWatch.stop();
}
Aggregations