Subversion Repositories DevTools

Rev

Rev 2094 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2088 ghuddy 1
using System;
2
using System.Collections;
3
using System.ComponentModel;
4
using System.Windows.Forms;
5
 
6
 
7
namespace EA_DocGen
8
{
9
	/// <summary>
10
	/// Summary description for EA_RelationshipMatrix.
11
	/// </summary>
12
	public class EA_RelationshipMatrix
13
	{
14
      private EA_Utilities EA_Utils = null;
15
 
16
      // declare option variables
17
      public string fromIntroText = null;     // This one is optional 
18
      public string fromPackageGUID = null;
19
      public string fromToTableTitle = null;  // This one is optional
20
      public string fromColumnTitle = null;
21
      public ArrayList fromElementTypes = null;
22
      public bool fromPackageRecursion = true;
23
      public EA.Package fromPackage = null;
24
 
25
      public string toIntroText = null;       // This one is optional
26
      public string toPackageGUID = null;
27
      public string toFromTableTitle = null;  // This one is optional
28
      public string toColumnTitle = null;
29
      public ArrayList toElementTypes = null;
30
      public bool toPackageRecursion = true;
31
      public EA.Package toPackage = null;
32
 
33
      private string [] options_string = null;
34
 
35
 
36
 
37
		public EA_RelationshipMatrix(EA_Utilities EA_UtilsRef)
38
		{
39
         EA_Utils = EA_UtilsRef;
40
         fromElementTypes = new ArrayList();
41
         toElementTypes = new ArrayList();
42
		}
43
 
44
      public void reset()
45
      {
46
         fromIntroText = null;
47
         fromPackageGUID = null;
48
         fromToTableTitle = null;
49
         fromColumnTitle = null;
50
         fromElementTypes.Clear();
51
         fromPackageRecursion = true;
52
         fromPackage = null;
53
         toIntroText = null;
54
         toPackageGUID = null;
55
         toFromTableTitle = null;
56
         toColumnTitle = null;
57
         toElementTypes.Clear();
58
         toPackageRecursion = true;
59
         toPackage = null;
60
      }
61
 
62
 
63
      public bool processRelationshipMatrixOptions(EA.Element theElement)
64
      {
65
         reset();
66
 
67
         // Extract the control options from the notes of the element
68
 
69
         string delimStr = "\n";
70
         char [] delim = delimStr.ToCharArray();
71
         options_string = theElement.Notes.ToString().Split(delim,100);
72
         int i = 0;
73
         foreach(string s in options_string)
74
         {
75
            options_string[i] = s.Trim();
76
            i++;
77
         }
78
 
79
         // scan the options string and assign values into the options variables as required
80
         foreach(string s in options_string)
81
         {
82
            if (s.Length > 0 && s != "\n" && s != "\r" && s[0] != '\\')
83
            {
84
               // FROM items
85
               if (s.StartsWith("fromIntroText"))
86
               {
87
                  fromIntroText = EA_Utils.options.getOptionValue(s, null);
88
               }
89
               else if (s.StartsWith("fromToTableTitle")) 
90
               {
91
                  fromToTableTitle = EA_Utils.options.getOptionValue(s, null);
92
               }
93
               else if (s.StartsWith("fromColumnTitle")) 
94
               {
95
                  fromColumnTitle = EA_Utils.options.getOptionValue(s, fromColumnTitle);
96
               }
97
               else if (s.StartsWith("fromPackageRecursion")) 
98
               {
99
                  fromPackageRecursion = EA_Utils.options.getOptionValue(s, fromPackageRecursion);
100
               }
101
               else if (s.StartsWith("fromPackage")) 
102
               {
103
                  fromPackageGUID = EA_Utils.options.getOptionValue(s, fromPackageGUID);
104
               }
105
               else if (s.StartsWith("fromElementType")) 
106
               {
107
                  string et = EA_Utils.options.getOptionValue(s,null);
108
                  if (et != null) 
109
                  {
110
                     fromElementTypes.Add( et );
111
                  }
112
               }
113
 
114
 
115
                  // TO items
116
               else if (s.StartsWith("toIntroText"))
117
               {
118
                  toIntroText = EA_Utils.options.getOptionValue(s, null);
119
               }
120
               else if (s.StartsWith("toFromTableTitle")) 
121
               {
122
                  toFromTableTitle = EA_Utils.options.getOptionValue(s, null);
123
               }
124
               else if (s.StartsWith("toColumnTitle")) 
125
               {
126
                  toColumnTitle = EA_Utils.options.getOptionValue(s, toColumnTitle);
127
               }
128
               else if (s.StartsWith("toPackageRecursion")) 
129
               {
130
                  toPackageRecursion = EA_Utils.options.getOptionValue(s, toPackageRecursion);
131
               }
132
               else if (s.StartsWith("toPackage")) 
133
               {
134
                  toPackageGUID = EA_Utils.options.getOptionValue(s, toPackageGUID);
135
               }
136
               else if (s.StartsWith("toElementType")) 
137
               {
138
                  string et = EA_Utils.options.getOptionValue(s,null);
139
                  if (et != null) 
140
                  {
141
                     toElementTypes.Add( et );
142
                  }
143
               }
144
            }
145
         }
146
 
147
         // Verify that we have all the necessary compulsory options
148
         if (fromToTableTitle == null && toFromTableTitle == null)
149
         {
150
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
151
               "Missing option: Must specify at least one table title");
152
            return false;
153
         }
154
 
155
         // FROM items
156
         if (fromColumnTitle == null)
157
         {
158
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
159
               "Missing option: fromColumnTitle");
160
            return false;
161
         }
162
         if (fromPackageGUID == null)
163
         {
164
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
165
               "Missing option: fromPackageGUID");
166
            return false;
167
         }
