Search in sources :

Example 1 with SearchEnumMultiSelectField

use of com.netsuite.webservices.platform.core.SearchEnumMultiSelectField 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 SearchEnumMultiSelectField

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

the class NetsuiteManagement_CXF method getSearchField.

private Object getSearchField(Class<?> searchClass, List<String> searchValue, String searchFieldName, String searchOperator) throws DatatypeConfigurationException {
    Object criteria = null;
    Method getFieldMethod = findMethod(searchClass, "get" + searchFieldName);
    String searchType = getFieldMethod.getReturnType().getSimpleName();
    if (searchType.equals("SearchStringField")) {
        SearchStringField searchArgumentType = new SearchStringField();
        if (searchValue != null && searchValue.size() != 0) {
            searchArgumentType.setSearchValue(searchValue.get(0));
        }
        searchArgumentType.setOperator(SearchStringFieldOperator.fromValue(searchOperator));
        criteria = searchArgumentType;
    } else if (searchType.equals("SearchLongField")) {
        SearchLongField searchArgumentType = new SearchLongField();
        if (searchValue != null && searchValue.size() != 0) {
            searchArgumentType.setSearchValue(Long.valueOf(Long.parseLong(searchValue.get(0))));
            if (searchValue.size() > 1) {
                searchArgumentType.setSearchValue2(Long.valueOf(Long.parseLong(searchValue.get(1))));
            }
        }
        searchArgumentType.setOperator(SearchLongFieldOperator.fromValue(searchOperator));
        criteria = searchArgumentType;
    } else if (searchType.equals("SearchDateField")) {
        SearchDateField searchArgumentType = new SearchDateField();
        if (searchValue != null && searchValue.size() != 0) {
            Calendar calValue = Calendar.getInstance();
            String dateFormat = "yyyy-MM-dd";
            String timeFormat = "HH:mm:ss";
            String format = dateFormat + " " + timeFormat;
            if (searchValue.get(0).length() == dateFormat.length()) {
                format = dateFormat;
            }
            if (searchValue.get(0).length() == timeFormat.length()) {
                searchValue.set(0, new SimpleDateFormat(dateFormat).format(calValue.getTime()) + " " + searchValue.get(0));
            }
            DateFormat df = new SimpleDateFormat(format);
            try {
                calValue.setTime(df.parse(searchValue.get(0)));
            } catch (ParseException e) {
                e.printStackTrace();
            }
            XMLGregorianCalendar xts = DatatypeFactory.newInstance().newXMLGregorianCalendar();
            xts.setYear(calValue.get(Calendar.YEAR));
            xts.setMonth(calValue.get(Calendar.MONTH) + 1);
            xts.setDay(calValue.get(Calendar.DAY_OF_MONTH));
            xts.setHour(calValue.get(Calendar.HOUR_OF_DAY));
            xts.setMinute(calValue.get(Calendar.MINUTE));
            xts.setSecond(calValue.get(Calendar.SECOND));
            xts.setMillisecond(calValue.get(Calendar.MILLISECOND));
            xts.setTimezone(calValue.get(Calendar.ZONE_OFFSET) / 60000);
            searchArgumentType.setSearchValue(xts);
            if (searchValue.size() > 1) {
                try {
                    calValue.setTime(df.parse(searchValue.get(1)));
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                XMLGregorianCalendar xts2 = DatatypeFactory.newInstance().newXMLGregorianCalendar();
                xts2.setYear(calValue.get(Calendar.YEAR));
                xts2.setMonth(calValue.get(Calendar.MONTH) + 1);
                xts2.setDay(calValue.get(Calendar.DAY_OF_MONTH));
                xts2.setHour(calValue.get(Calendar.HOUR_OF_DAY));
                xts2.setMinute(calValue.get(Calendar.MINUTE));
                xts2.setSecond(calValue.get(Calendar.SECOND));
                xts2.setMillisecond(calValue.get(Calendar.MILLISECOND));
                xts2.setTimezone(calValue.get(Calendar.ZONE_OFFSET) / 60000);
                searchArgumentType.setSearchValue2(xts2);
            }
        }
        searchArgumentType.setOperator(SearchDateFieldOperator.fromValue(searchOperator));
        criteria = searchArgumentType;
    } else if (searchType.equals("SearchBooleanField")) {
        SearchBooleanField searchArgumentType = new SearchBooleanField();
        searchArgumentType.setSearchValue(Boolean.valueOf(searchValue.get(0)));
        criteria = searchArgumentType;
    } else if (searchType.equals("SearchDoubleField")) {
        SearchDoubleField searchArgumentType = new SearchDoubleField();
        if (searchValue != null && searchValue.size() != 0) {
            searchArgumentType.setSearchValue(Double.valueOf(Double.parseDouble(searchValue.get(0))));
            if (searchValue.size() > 1) {
                searchArgumentType.setSearchValue2(Double.valueOf(Double.parseDouble(searchValue.get(1))));
            }
        }
        searchArgumentType.setOperator(SearchDoubleFieldOperator.fromValue(searchOperator));
        criteria = searchArgumentType;
    } else if (searchType.equals("SearchMultiSelectField")) {
        SearchMultiSelectField searchArgumentType = new SearchMultiSelectField();
        List<RecordRef> values = searchArgumentType.getSearchValue();
        for (int i = 0; i < searchValue.size(); i++) {
            RecordRef ref = new RecordRef();
            ref.setName(searchValue.get(i));
            ref.setInternalId(searchValue.get(i));
            ref.setExternalId(null);
            ref.setType(null);
            values.add(ref);
        }
        searchArgumentType.setOperator(SearchMultiSelectFieldOperator.fromValue(searchOperator));
        criteria = searchArgumentType;
    } else if (searchType.equals("SearchEnumMultiSelectField")) {
        SearchEnumMultiSelectField searchArgumentType = new SearchEnumMultiSelectField();
        searchArgumentType.getSearchValue().addAll(searchValue);
        searchArgumentType.setOperator(SearchEnumMultiSelectFieldOperator.fromValue(searchOperator));
        criteria = searchArgumentType;
    } else if (searchType.equals("String[]")) {
        SearchEnumMultiSelectField searchArgumentType = new SearchEnumMultiSelectField();
        searchArgumentType.getSearchValue().addAll(searchValue);
        searchArgumentType.setOperator(SearchEnumMultiSelectFieldOperator.fromValue(searchOperator));
        criteria = searchArgumentType;
    } else {
        throw new IllegalArgumentException("Unsupported search field type: " + searchType);
    }
    return criteria;
}
Also used : SearchDateField(com.netsuite.webservices.platform.core.SearchDateField) Calendar(java.util.Calendar) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) RecordRef(com.netsuite.webservices.platform.core.RecordRef) ListOrRecordRef(com.netsuite.webservices.platform.core.ListOrRecordRef) Method(java.lang.reflect.Method) SearchLongField(com.netsuite.webservices.platform.core.SearchLongField) SearchMultiSelectField(com.netsuite.webservices.platform.core.SearchMultiSelectField) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) SearchBooleanField(com.netsuite.webservices.platform.core.SearchBooleanField) SearchDoubleField(com.netsuite.webservices.platform.core.SearchDoubleField) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat) SearchStringField(com.netsuite.webservices.platform.core.SearchStringField) List(java.util.List) SearchCustomFieldList(com.netsuite.webservices.platform.core.SearchCustomFieldList) ArrayList(java.util.ArrayList) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) SearchEnumMultiSelectField(com.netsuite.webservices.platform.core.SearchEnumMultiSelectField)

Aggregations

SearchCustomFieldList (com.netsuite.webservices.platform.core.SearchCustomFieldList)2 SearchEnumMultiSelectField (com.netsuite.webservices.platform.core.SearchEnumMultiSelectField)2 Method (java.lang.reflect.Method)2 ListOrRecordRef (com.netsuite.webservices.platform.core.ListOrRecordRef)1 RecordRef (com.netsuite.webservices.platform.core.RecordRef)1 SearchBooleanField (com.netsuite.webservices.platform.core.SearchBooleanField)1 SearchDateField (com.netsuite.webservices.platform.core.SearchDateField)1 SearchDoubleField (com.netsuite.webservices.platform.core.SearchDoubleField)1 SearchLongField (com.netsuite.webservices.platform.core.SearchLongField)1 SearchMultiSelectField (com.netsuite.webservices.platform.core.SearchMultiSelectField)1 SearchRecord (com.netsuite.webservices.platform.core.SearchRecord)1 SearchStringField (com.netsuite.webservices.platform.core.SearchStringField)1 SearchRequest (com.netsuite.webservices.platform.messages.SearchRequest)1 DateFormat (java.text.DateFormat)1 ParseException (java.text.ParseException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 List (java.util.List)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1