Revision 240

View differences:

branches/modelio3.6.x/src/main/java/org/modelio/togaf/handlers/commands/Migration37.java
1
package org.modelio.togaf.handlers.commands;
2

  
3
import java.util.ArrayList;
4
import java.util.List;
5

  
6
import org.eclipse.draw2d.geometry.Point;
7
import org.eclipse.jface.dialogs.MessageDialog;
8
import org.eclipse.swt.widgets.Shell;
9
import org.modelio.api.modelio.diagram.IDiagramGraphic;
10
import org.modelio.api.modelio.diagram.IDiagramHandle;
11
import org.modelio.api.modelio.diagram.IDiagramLink;
12
import org.modelio.api.modelio.diagram.IDiagramNode;
13
import org.modelio.api.modelio.model.IModelingSession;
14
import org.modelio.api.modelio.model.ITransaction;
15
import org.modelio.api.module.IModule;
16
import org.modelio.api.module.command.DefaultModuleCommandHandler;
17
import org.modelio.metamodel.bpmn.bpmnDiagrams.BpmnProcessCollaborationDiagram;
18
import org.modelio.metamodel.bpmn.processCollaboration.BpmnCollaboration;
19
import org.modelio.metamodel.bpmn.processCollaboration.BpmnProcess;
20
import org.modelio.metamodel.bpmn.rootElements.BpmnBehavior;
21
import org.modelio.metamodel.diagrams.AbstractDiagram;
22
import org.modelio.metamodel.mmextensions.infrastructure.ExtensionNotFoundException;
23
import org.modelio.metamodel.uml.informationFlow.InformationFlow;
24
import org.modelio.metamodel.uml.infrastructure.Dependency;
25
import org.modelio.metamodel.uml.infrastructure.ModelElement;
26
import org.modelio.metamodel.uml.infrastructure.Note;
27
import org.modelio.metamodel.uml.statik.Classifier;
28
import org.modelio.togaf.i18n.Messages;
29
import org.modelio.togaf.impl.TogafArchitectModule;
30
import org.modelio.vcore.smkernel.AccessDeniedException;
31
import org.modelio.vcore.smkernel.mapi.MObject;
32

  
33
public class Migration37 extends DefaultModuleCommandHandler {
34
    @Override
35
    public void actionPerformed(List<MObject> selectedElements, IModule module) {
36
        // Prepare the ptoject to be megrated to Modelio 3.7
37
        
38
         // Coppy properties defined under BpmnBehavior stereotyped TogafProcess under owned BpmnProcess under :
39
         // * BpmnProcess is the process have no Pool
40
         // * BpncCollaboration is the process have more than one pool
41
         IModelingSession session = TogafArchitectModule.getInstance().getModuleContext().getModelingSession();
42
         
43
         try(ITransaction tr = session.createTransaction("Migration37")){
44
             for(BpmnBehavior behavior : session.findByClass(BpmnBehavior.class)){
45
                 if(behavior.isStereotyped("TogafArchitect", "TogafProcess")){
46
                     migrateProcess(behavior);
47
                 }
48
             }
49
             
50
             tr.commit();          
51
             MessageDialog.openInformation(new Shell(), Messages.getString("migration_success_title"), Messages.getString("migration_success_message"));            
52
         } catch (ExtensionNotFoundException e) {
53
             MessageDialog.openError(new Shell(), Messages.getString("migration_failled_title"), e.getMessage());
54
         }catch(AccessDeniedException e){
55
             MessageDialog.openError(new Shell(), Messages.getString("migration_failled_title"), Messages.getString("migration_failled_lock",e.getMessage()));
56
         }
57
    }
58

  
59
    @Override
60
    public boolean accept(List<MObject> selectedElements, IModule module) {
61
        // Generated call to the super method will check the scope conditions defined in Studio.
62
        // DO NOT REMOVE this call unless you need to take full control on the checks to be carried out.
63
        // However you can safely extends the checked conditions by adding custom code.
64
        if (super.accept(selectedElements, module) == false) {
65
            return false;
66
        }
67
        return true;
68
    }
69

  
70
    private void migrateProcess(BpmnBehavior behavior) throws ExtensionNotFoundException {
71
        List<BpmnProcess> process = behavior.getRootElement(BpmnProcess.class);
72
        List<BpmnCollaboration> collborations = behavior.getRootElement(BpmnCollaboration.class);
73
        
74
        if(process.size() == 0){
75
            createNewPorcess(behavior);        
76
        }else if(process.size() == 1){
77
            if(process.get(0).getLaneSet().size() > 0 &&process.get(0).getLaneSet().get(0).getLane().size() > 1){
78
                migrateToCollaboration(behavior,collborations.get(0));
79
            }else{
80
                migrateToProcess(behavior,process.get(0));
81
            }
82
        }else if(process.size() > 1){
83
            migrateToCollaboration(behavior,collborations.get(0));
84
        }
85
    }
86

  
87
    private void migrateToProcess(BpmnBehavior behavior, BpmnProcess bpmnProcess) throws ExtensionNotFoundException {
88
        bpmnProcess.setName(behavior.getName());
89
        bpmnProcess.addStereotype("TogafArchitect", "BPMProcess");
90
        cratePostMigrationNote(behavior,bpmnProcess);
91
        migrateDependecies(behavior,bpmnProcess);
92
    }
93

  
94
    private void migrateToCollaboration(BpmnBehavior behavior, BpmnCollaboration bpmnCollaboration) throws ExtensionNotFoundException {
95
        bpmnCollaboration.setName(behavior.getName());
96
        bpmnCollaboration.addStereotype("TogafArchitect", "BPMMacroProcess");        
97
        cratePostMigrationNote(behavior,bpmnCollaboration);
98
        migrateDependecies(behavior,bpmnCollaboration);
99
    }
100

  
101
    private void createNewPorcess(BpmnBehavior behavior) throws ExtensionNotFoundException {
102
        IModelingSession session = TogafArchitectModule.getInstance().getModuleContext().getModelingSession();
103
        BpmnProcess newProcess = session.getModel().createBpmnProcess();
104
        newProcess.setOwner(behavior);
105
        newProcess.setName(behavior.getName());
106
        newProcess.addStereotype("TogafArchitect", "BPMProcess");        
107
        BpmnProcessCollaborationDiagram diagram = session.getModel().createBpmnProcessCollaborationDiagram();
108
        diagram.setOrigin(newProcess);
109
    }
110

  
111
    
112
    private void cratePostMigrationNote(BpmnBehavior behavior, ModelElement modelElement) throws ExtensionNotFoundException {
113
        StringBuffer migrationData = new StringBuffer();
114
        
115
        // serialise position of behavior in diagrams
116
        for(AbstractDiagram diag : behavior.getDiagramElement()){    
117
            serailizeDiagramData(migrationData,behavior,diag);    
118
        }
119
        
120
        // serialise position of dependencies in diagrams
121
        for(Dependency dp: behavior.getDependsOnDependency()){
122
            for(AbstractDiagram diag : dp.getDiagramElement()){                
123
                serailizeDiagramData(migrationData,dp,diag);
124
            }
125
        }
126
        
127
        for(Dependency dp: behavior.getImpactedDependency()){
128
            for(AbstractDiagram diag : dp.getDiagramElement()){                
129
                serailizeDiagramData(migrationData,dp,diag);
130
            }
131
        }    
132
        
133
        // serialise informations related to informationflow
134
        for(InformationFlow flow : behavior.getSentInfo()){        
135
            if(!flow.getInformationTarget().isEmpty()){
136
                
137
                if(!"".equals(migrationData.toString())){
138
                    migrationData.append(",");
139
                }
140
                
141
                migrationData = migrationData.append("InformationFlow[");
142
                migrationData.append("InformationTarge:" +flow.getInformationTarget().get(0).getUuid());
143
                for(Classifier conv : flow.getConveyed()){
144
                    migrationData.append(",Conveyed:" +conv.getUuid());
145
                }
146
                migrationData.append("]");
147
                    
148
                for(AbstractDiagram diag : flow.getDiagramElement()){                
149
                    serailizeDiagramData(migrationData,flow,diag);
150
                }
151
            }    
152
        }    
153
        
154
        for(InformationFlow flow : behavior.getReceivedInfo()){        
155
            if(!flow.getInformationSource().isEmpty()){
156
                
157
                if(!"".equals(migrationData.toString())){
158
                    migrationData.append(",");
159
                }
160
                
161
                migrationData = migrationData.append("InformationFlow[");
162
                migrationData.append("InformationSource:" +flow.getInformationSource().get(0).getUuid());
163
                for(Classifier conv : flow.getConveyed()){
164
                    migrationData.append("|Conveyed:" +conv.getUuid());
165
                }
166
                
167
                migrationData.append("]");
168
                for(AbstractDiagram diag : flow.getDiagramElement()){                
169
                    serailizeDiagramData(migrationData,flow,diag);
170
                }
171
            
172
            }    
173
        }
174
        
175
        
176
        IModelingSession session = TogafArchitectModule.getInstance().getModuleContext().getModelingSession();
177
        Note note = session.getModel().createNote("ModelerModule","description",modelElement, "Migration37");
178
        note.setName("Migration37");
179
        note.setContent(migrationData.toString());
180
    }
181

  
182
    private void serailizeDiagramData(StringBuffer migrationData, ModelElement element, AbstractDiagram diag) {
183
        if(!"".equals(migrationData.toString())){
184
            migrationData.append(",");
185
        }
186
        
187
        migrationData.append("Diagram:" + diag.getUuid() +":"+element.getUuid()+":");
188
        IDiagramHandle handel =  TogafArchitectModule.getInstance().getModuleContext().getModelioServices().getDiagramService().getDiagramHandle(diag);
189
        try{
190
            List<IDiagramGraphic> graphics  = handel.getDiagramGraphics(element);
191
            if(!graphics.isEmpty()){
192
                if(graphics.get(0) instanceof IDiagramLink){
193
                    IDiagramLink link = (IDiagramLink)graphics.get(0);
194
                    migrationData.append("link{");
195
                    for(Point p: link.getPath().getPoints()){
196
                        migrationData.append(p.x +"&" + p.y);            
197
                        if(!p.equals(link.getPath().getPoints().get(link.getPath().getPoints().size()-1))){
198
                            migrationData.append("|");
199
                        }
200
                    }
201
                    migrationData.append("}");
202
                }else if (graphics.get(0) instanceof IDiagramNode){
203
                    IDiagramNode node = (IDiagramNode)graphics.get(0);
204
                    migrationData.append("node{"+node.getBounds().x +"&" + node.getBounds().y +"&" + node.getBounds().width +"&" + node.getBounds().width+"}");
205
                }    
206
            }
207
        }finally{
208
            handel.close();
209
        }
210
    }
211

  
212
    private void migrateDependecies(BpmnBehavior behavior, ModelElement modelElement) {
213
        for(Dependency dp: new ArrayList<>(behavior.getDependsOnDependency())){
214
            dp.setImpacted(modelElement);
215
        }
216
        
217
        for(Dependency dp: new ArrayList<>(behavior.getImpactedDependency())){
218
            dp.setDependsOn(modelElement);
219
        }
220
    }
221

  
222
}
0 223

  
branches/modelio3.6.x/src/main/java/org/modelio/togaf/profile/structure/commande/explorer/BusinessLayerCommande.java
45 45
	public boolean accept(List<MObject> selected_element, IModule module) {
46 46
		if (selected_element.size() > 0 && selected_element.get(0) instanceof ModelElement) {
47 47
			ModelElement element = (ModelElement) selected_element.get(0);
48
			
49
		
50
            List<Package> root =  ((Project)TogafArchitectModule.getInstance().getModuleContext().getModelingSession().getModel().getRoot(selected_element.get(0))).getModel();
51 48

  
52
            if (element instanceof Package && root.contains(element)) {
53
                return true;
54
            }
49
			List<Package> root = ((Project) TogafArchitectModule.getInstance().getModuleContext().getModelingSession().getModel().getRoot(selected_element.get(0))).getModel();
50

  
51
			if (element instanceof Package && root.contains(element)) {
52
				return true;
53
			}
55 54
		}
56 55
		return false;
57 56
	}
