use of org.talend.components.netsuite.client.model.customfield.CustomFieldRefType in project components by Talend.
the class BasicMetaDataTest method testGetCustomFieldRefType.
@Test
public void testGetCustomFieldRefType() {
EntityCustomField entityCustomField1 = new EntityCustomField();
entityCustomField1.setFieldType(CustomizationFieldType.FREE_FORM_TEXT);
entityCustomField1.setAppliesToContact(true);
entityCustomField1.setAppliesToVendor(true);
CustomFieldRefType customFieldRefType = basicMetaData.getCustomFieldRefType(TestRecordTypeEnum.CONTACT.getType(), BasicRecordType.ENTITY_CUSTOM_FIELD, entityCustomField1);
assertEquals(CustomFieldRefType.STRING, customFieldRefType);
customFieldRefType = basicMetaData.getCustomFieldRefType(TestRecordTypeEnum.VENDOR.getType(), BasicRecordType.ENTITY_CUSTOM_FIELD, entityCustomField1);
assertEquals(CustomFieldRefType.STRING, customFieldRefType);
customFieldRefType = basicMetaData.getCustomFieldRefType(TestRecordTypeEnum.PARTNER.getType(), BasicRecordType.ENTITY_CUSTOM_FIELD, entityCustomField1);
assertNull(customFieldRefType);
}
use of org.talend.components.netsuite.client.model.customfield.CustomFieldRefType in project components by Talend.
the class TestUtils method readCustomField.
public static CustomFieldDesc readCustomField(JsonNode node) {
String scriptId = node.get("scriptId").asText();
String internalId = node.get("internalId").asText();
String customizationType = node.get("customizationType").asText();
String type = node.get("valueType").asText();
NsRef ref = new NsRef();
ref.setRefType(RefType.CUSTOMIZATION_REF);
ref.setScriptId(scriptId);
ref.setInternalId(internalId);
ref.setType(customizationType);
CustomFieldRefType customFieldRefType = CustomFieldRefType.valueOf(type);
CustomFieldDesc fieldDesc = new CustomFieldDesc();
fieldDesc.setCustomFieldType(customFieldRefType);
fieldDesc.setCustomizationRef(ref);
fieldDesc.setName(scriptId);
fieldDesc.setValueType(NetSuiteDatasetRuntimeImpl.getCustomFieldValueClass(customFieldRefType));
fieldDesc.setNullable(true);
return fieldDesc;
}
use of org.talend.components.netsuite.client.model.customfield.CustomFieldRefType in project components by Talend.
the class NsObjectTransducer method getValueConverter.
/**
* Get value converter for given field descriptor.
*
* @param fieldDesc field descriptor
* @return value converter
*/
public AvroConverter<?, ?> getValueConverter(FieldDesc fieldDesc) {
Class<?> valueClass;
if (fieldDesc instanceof CustomFieldDesc) {
CustomFieldDesc customFieldDesc = (CustomFieldDesc) fieldDesc;
CustomFieldRefType customFieldRefType = customFieldDesc.getCustomFieldType();
valueClass = getCustomFieldValueConverterTargetClass(customFieldRefType);
} else {
valueClass = fieldDesc.getValueType();
}
AvroConverter<?, ?> converter = null;
if (valueClass != null) {
converter = getValueConverter(valueClass);
}
if (converter == null) {
converter = new NullConverter(valueClass, null);
}
return converter;
}
use of org.talend.components.netsuite.client.model.customfield.CustomFieldRefType in project components by Talend.
the class DefaultCustomMetaDataSource method createCustomFieldDescMap.
/**
* Create custom field descriptors.
*
* @param recordType record type
* @param customizationType customization type
* @param customFieldList list of native NetSuite objects describing custom fields
* @param <T> type of custom field data objects
* @return custom field descriptors as map
* @throws NetSuiteException if an error occurs during obtaining of customization data
*/
public static <T> Map<String, CustomFieldDesc> createCustomFieldDescMap(NetSuiteClientService<?> clientService, RecordTypeDesc recordType, BasicRecordType customizationType, List<T> customFieldList) throws NetSuiteException {
Map<String, CustomFieldDesc> customFieldDescMap = new HashMap<>();
for (T customField : customFieldList) {
CustomFieldRefType customFieldRefType = clientService.getBasicMetaData().getCustomFieldRefType(recordType.getType(), customizationType, customField);
if (customFieldRefType != null) {
CustomFieldDesc customFieldDesc = new CustomFieldDesc();
String internalId = (String) getSimpleProperty(customField, "internalId");
String scriptId = (String) getSimpleProperty(customField, "scriptId");
String label = (String) getSimpleProperty(customField, "label");
NsRef customizationRef = new NsRef();
customizationRef.setRefType(RefType.CUSTOMIZATION_REF);
customizationRef.setType(customizationType.getType());
customizationRef.setName(label);
customizationRef.setInternalId(internalId);
customizationRef.setScriptId(scriptId);
customFieldDesc.setCustomizationRef(customizationRef);
customFieldDesc.setName(customizationRef.getScriptId());
customFieldDesc.setCustomFieldType(customFieldRefType);
customFieldDesc.setValueType(getCustomFieldValueClass(customFieldRefType));
customFieldDesc.setNullable(true);
customFieldDescMap.put(customFieldDesc.getName(), customFieldDesc);
}
}
return customFieldDescMap;
}
use of org.talend.components.netsuite.client.model.customfield.CustomFieldRefType in project components by Talend.
the class NetSuiteDatasetRuntimeImpl method writeCustomField.
/**
* Write custom field meta data to a given <code>JsonProperties</code>.
*
* @see NetSuiteSchemaConstants
*
* @param properties properties object which to write meta data to
* @param fieldDesc information about custom field to be used
*/
public static void writeCustomField(JsonProperties properties, CustomFieldDesc fieldDesc) {
NsRef ref = fieldDesc.getCustomizationRef();
CustomFieldRefType customFieldRefType = fieldDesc.getCustomFieldType();
properties.addProp(NetSuiteSchemaConstants.NS_CUSTOM_FIELD, "true");
properties.addProp(NetSuiteSchemaConstants.NS_CUSTOM_FIELD_SCRIPT_ID, ref.getScriptId());
properties.addProp(NetSuiteSchemaConstants.NS_CUSTOM_FIELD_INTERNAL_ID, ref.getInternalId());
properties.addProp(NetSuiteSchemaConstants.NS_CUSTOM_FIELD_CUSTOMIZATION_TYPE, ref.getType());
properties.addProp(NetSuiteSchemaConstants.NS_CUSTOM_FIELD_TYPE, customFieldRefType.name());
}
Aggregations