use of com.netsuite.webservices.platform.core.SearchMultiSelectCustomField in project tdi-studio-se by Talend.
the class NetsuiteManagement_CXF method search.
public void search(String searchentity, String searchFieldName, String searchOperator, List<String> searchValue, String forcedType) throws DatatypeConfigurationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
if ((searchValue.get(0) != null) && (searchFieldName != null)) {
this.criteriaSetter = findMethod(this.searchBasicClass, "set" + searchFieldName);
if (this.criteriaSetter == null) {
SearchCustomField customCriteria = null;
if (forcedType.equals("String")) {
SearchStringCustomField searchArgumentType = new SearchStringCustomField();
searchArgumentType.setInternalId(searchFieldName);
if (searchValue != null && searchValue.size() != 0) {
searchArgumentType.setSearchValue(searchValue.get(0));
}
searchArgumentType.setOperator(SearchStringFieldOperator.fromValue(searchOperator));
customCriteria = searchArgumentType;
} else if (forcedType.equals("Long")) {
SearchLongCustomField searchArgumentType = new SearchLongCustomField();
searchArgumentType.setInternalId(searchFieldName);
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));
customCriteria = searchArgumentType;
} else if (forcedType.equals("Date")) {
SearchDateCustomField searchArgumentType = new SearchDateCustomField();
if (searchValue != null && searchValue.size() != 0) {
Calendar calValue = Calendar.getInstance();
Calendar calValue2 = 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));
if (searchValue.size() > 1) {
searchValue.set(1, new SimpleDateFormat(dateFormat).format(calValue.getTime()) + " " + searchValue.get(1));
}
}
DateFormat df = new SimpleDateFormat(format);
try {
calValue.setTime(df.parse(searchValue.get(0)));
if (searchValue.size() > 1) {
calValue2.setTime(df.parse(searchValue.get(1)));
}
} 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) {
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));
customCriteria = searchArgumentType;
} else if (forcedType.equals("Boolean")) {
SearchBooleanCustomField searchArgumentType = new SearchBooleanCustomField();
searchArgumentType.setInternalId(searchFieldName);
searchArgumentType.setSearchValue(Boolean.valueOf(Boolean.parseBoolean(searchValue.get(0))));
customCriteria = searchArgumentType;
} else if (forcedType.equals("Double")) {
SearchDoubleCustomField searchArgumentType = new SearchDoubleCustomField();
searchArgumentType.setInternalId(searchFieldName);
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));
customCriteria = searchArgumentType;
} else if (forcedType.equals("List")) {
SearchMultiSelectCustomField searchArgumentType = new SearchMultiSelectCustomField();
int len = searchValue.size();
List<ListOrRecordRef> lr = searchArgumentType.getSearchValue();
for (int i = 0; i < len; i++) {
ListOrRecordRef lRecordRef = new ListOrRecordRef();
lRecordRef.setName(searchValue.get(i));
lr.add(lRecordRef);
}
searchArgumentType.setOperator(SearchMultiSelectFieldOperator.fromValue(searchOperator));
customCriteria = searchArgumentType;
} else {
throw new IllegalArgumentException("Unsupported search field type: " + forcedType);
}
push(customCriteria);
this.hasCustomCriteria = true;
} else {
this.criteriaSetter.invoke(this.searchBasic, new Object[] { getSearchField(this.searchBasicClass, searchValue, searchFieldName, searchOperator) });
}
}
}
Aggregations