private void writeHydraVariableMapping(JsonGenerator jgen, @Nullable ActionDescriptor annotatedParameters, Collection<String> variableNames) throws IOException { if (annotatedParameters != null) { for (String variableName : variableNames) { // TODO: find also @Input ActionInputParameter annotatedParameter = annotatedParameters.getActionInputParameter(variableName); // TODO access @Input parameter, too // only unsatisfied parameters become hydra variables if (annotatedParameter != null && annotatedParameter.getValue() == null) { jgen.writeStartObject(); jgen.writeStringField("@type", "hydra:IriTemplateMapping"); jgen.writeStringField("hydra:variable", annotatedParameter.getParameterName()); jgen.writeBooleanField("hydra:required", annotatedParameter .isRequired()); jgen.writeStringField("hydra:property", getExposedPropertyOrParamName(annotatedParameter)); jgen.writeEndObject(); } } } }
private List<SirenField> toSirenFields(ActionDescriptor actionDescriptor) { List<SirenField> ret = new ArrayList<SirenField>(); if (actionDescriptor.hasRequestBody()) { recurseBeanCreationParams(ret, actionDescriptor.getRequestBody() .getParameterType(), actionDescriptor, actionDescriptor.getRequestBody(), actionDescriptor .getRequestBody() .getValue(), "", Collections.<String>emptySet()); } else { Collection<String> paramNames = actionDescriptor.getRequestParamNames(); for (String paramName : paramNames) { ActionInputParameter inputParameter = actionDescriptor.getActionInputParameter(paramName); Object[] possibleValues = inputParameter.getPossibleValues(actionDescriptor); ret.add(createSirenField(paramName, inputParameter.getValueFormatted(), inputParameter, possibleValues)); } } return ret; }
LdContextFactory.HTTP_SCHEMA_ORG, "schema:")); writeScalarValue(jgen, actionInputParameter.getValue(), actionInputParameter .getParameterType());
ActionInputParameter requestBody = actionDescriptor.getRequestBody(); Class<?> parameterType = requestBody.getParameterType(); recurseBeanProperties(parameterType, actionDescriptor, requestBody, requestBody.getValue(), ""); } else { // plain parameter list Collection<String> requestParams = actionDescriptor.getRequestParamNames();
ActionInputParameter requestBody = actionDescriptor.getRequestBody(); Class<?> parameterType = requestBody.getParameterType(); recurseBeanProperties(parameterType, actionDescriptor, requestBody, requestBody.getValue(), ""); } else { // plain parameter list Collection<String> requestParams = actionDescriptor.getRequestParamNames();
private static String getModelProperty(String href, ActionDescriptor actionDescriptor) { RequestMethod httpMethod = RequestMethod.valueOf(actionDescriptor.getHttpMethod()); StringBuffer model = new StringBuffer(); switch (httpMethod) { case POST: case PUT: case PATCH: { List<UberField> uberFields = new ArrayList<UberField>(); recurseBeanCreationParams(uberFields, actionDescriptor.getRequestBody() .getParameterType(), actionDescriptor, actionDescriptor.getRequestBody(), actionDescriptor .getRequestBody() .getValue(), "", Collections.<String>emptySet()); for (UberField uberField : uberFields) { if (model.length() > 0) { model.append("&"); } model.append(String.format(MODEL_FORMAT, uberField.getName(), uberField.getName())); } break; } default: } return model.length() == 0 ? null : model.toString(); }
private List<SirenField> toSirenFields(ActionDescriptor actionDescriptor) { List<SirenField> ret = new ArrayList<SirenField>(); if (actionDescriptor.hasRequestBody()) { recurseBeanCreationParams(ret, actionDescriptor.getRequestBody() .getParameterType(), actionDescriptor, actionDescriptor.getRequestBody(), actionDescriptor .getRequestBody() .getValue(), "", Collections.<String>emptySet()); } else { Collection<String> paramNames = actionDescriptor.getRequestParamNames(); for (String paramName : paramNames) { ActionInputParameter inputParameter = actionDescriptor.getActionInputParameter(paramName); Object[] possibleValues = inputParameter.getPossibleValues(actionDescriptor); ret.add(createSirenField(paramName, inputParameter.getValueFormatted(), inputParameter, possibleValues)); } } return ret; }
private static String getModelProperty(String href, ActionDescriptor actionDescriptor) { RequestMethod httpMethod = RequestMethod.valueOf(actionDescriptor.getHttpMethod()); StringBuffer model = new StringBuffer(); switch (httpMethod) { case POST: case PUT: case PATCH: { List<UberField> uberFields = new ArrayList<UberField>(); recurseBeanCreationParams(uberFields, actionDescriptor.getRequestBody() .getParameterType(), actionDescriptor, actionDescriptor.getRequestBody(), actionDescriptor .getRequestBody() .getValue(), "", Collections.<String>emptySet()); for (UberField uberField : uberFields) { if (model.length() > 0) { model.append("&"); } model.append(String.format(MODEL_FORMAT, uberField.getName(), uberField.getName())); } break; } default: } return model.length() == 0 ? null : model.toString(); }
requestBodyInputParameter, requestBodyInputParameter.getValue(), "");
ActionInputParameter parameterValue = actionDescriptor.getActionInputParameter(paramName); if (parameterValue != null) { from.add(parameterValue.getValue());
ActionInputParameter parameterValue = actionDescriptor.getActionInputParameter(paramName); if (parameterValue != null) { from.add(parameterValue.getValue());
if (pd.getWriteMethod() != null) { Object callValue = annotatedParameter.getValue(); Object propertyValue = null; if (callValue != null) {
if (pd.getWriteMethod() != null) { Object callValue = annotatedParameter.getValue(); Object propertyValue = null; if (callValue != null) {
private void appendSelectOne(String requestParamName, Object[] possibleValues, ActionInputParameter actionInputParameter) throws IOException { beginDiv(OptionalAttributes.attr("class", formGroupClass)); Object callValue = actionInputParameter.getValue(); String documentationUrl = documentationProvider.getDocumentationUrl(actionInputParameter, callValue); writeLabelWithDoc(requestParamName, requestParamName, documentationUrl); beginSelect(requestParamName, requestParamName, possibleValues.length, OptionalAttributes.attr("class", formControlClass)); for (Object possibleValue : possibleValues) { if (possibleValue.equals(callValue)) { option(possibleValue.toString(), attr("selected", "selected")); } else { option(possibleValue.toString()); } } endSelect(); endDiv(); }
private void appendSelectOne(String requestParamName, Object[] possibleValues, ActionInputParameter actionInputParameter) throws IOException { beginDiv(OptionalAttributes.attr("class", formGroupClass)); Object callValue = actionInputParameter.getValue(); String documentationUrl = documentationProvider.getDocumentationUrl(actionInputParameter, callValue); writeLabelWithDoc(requestParamName, requestParamName, documentationUrl); beginSelect(requestParamName, requestParamName, possibleValues.length, OptionalAttributes.attr("class", formControlClass)); for (Object possibleValue : possibleValues) { if (possibleValue.equals(callValue)) { option(possibleValue.toString(), attr("selected", "selected")); } else { option(possibleValue.toString()); } } endSelect(); endDiv(); }
/** * Appends simple input or select, depending on availability of possible values. * * @param parentInputParameter * the parent during bean recursion * @param paramName * of the child input parameter * @param childInputParameter * the current input to be rendered * @param possibleValues * suitable for childInputParameter * @throws IOException */ private void appendInputOrSelect(ActionInputParameter parentInputParameter, String paramName, ActionInputParameter childInputParameter, Object[] possibleValues) throws IOException { if (possibleValues.length > 0) { if (childInputParameter.isArrayOrCollection()) { // TODO multiple formatted callvalues appendSelectMulti(paramName, possibleValues, childInputParameter); } else { appendSelectOne(paramName, possibleValues, childInputParameter); } } else { appendInput(paramName, childInputParameter, childInputParameter.getValue(), parentInputParameter.isReadOnly(paramName)); } }
/** * Appends simple input or select, depending on availability of possible values. * * @param parentInputParameter * the parent during bean recursion * @param paramName * of the child input parameter * @param childInputParameter * the current input to be rendered * @param possibleValues * suitable for childInputParameter * @throws IOException */ private void appendInputOrSelect(ActionInputParameter parentInputParameter, String paramName, ActionInputParameter childInputParameter, Object[] possibleValues) throws IOException { if (possibleValues.length > 0) { if (childInputParameter.isArrayOrCollection()) { // TODO multiple formatted callvalues appendSelectMulti(paramName, possibleValues, childInputParameter); } else { appendSelectOne(paramName, possibleValues, childInputParameter); } } else { appendInput(paramName, childInputParameter, childInputParameter.getValue(), parentInputParameter.isReadOnly(paramName)); } }