use of org.talend.components.netsuite.client.model.RecordTypeInfo 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.RecordTypeInfo 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.RecordTypeInfo in project components by Talend.
the class NetSuiteDatasetRuntimeImpl method getSchemaForRecordRef.
public Schema getSchemaForRecordRef(String typeName) {
try {
// Get info for target record type
final RecordTypeInfo referencedRecordTypeInfo = metaDataSource.getRecordType(typeName);
final RefType refType = referencedRecordTypeInfo.getRefType();
// Get type info for record ref
final TypeDesc typeDesc = metaDataSource.getTypeInfo(refType.getTypeName());
List<FieldDesc> fieldDescList = new ArrayList<>(typeDesc.getFields());
// Sort in alphabetical order
Collections.sort(fieldDescList, FieldDescComparator.INSTANCE);
Schema schema = inferSchemaForType(typeDesc.getTypeName(), fieldDescList);
augmentSchemaWithCustomMetaData(metaDataSource, schema, referencedRecordTypeInfo, null);
return schema;
} catch (NetSuiteException e) {
throw new ComponentException(e);
}
}
use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.
the class NetSuiteDatasetRuntimeImpl method getSchema.
@Override
public Schema getSchema(String typeName) {
try {
final RecordTypeInfo recordTypeInfo = metaDataSource.getRecordType(typeName);
final TypeDesc typeDesc = metaDataSource.getTypeInfo(typeName);
List<FieldDesc> fieldDescList = new ArrayList<>(typeDesc.getFields());
// Sort in alphabetical order
Collections.sort(fieldDescList, FieldDescComparator.INSTANCE);
Schema schema = inferSchemaForType(typeDesc.getTypeName(), fieldDescList);
augmentSchemaWithCustomMetaData(metaDataSource, schema, recordTypeInfo, fieldDescList);
return schema;
} catch (NetSuiteException e) {
throw new ComponentException(e);
}
}
use of org.talend.components.netsuite.client.model.RecordTypeInfo in project components by Talend.
the class NetSuiteDatasetRuntimeImpl method getSchemaForUpdateFlow.
@Override
public Schema getSchemaForUpdateFlow(String typeName, Schema schema) {
RecordTypeInfo recordTypeInfo = metaDataSource.getRecordType(typeName);
TypeDesc typeDesc = metaDataSource.getTypeInfo(typeName);
// We should check and add key fields:
// internalId, externalId and scriptId (for custom record type)
List<FieldDesc> fieldDescList = new ArrayList<>();
Schema.Field internalIdField = getNsFieldByName(schema, "internalId");
if (internalIdField == null) {
FieldDesc fieldDesc = typeDesc.getField("internalId");
fieldDescList.add(fieldDesc);
}
Schema.Field externalIdField = getNsFieldByName(schema, "externalId");
if (externalIdField == null) {
FieldDesc fieldDesc = typeDesc.getField("externalId");
fieldDescList.add(fieldDesc);
}
if (recordTypeInfo instanceof CustomRecordTypeInfo) {
Schema.Field scriptIdField = getNsFieldByName(schema, "scriptId");
if (scriptIdField == null) {
FieldDesc fieldDesc = typeDesc.getField("scriptId");
if (fieldDesc != null) {
fieldDescList.add(fieldDesc);
}
}
}
// Create schema fields for mandatory fields.
List<Schema.Field> fields = new ArrayList<>();
Schema.Field f;
if (!fieldDescList.isEmpty()) {
Schema schemaToAdd = inferSchemaForType(typeName, fieldDescList);
for (Schema.Field sourceField : schemaToAdd.getFields()) {
f = copyField(sourceField);
f.addProp(SchemaConstants.TALEND_FIELD_GENERATED, "true");
f.addProp(SchemaConstants.TALEND_IS_LOCKED, "true");
fields.add(f);
}
}
return extendSchema(schema, typeName + "_FLOW", fields);
}
Aggregations