← Back to team overview

mlhim-specs-dev team mailing list archive

[Branch ~cdd-dev/cdd/trunk] Rev 286: Added a field for RM Version on the config dialog and used that version on the generated ccd.

 

------------------------------------------------------------
revno: 286
committer: Eduardo C. P. Ribeiro <eduardo.cesar@xxxxxxx>
branch nick: devel
timestamp: Thu 2012-12-06 18:12:09 -0200
message:
  Added a field for RM Version on the config dialog and used that version on the generated ccd.
modified:
  src/2.0/cdd.py
  src/2.0/cdd.wxg


--
lp:cdd
https://code.launchpad.net/~cdd-dev/cdd/trunk

Your team MLHIM Specifications Developers is subscribed to branch lp:cdd.
To unsubscribe from this branch go to https://code.launchpad.net/~cdd-dev/cdd/trunk/+edit-subscription
=== modified file 'src/2.0/cdd.py'
--- src/2.0/cdd.py	2012-12-06 19:56:34 +0000
+++ src/2.0/cdd.py	2012-12-06 20:12:09 +0000
@@ -1370,10 +1370,12 @@
         # begin wxGlade: ConfigDialog.__init__
         kwds["style"] = wx.DEFAULT_DIALOG_STYLE
         wx.Dialog.__init__(self, *args, **kwds)
+        self.text_ctrl_rm_version = wx.TextCtrl(self, -1, "")
+        self.sizer_81_staticbox = wx.StaticBox(self, -1, _("RM Version"))
+        self.text_ctrl_autosave = wx.TextCtrl(self, -1, "")
+        self.sizer_12_copy_staticbox = wx.StaticBox(self, -1, _("Autosave:"))
         self.text_ctrl_workspace = wx.TextCtrl(self, -1, "")
         self.sizer_9_staticbox = wx.StaticBox(self, -1, _("Workspace path:"))
-        self.text_ctrl_autosave = wx.TextCtrl(self, -1, "")
-        self.sizer_12_staticbox = wx.StaticBox(self, -1, _("Autosave:"))
         self.button_2 = wx.Button(self, wx.ID_CANCEL, "")
         self.button_1 = wx.Button(self, wx.ID_OK, "")
 
@@ -1386,7 +1388,7 @@
     def __set_properties(self):
         # begin wxGlade: ConfigDialog.__set_properties
         self.SetTitle(_("Configuration"))
-        self.SetSize((629, 205))
+        self.SetSize((629, 224))
         self.text_ctrl_autosave.SetMinSize((70, 27))
         self.text_ctrl_autosave.SetToolTipString(_("Put the interval in minutes that the current CDD will be automatically saved."))
         # end wxGlade
@@ -1397,21 +1399,24 @@
         sizer_14 = wx.BoxSizer(wx.VERTICAL)
         sizer_main = wx.BoxSizer(wx.VERTICAL)
         sizer_10 = wx.BoxSizer(wx.HORIZONTAL)
-        sizer_11 = wx.BoxSizer(wx.HORIZONTAL)
-        self.sizer_12_staticbox.Lower()
-        sizer_12 = wx.StaticBoxSizer(self.sizer_12_staticbox, wx.HORIZONTAL)
         sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
         self.sizer_9_staticbox.Lower()
         sizer_9 = wx.StaticBoxSizer(self.sizer_9_staticbox, wx.HORIZONTAL)
+        sizer_80 = wx.BoxSizer(wx.HORIZONTAL)
+        self.sizer_12_copy_staticbox.Lower()
+        sizer_12_copy = wx.StaticBoxSizer(self.sizer_12_copy_staticbox, wx.HORIZONTAL)
+        self.sizer_81_staticbox.Lower()
+        sizer_81 = wx.StaticBoxSizer(self.sizer_81_staticbox, wx.HORIZONTAL)
         sizer_13.Add((20, 20), 0, 0, 0)
         sizer_14.Add((20, 20), 0, 0, 0)
