use of org.talend.components.netsuite.client.model.search.SearchFieldOperatorName in project components by Talend.
the class BasicMetaDataTest method testGetSearchOperatorNames.
@Test
public void testGetSearchOperatorNames() {
Collection<SearchFieldOperatorName> operatorNames = basicMetaData.getSearchOperatorNames();
Collection<String> dataTypes = new HashSet<>();
for (SearchFieldOperatorName operatorName : operatorNames) {
dataTypes.add(operatorName.getDataType());
}
assertThat(dataTypes, containsInAnyOrder("Boolean", "String", "Long", "Double", "TextNumber", "Date", "PredefinedDate", "List"));
}
use of org.talend.components.netsuite.client.model.search.SearchFieldOperatorName in project components by Talend.
the class SearchQuery method condition.
/**
* Add condition for search query.
*
* @param condition condition to be added
* @return
* @throws NetSuiteException if an error occurs during adding of condition
*/
public SearchQuery condition(SearchCondition condition) throws NetSuiteException {
initSearch();
BeanInfo searchMetaData = Beans.getBeanInfo(searchRecordTypeDesc.getSearchBasicClass());
String fieldName = toInitialLower(condition.getFieldName());
PropertyInfo propertyInfo = searchMetaData.getProperty(fieldName);
SearchFieldOperatorName operatorQName = new SearchFieldOperatorName(condition.getOperatorName());
if (propertyInfo != null) {
Object searchField = processConditionForSearchRecord(searchBasic, condition);
setProperty(searchBasic, fieldName, searchField);
} else {
String dataType = operatorQName.getDataType();
SearchFieldType searchFieldType = null;
if (SearchFieldOperatorType.STRING.dataTypeEquals(dataType)) {
searchFieldType = SearchFieldType.CUSTOM_STRING;
} else if (SearchFieldOperatorType.BOOLEAN.dataTypeEquals(dataType)) {
searchFieldType = SearchFieldType.CUSTOM_BOOLEAN;
} else if (SearchFieldOperatorType.LONG.dataTypeEquals(dataType)) {
searchFieldType = SearchFieldType.CUSTOM_LONG;
} else if (SearchFieldOperatorType.DOUBLE.dataTypeEquals(dataType)) {
searchFieldType = SearchFieldType.CUSTOM_DOUBLE;
} else if (SearchFieldOperatorType.DATE.dataTypeEquals(dataType) || SearchFieldOperatorType.PREDEFINED_DATE.dataTypeEquals(dataType)) {
searchFieldType = SearchFieldType.CUSTOM_DATE;
} else if (SearchFieldOperatorType.MULTI_SELECT.dataTypeEquals(dataType)) {
searchFieldType = SearchFieldType.CUSTOM_MULTI_SELECT;
} else if (SearchFieldOperatorType.ENUM_MULTI_SELECT.dataTypeEquals(dataType)) {
searchFieldType = SearchFieldType.CUSTOM_SELECT;
} else {
throw new NetSuiteException("Invalid data type: " + searchFieldType);
}
Object searchField = processCondition(searchFieldType, condition);
customFieldList.add(searchField);
}
return this;
}
use of org.talend.components.netsuite.client.model.search.SearchFieldOperatorName in project components by Talend.
the class NetSuiteDatasetRuntimeImpl method getSearchFieldOperators.
@Override
public List<String> getSearchFieldOperators() {
List<SearchFieldOperatorName> operatorList = new ArrayList<>(metaDataSource.getBasicMetaData().getSearchOperatorNames());
List<String> operatorNames = new ArrayList<>(operatorList.size());
for (SearchFieldOperatorName operatorName : operatorList) {
operatorNames.add(operatorName.getQualifiedName());
}
// Sort in alphabetical order
Collections.sort(operatorNames);
return operatorNames;
}
use of org.talend.components.netsuite.client.model.search.SearchFieldOperatorName in project components by Talend.
the class BasicMetaData method getSearchFieldOperator.
/**
* Get search field operator for given search field type and operator name.
*
* @see SearchFieldOperatorType
* @see SearchFieldOperatorName
*
* @param fieldType search field type
* @param operatorName operator name
* @return search field operator
*/
public Object getSearchFieldOperator(SearchFieldType fieldType, String operatorName) {
SearchFieldOperatorName operatorQName = new SearchFieldOperatorName(operatorName);
SearchFieldOperatorType operatorType = SearchFieldType.getOperatorType(fieldType);
if (operatorType != null) {
SearchFieldOperatorTypeDesc def = searchFieldOperatorTypeMap.get(operatorType);
return def.getOperator(operatorName);
}
for (SearchFieldOperatorTypeDesc def : searchFieldOperatorTypeMap.values()) {
if (def.hasOperator(operatorQName)) {
return def.getOperator(operatorName);
}
}
throw new IllegalArgumentException("Unknown search field operator: " + fieldType + ", " + operatorName);
}
use of org.talend.components.netsuite.client.model.search.SearchFieldOperatorName in project components by Talend.
the class NetSuiteClientServiceTest method testBasicMetaData.
@Test
public void testBasicMetaData() throws Exception {
NetSuiteClientService<?> clientService = webServiceMockTestFixture.getClientService();
Set<SearchRecordType> searchRecordTypeSet = new HashSet<>(Arrays.asList(SearchRecordType.values()));
Set<String> searchRecordTypeNameSet = new HashSet<>();
for (SearchRecordType searchRecordType : searchRecordTypeSet) {
searchRecordTypeNameSet.add(toInitialUpper(searchRecordType.value()));
}
searchRecordTypeNameSet.add("Address");
searchRecordTypeNameSet.add("InventoryDetail");
searchRecordTypeNameSet.add("TimeEntry");
for (String searchRecordType : searchRecordTypeNameSet) {
try {
SearchRecordTypeDesc searchRecordInfo = clientService.getMetaDataSource().getSearchRecordType(searchRecordType);
assertNotNull("Search record def found: " + searchRecordType, searchRecordInfo);
} catch (Exception e) {
throw new AssertionError("Search record type: " + searchRecordType, e);
}
}
Set<RecordType> recordTypeSet = new HashSet<>(Arrays.asList(RecordType.values()));
recordTypeSet.remove(RecordType.CUSTOM_TRANSACTION_TYPE);
Set<String> recordTypeNameSet = new HashSet<>();
for (RecordType recordType : recordTypeSet) {
recordTypeNameSet.add(toInitialUpper(recordType.value()));
}
recordTypeNameSet.add("Address");
recordTypeNameSet.add("InventoryDetail");
recordTypeNameSet.add("TimeEntry");
for (String recordType : recordTypeNameSet) {
RecordTypeInfo recordTypeInfo = clientService.getMetaDataSource().getRecordType(recordType);
assertNotNull("Record type def found: " + recordType, recordTypeInfo);
}
Collection<SearchFieldOperatorName> searchOperatorNames = clientService.getBasicMetaData().getSearchOperatorNames();
List<SearchFieldOperatorName> searchFieldOperatorNameList = new ArrayList<>(searchOperatorNames);
Collections.sort(searchFieldOperatorNameList, new Comparator<SearchFieldOperatorName>() {
@Override
public int compare(SearchFieldOperatorName o1, SearchFieldOperatorName o2) {
return o1.getQualifiedName().compareTo(o2.getQualifiedName());
}
});
for (SearchFieldOperatorName operatorName : searchFieldOperatorNameList) {
assertNotNull(operatorName.getDataType());
if (!SearchFieldOperatorType.BOOLEAN.dataTypeEquals(operatorName.getDataType())) {
assertNotNull(operatorName.getName());
}
}
}
Aggregations