public EdmEntitySet getEntitySet() { return this.uriResourceEntitySet.getEntitySet(); }
public EdmEntitySet getEntitySet() { return this.uriResourceEntitySet.getEntitySet(); }
public EdmEntitySet getEntitySet() { return this.uriResourceEntitySet.getEntitySet(); }
public EdmEntitySet getEntitySet() { return this.uriResourceEntitySet.getEntitySet(); }
public EdmEntityType getEntityType() { return this.uriResourceEntitySet.getEntitySet().getEntityType(); }
private EdmBindingTarget getEntitySet(final UriResourceEntitySet uriResourceEntitySet) { return uriResourceEntitySet.isCollection() ? null : uriResourceEntitySet.getEntitySet(); }
public EdmEntityType getEntityType() { return this.uriResourceEntitySet.getEntitySet().getEntityType(); }
private EdmBindingTarget getEntitySet(final UriResourceEntitySet uriResourceEntitySet) { return uriResourceEntitySet.isCollection() ? null : uriResourceEntitySet.getEntitySet(); }
@Override public void visit(UriResourceEntitySet info) { Table table = DocumentNode.findTable(info.getEntitySet(), this.metadata); EdmEntityType type = info.getEntitySet().getEntityType(); List<UriParameter> keys = info.getKeyPredicates(); this.updateTable = new ScopedTable(table, type, keys); }
private void validateIsSingleton(HttpMethod method) throws ODataHandlerException { final int lastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 1; final UriResource pathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex); if (pathSegment instanceof UriResourceNavigation && uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1) instanceof UriResourceEntitySet && ((UriResourceEntitySet) uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1)).getEntitySet() .getRelatedBindingTarget( pathSegment.getSegmentValue()) instanceof EdmSingleton) { throwMethodNotAllowed(method); } }
private void validateIsSingleton(HttpMethod method) throws ODataHandlerException { final int lastPathSegmentIndex = uriInfo.getUriResourceParts().size() - 1; final UriResource pathSegment = uriInfo.getUriResourceParts().get(lastPathSegmentIndex); if (pathSegment instanceof UriResourceNavigation && uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1) instanceof UriResourceEntitySet && ((UriResourceEntitySet) uriInfo.getUriResourceParts().get(lastPathSegmentIndex - 1)).getEntitySet() .getRelatedBindingTarget( pathSegment.getSegmentValue()) instanceof EdmSingleton) { throwMethodNotAllowed(method); } }
@Override public void visit(UriResourceEntitySet info) { try { this.context = DocumentNode.build(info.getEntitySet().getEntityType(), info.getKeyPredicates(), this.metadata, this.odata, this.nameGenerator, this.aliasedGroups, getUriInfo(), this.parseService); } catch (TeiidException e) { this.exceptions.add(e); } }
public static EdmEntitySet getStartingEdmEntitySet(final UriInfoResource uriInfo,Locale locale) throws ODataApplicationException { EdmEntitySet entitySet = null; final List<UriResource> resourcePaths = uriInfo.getUriResourceParts(); // First must be an entity, an entity collection, a function import, or an action import. blockTypeFilters(resourcePaths.get(0),locale); if (resourcePaths.get(0) instanceof UriResourceEntitySet) { entitySet = ((UriResourceEntitySet) resourcePaths.get(0)).getEntitySet(); }else if (resourcePaths.get(0) instanceof UriResourceFunction) { entitySet = ((UriResourceFunction) resourcePaths.get(0)).getFunctionImport().getReturnedEntitySet(); } else if (resourcePaths.get(0) instanceof UriResourceAction) { entitySet = ((UriResourceAction) resourcePaths.get(0)).getActionImport().getReturnedEntitySet(); } else { getResourceLable(locale); throw new ODataApplicationException(labels.getString("INVALID_RESOURCE_TYPE"), HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), locale,labels.getString("INVALID_RESOURCE_TYPE_CODE")); } return entitySet; }
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()); }
public static DeleteEntityInfo transformToDeleteEntityInfo(UriInfo uriInfo){ DeleteEntityInfo dEinfo=new DeleteEntityInfo(); List<UriResource> uriParts = uriInfo.asUriInfoResource().getUriResourceParts(); UriResource lastUriResourcePart = uriParts.get(uriParts.size() - 1); UriResourceEntitySet uriRN=(UriResourceEntitySet) lastUriResourcePart; EdmEntitySet entitySet = ((UriResourceEntitySet) lastUriResourcePart).getEntitySet(); dEinfo.setEntityName(entitySet.getName()); dEinfo.setParententityName(entitySet.getName()); dEinfo.getColumns().addAll(resolveKeyPredicatesToColumnsUpdate(entitySet.getEntityType(),uriRN.getKeyPredicates())); return dEinfo; }
public static UpdateEntityInfo transformToUpdateEntityInfo(UriInfo uriInfo, DeserializerResult payLoad,boolean merge ,Map<String, AdminDataAnnotation> adminData){ UpdateEntityInfo uEinfo=new UpdateEntityInfo(); List<UriResource> uriParts = uriInfo.asUriInfoResource().getUriResourceParts(); UriResource lastUriResourcePart = uriParts.get(uriParts.size() - 1); UriResourceEntitySet uriRN=(UriResourceEntitySet) lastUriResourcePart; EdmEntitySet entitySet = ((UriResourceEntitySet) lastUriResourcePart).getEntitySet(); uEinfo.setEntityName(entitySet.getName()); uEinfo.setParententityName(entitySet.getName()); // Resolve Columns including Admin Data columns List<Column> columns = resolvePropertiesToColumnsUpdate(entitySet.getEntityType(),payLoad.getEntity(),merge,adminData); uEinfo.setColumns(columns); uEinfo.getColumns().addAll(resolveKeyPredicatesToColumnsUpdate( entitySet.getEntityType() , uriRN.getKeyPredicates() )); return uEinfo; }
@Override public final Entity updateEntity(UriInfo uriInfo, DeserializerResult payLoad,ODataRequest request,ODataResponse response) throws ODataApplicationException { this.conn = getConnection(request); UriResourceEntitySet entitySet = ((UriResourceEntitySet)uriInfo.getUriResourceParts().get(0)); String serviceName = entitySet.getEntityType().getNamespace(); Map<String, AdminDataAnnotation> adminDataMapForCreate = null; try{ adminDataMapForCreate = CSNUtil.getAdminDataMapForUpdate(serviceName,entitySet.getEntitySet().getName(),(conn != null && conn.getClientInfo(APPLICATIONUSER) != null)); }catch(SQLException ex){ CDSRuntimeException cdsRuntimeException = new CDSRuntimeException(CDSRuntimeException.MessageKeys.INTERNAL_ERROR, "UPDATE FAILED WITH INTERNAL ERROR", HttpStatusCode.INTERNAL_SERVER_ERROR.getStatusCode(), HeaderUtil.getlocale(request), "INSERT FAILED WITH INTERNAL ERROR"); logger.error("INSERT FAILED WITH INTERNAL ERROR", ex); throw cdsRuntimeException; } UpdateEntityInfo uEinfo=cdsprocessor.transormToUpdateEntityInfo(uriInfo, payLoad, request,(request!=null&&request.getMethod()==HttpMethod.PUT)?false:true ,adminDataMapForCreate); cdsprocessor.executeUpdate(uriInfo, uEinfo, conn, request); //--- Read Entity after successful UPdate --- if(isDraftFlow()) { return readDataFromMainTable(uriInfo, request, DraftUtilsV4.extractKeyPredicateFilterExpressions(uriInfo, false)); }else { return readEntity(uriInfo,request,response, false).getEntity(); } }
private Property determineProperty(final EdmEntitySet targetEdmEntitySet, final EntityCollection result) { UriResourceProperty uriProperty = null; Property property = null; boolean found = false; List<Property> properties = result.getEntities().get(0).getProperties(); for (UriResource hop : uriInfo.getUriResourceParts()) { if (hop.getKind().equals(UriResourceKind.entitySet) && ((UriResourceEntitySet) hop).getEntitySet() == targetEdmEntitySet || hop.getKind().equals(UriResourceKind.navigationProperty) && ((UriResourceNavigation) hop).getType() == targetEdmEntitySet.getEntityType()) found = true; if (found && hop.getKind().equals(UriResourceKind.complexProperty)) { uriProperty = (UriResourceProperty) hop; property = getProperty(uriProperty.getProperty().getName(), properties); if (!uriProperty.isCollection() && property != null)// Here it is assumed that the collection is the last hop // anyhow properties = ((ComplexValue) property.getValue()).getValue(); } } return property; }
@Override public void visit(UriResourceEntitySet info) { EdmEntityType edmEntityType = info.getEntitySet().getEntityType(); if (this.root) { try { this.ctxExpression = DocumentNode.build(edmEntityType, info.getKeyPredicates(), this.metadata, this.odata, this.nameGenerator, true, getUriInfo(), null); } catch (TeiidException e) { throw new TeiidRuntimeException(e); } } else { if (this.ctxQuery.getEdmEntityType().getFullQualifiedName().equals(edmEntityType.getFullQualifiedName())) { this.ctxExpression = this.ctxQuery; } else { for (DocumentNode er: this.ctxQuery.getSibilings()) { if (er.getEdmEntityType().getFullQualifiedName().equals(edmEntityType.getFullQualifiedName())) { this.ctxExpression = er; break; } } } } }