+        sizer_81.Add(self.text_ctrl_rm_version, 0, 0, 0)
+        sizer_80.Add(sizer_81, 0, wx.EXPAND, 0)
+        sizer_12_copy.Add(self.text_ctrl_autosave, 0, 0, 0)
+        sizer_80.Add(sizer_12_copy, 0, wx.EXPAND, 0)
+        sizer_main.Add(sizer_80, 1, wx.EXPAND, 0)
         sizer_9.Add(self.text_ctrl_workspace, 1, 0, 0)
         sizer_2.Add(sizer_9, 1, wx.EXPAND, 7)
         sizer_main.Add(sizer_2, 1, wx.EXPAND, 0)
-        sizer_12.Add(self.text_ctrl_autosave, 0, 0, 0)
-        sizer_11.Add(sizer_12, 0, wx.EXPAND, 0)
-        sizer_11.Add((20, 20), 1, wx.EXPAND, 0)
-        sizer_main.Add(sizer_11, 1, wx.EXPAND, 0)
         sizer_10.Add((20, 20), 1, 0, 0)
         sizer_10.Add(self.button_2, 0, wx.BOTTOM | wx.ALIGN_BOTTOM, 0)
         sizer_10.Add((20, 20), 0, 0, 0)
@@ -1426,6 +1431,7 @@
         # end wxGlade
 
     def init_things(self):
+        self.info = None
         self.init_config()
         self.read_config()
 
@@ -1461,7 +1467,8 @@
 
         self.config = ConfigParser.SafeConfigParser({
                 'autosave' : '5',
-                'workspace' : home + '/' + 'MLHIM2'
+                'workspace' : home + '/' + 'MLHIM2',
+                'rm_version' : '2.4.0',
                 })
 
         if not os.path.isdir(self.configdir):
@@ -1484,15 +1491,17 @@
         except IOError:
             popup_message(None, 'Config could not be saved.', 'Error saving config', wx.ICON_EXCLAMATION)
 
+        self.set_config_info()
 
     def get_panel_configs(self):
         self.config.set('DEFAULT', 'autosave', self.text_ctrl_autosave.GetValue().encode('utf8'))
         self.config.set('DEFAULT', 'workspace', self.text_ctrl_workspace.GetValue().encode('utf8'))
+        self.config.set('DEFAULT', 'rm_version', self.text_ctrl_rm_version.GetValue().encode('utf8'))
 
     def set_panel_configs(self):
         self.text_ctrl_autosave.SetValue(self.config.get('DEFAULT', 'autosave'))
         self.text_ctrl_workspace.SetValue(self.config.get('DEFAULT', 'workspace'))
-
+        self.text_ctrl_rm_version.SetValue(self.config.get('DEFAULT', 'rm_version'))
 
     def test_workspace_dir(self, panel):
         workspace = self.config.get('DEFAULT', 'workspace')
@@ -1510,10 +1519,16 @@
                         os.mkdir(workspace)
                     except OSError:
                         popup_message(None, 'Workspace directory NOT created.', 'Error creating workspace dir', wx.ICON_EXCLAMATION)
-
-
             dlg.Destroy()
 
+
+    def set_config_info(self):
+        # Sets the necessary config information in the info object
+        if self.info:
+            rm_version = self.config.get('DEFAULT', 'rm_version')
+            self.info.get_config_info(rm_version)
+
+
 # end of class ConfigDialog
 
 class MetadataPanel(wx.Panel):
@@ -1704,7 +1719,7 @@
         self.button_ok.Disable()
 
     def set_meta_info(self):
-        # Sets the necessary information to the info object
+        # Sets the necessary metadata information in the info object
         if self.info:
             title = self.text_ctrl_title.GetValue().encode('utf8')
             description = self.text_ctrl_description.GetValue().encode('utf8')
@@ -1724,7 +1739,8 @@
             tempo = self.datepicker_ctrl_date.GetValue()
             date = '{Y}-{M:02}-{D:02}'.format(Y=tempo.GetYear(), M=tempo.GetMonth()+1, D=tempo.GetDay())
 
