浏览代码

[oozie] Convert datetimes to strings when generating XML

Romain Rigaux 11 年之前
父节点
当前提交
2c7eb81

+ 9 - 7
apps/oozie/src/oozie/models2.py

@@ -1490,11 +1490,13 @@ class Coordinator(Job):
   def get_data_for_json(self):
     _data = self.data.copy()
 
-    if type(self._data['properties']['start']) == datetime:
-      _data['properties']['start'] = _data['properties']['start'].strftime('%Y-%m-%dT%H:%M:%S')
+    start_date = filter(lambda a: a['name'] == 'start_date', self._data['properties']['parameters'])
+    if start_date and type(start_date[0]['value']) == datetime:
+      start_date[0]['value'] = start_date[0]['value'].strftime('%Y-%m-%dT%H:%M:%S')
 
-    if type(self._data['properties']['end']) == datetime:
-      _data['properties']['end'] = _data['properties']['end'].strftime('%Y-%m-%dT%H:%M:%S')
+    end_date = filter(lambda a: a['name'] == 'end_date', self._data['properties']['parameters'])
+    if end_date and type(end_date[0]['value']) == datetime:
+      end_date[0]['value'] = end_date[0]['value'].strftime('%Y-%m-%dT%H:%M:%S')
 
     return _data
 
@@ -1582,11 +1584,11 @@ class Coordinator(Job):
 
   @property
   def start_utc(self):
-    return utc_datetime_format(self.data['properties']['start'])
+    return self.data['properties']['start']
 
   @property
   def end_utc(self):
-    return utc_datetime_format(self.data['properties']['end'])
+    return self.data['properties']['end']
 
   @property
   def frequency(self):
@@ -1622,7 +1624,7 @@ class Coordinator(Job):
   @property
   def properties(self):
     props = [{'name': dataset['workflow_variable'], 'value': dataset['dataset_variable']} for dataset in self.data['variables'] if dataset['dataset_type'] == 'parameter']
-    props += self.data['properties']['properties']
+    props += self.data['properties']['parameters']
     return props
 
 

+ 2 - 2
apps/oozie/src/oozie/templates/editor/coordinator_editor.mako

@@ -154,7 +154,7 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user) | n,unicode }
               </div>
 
               <div class="control-group">
-                <label class="control-label">${ _('Starts on') }</label>
+                <label class="control-label">${ _('From') }</label>
                 <div class="controls">
                   <div class="input-prepend input-group">
                     <span class="add-on input-group-addon"><i class="fa fa-calendar"></i></span><input type="text" class="input-small" data-bind="value: coordinator.properties.startDateUI, datepicker: {}" />
@@ -166,7 +166,7 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user) | n,unicode }
                 </div>
               </div>
               <div class="control-group">
-                <label class="control-label">${ _('Ends on') }</label>
+                <label class="control-label">${ _('To') }</label>
                 <div class="controls">
                   <div class="input-prepend input-group">
                     <span class="add-on input-group-addon"><i class="fa fa-calendar"></i></span><input type="text" class="input-small" data-bind="value: coordinator.properties.endDateUI, datepicker: {}" />

+ 3 - 3
apps/oozie/src/oozie/templates/editor/gen2/coordinator.xml.mako

@@ -60,18 +60,18 @@
   start="${ coord.start_utc }" end="${ coord.end_utc }" timezone="${ coord.data['properties']['timezone'] }"
   xmlns="${ 'uri:oozie:coordinator:0.4' if coord.data['properties']['sla_enabled'] else coord.data['properties']['schema_version'] | n,unicode }"
   ${ 'xmlns:sla="uri:oozie:sla:0.2"' if coord.data['properties']['sla_enabled'] else '' | n,unicode }>
-  % if coord.data['properties']['timeout'] or coord.data['properties']['concurrency'] or coord.data['properties']['execution'] or coord.data['properties']['throttle']:
+  % if coord.data['properties']['timeout'] or coord.data['properties'].get('concurrency') or coord.data['properties']['execution'] or coord.data['properties'].get('throttle'):
   <controls>
     % if coord.data['properties']['timeout']:
     <timeout>${ coord.data['properties']['timeout'] }</timeout>
     % endif
-    % if coord.data['properties']['concurrency']:
+    % if coord.data['properties'].get('concurrency'):
     <concurrency>${ coord.data['properties']['concurrency'] }</concurrency>
     % endif
     % if coord.data['properties']['execution']:
     <execution>${ coord.data['properties']['execution'] }</execution>
     % endif
-    % if coord.data['properties']['throttle']:
+    % if coord.data['properties'].get('throttle'):
     <throttle>${ coord.data['properties']['throttle'] }</throttle>
     % endif
   </controls>