コード例 #1
0
  @WebMethod
  public ReadResponse Read(
      @XmlElement(required = true, nillable = false) @WebParam(name = "request")
          ReadRequest request) {
    log.entering(this.getClass().getCanonicalName(), "Read");
    log.info("Read gateway invoked with the following content: [" + request + "]");

    Cruddable entityProxy = getCruddable(request.getFilter().getEntity());
    log.exiting(this.getClass().getCanonicalName(), "Read");

    ReadResponse response = entityProxy.Read(request);
    log.info("Read gateway completed by " + getLoggedUser() + " as: [" + response.getError() + "]");
    return response;
  }
コード例 #2
0
  @WebMethod
  public ReadResponse Save(
      @XmlElement(required = true, nillable = false) @WebParam(name = "request")
          SaveRequest request)
      throws Exception {

    ReadResponse response = new ReadResponse();
    response.setError(new GatewayError("0", "SUCCESS", "SAVE"));

    for (GatewayRecord parentRecord : request.getParentRecord()) {
      String operationName = "Create";
      String entityIdFieldName = parentRecord.getEntity() + "Id";
      for (GatewayField field : parentRecord.getField()) {
        if (field.getName().equalsIgnoreCase(entityIdFieldName) && !field.getValue().equals("0")) {
          log.fine("Found update operation for entityId: [" + field.getValue() + "]");
          operationName = "Update";
          break;
        }
      }

      CreateRequest transactionRequest = new CreateRequest();
      transactionRequest.setParentRecord(parentRecord);

      Cruddable entityProxy = getCruddable(parentRecord.getEntity());
      ReadResponse transactionResponse = null;
      if (operationName.equals("Create")) {
        log.info("Executing create operation with record: [" + transactionRequest + "]");
        transactionResponse = entityProxy.Create(transactionRequest);
      } else {
        log.info("Executing update operation with record: [" + transactionRequest + "]");
        transactionResponse = entityProxy.Update(transactionRequest);
      }

      if (!transactionResponse.getError().getExceptionId().equals("0")) {
        log.severe("An exception has occured during transaction processing.");
        response.setError(transactionResponse.getError());
        return response;
      } else {
        log.fine("Transaction succesfully executed, building response.");
        for (GatewayRecord responseRecord : transactionResponse.getParentRecord()) {
          log.finer("Adding response record: " + responseRecord);
          response.addParentRecord(responseRecord);
        }
      }
    }

    return response;
  }