You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by kb...@apache.org on 2017/02/14 09:01:07 UTC

incubator-atlas git commit: ATLAS-1548 : Create entity : Change PUT and POST object structure based on new API Changes

Repository: incubator-atlas
Updated Branches:
  refs/heads/master 8be1be677 -> b2ec89d59


ATLAS-1548 : Create entity : Change PUT and POST object structure based on new API Changes


Project: http://git-wip-us.apache.org/repos/asf/incubator-atlas/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-atlas/commit/b2ec89d5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-atlas/tree/b2ec89d5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-atlas/diff/b2ec89d5

Branch: refs/heads/master
Commit: b2ec89d59cd997ec3c12b9442112428c4a02e2b5
Parents: 8be1be6
Author: kevalbhatt <kb...@apache.org>
Authored: Tue Feb 14 13:07:18 2017 +0530
Committer: kevalbhatt <kb...@apache.org>
Committed: Tue Feb 14 14:29:05 2017 +0530

----------------------------------------------------------------------
 dashboardv2/public/js/models/VEntity.js         |  9 +--
 .../js/views/audit/AuditTableLayoutView.js      | 13 ++--
 .../views/audit/CreateAuditTableLayoutView.js   | 14 ++--
 .../js/views/entity/CreateEntityLayoutView.js   | 82 +++++++++++---------
 .../public/js/views/graph/LineageLayoutView.js  |  2 +-
 release-log.txt                                 |  2 +
 6 files changed, 65 insertions(+), 57 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b2ec89d5/dashboardv2/public/js/models/VEntity.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/models/VEntity.js b/dashboardv2/public/js/models/VEntity.js