-            self.info.get_info(title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage)
+            self.info.get_metadata_info(title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage)
+
 
     def get_panel_configs(self):
         self.config.set('DEFAULT', 'title', self.text_ctrl_title.GetValue().encode('utf8'))
@@ -1869,17 +1885,24 @@
 
     def init_things(self):
 
-        # Makes a config dialog
-        self.config_dialog = ConfigDialog(self)
-        self.config_dialog.test_workspace_dir(self)
 
         # Setup the tree
         self.setup_tree()
 
         # Setup the metadata
+        self.setup_config()
         self.setup_metadata()
         self.button_ok.Hide()
 
+    def setup_config(self):
+        # Makes a config dialog
+        self.config_dialog = ConfigDialog(self)
+
+        self.config_dialog.test_workspace_dir(self)
+
+        self.config_dialog.info = info
+        self.config_dialog.set_config_info()
+
 
     def setup_metadata(self):
         # Hack to make the metadata panel before it is called
@@ -2215,10 +2238,12 @@
         self.language = ''
 
         self.date = ''
+        
+        self.rm_version = ''
 
         self.ccd_id = "ccd_"+str(uuid.uuid4())
 
-    def get_info(self, title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage):
+    def get_metadata_info(self, title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage):
         self.title = title
         self.description = description
         self.creator = creator
@@ -2236,6 +2261,8 @@
 
         self.date = date
 
+    def get_config_info(self, rm_version):
+        self.rm_version = rm_version
 
     def generate_file(self, path):
 
@@ -2246,6 +2273,8 @@
 
         schema = self.ccd_id + ".xsd"
 
+        version = self.rm_version.replace('.','_');
+
         contributors_formated = '<dc:contributor>' + \
             '</dc:contributor>\n<dc:contributor>'.join([ escape(i).strip() for i in self.contributor.split(';')]) + \
             '</dc:contributor>'
