Search in sources :

Example 1 with AnnotatedDescriptorImpl

use of org.infinispan.protostream.impl.AnnotatedDescriptorImpl in project kogito-apps by kiegroup.

the class ProtoDomainModelProducer method onFileDescriptorRegistered.

public void onFileDescriptorRegistered(@Observes FileDescriptorRegisteredEvent event) {
    FileDescriptor descriptor = event.getDescriptor();
    String rootMessage = (String) descriptor.getOption("kogito_model").getValue();
    String processId = (String) descriptor.getOption("kogito_id").getValue();
    Map<String, Descriptor> map = descriptor.getMessageTypes().stream().collect(toMap(AnnotatedDescriptorImpl::getName, desc -> desc));
    Descriptor rootDescriptor = map.remove(rootMessage);
    DomainDescriptor domain = new DomainDescriptorMapper().apply(rootDescriptor);
    List<DomainDescriptor> additionalTypes = map.values().stream().map(desc -> new DomainDescriptorMapper().apply(desc)).collect(toList());
    domainEvent.fire(new DomainModelRegisteredEvent(processId, domain, additionalTypes));
}
Also used : Event(javax.enterprise.event.Event) FileDescriptor(org.infinispan.protostream.descriptors.FileDescriptor) Logger(org.slf4j.Logger) LoggerFactory(org.slf4j.LoggerFactory) Descriptor(org.infinispan.protostream.descriptors.Descriptor) Function(java.util.function.Function) FieldDescriptor(org.infinispan.protostream.descriptors.FieldDescriptor) Inject(javax.inject.Inject) AnnotatedDescriptorImpl(org.infinispan.protostream.impl.AnnotatedDescriptorImpl) AttributeDescriptor(org.kie.kogito.persistence.api.proto.AttributeDescriptor) FileDescriptorRegisteredEvent(org.kie.kogito.persistence.protobuf.FileDescriptorRegisteredEvent) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Collectors.toMap(java.util.stream.Collectors.toMap) DomainDescriptor(org.kie.kogito.persistence.api.proto.DomainDescriptor) Map(java.util.Map) Observes(javax.enterprise.event.Observes) DomainModelRegisteredEvent(org.kie.kogito.persistence.api.proto.DomainModelRegisteredEvent) ApplicationScoped(javax.enterprise.context.ApplicationScoped) FileDescriptor(org.infinispan.protostream.descriptors.FileDescriptor) Descriptor(org.infinispan.protostream.descriptors.Descriptor) FieldDescriptor(org.infinispan.protostream.descriptors.FieldDescriptor) AttributeDescriptor(org.kie.kogito.persistence.api.proto.AttributeDescriptor) DomainDescriptor(org.kie.kogito.persistence.api.proto.DomainDescriptor) DomainModelRegisteredEvent(org.kie.kogito.persistence.api.proto.DomainModelRegisteredEvent) DomainDescriptor(org.kie.kogito.persistence.api.proto.DomainDescriptor) FileDescriptor(org.infinispan.protostream.descriptors.FileDescriptor)

Aggregations

List (java.util.List)1 Map (java.util.Map)1 Function (java.util.function.Function)1 Collectors.toList (java.util.stream.Collectors.toList)1 Collectors.toMap (java.util.stream.Collectors.toMap)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Event (javax.enterprise.event.Event)1 Observes (javax.enterprise.event.Observes)1 Inject (javax.inject.Inject)1 Descriptor (org.infinispan.protostream.descriptors.Descriptor)1 FieldDescriptor (org.infinispan.protostream.descriptors.FieldDescriptor)1 FileDescriptor (org.infinispan.protostream.descriptors.FileDescriptor)1 AnnotatedDescriptorImpl (org.infinispan.protostream.impl.AnnotatedDescriptorImpl)1 AttributeDescriptor (org.kie.kogito.persistence.api.proto.AttributeDescriptor)1 DomainDescriptor (org.kie.kogito.persistence.api.proto.DomainDescriptor)1 DomainModelRegisteredEvent (org.kie.kogito.persistence.api.proto.DomainModelRegisteredEvent)1 FileDescriptorRegisteredEvent (org.kie.kogito.persistence.protobuf.FileDescriptorRegisteredEvent)1 Logger (org.slf4j.Logger)1 LoggerFactory (org.slf4j.LoggerFactory)1