use of org.talend.components.netsuite.client.model.beans.PropertyInfo in project components by Talend.
the class NetSuiteMockTestBase method createCustomFieldRefs.
protected Map<String, CustomFieldRef> createCustomFieldRefs(Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customFieldSpecs) throws Exception {
NetSuiteClientService<?> clientService = webServiceMockTestFixture.getClientService();
Map<String, CustomFieldRef> map = new HashMap<>();
for (CustomFieldSpec<RecordType, CustomizationFieldType> spec : customFieldSpecs.values()) {
CustomFieldRef fieldRef = clientService.getBasicMetaData().createInstance(spec.getFieldRefType().getTypeName());
fieldRef.setScriptId(spec.getScriptId());
fieldRef.setInternalId(spec.getInternalId());
BeanInfo beanInfo = Beans.getBeanInfo(fieldRef.getClass());
PropertyInfo valuePropInfo = beanInfo.getProperty("value");
Object value = composeValue(valuePropInfo.getWriteType());
if (value != null) {
Beans.setProperty(fieldRef, "value", value);
}
map.put(fieldRef.getScriptId(), fieldRef);
}
return map;
}
use of org.talend.components.netsuite.client.model.beans.PropertyInfo 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.beans.PropertyInfo in project components by Talend.
the class NetSuiteMockTestBase method createCustomFieldRefs.
protected Map<String, CustomFieldRef> createCustomFieldRefs(Map<String, CustomFieldSpec<RecordType, CustomizationFieldType>> customFieldSpecs) throws Exception {
NetSuiteClientService<?> clientService = webServiceMockTestFixture.getClientService();
Map<String, CustomFieldRef> map = new HashMap<>();
for (CustomFieldSpec spec : customFieldSpecs.values()) {
CustomFieldRef fieldRef = clientService.getBasicMetaData().createInstance(spec.getFieldRefType().getTypeName());
fieldRef.setScriptId(spec.getScriptId());
fieldRef.setInternalId(spec.getInternalId());
BeanInfo beanInfo = Beans.getBeanInfo(fieldRef.getClass());
PropertyInfo valuePropInfo = beanInfo.getProperty("value");
Object value = composeValue(valuePropInfo.getWriteType());
if (value != null) {
Beans.setProperty(fieldRef, "value", value);
}
map.put(fieldRef.getScriptId(), fieldRef);
}
return map;
}
use of org.talend.components.netsuite.client.model.beans.PropertyInfo in project components by Talend.
the class AbstractNetSuiteTestBase method composeObject.
protected static <T> T composeObject(Class<T> clazz) throws Exception {
BeanInfo beanInfo = Beans.getBeanInfo(clazz);
List<PropertyInfo> propertyInfoList = beanInfo.getProperties();
T obj = clazz.newInstance();
for (PropertyInfo propertyInfo : propertyInfoList) {
if (propertyInfo.getWriteType() != null) {
Object value;
if (propertyInfo.getName().equals("internalId")) {
value = composeValue(Integer.class).toString();
} else {
value = composeValue(propertyInfo.getWriteType());
}
setProperty(obj, propertyInfo.getName(), value);
}
}
return obj;
}
use of org.talend.components.netsuite.client.model.beans.PropertyInfo in project components by Talend.
the class BasicMetaData method getTypeInfo.
/**
* Get type descriptor for given type class.
*
* @param clazz class of type
* @return type descriptor
*/
public TypeDesc getTypeInfo(Class<?> clazz) {
BeanInfo beanInfo = Beans.getBeanInfo(clazz);
List<PropertyInfo> propertyInfos = beanInfo.getProperties();
List<FieldDesc> fields = new ArrayList<>(propertyInfos.size());
for (PropertyInfo propertyInfo : propertyInfos) {
String fieldName = propertyInfo.getName();
Class fieldValueType = propertyInfo.getReadType();
// Skip 'class' property
if ((propertyInfo.getName().equals("class") && fieldValueType == Class.class)) {
continue;
}
boolean isKey = isKeyField(propertyInfo);
SimpleFieldDesc fieldDesc = new SimpleFieldDesc(fieldName, fieldValueType, isKey, true);
fieldDesc.setPropertyName(propertyInfo.getName());
fields.add(fieldDesc);
}
return new TypeDesc(clazz.getSimpleName(), clazz, fields);
}
Aggregations