public static List<UriParameter> determineKeyPredicates(final UriResource uriResourceItem) throws ODataApplicationException { if (uriResourceItem instanceof UriResourceEntitySet) return ((UriResourceEntitySet) uriResourceItem).getKeyPredicates(); else if (uriResourceItem instanceof UriResourceNavigation) return ((UriResourceNavigation) uriResourceItem).getKeyPredicates(); else throw new ODataJPAQueryException(ODataJPAQueryException.MessageKeys.NOT_SUPPORTED_RESOURCE_TYPE, HttpStatusCode.BAD_REQUEST, uriResourceItem.getKind().name()); } }
public static EdmEntitySetInfo determineTargetEntitySetAndKeys(final List<UriResource> resources) { EdmEntitySet targetEdmEntitySet = null; List<UriParameter> targteKeyPredicates = new ArrayList<>(); StringBuilder naviPropertyName = new StringBuilder(); for (final UriResource resourceItem : resources) { if (resourceItem.getKind() == UriResourceKind.entitySet) { targetEdmEntitySet = ((UriResourceEntitySet) resourceItem).getEntitySet(); targteKeyPredicates = ((UriResourceEntitySet) resourceItem).getKeyPredicates(); } if (resourceItem.getKind() == UriResourceKind.complexProperty) { naviPropertyName.append(((UriResourceComplexProperty) resourceItem).getProperty().getName()); naviPropertyName.append(JPAPath.PATH_SEPERATOR); } if (resourceItem.getKind() == UriResourceKind.navigationProperty) { naviPropertyName.append(((UriResourceNavigation) resourceItem).getProperty().getName()); targteKeyPredicates = ((UriResourceNavigation) resourceItem).getKeyPredicates(); final EdmBindingTarget edmBindingTarget = targetEdmEntitySet.getRelatedBindingTarget(naviPropertyName .toString()); if (edmBindingTarget instanceof EdmEntitySet) targetEdmEntitySet = (EdmEntitySet) edmBindingTarget; naviPropertyName = new StringBuilder(); } } return new EdmEntitySetResult(targetEdmEntitySet, targteKeyPredicates, naviPropertyName.toString()); }
public static EdmEntitySetInfo determineModifyEntitySetAndKeys(final List<UriResource> resources) { EdmEntitySet targetEdmEntitySet = null; List<UriParameter> targteKeyPredicates = new ArrayList<>(); StringBuilder naviPropertyName = new StringBuilder(); for (final UriResource resourceItem : resources) { if (resourceItem.getKind() == UriResourceKind.entitySet) { targetEdmEntitySet = ((UriResourceEntitySet) resourceItem).getEntitySet(); targteKeyPredicates = ((UriResourceEntitySet) resourceItem).getKeyPredicates(); } if (resourceItem.getKind() == UriResourceKind.complexProperty) { naviPropertyName.append(((UriResourceComplexProperty) resourceItem).getProperty().getName()); naviPropertyName.append(JPAPath.PATH_SEPERATOR); } if (resourceItem.getKind() == UriResourceKind.navigationProperty) { naviPropertyName.append(((UriResourceNavigation) resourceItem).getProperty().getName()); final List<UriParameter> keyPredicates = ((UriResourceNavigation) resourceItem).getKeyPredicates(); if (!keyPredicates.isEmpty()) { targteKeyPredicates = keyPredicates; final EdmBindingTarget edmBindingTarget = targetEdmEntitySet.getRelatedBindingTarget(naviPropertyName .toString()); if (edmBindingTarget instanceof EdmEntitySet) targetEdmEntitySet = (EdmEntitySet) edmBindingTarget; naviPropertyName = new StringBuilder(); } } } return new EdmEntitySetResult(targetEdmEntitySet, targteKeyPredicates, naviPropertyName.toString()); }
if (!skipKeys && !nav.getKeyPredicates().isEmpty()) { sb.append("("); sb.append(helper.buildContextURLKeyPredicate(nav.getKeyPredicates())); sb.append(")");
if (!skipKeys && !nav.getKeyPredicates().isEmpty()) { sb.append("("); sb.append(helper.buildContextURLKeyPredicate(nav.getKeyPredicates())); sb.append(")");
@Override public void visit(UriResourceNavigation info) { EdmNavigationProperty property = info.getProperty(); try { DocumentNode joinResource = DocumentNode.build(property.getType(), info.getKeyPredicates(), this.metadata, this.odata, this.nameGenerator, true, getUriInfo(), parseService); this.context.joinTable(joinResource, property, JoinType.JOIN_INNER); // In the context of canonical queries if key predicates are available then do not set the criteria if (joinResource.getCriteria() == null) { joinResource.addCriteria(this.context.getCriteria()); } this.context = joinResource; this.navigation = true; } catch (TeiidException e) { this.exceptions.add(e); } }
@Override public void visit(UriResourceNavigation info) { try { DocumentNode navigationResource = DocumentNode.build( (EdmEntityType) info.getType(), info.getKeyPredicates(), this.metadata, this.odata, this.nameGenerator, true, getUriInfo(), this.parseService); Query query = new Query(); query.setSelect(new Select(Arrays.asList(new AggregateSymbol(AggregateSymbol.Type.COUNT.name(), false, null)))); query.setFrom(new From(Arrays.asList(navigationResource.getFromClause()))); Criteria criteria = this.ctxQuery.buildJoinCriteria(navigationResource, info.getProperty()); if (criteria == null) { throw new TeiidException(ODataPlugin.Event.TEIID16037, ODataPlugin.Util.gs(ODataPlugin.Event.TEIID16037)); } query.setCriteria(criteria); this.stack.add(new ScalarSubquery(query)); } catch (TeiidException e) { throw new TeiidRuntimeException(e); } }
putType(node, TYPE_FILTER_ON_ENTRY_NAME, ((UriResourceEntitySet) segment).getTypeFilterOnEntry()); } else if (segment instanceof UriResourceNavigation) { putParameters(node, KEYS_NAME, ((UriResourceNavigation) segment).getKeyPredicates()); putType(node, TYPE_FILTER_ON_COLLECTION_NAME, ((UriResourceNavigation) segment).getTypeFilterOnCollection()); putType(node, TYPE_FILTER_ON_ENTRY_NAME, ((UriResourceNavigation) segment).getTypeFilterOnEntry());
putType(node, TYPE_FILTER_ON_ENTRY_NAME, ((UriResourceEntitySet) segment).getTypeFilterOnEntry()); } else if (segment instanceof UriResourceNavigation) { putParameters(node, KEYS_NAME, ((UriResourceNavigation) segment).getKeyPredicates()); putType(node, TYPE_FILTER_ON_COLLECTION_NAME, ((UriResourceNavigation) segment).getTypeFilterOnCollection()); putType(node, TYPE_FILTER_ON_ENTRY_NAME, ((UriResourceNavigation) segment).getTypeFilterOnEntry());
@Override public void visit(UriResourceNavigation info) { EdmNavigationProperty property = info.getProperty(); this.referenceTable = new ScopedTable(DocumentNode.findTable(property.getType(), this.metadata), property.getType(), info.getKeyPredicates()); if (property.isCollection()) { ForeignKey fk = DocumentNode.joinFK(referenceTable, this.updateTable, property); referenceTable.setFk(fk); ScopedTable temp = this.updateTable; this.updateTable = referenceTable; this.referenceTable = temp; this.collection = true; } else { ForeignKey fk = DocumentNode.joinFK(this.updateTable, referenceTable, property); this.updateTable.setFk(fk); } }
appendType(gen, "typeFilterOnEntry", ((UriResourceEntitySet) resource).getTypeFilterOnEntry()); } else if (resource instanceof UriResourceNavigation) { appendParameters(gen, "keys", ((UriResourceNavigation) resource).getKeyPredicates()); appendType(gen, "typeFilterOnCollection", ((UriResourceNavigation) resource).getTypeFilterOnCollection()); appendType(gen, "typeFilterOnEntry", ((UriResourceNavigation) resource).getTypeFilterOnEntry());
prepareFilterForKeyPredicatesNavigation(uriRN.getKeyPredicates(), entity, eInfo);
appendType(gen, "typeFilterOnEntry", ((UriResourceEntitySet) resource).getTypeFilterOnEntry()); } else if (resource instanceof UriResourceNavigation) { appendParameters(gen, "keys", ((UriResourceNavigation) resource).getKeyPredicates()); appendType(gen, "typeFilterOnCollection", ((UriResourceNavigation) resource).getTypeFilterOnCollection()); appendType(gen, "typeFilterOnEntry", ((UriResourceNavigation) resource).getTypeFilterOnEntry());
prepareFilterForKeyPredicatesNavigation(uriRN.getKeyPredicates(), entity,eInfo);
prepareFilterForKeyPredicatesNavigation(uriRN.getKeyPredicates(), entity, eInfo);