public RuntimeOptionsResponse(RuntimeOptionsRequest request, List<RuntimeOptions> options) { super(); this.requestId = request.getRequestId(); this.mappedEventProperty = request.getMappedEventProperty(); this.options = options; }
private List<Option> handleResponse(Response httpResp) throws JsonSyntaxException, IOException { String resp = httpResp.returnContent().asString(); RuntimeOptionsResponse response = GsonSerializer .getGsonWithIds() .fromJson(resp, RuntimeOptionsResponse.class); return response .getOptions() .stream() .map(o -> new Option(o.getLabel(), o.getAdditionalPayload())) .collect(Collectors.toList()); }
@POST @Path("{elementId}/configurations") //@Consumes(MediaType.APPLICATION_JSON) //@Produces(MediaType.APPLICATION_JSON) public String fetchConfigurations(@PathParam("elementId") String elementId, String payload) { RuntimeOptionsRequest runtimeOptionsRequest = GsonSerializer.getGsonWithIds().fromJson(payload, RuntimeOptionsRequest.class); ResolvesContainerProvidedOptions resolvesOptions = (ResolvesContainerProvidedOptions) getDeclarerById(elementId); List<RuntimeOptions> availableOptions = resolvesOptions.resolveOptions(runtimeOptionsRequest.getRequestId(), runtimeOptionsRequest.getMappedEventProperty()); return GsonSerializer.getGsonWithIds().toJson(new RuntimeOptionsResponse(runtimeOptionsRequest, availableOptions)); }
public List<Option> fetchRemoteOptions(ContainerProvidedOptionsParameterRequest parameterRequest) { Optional<RuntimeResolvableSelectionStaticProperty> runtimeResolvableOpt = findProperty (parameterRequest.getStaticProperties(), parameterRequest.getRuntimeResolvableInternalId()); if (runtimeResolvableOpt.isPresent()) { RuntimeResolvableSelectionStaticProperty rsp = runtimeResolvableOpt.get(); RuntimeOptionsRequest request = new RuntimeOptionsRequest(rsp.getInternalName()); if (rsp.getLinkedMappingPropertyId() != null) { Optional<EventProperty> eventPropertyOpt = findEventProperty(parameterRequest.getEventProperties(), parameterRequest.getStaticProperties(), rsp .getLinkedMappingPropertyId()); eventPropertyOpt.ifPresent(request::setMappedEventProperty); } String httpRequestBody = GsonSerializer.getGsonWithIds() .toJson (request); try { Response httpResp = Request.Post(parameterRequest.getBelongsTo() +"/configurations").bodyString(httpRequestBody, ContentType.APPLICATION_JSON).execute(); return handleResponse(httpResp); } catch (Exception e) { e.printStackTrace(); return new ArrayList<>(); } } else { return new ArrayList<>(); } }
private List<Option> handleResponse(Response httpResp) throws JsonSyntaxException, IOException { String resp = httpResp.returnContent().asString(); RuntimeOptionsResponse response = GsonSerializer .getGsonWithIds() .fromJson(resp, RuntimeOptionsResponse.class); return response .getOptions() .stream() .map(o -> new Option(o.getLabel(), o.getAdditionalPayload())) .collect(Collectors.toList()); }
public List<Option> fetchRemoteOptions(ContainerProvidedOptionsParameterRequest parameterRequest) { Optional<RuntimeResolvableSelectionStaticProperty> runtimeResolvableOpt = findProperty (parameterRequest.getStaticProperties(), parameterRequest.getRuntimeResolvableInternalId()); if (runtimeResolvableOpt.isPresent()) { RuntimeResolvableSelectionStaticProperty rsp = runtimeResolvableOpt.get(); RuntimeOptionsRequest request = new RuntimeOptionsRequest(rsp.getInternalName()); if (rsp.getLinkedMappingPropertyId() != null) { Optional<EventProperty> eventPropertyOpt = findEventProperty(parameterRequest.getEventProperties(), parameterRequest.getStaticProperties(), rsp .getLinkedMappingPropertyId()); eventPropertyOpt.ifPresent(request::setMappedEventProperty); } String httpRequestBody = GsonSerializer.getGsonWithIds() .toJson (request); try { Response httpResp = Request.Post(parameterRequest.getBelongsTo() +"/configurations").bodyString(httpRequestBody, ContentType.APPLICATION_JSON).execute(); return handleResponse(httpResp); } catch (Exception e) { e.printStackTrace(); return new ArrayList<>(); } } else { return new ArrayList<>(); } }