Package org.openscoring.common

Examples of org.openscoring.common.EvaluationResponse


    EvaluationRequest request = new EvaluationRequest();
    request.setArguments(this.arguments);

    Invocation invocation = target.request(MediaType.APPLICATION_JSON_TYPE).buildPost(Entity.json(request));

    EvaluationResponse response = invocation.invoke(EvaluationResponse.class);

    System.out.println(response.getResult());

    client.close();
  }
View Full Code Here


  static
  private void compare(List<EvaluationResponse> expectedResponses, List<EvaluationResponse> actualResponses){
    assertEquals(expectedResponses.size(), actualResponses.size());

    for(int i = 0; i < expectedResponses.size(); i++){
      EvaluationResponse expectedResponse = expectedResponses.get(i);
      EvaluationResponse actualResponse = actualResponses.get(i);

      compare(expectedResponse.getResult(), actualResponse.getResult());
    }
  }
View Full Code Here

  static
  private List<EvaluationResponse> convert(List<EvaluationRequest> requests){
    List<EvaluationResponse> responses = Lists.newArrayList();

    for(EvaluationRequest request : requests){
      EvaluationResponse response = new EvaluationResponse(request.getId());
      response.setResult(request.getArguments());

      responses.add(response);
    }

    return responses;
View Full Code Here

      if(groupFields.size() > 1){
        throw new EvaluationException();
      }

      for(EvaluationRequest request : requests){
        EvaluationResponse response = evaluate(evaluator, request);

        responses.add(response);
      }
    } catch(Exception e){
      throw new InternalServerErrorException(e);
View Full Code Here

  protected EvaluationResponse evaluate(Evaluator evaluator, EvaluationRequest request){
    logger.info("Received {}", request);

    Map<String, ?> requestArguments = request.getArguments();

    EvaluationResponse response = new EvaluationResponse(request.getId());

    Map<FieldName, Object> arguments = Maps.newLinkedHashMap();

    List<FieldName> activeFields = evaluator.getActiveFields();
    for(FieldName activeField : activeFields){
      String key = activeField.getValue();

      Object value = requestArguments.get(key);
      if(value == null && !requestArguments.containsKey(key)){
        logger.warn("Evaluation request {} does not specify an active field {}", request.getId(), key);
      }

      arguments.put(activeField, EvaluatorUtil.prepare(evaluator, activeField, value));
    }

    logger.debug("Evaluation request {} has prepared arguments: {}", request.getId(), arguments);

    Map<FieldName, ?> result = evaluator.evaluate(arguments);

    logger.debug("Evaluation response {} has result: {}", response.getId(), result);

    response.setResult(EvaluatorUtil.decode(result));

    logger.info("Returned {}", response);

    return response;
  }
View Full Code Here

TOP

Related Classes of org.openscoring.common.EvaluationResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.