|
|
|
@ -23,7 +23,11 @@ import org.apache.commons.logging.Log;
|
|
|
|
|
import org.apache.commons.logging.LogFactory;
|
|
|
|
|
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
|
|
|
|
import org.wso2.carbon.device.mgt.common.search.Condition;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.search.mgt.*;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.search.mgt.Constants;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.search.mgt.InvalidOperatorException;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.search.mgt.QueryBuilder;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.search.mgt.QueryHolder;
|
|
|
|
|
import org.wso2.carbon.device.mgt.core.search.mgt.ValueType;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
@ -141,14 +145,7 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|
|
|
|
} else {
|
|
|
|
|
querySuffix = querySuffix + " AND DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey()) + con
|
|
|
|
|
.getOperator() + " ? ";
|
|
|
|
|
ValueType type = new ValueType();
|
|
|
|
|
if (Utils.checkColumnType(con.getKey())) {
|
|
|
|
|
type.setColumnType(ValueType.columnType.STRING);
|
|
|
|
|
type.setStringValue(con.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
type.setColumnType(ValueType.columnType.INTEGER);
|
|
|
|
|
type.setIntValue(Integer.parseInt(con.getValue()));
|
|
|
|
|
}
|
|
|
|
|
ValueType type = this.getValueType(con);
|
|
|
|
|
valueType[x] = type;
|
|
|
|
|
x++;
|
|
|
|
|
}
|
|
|
|
@ -189,14 +186,8 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|
|
|
|
querySuffix = querySuffix + " OR DD." + Utils.getDeviceDetailsColumnNames().get(con.getKey()) + con
|
|
|
|
|
.getOperator() + " ? ";
|
|
|
|
|
|
|
|
|
|
ValueType type = new ValueType();
|
|
|
|
|
if (Utils.checkColumnType(con.getKey())) {
|
|
|
|
|
type.setColumnType(ValueType.columnType.STRING);
|
|
|
|
|
type.setStringValue(con.getValue());
|
|
|
|
|
} else {
|
|
|
|
|
type.setColumnType(ValueType.columnType.INTEGER);
|
|
|
|
|
type.setIntValue(Integer.parseInt(con.getValue()));
|
|
|
|
|
}
|
|
|
|
|
ValueType type = this.getValueType(con);
|
|
|
|
|
|
|
|
|
|
valueType[x] = type;
|
|
|
|
|
x++;
|
|
|
|
|
}
|
|
|
|
@ -386,4 +377,35 @@ public class QueryBuilderImpl implements QueryBuilder {
|
|
|
|
|
throw new InvalidOperatorException("Error occurred while building the sql", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns a Value type based on the Condition data.
|
|
|
|
|
*
|
|
|
|
|
* @param con : The condition that passed.
|
|
|
|
|
* @re
|
|
|
|
|
*/
|
|
|
|
|
private ValueType getValueType(Condition con) {
|
|
|
|
|
ValueType type = new ValueType();
|
|
|
|
|
String colValue = Utils.checkColumnType(con.getKey());
|
|
|
|
|
|
|
|
|
|
switch (colValue) {
|
|
|
|
|
case "String":
|
|
|
|
|
type.setColumnType(ValueType.columnType.STRING);
|
|
|
|
|
type.setStringValue(con.getValue());
|
|
|
|
|
break;
|
|
|
|
|
case "Double":
|
|
|
|
|
type.setColumnType(ValueType.columnType.DOUBLE);
|
|
|
|
|
type.setDoubleValue(Double.parseDouble(con.getValue()));
|
|
|
|
|
break;
|
|
|
|
|
case "Integer":
|
|
|
|
|
type.setColumnType(ValueType.columnType.INTEGER);
|
|
|
|
|
type.setIntValue(Integer.parseInt(con.getValue()));
|
|
|
|
|
break;
|
|
|
|
|
case "Long":
|
|
|
|
|
type.setColumnType(ValueType.columnType.STRING);
|
|
|
|
|
type.setLongValue(Long.parseLong(con.getValue()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
}
|