branches/modelio3.6.x/src/main/conf/module.xml
785 785
                <TagTypes/>
786 786
            </Stereotype>
787 787
        </Profile>
788
        <Profile uid="0563bce5-d823-4231-bc72-17abce68428b" id="BPM">
789
            <Stereotype name="BPMProcess" metaclass="Standard.BpmnProcess" owner-stereotype="mref#'' {fd8b243a-ab70-11df-9861-0014224f9977} Infrastructure.Stereotype" is-hidden="false" label="%stereotype.BPMProcess.label" uid="b9d7cee1-8fe0-45ec-98fa-ea750d4ab42f">
790
                <TagTypes>
791
                    <TagType name="BPMProcess_criticality" uid="1ef49f0a-f0cd-409e-840b-375ec90b33d0" label="criticality" parameter-card="1" is-hidden="false" is-signed="false"/>
792
                    <TagType name="BPMProcess_isAutomated" uid="16f5e558-fba2-4e93-b2ba-e8234d36b9e8" label="isAutomated" parameter-card="0" is-hidden="false" is-signed="false"/>
793
                    <TagType name="BPMProcess_volumetrics" uid="99f72cce-0502-497c-9228-28cbfedd71da" label="volumetrics" parameter-card="1" is-hidden="false" is-signed="false"/>
