use of org.talend.components.netsuite.client.model.TypeDesc in project components by Talend.
the class NsObjectInputTransducerTest method testBasic.
@Test
public void testBasic() throws Exception {
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo("Opportunity");
final List<Opportunity> recordList = makeNsObjects(new NsObjectComposer<Opportunity>(clientService.getMetaDataSource(), typeDesc), 10);
mockSearchRequestResults(recordList, 100);
Schema schema = NetSuiteDatasetRuntimeImpl.inferSchemaForType(typeDesc.getTypeName(), typeDesc.getFields());
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
for (Record record : recordList) {
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
use of org.talend.components.netsuite.client.model.TypeDesc in project components by Talend.
the class NsObjectInputTransducerTest method testDynamicSchemaWithDynamicColumnLast.
@Test
public void testDynamicSchemaWithDynamicColumnLast() throws Exception {
TypeDesc basicTypeDesc = clientService.getMetaDataSource().getTypeInfo("Check");
final List<Check> recordList = makeNsObjects(new NsObjectComposer<Check>(clientService.getMetaDataSource(), basicTypeDesc), 10);
mockSearchRequestResults(recordList, 100);
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(basicTypeDesc.getTypeName());
Schema designSchema = SchemaBuilder.record(typeDesc.getTypeName()).fields().name("InternalId").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("internalId"))).noDefault().name("TranId").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("tranId"))).noDefault().name("LastModifiedDate").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("lastModifiedDate"))).noDefault().endRecord();
designSchema.addProp(NetSuiteSchemaConstants.TALEND6_DYNAMIC_COLUMN_POSITION, "3");
designSchema.addProp(NetSuiteSchemaConstants.TALEND6_DYNAMIC_COLUMN_ID, "dynamic");
Schema schema = AvroUtils.setIncludeAllFields(designSchema, true);
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
SearchResultSet<Record> rs = clientService.newSearch().target(basicTypeDesc.getTypeName()).search();
while (rs.next()) {
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
use of org.talend.components.netsuite.client.model.TypeDesc in project components by Talend.
the class NsObjectInputTransducerTest method testDynamicSchemaWithDynamicColumnMiddle.
@Test
public void testDynamicSchemaWithDynamicColumnMiddle() throws Exception {
TypeDesc basicTypeDesc = clientService.getMetaDataSource().getTypeInfo("Check");
final List<Check> recordList = makeNsObjects(new NsObjectComposer<Check>(clientService.getMetaDataSource(), basicTypeDesc), 10);
mockSearchRequestResults(recordList, 100);
TypeDesc typeDesc = clientService.getMetaDataSource().getTypeInfo(basicTypeDesc.getTypeName());
Schema designSchema = SchemaBuilder.record(typeDesc.getTypeName()).fields().name("InternalId").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("internalId"))).noDefault().name("TranId").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("tranId"))).noDefault().name("LastModifiedDate").type(NetSuiteDatasetRuntimeImpl.inferSchemaForField(typeDesc.getField("lastModifiedDate"))).noDefault().endRecord();
designSchema.addProp(NetSuiteSchemaConstants.TALEND6_DYNAMIC_COLUMN_POSITION, "1");
designSchema.addProp(NetSuiteSchemaConstants.TALEND6_DYNAMIC_COLUMN_ID, "dynamic");
Schema schema = AvroUtils.setIncludeAllFields(designSchema, true);
NsObjectInputTransducer transducer = new NsObjectInputTransducer(clientService, schema, typeDesc.getTypeName());
SearchResultSet<Record> rs = clientService.newSearch().target(basicTypeDesc.getTypeName()).search();
while (rs.next()) {
Record record = rs.get();
IndexedRecord indexedRecord = transducer.read(record);
assertIndexedRecord(typeDesc, indexedRecord);
}
}
use of org.talend.components.netsuite.client.model.TypeDesc 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.TypeDesc 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);
}
}
Aggregations