Search in sources :

Example 1 with RepresentationsConfiguration

use of org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration in project sirius-web by eclipse-sirius.

the class SubscriptionRepresentationsEventDataFetcher method get.

@Override
public Publisher<IPayload> get(DataFetchingEnvironment environment) throws Exception {
    Object argument = environment.getArgument(SubscriptionTypeProvider.INPUT_ARGUMENT);
    var input = this.objectMapper.convertValue(argument, RepresentationsEventInput.class);
    RepresentationsConfiguration representationsConfiguration = new RepresentationsConfiguration(input.getObjectId());
    // @formatter:off
    return this.editingContextEventProcessorRegistry.getOrCreateEditingContextEventProcessor(input.getEditingContextId()).flatMap(processor -> processor.acquireRepresentationEventProcessor(IFormEventProcessor.class, representationsConfiguration, input)).map(representationEventProcessor -> representationEventProcessor.getOutputEvents(input)).orElse(Flux.empty());
// @formatter:on
}
Also used : DataFetchingEnvironment(graphql.schema.DataFetchingEnvironment) SubscriptionTypeProvider(org.eclipse.sirius.web.graphql.schema.SubscriptionTypeProvider) IEditingContextEventProcessorRegistry(org.eclipse.sirius.components.collaborative.api.IEditingContextEventProcessorRegistry) Publisher(org.reactivestreams.Publisher) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) RepresentationsConfiguration(org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration) IDataFetcherWithFieldCoordinates(org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates) Objects(java.util.Objects) Flux(reactor.core.publisher.Flux) IPayload(org.eclipse.sirius.components.core.api.IPayload) SubscriptionDataFetcher(org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher) IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) RepresentationsEventInput(org.eclipse.sirius.components.collaborative.forms.dto.RepresentationsEventInput) IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) RepresentationsConfiguration(org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration)

Example 2 with RepresentationsConfiguration

use of org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration in project sirius-components by eclipse-sirius.

the class RepresentationsEventProcessorFactory method createRepresentationEventProcessor.

@Override
public <T extends IRepresentationEventProcessor> Optional<T> createRepresentationEventProcessor(Class<T> representationEventProcessorClass, IRepresentationConfiguration configuration, IEditingContext editingContext) {
    if (IFormEventProcessor.class.isAssignableFrom(representationEventProcessorClass) && configuration instanceof RepresentationsConfiguration) {
        RepresentationsConfiguration representationsConfiguration = (RepresentationsConfiguration) configuration;
        FormDescription formDescription = this.representationsDescriptionProvider.getRepresentationsDescription();
        Optional<Object> optionalObject = this.objectService.getObject(editingContext, representationsConfiguration.getObjectId());
        if (optionalObject.isPresent()) {
            Object object = optionalObject.get();
            // @formatter:off
            FormCreationParameters formCreationParameters = FormCreationParameters.newFormCreationParameters(representationsConfiguration.getId()).editingContext(editingContext).formDescription(formDescription).objects(List.of(object)).build();
            // @formatter:on
            FormEventProcessor formEventProcessor = new FormEventProcessor(formCreationParameters, this.formEventHandlers, this.subscriptionManagerFactory.create(), this.widgetSubscriptionManagerFactory.create(), this.representationRefreshPolicyRegistry);
            // @formatter:off
            return Optional.of(formEventProcessor).filter(representationEventProcessorClass::isInstance).map(representationEventProcessorClass::cast);
        // @formatter:on
        }
    }
    return Optional.empty();
}
Also used : IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) IFormEventProcessor(org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor) FormCreationParameters(org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters) FormDescription(org.eclipse.sirius.components.forms.description.FormDescription) RepresentationsConfiguration(org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration)

Aggregations

IFormEventProcessor (org.eclipse.sirius.components.collaborative.forms.api.IFormEventProcessor)2 RepresentationsConfiguration (org.eclipse.sirius.components.collaborative.forms.api.RepresentationsConfiguration)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 DataFetchingEnvironment (graphql.schema.DataFetchingEnvironment)1 Objects (java.util.Objects)1 SubscriptionDataFetcher (org.eclipse.sirius.components.annotations.spring.graphql.SubscriptionDataFetcher)1 IEditingContextEventProcessorRegistry (org.eclipse.sirius.components.collaborative.api.IEditingContextEventProcessorRegistry)1 FormCreationParameters (org.eclipse.sirius.components.collaborative.forms.api.FormCreationParameters)1 RepresentationsEventInput (org.eclipse.sirius.components.collaborative.forms.dto.RepresentationsEventInput)1 IPayload (org.eclipse.sirius.components.core.api.IPayload)1 FormDescription (org.eclipse.sirius.components.forms.description.FormDescription)1 IDataFetcherWithFieldCoordinates (org.eclipse.sirius.components.graphql.api.IDataFetcherWithFieldCoordinates)1 SubscriptionTypeProvider (org.eclipse.sirius.web.graphql.schema.SubscriptionTypeProvider)1 Publisher (org.reactivestreams.Publisher)1 Flux (reactor.core.publisher.Flux)1