VEntity.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. define([ "require", "utils/Globals", "models/BaseModel", "utils/UrlLinks" ], function(require, Globals, VBaseModel, UrlLinks) {
  2. "use strict";
  3. var VEntity = VBaseModel.extend({
  4. urlRoot: UrlLinks.entitiesApiUrl(),
  5. defaults: {},
  6. serverSchema: {},
  7. idAttribute: "id",
  8. initialize: function() {
  9. this.modelName = "VEntity";
  10. },
  11. toString: function() {
  12. return this.get("name");
  13. },
  14. getEntity: function(token, options) {
  15. var url = UrlLinks.entitiesApiUrl({
  16. guid: token
  17. });
  18. return options = _.extend({
  19. contentType: "application/json",
  20. dataType: "json"
  21. }, options), this.constructor.nonCrudOperation.call(this, url, "GET", options);
  22. },
  23. getEntityHeader: function(token, options) {
  24. var url = UrlLinks.entityHeaderApiUrl(token);
  25. return options = _.extend({
  26. contentType: "application/json",
  27. dataType: "json"
  28. }, options), this.constructor.nonCrudOperation.call(this, url, "GET", options);
  29. },
  30. saveTraitsEntity: function(token, options) {
  31. var url = UrlLinks.entitiesTraitsApiUrl(token);
  32. return options = _.extend({
  33. contentType: "application/json",
  34. dataType: "json"
  35. }, options), this.constructor.nonCrudOperation.call(this, url, "POST", options);
  36. },
  37. getEntityDef: function(name, options) {
  38. var url = UrlLinks.entitiesDefApiUrl(name);
  39. return options = _.extend({
  40. contentType: "application/json",
  41. dataType: "json"
  42. }, options), this.constructor.nonCrudOperation.call(this, url, "GET", options);
  43. },
  44. createOreditEntity: function(options) {
  45. var url = UrlLinks.entitiesApiUrl();
  46. return options = _.extend({
  47. contentType: "application/json",
  48. dataType: "json"
  49. }, options), this.constructor.nonCrudOperation.call(this, url, "", options);
  50. },
  51. saveEntityLabels: function(guid, options) {
  52. var url = UrlLinks.entityLabelsAPIUrl(guid);
  53. return options = _.extend({
  54. contentType: "application/json",
  55. dataType: "json"
  56. }, options), this.constructor.nonCrudOperation.call(this, url, "POST", options);
  57. },
  58. saveBusinessMetadata: function(options) {
  59. var url = UrlLinks.businessMetadataDefApiUrl();
  60. return options = _.extend({
  61. contentType: "application/json",
  62. dataType: "json"
  63. }, options), this.constructor.nonCrudOperation.call(this, url, "", options);
  64. },
  65. deleteBusinessMetadata: function(options) {
  66. var url = UrlLinks.businessMetadataDefApiUrl(options.typeName);
  67. return this.constructor.nonCrudOperation.call(this, url, "DELETE", options);
  68. },
  69. saveBusinessMetadataEntity: function(guid, options) {
  70. var url = UrlLinks.entitiesBusinessMetadataApiUrl(guid);
  71. return options = _.extend({
  72. contentType: "application/json",
  73. dataType: "json"
  74. }, options), this.constructor.nonCrudOperation.call(this, url, "POST", options);
  75. }
  76. }, {});
  77. return VEntity;
  78. });