quicklinks_mapper.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. * 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. */
  17. var App = require("app");
  18. App.quicklinksMapper = App.QuickDataMapper.create({
  19. model: App.QuickLinksConfig,
  20. config: {
  21. "id": "QuickLinkInfo.service_name",
  22. "file_name" : "QuickLinkInfo.file_name",
  23. "service_name" : "QuickLinkInfo.service_name",
  24. "stack_name" : "QuickLinkInfo.stack_name",
  25. "stack_version" : "QuickLinkInfo.stack_version",
  26. "name" : "QuickLinkInfo.quicklink_data.QuickLinksConfiguration.name",
  27. "protocol" : "QuickLinkInfo.quicklink_data.QuickLinksConfiguration.configuration.protocol",
  28. "links" : "QuickLinkInfo.quicklink_data.QuickLinksConfiguration.configuration.links"
  29. },
  30. map: function(json){
  31. console.time('App.quicklinksMapper execution time');
  32. var result = [];
  33. var linkResult = [];
  34. json.items.forEach(function(item) {
  35. var parseResult = this.parseIt(item, this.get('config'));
  36. console.log("parseResult", parseResult);
  37. result.push(parseResult);
  38. }, this);
  39. App.store.loadMany(this.get('model'), result);
  40. App.store.commit();
  41. console.timeEnd('App.quicklinksMapper execution time');
  42. }
  43. });