Search in sources :

Example 1 with JsonSchemaGenerator

use of org.kie.kogito.codegen.json.JsonSchemaGenerator in project kogito-runtimes by kiegroup.

the class ProcessesAssetsProcessor method generateJsonSchema.

private Collection<GeneratedFile> generateJsonSchema(KogitoBuildContext context, IndexView index, Map<String, byte[]> generatedClasses) throws IOException {
    ClassLoader cl = new InMemoryClassLoader(context.getClassLoader(), generatedClasses);
    List<AnnotationInstance> annotations = new ArrayList<>();
    annotations.addAll(index.getAnnotations(DotName.createSimple(ProcessInput.class.getCanonicalName())));
    annotations.addAll(index.getAnnotations(DotName.createSimple(UserTask.class.getCanonicalName())));
    List<Class<?>> annotatedClasses = annotations.stream().map(ann -> loadClassFromAnnotation(ann, cl)).filter(Optional::isPresent).map(Optional::get).collect(Collectors.toList());
    JsonSchemaGenerator jsonSchemaGenerator = new JsonSchemaGenerator.ClassBuilder(annotatedClasses.stream()).withSchemaVersion(System.getProperty("kogito.jsonSchema.version")).build();
    return jsonSchemaGenerator.generate();
}
Also used : ProcessErrorEventBody(org.kie.kogito.event.process.ProcessErrorEventBody) KogitoGeneratedSourcesBuildItem(org.kie.kogito.quarkus.common.deployment.KogitoGeneratedSourcesBuildItem) ClassInfo(org.jboss.jandex.ClassInfo) AdditionalStaticResourceBuildItem(io.quarkus.vertx.http.deployment.spi.AdditionalStaticResourceBuildItem) CombinedIndexBuildItem(io.quarkus.deployment.builditem.CombinedIndexBuildItem) BuildProducer(io.quarkus.deployment.annotations.BuildProducer) UserTaskInstanceDataEvent(org.kie.kogito.event.process.UserTaskInstanceDataEvent) GeneratedBeanBuildItem(io.quarkus.arc.deployment.GeneratedBeanBuildItem) Capabilities(io.quarkus.deployment.Capabilities) UserTaskInstanceEventBody(org.kie.kogito.event.process.UserTaskInstanceEventBody) AdditionalBeanBuildItem(io.quarkus.arc.deployment.AdditionalBeanBuildItem) ArchiveRootBuildItem(io.quarkus.deployment.builditem.ArchiveRootBuildItem) FeatureBuildItem(io.quarkus.deployment.builditem.FeatureBuildItem) KogitoQuarkusResourceUtils.registerResources(org.kie.kogito.quarkus.common.deployment.KogitoQuarkusResourceUtils.registerResources) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) JsonSchemaGenerator(org.kie.kogito.codegen.json.JsonSchemaGenerator) PathMatcher(java.nio.file.PathMatcher) ProcessDataEvent(org.kie.kogito.event.process.ProcessDataEvent) Path(java.nio.file.Path) QuarkusProcessIdFactory(org.kie.kogito.core.process.incubation.quarkus.support.QuarkusProcessIdFactory) QuarkusStraightThroughProcessService(org.kie.kogito.core.process.incubation.quarkus.support.QuarkusStraightThroughProcessService) ReflectiveHierarchyBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem) KogitoBuildContext(org.kie.kogito.codegen.api.context.KogitoBuildContext) KogitoProcessContainerGeneratorBuildItem(org.kie.kogito.quarkus.extensions.spi.deployment.KogitoProcessContainerGeneratorBuildItem) Collection(java.util.Collection) NativeImageResourceBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem) NativeOrNativeSourcesBuild(io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild) KogitoTypesProtobuf(org.kie.kogito.serialization.process.protobuf.KogitoTypesProtobuf) Collectors(java.util.stream.Collectors) KogitoNodeInstanceContentsProtobuf(org.kie.kogito.serialization.process.protobuf.KogitoNodeInstanceContentsProtobuf) List(java.util.List) Stream(java.util.stream.Stream) Model(org.kie.kogito.Model) AnnotationInstance(org.jboss.jandex.AnnotationInstance) QuarkusHumanTaskService(org.kie.kogito.core.process.incubation.quarkus.support.QuarkusHumanTaskService) ResolvedDependency(io.quarkus.maven.dependency.ResolvedDependency) Optional(java.util.Optional) ServiceProviderBuildItem(io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem) GeneratedFileType(org.drools.codegen.common.GeneratedFileType) AttachmentEventBody(org.kie.kogito.event.process.AttachmentEventBody) UserTaskDeadlineEventBody(org.kie.kogito.event.process.UserTaskDeadlineEventBody) ReflectiveClassBuildItem(io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem) KogitoQuarkusResourceUtils.getTargetClassesPath(org.kie.kogito.quarkus.common.deployment.KogitoQuarkusResourceUtils.getTargetClassesPath) MilestoneEventBody(org.kie.kogito.event.process.MilestoneEventBody) DotName(org.jboss.jandex.DotName) Type(org.jboss.jandex.Type) KogitoWorkItemsProtobuf(org.kie.kogito.serialization.process.protobuf.KogitoWorkItemsProtobuf) HashMap(java.util.HashMap) UserTask(org.kie.kogito.UserTask) CorrelationServiceProducer(org.kie.kogito.correlation.CorrelationServiceProducer) ObjectMarshallerStrategy(org.kie.kogito.serialization.process.ObjectMarshallerStrategy) CurateOutcomeBuildItem(io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem) ArrayList(java.util.ArrayList) GeneratedFileValidation.validateGeneratedFileTypes(org.kie.kogito.codegen.core.utils.GeneratedFileValidation.validateGeneratedFileTypes) Inject(javax.inject.Inject) IndexDependencyBuildItem(io.quarkus.deployment.builditem.IndexDependencyBuildItem) BuildStep(io.quarkus.deployment.annotations.BuildStep) ProcessInstanceEventBody(org.kie.kogito.event.process.ProcessInstanceEventBody) VariableInstanceDataEvent(org.kie.kogito.event.process.VariableInstanceDataEvent) KogitoGeneratedClassesBuildItem(org.kie.kogito.quarkus.common.deployment.KogitoGeneratedClassesBuildItem) NativeImageResourcePatternsBuildItem(io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem) ProcessInput(org.kie.kogito.ProcessInput) ProcessContainerGenerator(org.kie.kogito.codegen.process.ProcessContainerGenerator) NodeInstanceEventBody(org.kie.kogito.event.process.NodeInstanceEventBody) DroolsQuarkusResourceUtils.compileGeneratedSources(org.drools.drl.quarkus.util.deployment.DroolsQuarkusResourceUtils.compileGeneratedSources) ProcessInstanceDataEvent(org.kie.kogito.event.process.ProcessInstanceDataEvent) KogitoQuarkusResourceUtils.generateAggregatedIndex(org.kie.kogito.quarkus.common.deployment.KogitoQuarkusResourceUtils.generateAggregatedIndex) KogitoProcessInstanceProtobuf(org.kie.kogito.serialization.process.protobuf.KogitoProcessInstanceProtobuf) PersistenceGenerator(org.kie.kogito.codegen.process.persistence.PersistenceGenerator) CommentEventBody(org.kie.kogito.event.process.CommentEventBody) IndexView(org.jboss.jandex.IndexView) GeneratedResourceBuildItem(io.quarkus.deployment.builditem.GeneratedResourceBuildItem) Files(java.nio.file.Files) IOException(java.io.IOException) KogitoBuildContextBuildItem(org.kie.kogito.quarkus.common.deployment.KogitoBuildContextBuildItem) VariableInstanceEventBody(org.kie.kogito.event.process.VariableInstanceEventBody) Collectors.toList(java.util.stream.Collectors.toList) KogitoQuarkusResourceUtils.dumpFilesToDisk(org.kie.kogito.quarkus.common.deployment.KogitoQuarkusResourceUtils.dumpFilesToDisk) UserTaskDeadlineDataEvent(org.kie.kogito.event.process.UserTaskDeadlineDataEvent) Paths(java.nio.file.Paths) GeneratedFile(org.drools.codegen.common.GeneratedFile) LiveReloadBuildItem(io.quarkus.deployment.builditem.LiveReloadBuildItem) FileSystems(java.nio.file.FileSystems) QuarkusStatefulProcessService(org.kie.kogito.core.process.incubation.quarkus.support.QuarkusStatefulProcessService) Optional(java.util.Optional) ArrayList(java.util.ArrayList) UserTask(org.kie.kogito.UserTask) ProcessInput(org.kie.kogito.ProcessInput) JsonSchemaGenerator(org.kie.kogito.codegen.json.JsonSchemaGenerator) AnnotationInstance(org.jboss.jandex.AnnotationInstance)

