Search in sources :

Example 1 with CustomRecord

use of com.netsuite.webservices.setup.customization.CustomRecord 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)1 CustomRecord (com.netsuite.webservices.setup.customization.CustomRecord)1 Method (java.lang.reflect.Method)1