use of org.talend.components.netsuite.SchemaCustomMetaDataSource in project components by Talend.
the class NsObjectInputTransducer method prepare.
/**
* Prepare processing of data object.
*/
private void prepare() {
if (runtimeSchema != null) {
return;
}
if (AvroUtils.isIncludeAllFields(schema)) {
// It's dynamic schema, we should use dynamic schema as runtime schema.
typeDesc = metaDataSource.getTypeInfo(typeName);
runtimeSchema = getDynamicSchema(typeDesc, schema, typeDesc.getTypeName());
// Replace custom meta data source with SchemaCustomMetaDataSource
// which will be using new runtime schema
SchemaCustomMetaDataSource schemaCustomMetaDataSource = new SchemaCustomMetaDataSource(clientService.getBasicMetaData(), clientService.getMetaDataSource().getCustomMetaDataSource(), runtimeSchema);
metaDataSource.setCustomMetaDataSource(schemaCustomMetaDataSource);
} else {
typeDesc = metaDataSource.getTypeInfo(typeName);
// Use design schema as runtime schema
runtimeSchema = schema;
}
}
use of org.talend.components.netsuite.SchemaCustomMetaDataSource in project components by Talend.
the class NetSuiteSearchInputReader method start.
@Override
public boolean start() throws IOException {
try {
schema = properties.module.main.schema.getValue();
clientService = ((NetSuiteSource) getCurrentSource()).getClientService();
// Set up MetaDataSource which retrieves customization meta data from schema.
// We use MetaDataSource from NetSuite client as base source.
MetaDataSource originalMetaDataSource = clientService.getMetaDataSource();
metaDataSource = clientService.createDefaultMetaDataSource();
metaDataSource.setCustomizationEnabled(originalMetaDataSource.isCustomizationEnabled());
SchemaCustomMetaDataSource schemaCustomMetaDataSource = new SchemaCustomMetaDataSource(clientService.getBasicMetaData(), originalMetaDataSource.getCustomMetaDataSource(), schema);
metaDataSource.setCustomMetaDataSource(schemaCustomMetaDataSource);
// Execute search and get search result set.
resultSet = search();
return advance();
} catch (NetSuiteException e) {
throw new IOException(e);
}
}
use of org.talend.components.netsuite.SchemaCustomMetaDataSource in project components by Talend.
the class NetSuiteWriteOperation method createWriter.
@Override
public Writer<Result> createWriter(RuntimeContainer adaptor) {
NetSuiteClientService clientService = sink.getClientService();
OutputAction action = properties.module.action.getValue();
Schema schema = properties.module.main.schema.getValue();
MetaDataSource originalMetaDataSource = clientService.getMetaDataSource();
MetaDataSource metaDataSource = clientService.createDefaultMetaDataSource();
metaDataSource.setCustomizationEnabled(originalMetaDataSource.isCustomizationEnabled());
SchemaCustomMetaDataSource schemaCustomMetaDataSource = new SchemaCustomMetaDataSource(clientService.getBasicMetaData(), originalMetaDataSource.getCustomMetaDataSource(), schema);
metaDataSource.setCustomMetaDataSource(schemaCustomMetaDataSource);
NetSuiteOutputWriter<?, ?> writer;
switch(action) {
case ADD:
writer = new NetSuiteAddWriter<>(this, adaptor, metaDataSource);
break;
case UPDATE:
writer = new NetSuiteUpsertWriter<>(this, adaptor, metaDataSource);
break;
case UPSERT:
writer = new NetSuiteUpsertWriter<>(this, adaptor, metaDataSource);
Boolean useNativeUpsert = properties.module.useNativeUpsert.getValue();
if (useNativeUpsert != null) {
((NetSuiteUpsertWriter) writer).setUseNativeUpsert(useNativeUpsert);
}
break;
case DELETE:
writer = new NetSuiteDeleteWriter<>(this, adaptor, metaDataSource);
break;
default:
throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.INTERNAL_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.outputOperationNotImplemented", action));
}
Integer batchSize = properties.batchSize.getValue();
if (batchSize != null) {
writer.setBatchSize(batchSize);
}
Boolean dieOnError = properties.dieOnError.getValue();
if (dieOnError != null) {
writer.setExceptionForErrors(dieOnError);
}
return writer;
}
Aggregations