Search in sources :

Example 11 with CustomRecordTypeInfo

use of org.talend.components.netsuite.client.model.CustomRecordTypeInfo in project components by Talend.

the class DefaultCustomMetaDataSource method retrieveCustomRecordTypes.

/**
 * Retrieve custom record types from NetSuite web service.
 *
 * @see #customRecordTypeMap
 *
 * @throws NetSuiteException if an error occurs during retrieving of customization data
 */
protected void retrieveCustomRecordTypes() throws NetSuiteException {
    if (customRecordTypesLoaded) {
        return;
    }
    List<NsRef> customTypes = new ArrayList<>();
    List<NsRef> customRecordTypes = customMetaDataRetriever.retrieveCustomizationIds(BasicRecordType.CUSTOM_RECORD_TYPE);
    customTypes.addAll(customRecordTypes);
    List<NsRef> customTransactionTypes = customMetaDataRetriever.retrieveCustomizationIds(BasicRecordType.CUSTOM_TRANSACTION_TYPE);
    customTypes.addAll(customTransactionTypes);
    for (NsRef customizationRef : customTypes) {
        String recordType = customizationRef.getType();
        RecordTypeDesc recordTypeDesc = null;
        BasicRecordType basicRecordType = BasicRecordType.getByType(recordType);
        if (basicRecordType != null) {
            recordTypeDesc = clientService.getBasicMetaData().getRecordType(toInitialUpper(basicRecordType.getSearchType()));
        }
        CustomRecordTypeInfo customRecordTypeInfo = new CustomRecordTypeInfo(customizationRef.getScriptId(), recordTypeDesc, customizationRef);
        customRecordTypeMap.put(customRecordTypeInfo.getName(), customRecordTypeInfo);
    }
    customRecordTypesLoaded = true;
}
Also used : RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) ArrayList(java.util.ArrayList) BasicRecordType(org.talend.components.netsuite.client.model.BasicRecordType) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo)

Example 12 with CustomRecordTypeInfo

use of org.talend.components.netsuite.client.model.CustomRecordTypeInfo in project components by Talend.

the class DefaultCustomMetaDataSource method getCustomFieldsImpl.

/**
 * Get custom field descriptors for a given record type.
 *
 * @param recordTypeInfo record type info
 * @return custom field descriptors as map
 * @throws NetSuiteException if an error occurs during obtaining of customization data
 */
protected Map<String, CustomFieldDesc> getCustomFieldsImpl(RecordTypeInfo recordTypeInfo) throws NetSuiteException {
    RecordTypeDesc recordType = recordTypeInfo.getRecordType();
    Map<String, CustomFieldDesc> fieldDescMap;
    if (recordTypeInfo instanceof CustomRecordTypeInfo) {
        fieldDescMap = customRecordCustomFieldMap.get(recordTypeInfo.getName());
        if (fieldDescMap == null) {
            retrieveCustomRecordCustomFields((CustomRecordTypeInfo) recordTypeInfo);
            fieldDescMap = customRecordCustomFieldMap.get(recordTypeInfo.getName());
        }
    } else {
        fieldDescMap = recordCustomFieldMap.get(recordType.getType());
        if (fieldDescMap == null) {
            retrieveCustomFields(recordType);
            fieldDescMap = recordCustomFieldMap.get(recordType.getType());
        }
    }
    return fieldDescMap;
}
Also used : RecordTypeDesc(org.talend.components.netsuite.client.model.RecordTypeDesc) CustomFieldDesc(org.talend.components.netsuite.client.model.CustomFieldDesc) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo)

Aggregations

CustomRecordTypeInfo (org.talend.components.netsuite.client.model.CustomRecordTypeInfo)12 RecordTypeDesc (org.talend.components.netsuite.client.model.RecordTypeDesc)8 CustomFieldDesc (org.talend.components.netsuite.client.model.CustomFieldDesc)6 ArrayList (java.util.ArrayList)5 Schema (org.apache.avro.Schema)4 NsRef (org.talend.components.netsuite.client.NsRef)4 FieldDesc (org.talend.components.netsuite.client.model.FieldDesc)4 SearchRecordTypeDesc (org.talend.components.netsuite.client.model.SearchRecordTypeDesc)4 RecordTypeInfo (org.talend.components.netsuite.client.model.RecordTypeInfo)3 TypeDesc (org.talend.components.netsuite.client.model.TypeDesc)3 CustomRecordType (com.netsuite.webservices.test.setup.customization.CustomRecordType)2 List (java.util.List)2 Test (org.junit.Test)2 CustomFieldSpec (org.talend.components.netsuite.CustomFieldSpec)2 BasicRecordType (org.talend.components.netsuite.client.model.BasicRecordType)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)1 HashSet (java.util.HashSet)1 BeanInfo (org.talend.components.netsuite.client.model.beans.BeanInfo)1