use of org.talend.components.netsuite.client.NetSuiteException in project components by Talend.
the class NetSuiteDatasetRuntimeImpl method getRecordTypes.
@Override
public List<NamedThing> getRecordTypes() {
try {
Collection<RecordTypeInfo> recordTypeList = metaDataSource.getRecordTypes();
List<NamedThing> recordTypes = new ArrayList<>(recordTypeList.size());
for (RecordTypeInfo recordTypeInfo : recordTypeList) {
recordTypes.add(new SimpleNamedThing(recordTypeInfo.getName(), recordTypeInfo.getDisplayName()));
}
// Sort by display name in alphabetical order
Collections.sort(recordTypes, new Comparator<NamedThing>() {
@Override
public int compare(NamedThing o1, NamedThing o2) {
return o1.getDisplayName().compareTo(o2.getDisplayName());
}
});
return recordTypes;
} catch (NetSuiteException e) {
throw new ComponentException(e);
}
}
use of org.talend.components.netsuite.client.NetSuiteException 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);
}
}
use of org.talend.components.netsuite.client.NetSuiteException in project components by Talend.
the class NetSuiteDatasetRuntimeImpl method getSchemaForUpdate.
@Override
public Schema getSchemaForUpdate(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, typeDesc.getFields());
return schema;
} catch (NetSuiteException e) {
throw new ComponentException(e);
}
}
use of org.talend.components.netsuite.client.NetSuiteException in project components by Talend.
the class SearchQuery method processCondition.
/**
* Process search condition and update search record.
*
* @param fieldType type of search field
* @param condition condition
* @return search field built for this condition
* @throws NetSuiteException if an error occurs during processing of condition
*/
private Object processCondition(SearchFieldType fieldType, SearchCondition condition) throws NetSuiteException {
try {
String searchFieldName = toInitialLower(condition.getFieldName());
String searchOperator = condition.getOperatorName();
List<String> searchValue = condition.getValues();
SearchFieldAdapter<?> fieldAdapter = metaDataSource.getBasicMetaData().getSearchFieldAdapter(fieldType);
Object searchField = fieldAdapter.populate(searchFieldName, searchOperator, searchValue);
return searchField;
} catch (IllegalArgumentException e) {
throw new NetSuiteException(e.getMessage(), e);
}
}
use of org.talend.components.netsuite.client.NetSuiteException in project components by Talend.
the class SearchQuery method initSearch.
/**
* Performs lazy initialization of search query.
*
* @throws NetSuiteException if an error occurs during obtaining of meta data
*/
private void initSearch() throws NetSuiteException {
if (searchBasic != null) {
return;
}
try {
// get a search class instance
if (searchRecordTypeDesc.getSearchClass() != null) {
search = (SearchT) searchRecordTypeDesc.getSearchClass().newInstance();
}
// get a advanced search class instance and set 'savedSearchId' into it
searchAdvanced = null;
if (savedSearchId != null && savedSearchId.length() > 0) {
if (searchRecordTypeDesc.getSearchAdvancedClass() != null) {
searchAdvanced = (SearchT) searchRecordTypeDesc.getSearchAdvancedClass().newInstance();
setProperty(searchAdvanced, "savedSearchId", savedSearchId);
} else {
throw new NetSuiteException("Advanced search not available: " + recordTypeName);
}
}
// basic search class not found or supported
if (searchRecordTypeDesc.getSearchBasicClass() == null) {
throw new IllegalArgumentException("Search basic class not found: " + recordTypeName);
}
// get a basic search class instance
searchBasic = (SearchT) searchRecordTypeDesc.getSearchBasicClass().newInstance();
} catch (InstantiationException | IllegalAccessException e) {
throw new NetSuiteException(e.getMessage(), e);
}
}
Aggregations