Examples of DataService


Examples of org.wso2.carbon.dataservices.core.engine.DataService

   * @throws DataServiceFault
   */
  @SuppressWarnings("unchecked")
  private static DataService createDataServiceFromAxisService(
      AxisService axisService) throws DataServiceFault {
    DataService dataService = new DataService(
        extractServiceNameFromHeirachicalName(axisService.getName()),
        null, null, null, DBConstants.ServiceStatusValues.INACTIVE,
        false, false, false, null, false);
   
    /* add dummy config */
    String dummyConfigId = DBConstants.DEFAULT_CONFIG_ID;
    dataService.addConfig(getDummyConfig(dataService, dummyConfigId));
   
    /* compile schema */
    Map<QName, Document> modelMap;
    Map<QName, String> elementMap;
    try {
      CompilerOptions options = new CompilerOptions();
      SchemaCompiler schemaCompiler = new SchemaCompiler(options);
      schemaCompiler.compile(axisService.getSchema());
      modelMap = schemaCompiler.getProcessedModelMap();
      elementMap = schemaCompiler.getProcessedElementMap();
    } catch (SchemaCompilationException e) {
      throw new DataServiceFault(e, "Error in schema compile");
    }
   
    /* add queries/operations */
    AxisOperation axisOperation;
    String operationName;
    String queryId;
    List<QueryParam> queryParams;
    for (Iterator<AxisOperation> axisOperations = axisService.getOperations(); axisOperations.hasNext();) {
      axisOperation = axisOperations.next();
      operationName = axisOperation.getName().getLocalPart();
      queryId = operationName + DBConstants.CONTRACT_FIRST_QUERY_SUFFIX;
      queryParams = getQueryParamsFromAxisOperation(modelMap, elementMap, axisOperation);
      /* query */
      dataService.addQuery(new SQLQuery(dataService, queryId, dummyConfigId, false, null,
          DBConstants.CONTRACT_FIRST_DUMMY_SQL, queryParams,
          getResultFromAxisOperation(dataService, axisOperation), null, null,
          new HashMap<String, String>(),
          dataService.getServiceNamespace()));
      /* operation */
      dataService.addOperation(new Operation(dataService, operationName, null,
          getOperationCallQueryGroupFromQueryParams(dataService, queryId, queryParams),
          false, null, false, false));
    }
    return dataService;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.