168
         if (fromElementTypes.Count == 0)
169
         {
170
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
171
               "Missing option(s): fromElementTypes");
172
            return false;
173
         }      
174
 
175
         // TO items
176
         if (toColumnTitle == null)
177
         {
178
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
179
               "Missing option: toColumnTitle");
180
            return false;
181
         }
182
         if (toPackageGUID == null)
183
         {
184
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
185
               "Missing option: toPackageGUID");
186
            return false;
187
         }
188
         if (toElementTypes.Count == 0)
189
         {
190
            MessageBox.Show("Error in EA_DocGenRelationshipMatrix options list\n\n" +
191
               "Missing option(s): toElementTypes");
192
            return false;
193
         }   
194
 
195
         // Find GUID linked packages in the repository
196
         fromPackage = EA_Utils.EA_Finder.findPackageInRepositoryByGUID( fromPackageGUID );
197
         if (fromPackage == null)
198
         {
199
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
200
               "could not locate fromPackage in Repository");
201
            return false;
202
         }
203
 
204
         toPackage = EA_Utils.EA_Finder.findPackageInRepositoryByGUID( toPackageGUID );
205
         if (toPackage == null)
206
         {
207
            MessageBox.Show("Error processing EA_DocGenRelationshipMatrix\n\n" +
208
               "could not locate toPackage in Repository");
209
            return false;
210
         }
211
 
212
         return true;
213
      }
214
 
215
 
216
      public string optionTemplateForRelationshipMatrix()
217
      {
218
         return
219
           "fromToTableTitle=\r\n"
220
         + "fromIntroText=\r\n"
221
         + "fromColumnTitle=\r\n"
222
         + "fromPackage=\r\n"
223
         + "fromElementType=\r\n"
224
         + "fromElementType=\r\n"
225
         + "fromPackageRecursion=true\r\n"
226
         + "toFromTableTitle=\r\n"
227
         + "toIntroText=\r\n"
228
         + "toColumnTitle=\r\n"
229
         + "toPackage=\r\n"
230
         + "toElementType=\r\n"
231
         + "toPackageRecursion=true\r\n";
232
      }
233
 
234
 
235
	}
236
}