component.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. /**
  19. * Here will be stored slave functions related to components
  20. * @type {Object}
  21. */
  22. var App = require('app');
  23. module.exports = {
  24. /**
  25. * Format and load info about components to StackServiceComponent model.
  26. *
  27. * @method loadStackServiceComponentModel
  28. * @param data {object} response from server
  29. * @return {object} formatted info about components
  30. */
  31. loadStackServiceComponentModel: function(data) {
  32. var serviceComponents = {items: []};
  33. data.items.forEach(function(item){
  34. item.serviceComponents.forEach(function(_serviceComponent){
  35. var stackServiceComponents = _serviceComponent.StackServiceComponents;
  36. var serviceComponent = {
  37. component_name: stackServiceComponents.component_name,
  38. service_name: stackServiceComponents.service_name,
  39. component_category: stackServiceComponents.component_category,
  40. is_master: stackServiceComponents.is_master,
  41. is_client: stackServiceComponents.is_client,
  42. stack_name: stackServiceComponents.stack_name,
  43. stack_version: stackServiceComponents.stack_version
  44. };
  45. serviceComponents.items.pushObject(serviceComponent);
  46. },this);
  47. },this);
  48. App.stackServiceComponentMapper.map(serviceComponents);
  49. App.handleStackDependedComponents();
  50. return serviceComponents;
  51. }
  52. };