794
                    <TagType name="BPMProcess_duration" uid="ec7f20ac-cc6a-4c80-9424-004b7c7b00a3" label="duration" parameter-card="1" is-hidden="false" is-signed="false"/>
795
                    <TagType name="BPMProcess_KPI" uid="5abed804-37dd-42ad-9be7-54a0ffa2a8cb" label="kpi" parameter-card="1" is-hidden="false" is-signed="false"/>
796
                    <TagType name="BPMProcess_used_resources" uid="aacd517a-6c5c-403e-937f-2b25e1b4b76b" label="used_resources" parameter-card="1" is-hidden="false" is-signed="false"/>
797
                    <TagType name="BPMProcess_kind" uid="4f2feca9-902f-4fb8-bb4d-d9fb4658a6a9" label="kind" parameter-card="1" is-hidden="false" is-signed="false"/>
798
                </TagTypes>
799
            </Stereotype>
800
            <Stereotype name="BPMMacroProcess" metaclass="Standard.BpmnCollaboration" owner-stereotype="mref#'' {fd8b243a-ab70-11df-9861-0014224f9977} Infrastructure.Stereotype" is-hidden="false" label="%stereotype.BPMMacroProcess.label" uid="669d8f10-9c4c-4aee-b9d5-36fd8a5532d0">
