MobileConfigurationModel.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // IBM Confidential
  3. // OCO Source Materials
  4. // BI and PM: Mobile
  5. // (C) Copyright IBM Corp. 2013
  6. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  7. //
  8. dojo.provide('mobileAdmin.serverConfig.model.MobileConfigurationModel');
  9. // dojo dependencies
  10. dojo.require('dojo.store.Memory');
  11. dojo.require('dojo.data.ObjectStore');
  12. dojo.declare('mobileAdmin.serverConfig.model.MobileConfigurationModel', null, {
  13. constructor: function(args){
  14. dojo.mixin(this, args);
  15. this.setCognosExpressMode(this.cognosExpressMode);
  16. this.setDataObjectKey(this.dataObjectKey);
  17. this.setDataObject(this.dataObject);
  18. this.setObjectStore(this.objectStore);
  19. this.setDojoData(this.dojoData);
  20. },
  21. cognosExpressMode:false,
  22. dataObjectKey:null,
  23. dataObject:null,
  24. objectStore:null,
  25. dojoData:null,
  26. setCognosExpressMode: function(expressMode) {
  27. if(typeof expressMode != "boolean") {
  28. this.cognosExpressMode = false;
  29. } else {
  30. this.cognosExpressMode = expressMode;
  31. }
  32. },
  33. setDataObjectKey: function(dataObjectKey) {
  34. if(!dataObjectKey) {
  35. this.dataObjectKey = "";
  36. }
  37. },
  38. setDataObject: function(dataObject) {
  39. if(!dataObject) {
  40. this.dataObject = [];
  41. }
  42. },
  43. setObjectStore: function(objectStore) {
  44. if(!objectStore) {
  45. this.objectStore = new dojo.store.Memory({data:this.dataObject, idProperty:this.dataObjectKey});
  46. }
  47. },
  48. setDojoData: function(dojoData) {
  49. if(!dojoData) {
  50. this.dojoData = new dojo.data.ObjectStore({objectStore:this.objectStore});
  51. }
  52. },
  53. queryProperties: function() {
  54. var configProperties = [];
  55. this.objectStore.query({})
  56. .forEach( function(property) {
  57. configProperties.push(property);
  58. });
  59. return configProperties;
  60. },
  61. queryGroupLabels: function() {
  62. var configPropertyGroups = [];
  63. this.objectStore.query({}, {
  64. sort:[{attribute:'parentID', descending:false}]
  65. }).map( function(property) {
  66. return property;
  67. }).forEach( dojo.hitch(this, function(property) {
  68. var parentLabel = property.parentLabel;
  69. var index = dojo.indexOf(configPropertyGroups, parentLabel);
  70. if(-1 == index) {
  71. if(this.cognosExpressMode) {
  72. if(property.displayInExpressMode) {
  73. configPropertyGroups.push(parentLabel);
  74. }
  75. } else {
  76. configPropertyGroups.push(parentLabel);
  77. }
  78. }
  79. }));
  80. return configPropertyGroups;
  81. },
  82. queryGroupProperties: function(propertyGroupLabel) {
  83. var configProperties = [];
  84. this.objectStore.query({parentLabel:propertyGroupLabel}, {
  85. sort:[{attribute:'propertyID', descending:false}]
  86. }).map( function(property) {
  87. return property;
  88. }).forEach( dojo.hitch(this, function(property) {
  89. if(this.cognosExpressMode) {
  90. if(property.displayInExpressMode) {
  91. configProperties.push(property);
  92. }
  93. } else {
  94. configProperties.push(property);
  95. }
  96. }));
  97. return configProperties;
  98. }
  99. });