index 6f44a88..88310ab 100644
--- a/dashboardv2/public/js/models/VEntity.js
+++ b/dashboardv2/public/js/models/VEntity.js
@@ -70,13 +70,8 @@ define(['require',
 
             return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
         },
-        createOreditEntity: function(guid, options) {
-            var url;
-            if (guid) {
-                url = UrlLinks.entitiesApiUrl(guid);
-            } else {
-                url = UrlLinks.entitiesApiUrl();
-            }
+        createOreditEntity: function(options) {
+            var url = UrlLinks.entitiesApiUrl();
             options = _.extend({
                 contentType: 'application/json',
                 dataType: 'json'

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b2ec89d5/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/audit/AuditTableLayoutView.js b/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
index d0129f7..d837cf3 100644
--- a/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/AuditTableLayoutView.js
@@ -136,17 +136,16 @@ define(['require',
                         that.$('.fontLoader').hide();
                         that.$('.auditTable').show();
                         that.renderOffset(options);
-                        if (that.entityCollection && (that.entityCollection.models.length < that.count && that.currPage == 1) && that.next == that.entityCollection.last().get('eventKey')) {
-                            options.next.attr('disabled', true);
-                            options.previous.removeAttr("disabled");
-                        } else {
-                            if (that.entityCollection.models.length > 0) {
+                        if (that.entityCollection.models.length) {
+                            if (that.entityCollection && (that.entityCollection.models.length < that.count && that.currPage == 1) && that.next == that.entityCollection.last().get('eventKey')) {
+                                options.next.attr('disabled', true);
+                                options.previous.removeAttr("disabled");
+                            } else {
                                 that.next = that.entityCollection.last().get('eventKey');
                                 if (that.pervOld.length === 0) {
                                     options.previous.attr('disabled', true);
                                 }
                             }
-
                         }
                         that.renderTableLayoutView();
                     },
@@ -207,7 +206,7 @@ define(['require',
                         sortable: false,
                         formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
                             fromRaw: function(rawValue, model) {
-                                return '<div class="label label-success auditDetailBtn" data-id="auditCreate" data-action="' + Enums.auditAction[model.attributes.action] + '" data-modalId="' + model.get('eventKey') + '">Detail</div>';
+                                return '<div class="label label-success auditDetailBtn" data-id="auditCreate" data-action="' + Enums.auditAction[model.get('action')] + '" data-modalId="' + model.get('eventKey') + '">Detail</div>';
                             }
                         })
                     },

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b2ec89d5/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
index 12244af..cbf6a9f 100644
--- a/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
+++ b/dashboardv2/public/js/views/audit/CreateAuditTableLayoutView.js
@@ -65,15 +65,17 @@ define(['require',
                     table = "";
                 var detailObj = this.entityModel.get('details');
                 if (detailObj && detailObj.search(':') >= 0) {
-                    var parseDetailsObject = detailObj;
-                    var appendedString = "{" + detailObj + "}";
-                    var auditData = appendedString.split('"')[0].split(':')[0].split("{")[1];
+                    var parseDetailsObject = detailObj.split(':');
+                    if (parseDetailsObject.length > 1) {
+                        parseDetailsObject.shift();
+                        var auditData = parseDetailsObject.join(":");
+                    }
                     try {
-                        parseDetailsObject = JSON.parse(appendedString.replace("{" + auditData + ":", '{"' + auditData + '":'))[auditData];
+                        parseDetailsObject = JSON.parse(auditData);
                         var name = _.escape(parseDetailsObject.typeName);
                     } catch (err) {
-                        if (parseDetailsObject.search(':') >= 0) {
-                            var name = parseDetailsObject.split(":")[1];
+                        if (_.isArray(parseDetailsObject)) {
+                            var name = _.escape(parseDetailsObject[0]);
                         }
                     }
                     var values = parseDetailsObject.values;

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b2ec89d5/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
index cf2b2c6..1b465c2 100644
--- a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
+++ b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
@@ -125,18 +125,18 @@ define(['require',
             bindEvents: function() {
                 var that = this;
                 this.listenTo(this.collection, "reset", function() {
-                    --this.asyncFetchCounter;
+                    this.decrementCounter('asyncFetchCounter');
                     this.entityCollectionList();
                 }, this);
                 this.listenTo(this.collection, 'error', function() {
-                    --this.asyncFetchCounter
+                    this.decrementCounter('asyncFetchCounter');
                     if (this.asyncFetchCounter === 0) {
                         this.hideLoader();
                     }
                 }, this);
                 this.listenTo(this.searchCollection, "reset", function() {
                     var that = this;
-                    --this.asyncFetchLOVCounter
+                    this.decrementCounter('asyncFetchLOVCounter');
                     _.each(this.searchCollection.fullCollection.models, function(model) {
                         var obj = model.toJSON();
                         obj['queryText'] = model.collection.queryText;
@@ -145,7 +145,7 @@ define(['require',
                     this.addJsonSearchData();
                 }, this);
                 this.listenTo(this.searchCollection, 'error', function(data, key) {
-                    --this.asyncFetchLOVCounter;
+                    this.decrementCounter('asyncFetchLOVCounter');
                     this.addJsonSearchData();
                 }, this);
                 this.ui.entityInputData.on("keyup", "textarea", function() {
@@ -179,6 +179,11 @@ define(['require',
                 this.bindEvents();
                 this.fetchCollections();
             },
+            decrementCounter: function(counter) {
+                if (this[counter] > 0) {
+                    --this[counter];
+                }
+            },
             fetchCollections: function() {
                 if (this.guid) {
                     this.collection.url = UrlLinks.entitiesApiUrl(this.guid);
@@ -194,7 +199,7 @@ define(['require',
                     value;
                 if (this.guid) {
                     this.collection.each(function(val) {
-                        name += _.escape(val.get("attributes").name) || _.escape(val.get("attributes").qualifiedName) || _.escape(val.get("attributes").id);
+                        name += _.escape(val.get("entity").attributes.name) || _.escape(val.get("entity").attributes.qualifiedName) || _.escape(val.get("entity").attributes.id);
                         that.entityData = val;
                     });
                     this.ui.assetName.html(name);
@@ -242,15 +247,12 @@ define(['require',
             onEntityChange: function(e, value) {
                 this.modal.$el.find('button.ok').prop("disabled", false);
                 var that = this,
-                    typeName;
+                    typeName = value && value.get('entity') ? value.get('entity').typeName : null;
                 this.showLoader();
                 this.ui.entityInputData.empty();
-                if (value) {
-                    typeName = value.get("typeName");
-                }
                 if (typeName) {
                     this.collection.url = UrlLinks.entitiesDefApiUrl(typeName);
-                } else {
+                } else if (e) {
                     this.collection.url = UrlLinks.entitiesDefApiUrl(e.target.value);
                     this.collection.modelAttrName = 'attributeDefs';
                 }
@@ -303,7 +305,7 @@ define(['require',
                         that.subAttributeData(data);
                     },
                     complete: function() {
-                        --that.asyncFetchCounter;
+                        that.decrementCounter('asyncFetchCounter');
                         that.initilizeElements();
                     },
                     silent: true
@@ -334,7 +336,7 @@ define(['require',
                     this.$('select[data-type="boolean"]').each(function(value, key) {
                         var dataKey = $(key).data('key');
                         if (that.entityData) {
-                            var setValue = that.entityData.get("attributes")[dataKey];
+                            var setValue = that.entityData.get("entity").attributes[dataKey];
                             this.value = setValue;
                         }
                     });
@@ -417,7 +419,7 @@ define(['require',
                 var typeName = value.typeName,
                     entityValue = "";
                 if (this.guid) {
-                    var dataValue = this.entityData.get("attributes")[value.name];
+                    var dataValue = this.entityData.get("entity").attributes[value.name];
                     if (_.isObject(dataValue)) {
                         entityValue = JSON.stringify(dataValue);
                     } else {
@@ -461,7 +463,8 @@ define(['require',
                 var that = this;
                 this.showLoader();
                 this.parentEntity = this.ui.entityList.val();
-                var entityAttribute = {};
+                var entity = {};
+                var referredEntities = {};
                 var extractValue = function(value) {
                     if (_.isArray(value)) {
                         if (that.selectStoreCollection.length) {
@@ -471,8 +474,10 @@ define(['require',
                                 temp['labelName'] = val;
                                 if (that.selectStoreCollection.findWhere(temp)) {
                                     var valueData = that.selectStoreCollection.findWhere(temp).toJSON();
-                                    valueData['guid'] = valueData.guid;
-                                    parseData.push(valueData);
+                                    if (valueData) {
+                                        //referredEntities[valueData.guid] = valueData;
+                                        parseData.push({ guid: valueData.guid, typeName: valueData.typeName });
+                                    }
                                 }
                             });
                         }
@@ -481,8 +486,11 @@ define(['require',
                             var temp = {} // I9 support;
                             temp['labelName'] = value;
                             if (that.selectStoreCollection.findWhere(temp)) {
-                                var parseData = that.selectStoreCollection.findWhere(temp).toJSON();
-                                parseData['guid'] = parseData.guid;
+                                var valueData = that.selectStoreCollection.findWhere(temp).toJSON();
+                                if (valueData) {
+                                    //referredEntities[valueData.guid] = valueData;
+                                    var parseData = { guid: valueData.guid, typeName: valueData.typeName };
+                                }
                             }
                         }
                     }
@@ -524,14 +532,14 @@ define(['require',
                         // Extract Data
                         if (dataTypeEnitity && datakeyEntity) {
                             if (that.entityDefCollection.fullCollection.find({ name: dataTypeEnitity })) {
-                                entityAttribute[datakeyEntity] = extractValue(value);
+                                entity[datakeyEntity] = extractValue(value);
                             } else if (typeof dataTypeEnitity === 'string' && datakeyEntity.indexOf("Time") > -1) {
-                                entityAttribute[datakeyEntity] = Date.parse(value);
+                                entity[datakeyEntity] = Date.parse(value);
                             } else if (dataTypeEnitity.indexOf("map") > -1) {
                                 try {
                                     if (value && value.length) {
                                         parseData = JSON.parse(value);
-                                        entityAttribute[datakeyEntity] = parseData;
+                                        entity[datakeyEntity] = parseData;
                                     }
                                 } catch (err) {
                                     $(this).addClass('errorClass');
@@ -539,29 +547,30 @@ define(['require',
                                     return;
                                 }
                             } else if (dataTypeEnitity.indexOf("array") > -1 && dataTypeEnitity.indexOf("string") === -1) {
-                                entityAttribute[datakeyEntity] = extractValue(value);
+                                entity[datakeyEntity] = extractValue(value);
                             } else {
                                 if (_.isString(value)) {
                                     if (value.length) {
-                                        entityAttribute[datakeyEntity] = value;
+                                        entity[datakeyEntity] = value;
                                     }
                                 } else {
-                                    entityAttribute[datakeyEntity] = value;
+                                    entity[datakeyEntity] = value;
                                 }
 
                             }
                         }
                     });
                     var entityJson = {
-                        "typeName": this.guid ? this.entityData.get("typeName") : this.parentEntity,
-                        "attributes": entityAttribute
-                    };
-                    if (this.guid) {
-                        entityJson["guid"] = this.entityData.get("guid");
+                        "entity": {
+                            "typeName": (this.guid ? this.entityData.get("entity").typeName : this.parentEntity),
+                            "attributes": entity,
+                            "guid": (this.guid ? this.guid : -1)
+                        },
+                        "referredEntities": referredEntities
                     };
-                    this.entityModel.createOreditEntity(this.guid, {
+                    this.entityModel.createOreditEntity({
                         data: JSON.stringify(entityJson),
-                        type: this.guid ? "PUT" : "POST",
+                        type: "POST",
                         success: function(model, response) {
                             that.modal.close();
                             Utils.notifySuccess({
@@ -643,10 +652,11 @@ define(['require',
                         $this.attr("multiple", ($this.data('type').indexOf("array") === -1 ? false : true));
 
                         if (that.guid) {
-                            var dataValue = that.entityData.get("attributes")[keyData];
-                            if (that.selectStoreCollection.length) {
-                                var selectedValue = [];
-                            }
+                            var dataValue = that.entityData.get("entity").attributes[keyData];
+                            var selectedValue = [];
+                            // if (that.selectStoreCollection.length) {
+                            //     var selectedValue = [];
+                            // }
                             var setValue = function(selectValue) {
                                 var obj = selectValue.toJSON();
                                 if (dataValue !== null && _.isArray(dataValue)) {
@@ -692,7 +702,7 @@ define(['require',
                         $this.select2({
                             placeholder: placeholderName,
                             allowClear: true,
-                            tags: true
+                            tags: ($this.data('querydata') == "string" ? true : false)
                         });
                     });
                     this.hideLoader();

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b2ec89d5/dashboardv2/public/js/views/graph/LineageLayoutView.js
----------------------------------------------------------------------
diff --git a/dashboardv2/public/js/views/graph/LineageLayoutView.js b/dashboardv2/public/js/views/graph/LineageLayoutView.js
index 986b4c3..02ede88 100644
--- a/dashboardv2/public/js/views/graph/LineageLayoutView.js
+++ b/dashboardv2/public/js/views/graph/LineageLayoutView.js
@@ -107,7 +107,7 @@ define(['require',
             },
             noLineage: function() {
                 this.$('.fontLoader').hide();
-                this.$('svg').height('100');
+                //this.$('svg').height('100');
                 this.$('svg').html('<text x="' + (this.$('svg').width() - 150) / 2 + '" y="' + this.$('svg').height() / 2 + '" fill="black">No lineage data found</text>');
             },
             generateData: function(relations, guidEntityMap) {

http://git-wip-us.apache.org/repos/asf/incubator-atlas/blob/b2ec89d5/release-log.txt
----------------------------------------------------------------------
diff --git a/release-log.txt b/release-log.txt
index 44f4658..e2155f4 100644
--- a/release-log.txt
+++ b/release-log.txt
@@ -9,6 +9,8 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al
 ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
 
 ALL CHANGES:
+ATLAS-1548 Create entity : Change PUT and POST object structure based on new API Changes (kevalbhatt)
+ATLAS-1522 entity type attributes (like hive_table.sd, hive_table.columns) should use AtlasObjectId as value instead of entire entity contents (mneethiraj)
 ATLAS-1546 Hive hook should choose appropriate JAAS config when host uses kerberos ticket-cache (nixonrodrigues,gss2002 via mneethiraj)
 ATLAS-1539 Integration tests in projects which use the typesystem test jar (e.g. webapp) can now be run successfully when invoked in the project directory (dkantor)
 ATLAS-1542 Atlas server fails to start if duplicate types are found during Typesystem bootstrap (svimal2106)