sqoop.framework.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. // Licensed to Cloudera, Inc. under one
  2. // or more contributor license agreements. See the NOTICE file
  3. // distributed with this work for additional information
  4. // regarding copyright ownership. Cloudera, Inc. licenses this file
  5. // to you under the Apache License, Version 2.0 (the
  6. // "License"); you may not use this file except in compliance
  7. // with the License. You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. var framework = (function($) {
  17. var FrameworkModel = koify.Model.extend({
  18. 'id': 1,
  19. 'job_forms': {
  20. 'IMPORT': [],
  21. 'EXPORT': []
  22. },
  23. 'con_forms': [],
  24. 'resources': {},
  25. 'initialize': function(attrs) {
  26. var self = this;
  27. var _attrs = $.extend(true, {}, attrs);
  28. _attrs = transform_keys(_attrs, {
  29. 'job-forms': 'job_forms',
  30. 'con-forms': 'con_forms'
  31. });
  32. _attrs = transform_values(_attrs, {
  33. 'con_forms': to_forms,
  34. 'job_forms': function(key, value) {
  35. transform_values(value, {
  36. 'IMPORT': to_forms,
  37. 'EXPORT': to_forms
  38. });
  39. return value;
  40. }
  41. });
  42. return _attrs;
  43. }
  44. });
  45. var Framework = koify.Node.extend({
  46. 'identifier': 'framework',
  47. 'persists': false,
  48. 'model_class': FrameworkModel,
  49. 'base_url': '/sqoop/api/framework/',
  50. 'initialize': function() {
  51. var self = this;
  52. self.parent.initialize.apply(self, arguments);
  53. self.selected = ko.observable();
  54. },
  55. 'map': function() {
  56. var self = this;
  57. var mapping_options = $.extend(true, {
  58. 'ignore': ['parent', 'initialize']
  59. }, forms.MapProperties);
  60. if ('__ko_mapping__' in self) {
  61. ko.mapping.fromJS(self.model, mapping_options, self);
  62. } else {
  63. var mapped = ko.mapping.fromJS(self.model, mapping_options);
  64. $.extend(self, mapped);
  65. }
  66. }
  67. });
  68. return {
  69. 'FrameworkModel': FrameworkModel,
  70. 'Framework': Framework
  71. }
  72. })($);