Package net.carchrae.smartgwt.shared.data

Examples of net.carchrae.smartgwt.shared.data.DataSourceDescriptor


   * @param req
   * @return
   */
  public Map<String, String> getValueMap(HttpServletRequest req) {
    String dataSourceName = req.getParameter("_dataSource");
    DataSourceDescriptor dataSource = dataSourceService
        .getDataSource(dataSourceName);
    Map<String, String> map = new HashMap<String, String>();
    for (String field : dataSource.getFields().keySet()) {
      if (req.getParameterMap().containsKey(field)) {
        String value = req.getParameter(field);
        map.put(field, value);
      }
    }
View Full Code Here


    }
  }

  @Override
  public DataSourceDescriptor getDataSource(String name) {
    DataSourceDescriptor descriptor = dataSourceMap.get(name);
    if (descriptor == null) {
      Class<?> class1 = classMap.get(name.toLowerCase());
      if (class1 != null)
        dataSourceMap.put(name,
            descriptor = createDataSourceDescriptor(class1));
View Full Code Here

    }
    return descriptor;
  }

  private DataSourceDescriptor createDataSourceDescriptor(Class<?> clazz) {
    DataSourceDescriptor dataSourceDescriptor = new DataSourceDescriptor();

    String name = clazz.getSimpleName().toLowerCase();
    dataSourceDescriptor.put("name", name);
    // dataSourceDescriptor.put("dataFormat", DSDataFormat.JSON.getValue());
    dataSourceDescriptor.put("dataFormat", "json");

    for (Field field : clazz.getDeclaredFields()) {
      if (!TypeUtils.isSaveable(field))
        continue;

      boolean original = field.isAccessible();
      field.setAccessible(true);
      String fieldName = field.getName();

      Map<String, String> map = new HashMap<String, String>();
      dataSourceDescriptor.getFields().put(fieldName, map);

      System.out.println("getting type for " + fieldName + " "
          + field.getType().getSimpleName());
      String fieldType;
      if (isCollection(field.getType())) {
        map.put("multiple", "true");
        fieldType = convertToDataSourceFieldType((Class<?>) getTypeInCollection(field));
      } else
        fieldType = convertToDataSourceFieldType(field.getType());
      map.put("type", fieldType);

      if (field.isAnnotationPresent(Id.class)) {
        map.put("primaryKey", "true");
        dataSourceDescriptor.setId(fieldName);
      }

      field.setAccessible(original);
    }
    return dataSourceDescriptor;
View Full Code Here

TOP

Related Classes of net.carchrae.smartgwt.shared.data.DataSourceDescriptor

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.