sqoop.driver.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 driver = (function($) {
  17. var DriverModel = koify.Model.extend({
  18. 'id': 1,
  19. 'job_config': [],
  20. 'config_resources': {},
  21. 'initialize': function(attrs) {
  22. var self = this;
  23. var _attrs = $.extend(true, {}, attrs);
  24. _attrs = transform_keys(_attrs, {
  25. 'job_config': 'job_config'
  26. });
  27. _attrs = transform_values(_attrs, {
  28. 'job_config': to_configs
  29. });
  30. return _attrs;
  31. }
  32. });
  33. var Driver = koify.Node.extend({
  34. 'identifier': 'driver',
  35. 'persists': false,
  36. 'model_class': DriverModel,
  37. 'base_url': '/sqoop/api/driver/',
  38. 'initialize': function() {
  39. var self = this;
  40. self.parent.initialize.apply(self, arguments);
  41. self.selected = ko.observable();
  42. },
  43. 'map': function() {
  44. var self = this;
  45. var mapping_options = $.extend(true, {
  46. 'ignore': ['parent', 'initialize']
  47. }, configs.MapProperties);
  48. if ('__ko_mapping__' in self) {
  49. ko.mapping.fromJS(self.model, mapping_options, self);
  50. } else {
  51. var mapped = ko.mapping.fromJS(self.model, mapping_options);
  52. $.extend(self, mapped);
  53. }
  54. }
  55. });
  56. return {
  57. 'DriverModel': DriverModel,
  58. 'Driver': Driver
  59. }
  60. })($);