Package org.restsql.core

Examples of org.restsql.core.Request


    Connection connection = null;

    try {
      connection = Factory.getConnection(SqlResourceDefinitionUtils.getDefaultDatabase(definition));
      if (metaData.isHierarchical()) {
        final Request childRequest = Factory.getChildRequest(request);
        if (request.getChildrenParameters() != null) {

          // Set up response
          List<Set<ResponseValue>> childListResponseValues = null;
          Set<ResponseValue> childResponseValues = null;
          if (request.getType() == Type.INSERT) {
            childListResponseValues = new ArrayList<Set<ResponseValue>>(request
                .getChildrenParameters().size());
            responseValues.add(new ResponseValue(getChildRowsName(), childListResponseValues,
                Integer.MAX_VALUE));
            // Add parent params, since we won't be executing the write on the parent
            for (final TableMetaData table : metaData.getParentPlusExtTables()) {
              addRequestParamsToResponseValues(request, responseValues, table);
            }
          }

          // Delete, update or insert each specified child row
          for (final List<RequestValue> childRowParams : request.getChildrenParameters()) {
            if (request.getType() == Type.INSERT) {
              // Set up response value set
              childResponseValues = new TreeSet<ResponseValue>();
              childListResponseValues.add(childResponseValues);

              // Add the parent pks, since inserts ignore the resIds
              childRowParams.addAll(request.getResourceIdentifiers());
            } // else deletes and updates use resIds
            childRequest.setParameters(childRowParams);
            rowsAffected += execWrite(connection, childRequest, false, childResponseValues);
          }
          // Don't touch the parent(s)
          doParent = false;
        } else if (request.getType() == Request.Type.DELETE) {
          // Delete all children and the parent(s)
          if (request.getResourceIdentifiers() == null) {
            childRequest.setParameters(request.getParameters());
          }
          rowsAffected += execWrite(connection, childRequest, false, responseValues);
          // Now do the parent as well, doParent already equals true
        }
        // else just insert or update the parent (+ extensions)
View Full Code Here


    // Private util methods

    private void executeRequest() {
      try {
        final Request request = Factory.getRequest(httpAttributes, requestType,
            sqlResource.getName(), resIds, params, childrenParams, requestLogger);
        WriteResponse localResponse = sqlResource.write(request);
        if (response == null) {
          response = localResponse;
        } else {
View Full Code Here

   *
   * @throws InvalidRequestException if main query is invalid
   */
  protected String getSqlMainQuery(final SqlResourceDefinition definition, final SqlBuilder sqlBuilder)
      throws InvalidRequestException {
    Request request = Factory.getRequest(Type.SELECT, resName, null, null, null, null);
    request.setSelectLimit(new Integer(1));
    request.setSelectOffset(new Integer(0));
    return sqlBuilder.buildSelectSql(this, definition.getQuery().getValue(), request).getStatement();
  }
View Full Code Here

      }
    }

    private void executeRequest() {
      try {
        final Request request = Factory.getRequest(httpAttributes, requestType,
            sqlResource.getName(), resIds, params, childrenParams, requestLogger);
        WriteResponse localResponse = sqlResource.write(request);
        if (response == null) {
          response = localResponse;
        } else {
View Full Code Here

        sqlResource = Factory.getSqlResource(resName);
      }

      // Execute request
      if (requestType.equals(Request.Type.SELECT)) {
        final Request request = Factory.getRequest(httpAttributes, requestType, resName, resIds,
            params, null, requestLogger);
        responseBody = sqlResource.read(request, responseMediaType);
      } else { // INSERT, UPDATE or DELETE
        final WriteResponse writeResponse;
        if (requestMediaType != null
            && !requestMediaType.equals(MediaType.APPLICATION_FORM_URLENCODED)
            && requestBody != null && requestBody.length() > 0) {
          // requestBody is not null, use request processor
          writeResponse = Factory.getRequestDeserializer(requestMediaType).execWrite(httpAttributes,
              requestType, resIds, sqlResource, requestBody, requestLogger);
        } else {
          final Request request = Factory.getRequest(httpAttributes, requestType, resName, resIds,
              params, null, requestLogger);
          writeResponse = sqlResource.write(request);
        }
        responseBody = Factory.getResponseSerializer(responseMediaType).serializeWrite(sqlResource, writeResponse);
      }
View Full Code Here

TOP

Related Classes of org.restsql.core.Request

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.