use of org.talend.components.netsuite.schema.SearchFieldInfo 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.schema.SearchFieldInfo in project components by Talend.
the class NetSuitePropertiesTestBase method createTestDataset1.
protected TestDataset createTestDataset1() {
TestDataset dataset = new TestDataset();
dataset.getRecordTypes().addAll(Arrays.<NamedThing>asList(new SimpleNamedThing("Account"), new SimpleNamedThing("Opportunity")));
dataset.getSearchableTypes().addAll(Arrays.<NamedThing>asList(new SimpleNamedThing("Account"), new SimpleNamedThing("Opportunity"), new SimpleNamedThing("Transaction")));
dataset.getTypeSchemaMap().put("Account", SchemaBuilder.builder().record("Account").fields().name("AccountField1").type(AvroUtils._boolean()).noDefault().name("AccountField2").type(AvroUtils._string()).noDefault().name("AccountField3").type(AvroUtils._logicalTimestamp()).noDefault().endRecord());
dataset.getTypeSchemaMap().put("Opportunity", SchemaBuilder.builder().record("Opportunity").fields().name("OpportunityField1").type(AvroUtils._boolean()).noDefault().name("OpportunityField2").type(AvroUtils._double()).noDefault().name("OpportunityField3").type(AvroUtils._logicalTimestamp()).noDefault().endRecord());
dataset.getTypeSchemaMap().put("RecordRef", SchemaBuilder.builder().record("RecordRef").fields().name("InternalId").type(AvroUtils._boolean()).noDefault().name("Type").type(AvroUtils._string()).noDefault().endRecord());
dataset.getSearchOperators().addAll(Arrays.<NamedThing>asList(new SimpleNamedThing("Boolean"), new SimpleNamedThing("Date.onOrAfter"), new SimpleNamedThing("String.contains")));
dataset.getSearchInfoMap().put("Account", new SearchInfo("Account", Arrays.asList(new SearchFieldInfo("AccountField1", Boolean.class), new SearchFieldInfo("AccountField2", String.class), new SearchFieldInfo("AccountField3", XMLGregorianCalendar.class))));
dataset.getSearchInfoMap().put("Opportunity", new SearchInfo("Opportunity", Arrays.asList(new SearchFieldInfo("OpportunityField1", Boolean.class), new SearchFieldInfo("OpportunityField2", Double.class), new SearchFieldInfo("OpportunityField3", XMLGregorianCalendar.class))));
return dataset;
}
use of org.talend.components.netsuite.schema.SearchFieldInfo in project components by Talend.
the class NetSuiteInputModuleProperties method setupSearchSchema.
/**
* Set up search query design-time model.
*/
private void setupSearchSchema() {
assertModuleName();
SearchInfo searchSchema = getSearchInfo(moduleName.getValue());
List<String> fieldNames = new ArrayList<>(searchSchema.getFields().size());
for (SearchFieldInfo field : searchSchema.getFields()) {
fieldNames.add(field.getName());
}
// Set up list of available search fields
searchQuery.field.setPossibleValues(fieldNames);
searchQuery.field.setValue(new ArrayList<String>());
// Set up list of search operators
searchQuery.operator.setPossibleValues(getSearchFieldOperators());
searchQuery.operator.setValue(new ArrayList<String>());
// Clear search values
searchQuery.value1.setValue(new ArrayList<>());
searchQuery.value2.setValue(new ArrayList<>());
searchQuery.refreshLayout(searchQuery.getForm(Form.MAIN));
}
Aggregations