final StringBuilder bld = new StringBuilder();
// Contains used identifiers in order to avoid replications
final Set<String> used = new HashSet<String>();
USchema schema;
// Create several clauses: one for eanch identifiers
for (int i = 0; i < identifiers.size(); i++) {
if (!used.contains(identifiers.get(i))) {
// verify schema existence and get schema type
schema = schemaDAO.find(identifiers.get(i), USchema.class);
if (schema == null) {
LOG.error("Invalid schema name '{}'", identifiers.get(i));
throw new InvalidSearchConditionException("Invalid schema name " + identifiers.get(i));
}
// clear builder
bld.delete(0, bld.length());
bld.append("(");
// set schema name
bld.append("s.name = '").append(identifiers.get(i)).append("'");
bld.append(" AND ");
bld.append("s.name = a.schema_name").append(" AND ");
bld.append("a.id = v.attribute_id");
bld.append(" AND ");
// use a value clause different for eanch different schema type
switch (schema.getType()) {
case Boolean:
bld.append("v.booleanValue = '").append(attrValues.get(i)).append("'");
break;
case Long:
bld.append("v.longValue = ").append(attrValues.get(i));