@@ -2254,11 +2283,11 @@
 
         f.write("""<?xml version="1.0" encoding="UTF-8"?>
 <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
-	   xmlns:mlhim2="http://www.mlhim.org/xmlns/mlhim2/2_4_0"; 
+	   xmlns:mlhim2="http://www.mlhim.org/xmlns/mlhim2/{version}"; 
 	   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"; 
 	   xmlns:dc= "http://purl.org/dc/elements/1.1/";
 	   elementFormDefault="qualified"
-	   targetNamespace="http://www.mlhim.org/xmlns/mlhim2/2_4_0";
+	   targetNamespace="http://www.mlhim.org/xmlns/mlhim2/{version}";
 	   xmlns:data-view="http://www.w3.org/2003/g/data-view#"; 
 	   data-view:transformation="http://www.mlhim.org/ccd/ccd_md_view.xsl";>
 
@@ -2288,7 +2317,7 @@
     </xs:appinfo>
   </xs:annotation>
 
-  <xs:include schemaLocation="http://www.mlhim.org/xmlns/mlhim2/2_4_0/mlhim2.xsd"/>
+  <xs:include schemaLocation="http://www.mlhim.org/xmlns/mlhim2/{version}/mlhim2.xsd"/>
 
   <xs:element name="{ccd_id}" type="mlhim2:{UUID_complex}"/>
   <xs:complexType name="{UUID_complex}">
@@ -2325,6 +2354,8 @@
            resource_format = "text/xml",
            identifier = self.ccd_id,
 
+           version = version,
+
            ))
 
 
@@ -2360,7 +2391,7 @@
         tempo = panel.datepicker_ctrl_date.GetValue()
         date = '{Y}-{M:02}-{D:02}'.format(Y=tempo.GetYear(), M=tempo.GetMonth()+1, D=tempo.GetDay())
 
-        self.get_info(title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage)
+        self.get_metadata_info(title, description, date, creator, creator_email, contributor, language, publisher, subject, source, rights, relation, coverage)
 
 ###########################################################################
 # Misc functions - Maybe put them inside a class in the future
@@ -2422,6 +2453,8 @@
 def not_implemented_diag(self):
     popup_message(self, 'Not implemented yet.', 'Under construction', wx.ICON_INFORMATION | wx.OK)
 
+
+# Object that retains all information necessary to create the cdd
 info = Info()
 
 if __name__ == "__main__":

=== modified file 'src/2.0/cdd.wxg'
--- src/2.0/cdd.wxg	2012-10-01 02:58:34 +0000
+++ src/2.0/cdd.wxg	2012-12-06 20:12:09 +0000
@@ -1,5 +1,5 @@
 <?xml version="1.0"?>
-<!-- generated by wxGlade 0.6.4 on Sun Sep 30 23:52:34 2012 -->
+<!-- generated by wxGlade 0.6.4 on Thu Dec  6 13:12:50 2012 -->
 
 <application path="cdd.py" name="" class="" option="0" language="python" top_window="dialog_config" encoding="UTF-8" use_gettext="1" overwrite="0" use_new_namespace="1" for_version="2.8" is_template="0" indent_amount="4" indent_symbol="space" source_extension=".cpp" header_extension=".h">
     <object class="MainFrame" name="frame_main" base="EditFrame">
@@ -2134,161 +2134,6 @@
             </object>
         </object>
     </object>
-    <object class="ConfigDialog" name="dialog_config" base="EditDialog">
-        <style>wxDEFAULT_DIALOG_STYLE</style>
-        <title>Configuration</title>
-        <size>629, 205</size>
-        <object class="wxBoxSizer" name="sizer_13" base="EditBoxSizer">
-            <orient>wxHORIZONTAL</orient>
-            <object class="sizeritem">
-                <border>0</border>
-                <option>0</option>
-                <object class="spacer" name="spacer" base="EditSpacer">
-                    <height>20</height>
-                    <width>20</width>
-                </object>
-            </object>
-            <object class="sizeritem">
-                <flag>wxEXPAND</flag>
-                <border>0</border>
-                <option>1</option>
-                <object class="wxBoxSizer" name="sizer_14" base="EditBoxSizer">
-                    <orient>wxVERTICAL</orient>
-                    <object class="sizeritem">
-                        <border>0</border>
-                        <option>0</option>
-                        <object class="spacer" name="spacer" base="EditSpacer">
-                            <height>20</height>
-                            <width>20</width>
-                        </object>
-                    </object>
-                    <object class="sizeritem">
-                        <flag>wxEXPAND</flag>
-                        <border>0</border>
-                        <option>1</option>
-                        <object class="wxBoxSizer" name="sizer_main" base="EditBoxSizer">
-                            <orient>wxVERTICAL</orient>
-                            <object class="sizeritem">
-                                <flag>wxEXPAND</flag>
-                                <border>0</border>
-                                <option>1</option>
-                                <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
-                                    <orient>wxHORIZONTAL</orient>
-                                    <object class="sizeritem">
-                                        <flag>wxEXPAND</flag>
-                                        <border>7</border>
-                                        <option>1</option>
-                                        <object class="wxStaticBoxSizer" name="sizer_9" base="EditStaticBoxSizer">
-                                            <orient>wxHORIZONTAL</orient>
-                                            <label>Workspace path:</label>
-                                            <object class="sizeritem">
-                                                <border>0</border>
-                                                <option>1</option>
-                                                <object class="wxTextCtrl" name="text_ctrl_workspace" base="EditTextCtrl">
-                                                </object>
-                                            </object>
-                                        </object>
-                                    </object>
-                                </object>
-                            </object>
-                            <object class="sizeritem">
-                                <flag>wxEXPAND</flag>
-                                <border>0</border>
-                                <option>1</option>
-                                <object class="wxBoxSizer" name="sizer_11" base="EditBoxSizer">
-                                    <orient>wxHORIZONTAL</orient>
-                                    <object class="sizeritem">
-                                        <flag>wxEXPAND</flag>
-                                        <border>0</border>
-                                        <option>0</option>
-                                        <object class="wxStaticBoxSizer" name="sizer_12" base="EditStaticBoxSizer">
-                                            <orient>wxHORIZONTAL</orient>
-                                            <label>Autosave:</label>
-                                            <object class="sizeritem">
-                                                <border>0</border>
-                                                <option>0</option>
-                                                <object class="wxTextCtrl" name="text_ctrl_autosave" base="EditTextCtrl">
-                                                    <tooltip>Put the interval in minutes that the current CDD will be automatically saved.</tooltip>
-                                                    <size>70, 27</size>
-                                                </object>
-                                            </object>
-                                        </object>
-                                    </object>
-                                    <object class="sizeritem">
-                                        <flag>wxEXPAND</flag>
-                                        <border>0</border>
-                                        <option>1</option>
-                                        <object class="spacer" name="spacer" base="EditSpacer">
-                                            <height>20</height>
-                                            <width>20</width>
-                                        </object>
-                                    </object>
-                                </object>
-                            </object>
-                            <object class="sizeritem">
-                                <flag>wxEXPAND</flag>
-                                <border>0</border>
-                                <option>1</option>
-                                <object class="wxBoxSizer" name="sizer_10" base="EditBoxSizer">
-                                    <orient>wxHORIZONTAL</orient>
-                                    <object class="sizeritem">
-                                        <border>0</border>
-                                        <option>1</option>
-                                        <object class="spacer" name="spacer" base="EditSpacer">
-                                            <height>20</height>
-                                            <width>20</width>
-                                        </object>
-                                    </object>
-                                    <object class="sizeritem">
-                                        <flag>wxBOTTOM|wxALIGN_BOTTOM</flag>
-                                        <border>0</border>
-                                        <option>0</option>
-                                        <object class="wxButton" name="button_2" base="EditButton">
-                                            <stockitem>CANCEL</stockitem>
-                                            <label>&amp;Cancel</label>
-                                        </object>
-                                    </object>
-                                    <object class="sizeritem">
-                                        <border>0</border>
-                                        <option>0</option>
-                                        <object class="spacer" name="spacer" base="EditSpacer">
-                                            <height>20</height>
-                                            <width>20</width>
-                                        </object>
-                                    </object>
-                                    <object class="sizeritem">
-                                        <flag>wxBOTTOM|wxALIGN_BOTTOM</flag>
-                                        <border>0</border>
-                                        <option>0</option>
-                                        <object class="wxButton" name="button_1" base="EditButton">
-                                            <stockitem>OK</stockitem>
-                                            <label>&amp;OK</label>
-                                        </object>
-                                    </object>
-                                </object>
-                            </object>
-                        </object>
-                    </object>
-                    <object class="sizeritem">
-                        <border>0</border>
-                        <option>0</option>
-                        <object class="spacer" name="spacer" base="EditSpacer">
-                            <height>20</height>
-                            <width>20</width>
-                        </object>
-                    </object>
-                </object>
-            </object>
-            <object class="sizeritem">
-                <border>0</border>
-                <option>0</option>
-                <object class="spacer" name="spacer" base="EditSpacer">
-                    <height>20</height>
-                    <width>20</width>
-                </object>
-            </object>
-        </object>
-    </object>
     <object class="MetadataPanel" name="panel_metadata" base="EditTopLevelPanel">
         <style>wxTAB_TRAVERSAL</style>
         <size>685, 585</size>
@@ -2726,7 +2571,7 @@
     <object class="ConfigDialog" name="dialog_config" base="EditDialog">
         <style>wxDEFAULT_DIALOG_STYLE</style>
         <title>Configuration</title>
-        <size>629, 205</size>
+        <size>629, 224</size>
         <object class="wxBoxSizer" name="sizer_13" base="EditBoxSizer">
             <orient>wxHORIZONTAL</orient>
             <object class="sizeritem">
@@ -2761,6 +2606,46 @@
                                 <flag>wxEXPAND</flag>
                                 <border>0</border>
                                 <option>1</option>
+                                <object class="wxBoxSizer" name="sizer_80" base="EditBoxSizer">
+                                    <orient>wxHORIZONTAL</orient>
+                                    <object class="sizeritem">
+                                        <flag>wxEXPAND</flag>
+                                        <border>0</border>
+                                        <option>0</option>
+                                        <object class="wxStaticBoxSizer" name="sizer_81" base="EditStaticBoxSizer">
+                                            <orient>wxHORIZONTAL</orient>
+                                            <label>RM Version</label>
+                                            <object class="sizeritem">
+                                                <border>0</border>
+                                                <option>0</option>
+                                                <object class="wxTextCtrl" name="text_ctrl_rm_version" base="EditTextCtrl">
+                                                </object>
+                                            </object>
+                                        </object>
+                                    </object>
+                                    <object class="sizeritem">
+                                        <flag>wxEXPAND</flag>
+                                        <border>0</border>
+                                        <option>0</option>
+                                        <object class="wxStaticBoxSizer" name="sizer_12_copy" base="EditStaticBoxSizer">
+                                            <orient>wxHORIZONTAL</orient>
+                                            <label>Autosave:</label>
+                                            <object class="sizeritem">
+                                                <border>0</border>
+                                                <option>0</option>
+                                                <object class="wxTextCtrl" name="text_ctrl_autosave" base="EditTextCtrl">
+                                                    <tooltip>Put the interval in minutes that the current CDD will be automatically saved.</tooltip>
+                                                    <size>70, 27</size>
+                                                </object>
+                                            </object>
+                                        </object>
+                                    </object>
+                                </object>
+                            </object>
+                            <object class="sizeritem">
+                                <flag>wxEXPAND</flag>
+                                <border>0</border>
+                                <option>1</option>
                                 <object class="wxBoxSizer" name="sizer_2" base="EditBoxSizer">
                                     <orient>wxHORIZONTAL</orient>
                                     <object class="sizeritem">
@@ -2784,40 +2669,6 @@
                                 <flag>wxEXPAND</flag>
                                 <border>0</border>
                                 <option>1</option>
-                                <object class="wxBoxSizer" name="sizer_11" base="EditBoxSizer">
-                                    <orient>wxHORIZONTAL</orient>
-                                    <object class="sizeritem">
-                                        <flag>wxEXPAND</flag>
-                                        <border>0</border>
-                                        <option>0</option>
-                                        <object class="wxStaticBoxSizer" name="sizer_12" base="EditStaticBoxSizer">
-                                            <orient>wxHORIZONTAL</orient>
-                                            <label>Autosave:</label>
-                                            <object class="sizeritem">
-                                                <border>0</border>
-                                                <option>0</option>
-                                                <object class="wxTextCtrl" name="text_ctrl_autosave" base="EditTextCtrl">
-                                                    <tooltip>Put the interval in minutes that the current CDD will be automatically saved.</tooltip>
-                                                    <size>70, 27</size>
-                                                </object>
-                                            </object>
-                                        </object>
-                                    </object>
-                                    <object class="sizeritem">
-                                        <flag>wxEXPAND</flag>
-                                        <border>0</border>
-                                        <option>1</option>
-                                        <object class="spacer" name="spacer" base="EditSpacer">
-                                            <height>20</height>
-                                            <width>20</width>
-                                        </object>
-                                    </object>
-                                </object>
-                            </object>
-                            <object class="sizeritem">
-                                <flag>wxEXPAND</flag>
-                                <border>0</border>
-                                <option>1</option>
                                 <object class="wxBoxSizer" name="sizer_10" base="EditBoxSizer">
                                     <orient>wxHORIZONTAL</orient>
                                     <object class="sizeritem">