Statistics
| Revision:

root / branches / modelio3.7.x / src / main / java / org / modelio / togaf / conf / TogafModelContributor.java @ 252

History | View | Annotate | Download (5.83 KB)

1
package org.modelio.togaf.conf;
2

    
3
import org.modelio.metamodel.mda.Project;
4
import org.modelio.metamodel.mmextensions.infrastructure.ExtensionNotFoundException;
5
import org.modelio.metamodel.uml.infrastructure.ModelElement;
6
import org.modelio.metamodel.uml.statik.Package;
7
import org.modelio.togaf.i18n.Messages;
8
import org.modelio.togaf.impl.TogafArchitectModule;
9
import org.modelio.togaf.profile.applicationarchitecture.model.ApplicationArchitectureDomain;
10
import org.modelio.togaf.profile.businessarchitecture.model.BusinessOrganizationDomain;
11
import org.modelio.togaf.profile.structure.model.ApplicationArchitecture;
12
import org.modelio.togaf.profile.structure.model.ApplicationLayer;
13
import org.modelio.togaf.profile.structure.model.BusinessArchitecture;
14
import org.modelio.togaf.profile.structure.model.BusinessEntities;
15
import org.modelio.togaf.profile.structure.model.BusinessLayer;
16
import org.modelio.togaf.profile.structure.model.LogicalDataModel;
17
import org.modelio.togaf.profile.structure.model.TechnologyArchitecture;
18
import org.modelio.vcore.smkernel.mapi.MObject;
19

    
20
public class TogafModelContributor {
21

    
22
        public void createInitialModel() {
23
                ApplicationLayer applilayer = null;
24
                TechnologyArchitecture techno = null;
25
                BusinessLayer business = null;
26

    
27

    
28
                Package root = null;
29
                for(MObject obj : TogafArchitectModule.getInstance().getModuleContext().getModelingSession().getModel().getModelRoots()){
30
                        if(obj instanceof Project){
31
                                if(!((Project)obj).getModel().isEmpty()){
32
                                        root = ((Project)obj).getModel().get(0);
33
                                }
34
                                
35
                                try {
36
                    ((Project)obj).putTagValue(TogafArchitectModule.MODULE_NAME, "togaf.modelVersion", TogafArchitectModule.LATEST_PROJECT_VERSION.toString());
37
                } catch (ExtensionNotFoundException e) {
38
                    e.printStackTrace();
39
                }
40
                        }
41
                }
42

    
43
                if (root == null) {
44
                        return;
45
                }
46

    
47
                for (ModelElement sub : root.getOwnedElement()) {
48
                        if (sub.isStereotyped("TogafArchitect","BusinessLayer")) {
49
                                business = new BusinessLayer((Package) sub);
50
                        } else if (sub.isStereotyped("TogafArchitect","ApplicationLayer")) {
51
                                applilayer = new ApplicationLayer((Package) sub);
52
                        } else if (sub.isStereotyped("TogafArchitect","TechnologyArchitecture")) {
53
                                techno = new TechnologyArchitecture((Package) sub);
54
                        }
55
                }
56

    
57
                try {
58
                        if(!root.isStereotyped("TogafArchitect", "TogafRoot")){
59
                                root.addStereotype("TogafArchitect", "TogafRoot");
60
                        }
61
                        if (business == null) {
62
                                business = new BusinessLayer();
63
                                business.setParent(root);
64
                                business.getElement().putNoteContent("ModelerModule", "description",Messages.getString("BusinessLayer_Template"));
65

    
66
                                BusinessEntities entities = new BusinessEntities();
67
                                entities.setParent(business.getElement());
68
                                entities.getElement().putNoteContent("ModelerModule", "description",Messages.getString("BusinessEntities_Template"));
69

    
70
                                BusinessArchitecture architecture = new BusinessArchitecture();
71
                                architecture.setParent(business.getElement());
72
                                architecture.getElement().putNoteContent("ModelerModule", "description",Messages.getString("BusinessArchitecture_Template"));
73

    
74
                                BusinessOrganizationDomain organization = new BusinessOrganizationDomain();
75
                                organization.getElement().setName("Organization");
76
                                organization.setParent(architecture.getElement());
77
                                organization.getElement().putNoteContent("ModelerModule", "description",Messages.getString("Organization_Template"));
78

    
79
                                BusinessOrganizationDomain processes = new BusinessOrganizationDomain();
80
                                processes.getElement().setName("Processes");
81
                                processes.setParent(architecture.getElement());
82
                                processes.getElement().putNoteContent("ModelerModule", "description",Messages.getString("Processes_Template"));
83

    
84
                                BusinessOrganizationDomain businessfunction = new BusinessOrganizationDomain();
85
                                businessfunction.getElement().setName("Business Function");
86
                                businessfunction.setParent(architecture.getElement());
87
                                businessfunction.getElement().putNoteContent("ModelerModule", "description",Messages.getString("Function_Template"));
88

    
89
                                BusinessOrganizationDomain locations = new BusinessOrganizationDomain();
90
                                locations.getElement().setName("Locations");
91
                                locations.setParent(architecture.getElement());
92
                                locations.getElement().putNoteContent("ModelerModule", "description",Messages.getString("Locations_Template"));
93
                        }
94
                        if (applilayer == null) {
95
                                applilayer = new ApplicationLayer();
96
                                applilayer.setParent(root);
97
                                applilayer.getElement().putNoteContent("ModelerModule", "description",Messages.getString("ApplicationLayer_Template"));
98

    
99
                                LogicalDataModel data = new LogicalDataModel();
100
                                data.setParent(applilayer.getElement());
101
                                data.getElement().putNoteContent("ModelerModule", "description",Messages.getString("Data_Template"));
102

    
103
                                ApplicationArchitecture appliarchi = new ApplicationArchitecture();
104
                                appliarchi.setParent(applilayer.getElement());
105
                                appliarchi.getElement().putNoteContent("ModelerModule", "description",Messages.getString("ApplicationArchitecture_Template"));
106

    
107
                                ApplicationArchitectureDomain servicedata = new ApplicationArchitectureDomain();
108
                                servicedata.getElement().setName("Service Data");
109
                                servicedata.setParent(appliarchi.getElement());
110
                                servicedata.getElement().putNoteContent("ModelerModule", "description",Messages.getString("Service_Template"));
111

    
112
                                ApplicationArchitectureDomain systemeusecase = new ApplicationArchitectureDomain();
113
                                systemeusecase.getElement().setName("System Use Case");
114
                                systemeusecase.setParent(appliarchi.getElement());
115
                                systemeusecase.getElement().putNoteContent("ModelerModule", "description",Messages.getString("Systeme_Template"));
116
                        }
117

    
118
                        if (techno == null) {
119
                                techno = new TechnologyArchitecture();
120
                                techno.setParent(root);
121
                                techno.getElement().putNoteContent("ModelerModule", "description",Messages.getString("TechnologyArchitecture_Template"));
122
                        }
123
                } catch (Exception e) {
124
                        e.printStackTrace();
125
                }
126
        }
127
}