@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 EdmBindingTarget getEntitySet(final UriResourceEntitySet uriResourceEntitySet) { return uriResourceEntitySet.isCollection() ? null : uriResourceEntitySet.getEntitySet(); }
appendParameters(gen, "keys", ((UriResourceEntitySet) resource).getKeyPredicates()); appendType(gen, "typeFilterOnCollection", ((UriResourceEntitySet) resource).getTypeFilterOnCollection()); appendType(gen, "typeFilterOnEntry", ((UriResourceEntitySet) resource).getTypeFilterOnEntry()); } else if (resource instanceof UriResourceNavigation) { appendParameters(gen, "keys", ((UriResourceNavigation) resource).getKeyPredicates());
public EdmEntitySet getEntitySet() { return this.uriResourceEntitySet.getEntitySet(); }
public List<UriParameter> getKeyPredicates() { if (this.uriResourceEntitySet != null) { return this.uriResourceEntitySet.getKeyPredicates(); } return null; }
entity = startUriRes.getEntityType(); eInfo = new ReadEntityInfo(); eInfo.setEntityName(currentUri.getSegmentValue().toString()); prepareFilterForKeyPredicatesStartRes(startUriRes.getKeyPredicates(), entity, eInfo); eInfo.setIscollection(startUriRes.isCollection()); if (beforeCount) { Column count = new Column("COUNT(*)").setDbaliasName("C");
private Object createBindingParameter(UriResourceEntitySet entitySet, JPAParameter parameter) throws ODataJPAModelException, ODataApplicationException { try { final JPAConversionHelper helper = new JPAConversionHelper(); final JPAModifyUtil util = new JPAModifyUtil(); final Constructor<?> c = parameter.getType().getConstructor(); final Map<String, Object> jpaAttributes = helper.convertUriKeys(odata, sd.getEntity(entitySet.getEntityType()), entitySet.getKeyPredicates()); if (c != null) { final Object param = c.newInstance(); util.setAttributesDeep(jpaAttributes, param, sd.getEntity(entitySet.getEntityType())); return param; } } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException e) { throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); } catch (InvocationTargetException e) { Throwable cause = e.getCause(); if (cause != null && cause instanceof ODataApplicationException) { throw (ODataApplicationException) cause; } else { throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); } } return null; }
private static void blockTypeFilters(final UriResource uriResource,Locale locale) throws ODataApplicationException { if (uriResource instanceof UriResourceEntitySet && (((UriResourceEntitySet) uriResource).getTypeFilterOnCollection() != null || ((UriResourceEntitySet) uriResource).getTypeFilterOnEntry() != null) || uriResource instanceof UriResourceFunction && (((UriResourceFunction) uriResource).getTypeFilterOnCollection() != null || ((UriResourceFunction) uriResource).getTypeFilterOnEntry() != null) || uriResource instanceof UriResourceNavigation && (((UriResourceNavigation) uriResource).getTypeFilterOnCollection() != null || ((UriResourceNavigation) uriResource).getTypeFilterOnEntry() != null)) { getResourceLable(locale); throw new ODataApplicationException(labels.getString("TYPE_FILTERS_NOT_SUPPORTED"), HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), locale,labels.getString("TYPE_FILTERS_NOT_SUPPORTED_CODE")); } }
@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(); } }
public static String getNameSpace(UriInfo uriInfo){ UriInfoResource uriInfoResource = uriInfo.asUriInfoResource(); List<UriResource> uriResourceParts = uriInfoResource.getUriResourceParts(); UriResourceEntitySet startEntitySetUriResource = ((UriResourceEntitySet) uriResourceParts.get(0)); return startEntitySetUriResource.getEntityType().getNamespace(); }
public static JPAAssociationPath determineAssoziationPath(final JPAServiceDocument sd, final UriResourcePartTyped naviStart, final StringBuilder associationName) throws ODataApplicationException { JPAEntityType naviStartType = null; try { if (naviStart instanceof UriResourceEntitySet) if (((UriResourceEntitySet) naviStart).getTypeFilterOnEntry() != null) naviStartType = sd.getEntity(((UriResourceEntitySet) naviStart).getTypeFilterOnEntry()); else naviStartType = sd.getEntity(((UriResourceEntitySet) naviStart).getType()); else if (naviStart instanceof UriResourceNavigation) if (((UriResourceNavigation) naviStart).getTypeFilterOnEntry() != null) naviStartType = sd.getEntity(((UriResourceNavigation) naviStart).getTypeFilterOnEntry()); else naviStartType = sd.getEntity(((UriResourceNavigation) naviStart).getProperty().getType()); JPAAssociationPath path = naviStartType == null ? null : naviStartType.getAssociationPath(associationName .toString()); if (path == null && naviStartType != null) { final JPACollectionAttribute collcetion = naviStartType.getCollectionAttribute(associationName.toString()); if (collcetion != null) path = collcetion.asAssociation(); } return path; } catch (ODataJPAModelException e) { throw new ODataJPAUtilException(ODataJPAUtilException.MessageKeys.UNKNOWN_NAVI_PROPERTY, HttpStatusCode.BAD_REQUEST); } }
castType = ((UriResourceNavigation) naviInfo.getUriResiource()).getTypeFilterOnEntry(); else castType = ((UriResourceEntitySet) naviInfo.getUriResiource()).getTypeFilterOnEntry(); if (castType != null) target = (From<?, ?>) target.as(sd.getEntity(castType.getFullQualifiedName()).getTypeClass());
public boolean isCollection() { if (!this.uriNavigations.isEmpty()) { return this.uriNavigations.getLast().isCollection(); } return this.uriResourceEntitySet != null && this.uriResourceEntitySet.isCollection(); }
getFullQualifiedName().getFullQualifiedNameAsString()); } else if (resource instanceof UriResourceEntitySet && ((UriResourceEntitySet) resource).getTypeFilterOnCollection() != null) { path.add(((UriResourceEntitySet) resource).getTypeFilterOnCollection(). getFullQualifiedName().getFullQualifiedNameAsString());
appendParameters(gen, "keys", ((UriResourceEntitySet) resource).getKeyPredicates()); appendType(gen, "typeFilterOnCollection", ((UriResourceEntitySet) resource).getTypeFilterOnCollection()); appendType(gen, "typeFilterOnEntry", ((UriResourceEntitySet) resource).getTypeFilterOnEntry()); } else if (resource instanceof UriResourceNavigation) { appendParameters(gen, "keys", ((UriResourceNavigation) resource).getKeyPredicates());
public EdmEntitySet getEntitySet() { return this.uriResourceEntitySet.getEntitySet(); }
public List<UriParameter> getKeyPredicates() { if (this.uriResourceEntitySet != null) { return this.uriResourceEntitySet.getKeyPredicates(); } return null; }
entity = startUriRes.getEntityType(); eInfo = new ReadEntityInfo(); prepareFilterForKeyPredicatesStartRes(startUriRes.getKeyPredicates(), entity, eInfo); eInfo.setIscollection(startUriRes.isCollection()); eInfo.setColumns(resolvePropertiesToColumns(entity, "", null,eInfo));
private void blockTypeFilters(final UriResource uriResource) throws ODataApplicationException { if (uriResource instanceof UriResourceEntitySet && (((UriResourceEntitySet) uriResource).getTypeFilterOnCollection() != null || ((UriResourceEntitySet) uriResource).getTypeFilterOnEntry() != null) || uriResource instanceof UriResourceFunction && (((UriResourceFunction) uriResource).getTypeFilterOnCollection() != null || ((UriResourceFunction) uriResource).getTypeFilterOnEntry() != null) || uriResource instanceof UriResourceNavigation && (((UriResourceNavigation) uriResource).getTypeFilterOnCollection() != null || ((UriResourceNavigation) uriResource).getTypeFilterOnEntry() != null)) { throw new ODataApplicationException("Type filters are not supported.", HttpStatusCode.NOT_IMPLEMENTED.getStatusCode(), Locale.ROOT); } }
private boolean isEntityOrNavigationMedia(final UriResource pathSegment) { // This method MUST NOT check if the resource is of type function since these are handled differently return pathSegment instanceof UriResourceEntitySet && ((UriResourceEntitySet) pathSegment).getEntityType().hasStream() || pathSegment instanceof UriResourceNavigation && ((EdmEntityType) ((UriResourceNavigation) pathSegment).getType()).hasStream(); }