use of org.platformlayer.model.ClassModel in project platformlayer by platformlayer.
the class GwtCodegenFileVisitor method processClassRequestFactory.
private void processClassRequestFactory(Class<?> clazz) throws MojoExecutionException {
Map<String, Object> model = new HashMap<String, Object>();
ClassModel classModel = new ClassModel();
classModel.className = clazz.getSimpleName();
classModel.proxyClassName = classModel.className + "Proxy";
classModel.serviceClassName = classModel.className + "GwtService";
classModel.editorClassName = classModel.className + "Editor";
for (Field field : clazz.getFields()) {
FieldModel fieldModel = new FieldModel();
Class<?> type = field.getType();
if (!isNativeType(type)) {
continue;
}
Class<?> accessorType = type;
if (accessorType.isPrimitive()) {
accessorType = Utils.getBoxedType(accessorType);
}
String fieldName = field.getName();
String beanName = Utils.capitalize(fieldName);
fieldModel.type = type.getName();
fieldModel.accessorType = accessorType.getName();
fieldModel.beanName = beanName;
fieldModel.name = fieldName;
classModel.fields.add(fieldModel);
}
model.put("className", classModel.className);
model.put("proxyClassName", classModel.proxyClassName);
model.put("serviceClassName", classModel.serviceClassName);
model.put("editorClassName", classModel.editorClassName);
model.put("fields", classModel.fields);
if (gwtBasePathComponents == null) {
throw new MojoExecutionException("Did not find .gwt.xml file above " + clazz);
}
File gwtOutDir = new File(outDir, Joiner.on("/").join(gwtBasePathComponents));
Utils.mkdirs(gwtOutDir);
String gwtPackage = Joiner.on(".").join(gwtBasePathComponents);
model.put("gwtPackage", gwtPackage);
String modelPackage = Joiner.on(".").join(getPathComponents());
model.put("modelPackage", modelPackage);
String editorPackage = gwtPackage + ".client";
model.put("editorPackage", editorPackage);
runTemplate("requestfactory/GwtProxy.ftl", model, new File(new File(gwtOutDir, "shared"), classModel.proxyClassName + ".java"));
runTemplate("requestfactory/GwtRequestFactory.ftl", model, new File(new File(gwtOutDir, "shared"), classModel.className + "RequestFactory.java"));
runTemplate("requestfactory/GwtService.ftl", model, new File(new File(gwtOutDir, "server"), classModel.serviceClassName + ".java"));
}
Aggregations