use of org.uberfire.annotations.processors.exceptions.GenerationException in project kie-wb-common by kiegroup.
the class MainProcessor method processLastRoundDefinitionFactory.
private boolean processLastRoundDefinitionFactory(final Set<? extends TypeElement> set, final RoundEnvironment roundEnv) throws Exception {
final Messager messager = processingEnv.getMessager();
try {
final int size = processingContext.getDefinitionAnnotations().getBuilderFieldNames().size() + processingContext.getDefSetAnnotations().getBuilderFieldNames().size();
if (size > 0) {
final Map<String, String> buildersMap = new LinkedHashMap<>();
if (!processingContext.getDefinitionAnnotations().getBuilderFieldNames().isEmpty()) {
buildersMap.putAll(processingContext.getDefinitionAnnotations().getBuilderFieldNames());
}
if (!processingContext.getDefSetAnnotations().getBuilderFieldNames().isEmpty()) {
buildersMap.putAll(processingContext.getDefSetAnnotations().getBuilderFieldNames());
}
// Ensure visible on both backend and client sides.
final String packageName = getGeneratedPackageName() + ".definition.factory";
final String className = getSetClassPrefix() + DEFINITION_FACTORY_CLASSNAME;
final String classFQName = packageName + "." + className;
messager.printMessage(Diagnostic.Kind.NOTE, "Starting ModelFactory adf for class named " + classFQName);
final StringBuffer ruleClassCode = generatedDefinitionFactoryGenerator.generate(packageName, className, buildersMap, messager);
writeCode(packageName, className, ruleClassCode);
}
} catch (GenerationException ge) {
final String msg = ge.getMessage();
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
}
return true;
}
use of org.uberfire.annotations.processors.exceptions.GenerationException in project kie-wb-common by kiegroup.
the class MainProcessor method processLastRoundPropertySetAdapter.
private boolean processLastRoundPropertySetAdapter(final Set<? extends TypeElement> set, final RoundEnvironment roundEnv) throws Exception {
final Messager messager = processingEnv.getMessager();
try {
// Ensure visible on both backend and client sides.
final String packageName = getGeneratedPackageName() + ".definition.adapter.binding";
final String className = getSetClassPrefix() + PROPERTYSET_ADAPTER_CLASSNAME;
final String classFQName = packageName + "." + className;
messager.printMessage(Diagnostic.Kind.NOTE, "Starting ErraiBinderAdapter adf named " + classFQName);
final StringBuffer ruleClassCode = propertySetAdapterGenerator.generate(packageName, className, processingContext.getPropertySetAnnotations(), messager);
writeCode(packageName, className, ruleClassCode);
} catch (GenerationException ge) {
final String msg = ge.getMessage();
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
}
return true;
}
use of org.uberfire.annotations.processors.exceptions.GenerationException in project kie-wb-common by kiegroup.
the class MainProcessor method processLastRoundDefinitionSetAdapter.
private boolean processLastRoundDefinitionSetAdapter(final Set<? extends TypeElement> set, final RoundEnvironment roundEnv) throws Exception {
final Messager messager = processingEnv.getMessager();
try {
// Ensure visible on both backend and client sides.
final String packageName = getGeneratedPackageName() + ".definition.adapter.binding";
final String className = getSetClassPrefix() + DEFINITIONSET_ADAPTER_CLASSNAME;
final String classFQName = packageName + "." + className;
messager.printMessage(Diagnostic.Kind.NOTE, "Starting ErraiBinderAdapter adf named " + classFQName);
final StringBuffer ruleClassCode = definitionSetAdapterGenerator.generate(packageName, className, processingContext.getDefSetAnnotations(), messager);
writeCode(packageName, className, ruleClassCode);
} catch (GenerationException ge) {
final String msg = ge.getMessage();
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
}
return true;
}
use of org.uberfire.annotations.processors.exceptions.GenerationException in project kie-wb-common by kiegroup.
the class MainProcessor method processLastRoundPropertyAdapter.
private boolean processLastRoundPropertyAdapter(final Set<? extends TypeElement> set, final RoundEnvironment roundEnv) throws Exception {
final Messager messager = processingEnv.getMessager();
try {
// Ensure visible on both backend and client sides.
final String packageName = getGeneratedPackageName() + ".definition.adapter.binding";
final String className = getSetClassPrefix() + PROPERTY_ADAPTER_CLASSNAME;
final String classFQName = packageName + "." + className;
messager.printMessage(Diagnostic.Kind.NOTE, "Starting ErraiBinderAdapter adf named " + classFQName);
final StringBuffer ruleClassCode = propertyAdapterGenerator.generate(packageName, className, processingContext.getPropertyAnnotations(), messager);
writeCode(packageName, className, ruleClassCode);
} catch (GenerationException ge) {
final String msg = ge.getMessage();
processingEnv.getMessager().printMessage(Diagnostic.Kind.ERROR, msg);
}
return true;
}
use of org.uberfire.annotations.processors.exceptions.GenerationException in project kie-wb-common by kiegroup.
the class EdgeCardinalityRuleGenerator method generateRule.
private StringBuffer generateRule(final Messager messager, final String ruleName, final String ruleDefinitionId, final String role, final String direction, final long min, final long max) throws GenerationException {
Map<String, Object> root = new HashMap<String, Object>();
root.put("ruleName", ruleName);
root.put("edgeId", ruleDefinitionId);
root.put("role", role);
root.put("direction", direction);
root.put("min", min);
root.put("max", max);
// Generate code
final StringWriter sw = new StringWriter();
final BufferedWriter bw = new BufferedWriter(sw);
try {
final Template template = config.getTemplate("EdgeCardinalityRule.ftl");
template.process(root, bw);
} catch (IOException ioe) {
throw new GenerationException(ioe);
} catch (TemplateException te) {
throw new GenerationException(te);
} finally {
try {
bw.close();
sw.close();
} catch (IOException ioe) {
throw new GenerationException(ioe);
}
}
messager.printMessage(Diagnostic.Kind.NOTE, "Successfully generated code for [" + ruleName + "]");
return sw.getBuffer();
}
Aggregations