private UriParameter getParameter(String name, List<UriParameter> keys) { for (UriParameter parameter:keys) { String propertyName = parameter.getName(); if (propertyName.equals(name)) { return parameter; } } return null; }
protected static List<String> getParameterNames(final List<UriParameter> parameters) { List<String> names = new ArrayList<String>(); for (final UriParameter parameter : parameters) { names.add(parameter.getName()); } return names; }
protected static List<String> getParameterNames(final List<UriParameter> parameters) { List<String> names = new ArrayList<String>(); for (final UriParameter parameter : parameters) { names.add(parameter.getName()); } return names; }
private UriParameter findUriParameter(final JPAParameter jpaFunctionParam) { for (final UriParameter uriParam : uriParams) { if (uriParam.getName().equals(jpaFunctionParam.getName())) { return uriParam; } } return null; }
public static boolean isUriFromMainTable(UriInfo uriInfo) throws ODataApplicationException{ UriInfoResource uriInfoResource = uriInfo.asUriInfoResource(); List<UriResource> uriResourceParts = uriInfoResource.getUriResourceParts(); UriResource currentUri = uriResourceParts.get(0); UriResourceEntitySet startUriRes = (UriResourceEntitySet) currentUri; for(Iterator<UriParameter> iter=startUriRes.getKeyPredicates().iterator();iter.hasNext();) { UriParameter param=iter.next(); if(param.getName().equalsIgnoreCase(DRAFTS_ISACTIVE_ENTITY)){ return param.getText().equalsIgnoreCase("true"); } } return false; }
private void appendParameters(final JsonGenerator gen, final String name, final List<UriParameter> parameters) throws IOException { if (!parameters.isEmpty()) { Map<String, String> parameterMap = new LinkedHashMap<String, String>(); for (final UriParameter parameter : parameters) { parameterMap.put(parameter.getName(), parameter.getText() == null ? parameter.getAlias() : parameter.getText()); } gen.writeFieldName(name); DebugResponseHelperImpl.appendJsonTable(gen, parameterMap); } }
private void appendParameters(final JsonGenerator gen, final String name, final List<UriParameter> parameters) throws IOException { if (!parameters.isEmpty()) { Map<String, String> parameterMap = new LinkedHashMap<String, String>(); for (final UriParameter parameter : parameters) { parameterMap.put(parameter.getName(), parameter.getText() == null ? parameter.getAlias() : parameter.getText()); } gen.writeFieldName(name); DebugResponseHelperImpl.appendJsonTable(gen, parameterMap); } }
private static List<Column> resolveKeyPredicatesToColumnsUpdate(EdmEntityType entityType, List<UriParameter> keyPredicates){ List<Column> columns = new ArrayList<Column>(); for(UriParameter uriPred:keyPredicates){ Column col=formNewColumnObject(uriPred.getName().replace("_", "."),null,getValueOfProperty(uriPred),true); col.setColumnDataType(entityType.getProperty(uriPred.getName()).getType().getName()); columns.add(col); } return columns; }
public static List<UriParameter> extractKeyPredicateRefsFromUriInfo(UriInfo uriInfo,boolean considerActiveEntityKey) throws ODataApplicationException { UriInfoResource uriInfoResource = uriInfo.asUriInfoResource(); List<UriResource> uriResourceParts = uriInfoResource.getUriResourceParts(); UriResource currentUri = uriResourceParts.get(0); UriResourceEntitySet startUriRes = (UriResourceEntitySet) currentUri; List<UriParameter> keyparams=new ArrayList<>(); if(!considerActiveEntityKey) { for(Iterator<UriParameter> iter=startUriRes.getKeyPredicates().iterator();iter.hasNext();) { UriParameter param=iter.next(); if(!param.getName().equalsIgnoreCase(DRAFTS_ISACTIVE_ENTITY)){ keyparams.add(param); } } }else { keyparams.addAll(startUriRes.getKeyPredicates()); } return keyparams; }
private UriParameter findParameterByExternalName(final JPAParameter parameter, final List<UriParameter> uriParameters) throws ODataApplicationException { for (final UriParameter uriParameter : uriParameters) { if (uriParameter.getName().equals(parameter.getName())) return uriParameter; } throw new ODataJPADBAdaptorException(ODataJPADBAdaptorException.MessageKeys.PARAMETER_MISSING, HttpStatusCode.BAD_REQUEST, parameter.getName()); }
private UriParameter findParameterByExternalName(final JPAParameter parameter, final List<UriParameter> uriParameters) throws ODataApplicationException { for (final UriParameter uriParameter : uriParameters) { if (uriParameter.getName().equals(parameter.getName())) return uriParameter; } throw new ODataJPADBAdaptorException(ODataJPADBAdaptorException.MessageKeys.PARAMETER_MISSING, HttpStatusCode.BAD_REQUEST, parameter.getName()); }
protected final UriParameter findParameterByExternalName(final JPAParameter parameter, final List<UriParameter> uriParameters) throws ODataApplicationException { for (final UriParameter uriParameter : uriParameters) { if (uriParameter.getName().equals(parameter.getName())) return uriParameter; } throw new ODataJPADBAdaptorException(ODataJPADBAdaptorException.MessageKeys.PARAMETER_MISSING, HttpStatusCode.BAD_REQUEST, parameter.getName()); }
/** * This method wraps list of eir parameters into single Data Entry object. * * @param keys list of URI parameters * @return DataEntry * @see UriParameter * @see DataEntry */ private ODataEntry wrapKeyParamToDataEntry(List<UriParameter> keys) { ODataEntry entry = new ODataEntry(); for (UriParameter key : keys) { String value = key.getText(); if (value.startsWith("'") && value.endsWith("'")) { value = value.substring(1, value.length() - 1); } entry.addValue(key.getName(), value); } return entry; }
private void putParameters(ObjectNode node, final String name, final List<UriParameter> parameters) { if (!parameters.isEmpty()) { ObjectNode parametersNode = node.putObject(name); for (final UriParameter parameter : parameters) { parametersNode.put(parameter.getName(), parameter.getText() == null ? parameter.getAlias() : parameter.getText()); } } }
/** * Builds a key predicate for the ContextURL. * @param keys the keys as a list of {@link UriParameter} instances * @return a String with the key predicate */ public static String buildKeyPredicate(final List<UriParameter> keys) throws SerializerException { if (keys == null || keys.isEmpty()) { return null; } else if (keys.size() == 1) { return Encoder.encode(keys.get(0).getText()); } else { StringBuilder result = new StringBuilder(); for (final UriParameter key : keys) { if (result.length() > 0) { result.append(','); } result.append(Encoder.encode(key.getName())).append('=').append(Encoder.encode(key.getText())); } return result.toString(); } } }
private void putParameters(ObjectNode node, final String name, final List<UriParameter> parameters) { if (!parameters.isEmpty()) { ObjectNode parametersNode = node.putObject(name); for (final UriParameter parameter : parameters) { parametersNode.put(parameter.getName(), parameter.getText() == null ? parameter.getAlias() : parameter.getText()); } } }
/** * Builds a key predicate for the ContextURL. * @param keys the keys as a list of {@link UriParameter} instances * @return a String with the key predicate */ public static String buildKeyPredicate(final List<UriParameter> keys) throws SerializerException { if (keys == null || keys.isEmpty()) { return null; } else if (keys.size() == 1) { return Encoder.encode(keys.get(0).getText()); } else { StringBuilder result = new StringBuilder(); for (final UriParameter key : keys) { if (result.length() > 0) { result.append(','); } result.append(Encoder.encode(key.getName())).append('=').append(Encoder.encode(key.getText())); } return result.toString(); } } }
@Override public Object getValue(EdmParameter edmParameter, Class<?> runtimeType) throws TeiidProcessingException { for (UriParameter parameter : this.parameters) { if (parameter.getName().equals(edmParameter.getName())) { // In Teiid one can only pass simple literal values, not complex // types, no complex parsing required. And LOBs can not be inlined // for Function return ODataTypeManager.parseLiteral(edmParameter, runtimeType, parameter.getText()); } } return null; } }
/** * * @param keyPredicates * @return * @throws ODataJPAFilterException * @throws ODataJPAProcessorException */ public Map<String, Object> convertUriKeys(final OData odata, final JPAStructuredType st, final List<UriParameter> keyPredicates) throws ODataJPAFilterException, ODataJPAProcessorException { Map<String, Object> result = new HashMap<>(keyPredicates.size()); String internalName; for (UriParameter key : keyPredicates) { try { final JPAAttribute attribute = st.getPath(key.getName()).getLeaf(); internalName = attribute.getInternalName(); Object jpaAttribute = ExpressionUtil.convertValueOnAttribute(odata, attribute, key.getText(), true); result.put(internalName, jpaAttribute); } catch (ODataJPAModelException e) { throw new ODataJPAProcessorException(e, HttpStatusCode.INTERNAL_SERVER_ERROR); } } return result; }
public static Expression<Boolean> createEQExpression(final OData odata, CriteriaBuilder cb, From<?, ?> root, JPAEntityType jpaEntity, UriParameter keyPredicate) throws ODataJPAFilterException, ODataJPAModelException { JPAPath path = jpaEntity.getPath(keyPredicate.getName()); JPAAttribute attribute = path.getLeaf(); return cb.equal(convertToCriteriaPath(root, path.getPath()), convertValueOnAttribute(odata, attribute, keyPredicate .getText())); }