use of org.kie.workbench.common.screens.datamodeller.backend.server.handler.DomainHandler in project kie-wb-common by kiegroup.
the class DataModelerServiceImpl method getAnnotationDefinitions.
@Override
public Map<String, AnnotationDefinition> getAnnotationDefinitions() {
Map<String, AnnotationDefinition> annotations = new HashMap<String, AnnotationDefinition>();
// add additional annotations configured by external domains
Iterator<DomainHandler> it = domainHandlers != null ? domainHandlers.iterator() : null;
DomainHandler domainHandler;
List<List<AnnotationDefinition>> allDomainsAnnotations = new ArrayList<List<AnnotationDefinition>>();
while (it != null && it.hasNext()) {
domainHandler = it.next();
allDomainsAnnotations.add(domainHandler.getManagedAnnotations());
}
List<AnnotationDefinition> coreAnnotationDefinitions = (new JavaRoasterModelDriver()).getConfiguredAnnotations();
allDomainsAnnotations.add(coreAnnotationDefinitions);
for (List<AnnotationDefinition> annotationDefinitionList : allDomainsAnnotations) {
if (annotationDefinitionList != null) {
for (AnnotationDefinition annotationDefinition : annotationDefinitionList) {
annotations.put(annotationDefinition.getClassName(), annotationDefinition);
}
}
}
return annotations;
}
use of org.kie.workbench.common.screens.datamodeller.backend.server.handler.DomainHandler in project kie-wb-common by kiegroup.
the class DataModelerServiceImpl method createJavaFile.
@Override
public Path createJavaFile(final Path context, final String fileName, final String comment, final Map<String, Object> options) {
final org.uberfire.java.nio.file.Path nioPath = Paths.convert(context).resolve(fileName);
final Path newPath = Paths.convert(nioPath);
if (ioService.exists(nioPath)) {
throw new FileAlreadyExistsException(nioPath.toString());
}
try {
final Package currentPackage = moduleService.resolvePackage(context);
String packageName = currentPackage.getPackageName();
String className = fileName.substring(0, fileName.indexOf(".java"));
final KieModule currentModule = moduleService.resolveModule(context);
DataObject dataObject = new DataObjectImpl(packageName, className);
Iterator<DomainHandler> it = domainHandlers != null ? domainHandlers.iterator() : null;
while (it != null && it.hasNext()) {
it.next().setDefaultValues(dataObject, options);
}
String source = createJavaSource(dataObject);
ioService.write(nioPath, source, serviceHelper.makeCommentedOption(comment));
dataObjectCreatedEvent.fire(new DataObjectCreatedEvent(currentModule, dataObject));
return newPath;
} catch (Exception e) {
// uncommon error.
logger.error("It was not possible to create Java file, for path: " + context.toURI() + ", fileName: " + fileName, e);
throw new ServiceException("It was not possible to create Java file, for path: " + context.toURI() + ", fileName: " + fileName, e);
}
}
Aggregations