Aggregations

AdditionalBeanBuildItem (io.quarkus.arc.deployment.AdditionalBeanBuildItem)1 GeneratedBeanBuildItem (io.quarkus.arc.deployment.GeneratedBeanBuildItem)1 Capabilities (io.quarkus.deployment.Capabilities)1 BuildProducer (io.quarkus.deployment.annotations.BuildProducer)1 BuildStep (io.quarkus.deployment.annotations.BuildStep)1 ArchiveRootBuildItem (io.quarkus.deployment.builditem.ArchiveRootBuildItem)1 CombinedIndexBuildItem (io.quarkus.deployment.builditem.CombinedIndexBuildItem)1 FeatureBuildItem (io.quarkus.deployment.builditem.FeatureBuildItem)1 GeneratedResourceBuildItem (io.quarkus.deployment.builditem.GeneratedResourceBuildItem)1 IndexDependencyBuildItem (io.quarkus.deployment.builditem.IndexDependencyBuildItem)1 LiveReloadBuildItem (io.quarkus.deployment.builditem.LiveReloadBuildItem)1 NativeImageResourceBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourceBuildItem)1 NativeImageResourcePatternsBuildItem (io.quarkus.deployment.builditem.nativeimage.NativeImageResourcePatternsBuildItem)1 ReflectiveClassBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem)1 ReflectiveHierarchyBuildItem (io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem)1 ServiceProviderBuildItem (io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem)1 CurateOutcomeBuildItem (io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem)1 NativeOrNativeSourcesBuild (io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild)1 ResolvedDependency (io.quarkus.maven.dependency.ResolvedDependency)1 AdditionalStaticResourceBuildItem (io.quarkus.vertx.http.deployment.spi.AdditionalStaticResourceBuildItem)1