801
                <TagTypes>
802
                    <TagType name="BPMMacroProcess_criticality" uid="14efc6c8-cacc-4542-a5cc-a5d70604a2c6" label="criticality" parameter-card="1" is-hidden="false" is-signed="false"/>
803
                    <TagType name="BPMMacroProcess_isAutomated" uid="d9e6d98a-51b2-43be-8eb0-c11dfec1557a" label="isAutomated" parameter-card="0" is-hidden="false" is-signed="false"/>
804
                    <TagType name="BPMMacroProcess_volumetrics" uid="5f794eab-8a3b-46e5-8a1f-0c5ea0c404c0" label="volumetrics" parameter-card="1" is-hidden="false" is-signed="false"/>
805
                    <TagType name="BPMMacroProcess_duration" uid="7f55f357-c4de-4d63-ad18-d4c15b497a76" label="duration" parameter-card="1" is-hidden="false" is-signed="false"/>
806
                    <TagType name="BPMMacroProcess_KPI" uid="c0d736ee-0143-4c7d-9dc3-28a99acfccce" label="kpi" parameter-card="1" is-hidden="false" is-signed="false"/>
807
                    <TagType name="BPMMacroProcess_used_resources" uid="a37d9ce3-17d7-4ea7-b129-5e4ec994cc1f" label="used_resources" parameter-card="1" is-hidden="false" is-signed="false"/>
808
                    <TagType name="BPMMacroProcess_kind" uid="f40f34fd-5db9-4aab-8c37-6319c9a83ec8" label="kind" parameter-card="1" is-hidden="false" is-signed="false"/>
809
                </TagTypes>
810
            </Stereotype>
811
        </Profile>
788 812
    </Profiles>
789 813
    <Parameters>
790 814
        <Parameter id="DisplayNote" group="Diagrams" uid="417e78ae-d6a2-11df-ade8-0014224f9977"/>
791 815
    </Parameters>
792 816
    <Gui>
793 817
        <Commands>
818
            <Command id="Migration_Modelio_3.7" label="%command.Migration_Modelio_3.7.label" tooltip="%command.Migration_Modelio_3.7.tooltip" modify-model="true">
819
                <Scope metaclass="Infrastructure.ModelElement" stereotype=""/>
820
                <Handler class="org.modelio.togaf.handlers.commands.Migration37"/>
821
            </Command>
794 822
            <Command id="TogafClassDiagramCommand" label="%TogafClassDiagramCommand.label" tooltip="%TogafClassDiagramCommand.tooltip" image="%TogafClassDiagramCommand.image" group="%Diagrams.group" modify-model="true" group-image="%Diagrams.groupimage">
795 823
                <Scope metaclass="Package"/>
796 824
                <Scope metaclass="Class"/>
......
1866 1894
            </Tool>
1867 1895
        </Tools>
