001package org.nasdanika.html.flow;
002
003import org.eclipse.emf.ecore.EClass;
004import org.eclipse.emf.ecore.EOperation;
005import org.eclipse.emf.ecore.EPackage;
006import org.eclipse.emf.ecore.EStructuralFeature;
007import org.nasdanika.common.Context;
008import org.nasdanika.emf.FunctionAdapterFactory;
009import org.nasdanika.flow.Activity;
010import org.nasdanika.flow.Artifact;
011import org.nasdanika.flow.Flow;
012import org.nasdanika.flow.FlowPackage;
013import org.nasdanika.flow.Participant;
014import org.nasdanika.flow.PseudoState;
015import org.nasdanika.flow.Resource;
016import org.nasdanika.flow.Service;
017import org.nasdanika.html.emf.ActionProviderAdapterFactory;
018import org.nasdanika.html.model.app.util.ActionProvider;
019
020/**
021 * Provides adapters for the Ecore types - {@link EPackage}, {@link EClass}, {@link EStructuralFeature}, {@link EOperation}, ...
022 * @author Pavel
023 *
024 */
025public class FlowActionProviderAdapterFactory extends ActionProviderAdapterFactory {
026        
027        public FlowActionProviderAdapterFactory(Context context) {
028                super(context);
029                // Registering adapter factories.
030                registerAdapterFactory(
031                        new FunctionAdapterFactory<ActionProvider, org.nasdanika.flow.Package>(
032                                FlowPackage.Literals.PACKAGE, 
033                                ActionProvider.class, 
034                                this.getClass().getClassLoader(), 
035                                e -> new PackageActionBuilder(e, context).asActionProvider()));
036
037                // Participant
038                registerAdapterFactory(
039                                new FunctionAdapterFactory<ActionProvider, Participant>(
040                                        FlowPackage.Literals.PARTICIPANT, 
041                                        ActionProvider.class, 
042                                        this.getClass().getClassLoader(), 
043                                        e -> new ParticipantActionBuilder(e, context).asActionProvider()));
044                
045                // Resource
046                registerAdapterFactory(
047                                new FunctionAdapterFactory<ActionProvider, Resource>(
048                                        FlowPackage.Literals.RESOURCE, 
049                                        ActionProvider.class, 
050                                        this.getClass().getClassLoader(), 
051                                        e -> new ResourceActionBuilder(e, context).asActionProvider()));
052                
053                // Artifact
054                registerAdapterFactory(
055                                new FunctionAdapterFactory<ActionProvider, Artifact>(
056                                        FlowPackage.Literals.ARTIFACT, 
057                                        ActionProvider.class, 
058                                        this.getClass().getClassLoader(), 
059                                        e -> new ArtifactActionBuilder(e, context).asActionProvider()));
060                
061                // Pseudo-state
062                registerAdapterFactory(
063                                new FunctionAdapterFactory<ActionProvider, PseudoState>(
064                                        FlowPackage.Literals.PSEUDO_STATE, 
065                                        ActionProvider.class, 
066                                        this.getClass().getClassLoader(), 
067                                        e -> new PseudoStateActionBuilder<PseudoState>(e, context).asActionProvider()));
068                
069                // Activity
070                registerAdapterFactory(
071                                new FunctionAdapterFactory<ActionProvider, Activity<?>>(
072                                        FlowPackage.Literals.ACTIVITY, 
073                                        ActionProvider.class, 
074                                        this.getClass().getClassLoader(), 
075                                        e -> new ActivityActionBuilder<Activity<?>>(e, context).asActionProvider()));
076                
077                // Flow
078                registerAdapterFactory(
079                                new FunctionAdapterFactory<ActionProvider, Flow>(
080                                        FlowPackage.Literals.FLOW, 
081                                        ActionProvider.class, 
082                                        this.getClass().getClassLoader(), 
083                                        e -> new FlowActionBuilder(e, context).asActionProvider()));
084                
085                // Service
086                registerAdapterFactory(
087                                new FunctionAdapterFactory<ActionProvider, Service>(
088                                        FlowPackage.Literals.SERVICE, 
089                                        ActionProvider.class, 
090                                        this.getClass().getClassLoader(), 
091                                        e -> new ServiceActionBuilder(e, context).asActionProvider()));
092                
093        }
094                
095}