private MapXNodeImpl serializeInOidFilter(InOidFilter filter) { MapXNodeImpl clauseMap = new MapXNodeImpl(); if (filter.getOids() != null && !filter.getOids().isEmpty()) { ListXNodeImpl valuesNode = new ListXNodeImpl(); for (String oid : filter.getOids()) { XNodeImpl val = createPrimitiveXNode(oid, DOMUtil.XSD_STRING); valuesNode.add(val); } clauseMap.put(ELEMENT_VALUE, valuesNode); } else if (filter.getExpression() != null) { // TODO serialize expression } else { // just an empty filter -- ignore it // throw new SchemaException("InOid filter with no values nor expression"); } if (filter.isConsiderOwner()) { clauseMap.put(ELEMENT_CONSIDER_OWNER, new PrimitiveXNodeImpl<>(true)); } return createFilter(CLAUSE_IN_OID, clauseMap); }
@Override public Condition interpret() throws QueryException { String hqlPath = getBaseHqlEntity().getHqlPath() + "."; Collection<?> idValues; // TODO check applicability if (filter.isConsiderOwner()) { hqlPath += "ownerOid"; idValues = filter.getOids(); } else if (RObject.class.isAssignableFrom(getBaseHqlEntity().getJpaDefinition().getJpaClass())) { hqlPath += "oid"; idValues = filter.getOids(); } else if (Container.class.isAssignableFrom(getBaseHqlEntity().getJpaDefinition().getJpaClass())) { hqlPath += "id"; // quite a hack idValues = toIntList(filter.getOids()); } else { throw new QueryException("InOidRestriction cannot be applied to the entity: " + getBaseHqlEntity()); } return getContext().getHibernateQuery().createIn(hqlPath, idValues); }