1868 1896
        <ContextualMenu>
1897
            <CommandRef refid="Migration_Modelio_3.7"/>
1869 1898
            <CommandRef refid="TogafClassDiagramCommand"/>
1870 1899
            <CommandRef refid="TogafClassHierachyDiagramCommand"/>
1871 1900
            <CommandRef refid="TogafDataLifeCycleDiagramCommand"/>
branches/modelio3.6.x/src/main/conf/module_fr.properties
769 769
TogafMatrixDiagramCommande.tooltip =  Diagramme de tra?abilit?
770 770
TogafMatrixDiagramCommande.image =  res/bmp/profile/togafmatrixdiagram16.png
771 771

  
772
command.Migration_Modelio_3.7.label=Migration Modelio 3.7
773
command.Migration_Modelio_3.7.tooltip=Migration Modelio 3.7
774

  
772 775
Diagrams.group = Diagrammes Togaf
773 776
Diagrams.groupimage = res/bmp/profile/togafdiagram16.png
774 777
TogafPropertyPage.label = Togaf
branches/modelio3.6.x/src/main/conf/module.properties
1134 1134
TogafMatrixDiagramCommande.tooltip =  Traceability diagram
1135 1135
TogafMatrixDiagramCommande.image =  res/bmp/profile/togafmatrixdiagram16.png
1136 1136

  
1137
command.Migration_Modelio_3.7.label=Migration Modelio 3.7
1138
command.Migration_Modelio_3.7.tooltip=Migration Modelio 3.7
1139

  
1137 1140
Diagrams.group = Togaf diagrams
1138 1141
Diagrams.groupimage = res/bmp/profile/togafdiagram16.png
1139 1142
TogafPropertyPage.label = Togaf
branches/modelio3.6.x/src/main/resources/org/modelio/togaf/i18n/messages_fr.properties
955 955
TogafMatrixDiagram_SHORTNOTE=L\u0027objectif des diagrammes de matrices est de d\u00e9finir les d\u00e9pendances qui produiront les matrices Excel. Les diagrammes de matrices sont \u00e9galement utiles \u00e0 la d\u00e9finition de la tra\u00e7abilit\u00e9 g\u00e9n\u00e9rale entre \u00e9l\u00e9ments.
956 956

  
957 957
TogafApplicationAndUserLocationDiagram_NOTE=Le diagramme de localisation des applications et utilisateurs pr\u00E9sente la distribution g\u00E9ographique des applications. 
958

  
959
migration_success_title=Migration R?ussi
960
migration_success_message=Votre projet est maintenant 
961
migration_failled_title=Migration Echou?
962
migration_failled_lock= La migration ? ?chou?e cause d'un element en lecture seule dans le mod?le.Si votre projet est g?r? en version avec SVN,merci de prendre les v?rous sur cellui-ci. \n\n.Plus d'informations : \n  {0}
branches/modelio3.6.x/src/main/resources/org/modelio/togaf/i18n/messages.properties
867 867
TogafUseCaseDiagram_NOTE=\nA Use-Case diagram displays the relationships between consumers and providers of services.  Services are consumed by actors or other component services and the Use-Case diagram provides added richness in describing service components functionalities by illustrating how and when these functionalities are used. The purpose of the Use-Case diagram is to help describing and validating the interaction between actors and their roles with applications. As the architecture progresses, the use-case can evolve from functional information to include technical realization details. Architectural use-cases can also be re-used in more detailed systems design work.\nUnder Modelio : Create use cases, drag and drop roles and actors, drag and drop service components, and draw communication links between roles and use cases, and component realization links between components and use cases.
868 868
TogafUseCaseDiagram_SHORTNOTE=A Use-Case diagram displays the relationships between consumers and providers of Services. 
869 869

  
870
migration_success_title=Migration Success
871
migration_success_message=Your project is now ready to be migrated to Modelio 3.7
872
migration_failled_title=Migration Failed
873
migration_failled_lock= The Migration has failed due to a read only element of the model.If your project is an SVN model, please take locks on all the model. \n\n.More informations : \n  {0}
870 874

  
branches/modelio3.6.x/pom.xml
5 5

  
6 6
	<groupId>org.modelio.module</groupId>
7 7
	<artifactId>togafarchitect</artifactId>
8
	<version>3.6.00</version>
8
	<version>3.6.01</version>
9 9
	<name>TogafArchitect</name>
10 10

  
11 11
	<repositories>

Also available in: Unified diff