Search in sources :

Example 1 with SearchRecord

use of com.netsuite.webservices.platform.core.SearchRecord in project tdi-studio-se by Talend.

the class NetsuiteManagement_CXF method submitRequest.

public List<Record> submitRequest(boolean useRequestLevelAuth) throws Exception {
    if (useRequestLevelAuth) {
        initializeStub();
    }
    List<String> list = Arrays.asList(TalendComponentGenerator.transactionTypeList);
    if (list.contains(this.entityClass.getSimpleName())) {
        Method typeSetter = findMethod(this.searchBasicClass, "setType");
        SearchEnumMultiSelectField semsf = new SearchEnumMultiSelectField();
        semsf.getSearchValue().add(TalendComponentGenerator.toInitialLower(this.entityClass.getSimpleName()));
        semsf.setOperator(SearchEnumMultiSelectFieldOperator.ANY_OF);
        typeSetter.invoke(this.searchBasic, new Object[] { semsf });
    }
    if (this.hasCustomCriteria) {
        this.criteriaSetter = findMethod(this.searchBasicClass, "setCustomFieldList");
        SearchCustomFieldList scl = new SearchCustomFieldList();
        scl.getCustomField().addAll(Arrays.asList(this.customCriteria));
        this.criteriaSetter.invoke(this.searchBasic, new Object[] { scl });
    }
    Method basicSetter = findMethod(this.searchClass, "setBasic");
    basicSetter.invoke(this.search, new Object[] { this.searchBasic });
    SearchRecord s = this.search;
    if (this.searchAdvanced != null) {
        s = this.searchAdvanced;
        Method setCriteriaMethod = findMethod(this.searchAdvancedClass, "setCriteria");
        setCriteriaMethod.invoke(this.searchAdvanced, new Object[] { this.search });
    }
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setSearchRecord(s);
    this.searchResult = this._port.search(searchRequest).getSearchResult();
    if (this.searchResult.getStatus().isIsSuccess()) {
        this.searchId = this.searchResult.getSearchId();
        if (this.searchResult.getRecordList() != null) {
            return filterItemSearch();
        }
    }
    return null;
}
Also used : SearchRecord(com.netsuite.webservices.platform.core.SearchRecord) SearchRequest(com.netsuite.webservices.platform.messages.SearchRequest) SearchCustomFieldList(com.netsuite.webservices.platform.core.SearchCustomFieldList) Method(java.lang.reflect.Method) SearchEnumMultiSelectField(com.netsuite.webservices.platform.core.SearchEnumMultiSelectField)

Example 2 with SearchRecord

use of com.netsuite.webservices.platform.core.SearchRecord in project tdi-studio-se by Talend.

the class NetsuiteManagement_CXF method initialize.

public void initialize(String searchentity, String savedSearchId) throws SecurityException, NoSuchMethodException, SOAPException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
    this.entityClass = TalendComponentGenerator.getEntityClass(searchentity);
    this.searchClass = TalendComponentGenerator.getSearchClass(searchentity);
    this.searchBasicClass = TalendComponentGenerator.getSearchBasicClass(searchentity);
    this.searchAdvancedClass = TalendComponentGenerator.getSearchAdvancedClass(searchentity);
    this.customCriteria = new SearchCustomField[1];
    // if type is customRecord
    if (this.searchClass == null) {
        this.searchClass = CustomRecordSearch.class;
        searchentity = CustomRecord.class.getName();
        this.searchAdvancedClass = CustomRecordSearchAdvanced.class;
        this.searchBasicClass = TalendComponentGenerator.getSearchBasicClass(searchentity);
    }
    // search class not found or supported
    if (this.searchClass == null) {
        throw new IllegalArgumentException("SearchClass not found - " + searchentity);
    }
    // get a search class instance
    Constructor<?> constructor = this.searchClass.getConstructor(new Class[0]);
    this.search = ((SearchRecord) constructor.newInstance(new Object[0]));
    // get a advanced search class instance and set SaveSearchId into it
    this.searchAdvanced = null;
    if ((savedSearchId != null) && (savedSearchId.length() > 0)) {
        constructor = this.searchAdvancedClass.getConstructor(new Class[0]);
        this.searchAdvanced = ((SearchRecord) constructor.newInstance(new Object[0]));
        Method setSavedSearchIdMethod = findMethod(this.searchAdvancedClass, "setSavedSearchId");
        Object[] args = { savedSearchId };
        setSavedSearchIdMethod.invoke(this.searchAdvanced, args);
    }
    // search class is itemSearch, it's special
    if (this.searchClass.getSimpleName().equals("ItemSearch")) {
        this.isItemSearch = true;
    }
    // basic search class not found or supported
    if (this.searchBasicClass == null) {
        throw new IllegalArgumentException("SearchBasicClass not found-" + searchentity);
    }
    // get a basic search class instance
    constructor = this.searchBasicClass.getConstructor(null);
    this.searchBasic = ((SearchRecord) constructor.newInstance(new Object[0]));
}
Also used : SearchRecord(com.netsuite.webservices.platform.core.SearchRecord) CustomRecord(com.netsuite.webservices.setup.customization.CustomRecord) Method(java.lang.reflect.Method)

Aggregations

SearchRecord (com.netsuite.webservices.platform.core.SearchRecord)2 Method (java.lang.reflect.Method)2 SearchCustomFieldList (com.netsuite.webservices.platform.core.SearchCustomFieldList)1 SearchEnumMultiSelectField (com.netsuite.webservices.platform.core.SearchEnumMultiSelectField)1 SearchRequest (com.netsuite.webservices.platform.messages.SearchRequest)1 CustomRecord (com.netsuite.webservices.setup.customization.CustomRecord)1