Search in sources :

Example 1 with BasicRecordType

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

the class DefaultCustomMetaDataSource method retrieveCustomFields.

/**
 * Retrieve custom fields for a given record type.
 *
 * @param recordType record type
 * @throws NetSuiteException if an error occurs during retrieving of customization data
 */
protected void retrieveCustomFields(RecordTypeDesc recordType) throws NetSuiteException {
    retrieveCustomFields();
    Map<String, CustomFieldDesc> fieldDescMap = new HashMap<>();
    for (BasicRecordType customizationType : fieldCustomizationTypes) {
        List<?> customFieldList = customFieldMap.get(customizationType);
        Map<String, CustomFieldDesc> customFieldDescMap = createCustomFieldDescMap(clientService, recordType, customizationType, customFieldList);
        fieldDescMap.putAll(customFieldDescMap);
    }
    recordCustomFieldMap.put(recordType.getType(), fieldDescMap);
}
Also used : HashMap(java.util.HashMap) CustomFieldDesc(org.talend.components.netsuite.client.model.CustomFieldDesc) BasicRecordType(org.talend.components.netsuite.client.model.BasicRecordType)

Example 2 with BasicRecordType

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

the class SearchQuery method toNativeQuery.

/**
 * Finalize building of search query and get built NetSuite's search record object.
 *
 * @return
 * @throws NetSuiteException if an error occurs during updating of search record
 */
public SearchT toNativeQuery() throws NetSuiteException {
    initSearch();
    BasicRecordType basicRecordType = BasicRecordType.getByType(searchRecordTypeDesc.getType());
    if (BasicRecordType.TRANSACTION == basicRecordType) {
        SearchFieldAdapter<?> fieldAdapter = metaDataSource.getBasicMetaData().getSearchFieldAdapter(SearchFieldType.SELECT);
        Object searchTypeField = fieldAdapter.populate("List.anyOf", Arrays.asList(recordTypeInfo.getRecordType().getType()));
        setProperty(searchBasic, "type", searchTypeField);
    } else if (BasicRecordType.CUSTOM_RECORD == basicRecordType) {
        CustomRecordTypeInfo customRecordTypeInfo = (CustomRecordTypeInfo) recordTypeInfo;
        NsRef customizationRef = customRecordTypeInfo.getCustomizationRef();
        Object recType = metaDataSource.getBasicMetaData().createInstance(RefType.CUSTOMIZATION_REF.getTypeName());
        setProperty(recType, "scriptId", customizationRef.getScriptId());
        setProperty(recType, "internalId", customizationRef.getInternalId());
        setProperty(searchBasic, "recType", recType);
    }
    // Set custom fields
    if (!customFieldList.isEmpty()) {
        Object customFieldListWrapper = metaDataSource.getBasicMetaData().createInstance("SearchCustomFieldList");
        List<Object> customFields = (List<Object>) getProperty(customFieldListWrapper, "customField");
        for (Object customField : customFieldList) {
            customFields.add(customField);
        }
        setProperty(searchBasic, "customFieldList", customFieldListWrapper);
    }
    SearchT searchRecord;
    if (searchRecordTypeDesc.getSearchClass() != null) {
        setProperty(search, "basic", searchBasic);
        searchRecord = search;
        if (searchAdvanced != null) {
            setProperty(searchAdvanced, "condition", search);
            searchRecord = searchAdvanced;
        }
    } else {
        searchRecord = searchBasic;
    }
    return searchRecord;
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) BasicRecordType(org.talend.components.netsuite.client.model.BasicRecordType) CustomRecordTypeInfo(org.talend.components.netsuite.client.model.CustomRecordTypeInfo) NsRef(org.talend.components.netsuite.client.NsRef)

Example 3 with BasicRecordType

use of org.talend.components.netsuite.client.model.BasicRecordType 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 4 with BasicRecordType

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

the class DefaultCustomMetaDataSource method retrieveCustomFields.

/**
 * Retrieve custom fields for standard record types from NetSuite web service.
 *
 * @throws NetSuiteException if an error occurs during retrieving of customization data
 */
protected void retrieveCustomFields() throws NetSuiteException {
    if (customFieldsLoaded) {
        return;
    }
    Map<BasicRecordType, List<NsRef>> fieldCustomizationRefs = new HashMap<>(32);
    for (BasicRecordType customizationType : fieldCustomizationTypes) {
        List<NsRef> customizationRefs = customMetaDataRetriever.retrieveCustomizationIds(customizationType);
        fieldCustomizationRefs.put(customizationType, customizationRefs);
    }
    for (BasicRecordType customizationType : fieldCustomizationTypes) {
        List<NsRef> customizationRefs = fieldCustomizationRefs.get(customizationType);
        List<?> fieldCustomizationList = customMetaDataRetriever.retrieveCustomizations(customizationRefs);
        customFieldMap.put(customizationType, fieldCustomizationList);
    }
    customFieldsLoaded = true;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) BasicRecordType(org.talend.components.netsuite.client.model.BasicRecordType)

Aggregations

BasicRecordType (org.talend.components.netsuite.client.model.BasicRecordType)4 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)2 List (java.util.List)2 CustomRecordTypeInfo (org.talend.components.netsuite.client.model.CustomRecordTypeInfo)2 NsRef (org.talend.components.netsuite.client.NsRef)1 CustomFieldDesc (org.talend.components.netsuite.client.model.CustomFieldDesc)1 RecordTypeDesc (org.talend.components.netsuite.client.model.RecordTypeDesc)1