Commit b2ec89d5 by kevalbhatt

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

parent 8be1be67
...@@ -70,13 +70,8 @@ define(['require', ...@@ -70,13 +70,8 @@ define(['require',
return this.constructor.nonCrudOperation.call(this, url, 'GET', options); return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
}, },
createOreditEntity: function(guid, options) { createOreditEntity: function(options) {
var url; var url = UrlLinks.entitiesApiUrl();
if (guid) {
url = UrlLinks.entitiesApiUrl(guid);
} else {
url = UrlLinks.entitiesApiUrl();
}
options = _.extend({ options = _.extend({
contentType: 'application/json', contentType: 'application/json',
dataType: 'json' dataType: 'json'
......
...@@ -136,17 +136,16 @@ define(['require', ...@@ -136,17 +136,16 @@ define(['require',
that.$('.fontLoader').hide(); that.$('.fontLoader').hide();
that.$('.auditTable').show(); that.$('.auditTable').show();
that.renderOffset(options); that.renderOffset(options);
if (that.entityCollection && (that.entityCollection.models.length < that.count && that.currPage == 1) && that.next == that.entityCollection.last().get('eventKey')) { if (that.entityCollection.models.length) {
options.next.attr('disabled', true); if (that.entityCollection && (that.entityCollection.models.length < that.count && that.currPage == 1) && that.next == that.entityCollection.last().get('eventKey')) {
options.previous.removeAttr("disabled"); options.next.attr('disabled', true);
} else { options.previous.removeAttr("disabled");
if (that.entityCollection.models.length > 0) { } else {
that.next = that.entityCollection.last().get('eventKey'); that.next = that.entityCollection.last().get('eventKey');
if (that.pervOld.length === 0) { if (that.pervOld.length === 0) {
options.previous.attr('disabled', true); options.previous.attr('disabled', true);
} }
} }
} }
that.renderTableLayoutView(); that.renderTableLayoutView();
}, },
...@@ -207,7 +206,7 @@ define(['require', ...@@ -207,7 +206,7 @@ define(['require',
sortable: false, sortable: false,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, { formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) { 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>';
} }
}) })
}, },
......
...@@ -65,15 +65,17 @@ define(['require', ...@@ -65,15 +65,17 @@ define(['require',
table = ""; table = "";
var detailObj = this.entityModel.get('details'); var detailObj = this.entityModel.get('details');
if (detailObj && detailObj.search(':') >= 0) { if (detailObj && detailObj.search(':') >= 0) {
var parseDetailsObject = detailObj; var parseDetailsObject = detailObj.split(':');
var appendedString = "{" + detailObj + "}"; if (parseDetailsObject.length > 1) {
var auditData = appendedString.split('"')[0].split(':')[0].split("{")[1]; parseDetailsObject.shift();
var auditData = parseDetailsObject.join(":");
}
try { try {
parseDetailsObject = JSON.parse(appendedString.replace("{" + auditData + ":", '{"' + auditData + '":'))[auditData]; parseDetailsObject = JSON.parse(auditData);
var name = _.escape(parseDetailsObject.typeName); var name = _.escape(parseDetailsObject.typeName);
} catch (err) { } catch (err) {
if (parseDetailsObject.search(':') >= 0) { if (_.isArray(parseDetailsObject)) {
var name = parseDetailsObject.split(":")[1]; var name = _.escape(parseDetailsObject[0]);
} }
} }
var values = parseDetailsObject.values; var values = parseDetailsObject.values;
......
...@@ -125,18 +125,18 @@ define(['require', ...@@ -125,18 +125,18 @@ define(['require',
bindEvents: function() { bindEvents: function() {
var that = this; var that = this;
this.listenTo(this.collection, "reset", function() { this.listenTo(this.collection, "reset", function() {
--this.asyncFetchCounter; this.decrementCounter('asyncFetchCounter');
this.entityCollectionList(); this.entityCollectionList();
}, this); }, this);
this.listenTo(this.collection, 'error', function() { this.listenTo(this.collection, 'error', function() {
--this.asyncFetchCounter this.decrementCounter('asyncFetchCounter');
if (this.asyncFetchCounter === 0) { if (this.asyncFetchCounter === 0) {
this.hideLoader(); this.hideLoader();
} }
}, this); }, this);
this.listenTo(this.searchCollection, "reset", function() { this.listenTo(this.searchCollection, "reset", function() {
var that = this; var that = this;
--this.asyncFetchLOVCounter this.decrementCounter('asyncFetchLOVCounter');
_.each(this.searchCollection.fullCollection.models, function(model) { _.each(this.searchCollection.fullCollection.models, function(model) {
var obj = model.toJSON(); var obj = model.toJSON();
obj['queryText'] = model.collection.queryText; obj['queryText'] = model.collection.queryText;
...@@ -145,7 +145,7 @@ define(['require', ...@@ -145,7 +145,7 @@ define(['require',
this.addJsonSearchData(); this.addJsonSearchData();
}, this); }, this);
this.listenTo(this.searchCollection, 'error', function(data, key) { this.listenTo(this.searchCollection, 'error', function(data, key) {
--this.asyncFetchLOVCounter; this.decrementCounter('asyncFetchLOVCounter');
this.addJsonSearchData(); this.addJsonSearchData();
}, this); }, this);
this.ui.entityInputData.on("keyup", "textarea", function() { this.ui.entityInputData.on("keyup", "textarea", function() {
...@@ -179,6 +179,11 @@ define(['require', ...@@ -179,6 +179,11 @@ define(['require',
this.bindEvents(); this.bindEvents();
this.fetchCollections(); this.fetchCollections();
}, },
decrementCounter: function(counter) {
if (this[counter] > 0) {
--this[counter];
}
},
fetchCollections: function() { fetchCollections: function() {
if (this.guid) { if (this.guid) {
this.collection.url = UrlLinks.entitiesApiUrl(this.guid); this.collection.url = UrlLinks.entitiesApiUrl(this.guid);
...@@ -194,7 +199,7 @@ define(['require', ...@@ -194,7 +199,7 @@ define(['require',
value; value;
if (this.guid) { if (this.guid) {
this.collection.each(function(val) { 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; that.entityData = val;
}); });
this.ui.assetName.html(name); this.ui.assetName.html(name);
...@@ -242,15 +247,12 @@ define(['require', ...@@ -242,15 +247,12 @@ define(['require',
onEntityChange: function(e, value) { onEntityChange: function(e, value) {
this.modal.$el.find('button.ok').prop("disabled", false); this.modal.$el.find('button.ok').prop("disabled", false);
var that = this, var that = this,
typeName; typeName = value && value.get('entity') ? value.get('entity').typeName : null;
this.showLoader(); this.showLoader();
this.ui.entityInputData.empty(); this.ui.entityInputData.empty();
if (value) {
typeName = value.get("typeName");
}
if (typeName) { if (typeName) {
this.collection.url = UrlLinks.entitiesDefApiUrl(typeName); this.collection.url = UrlLinks.entitiesDefApiUrl(typeName);
} else { } else if (e) {
this.collection.url = UrlLinks.entitiesDefApiUrl(e.target.value); this.collection.url = UrlLinks.entitiesDefApiUrl(e.target.value);
this.collection.modelAttrName = 'attributeDefs'; this.collection.modelAttrName = 'attributeDefs';
} }
...@@ -303,7 +305,7 @@ define(['require', ...@@ -303,7 +305,7 @@ define(['require',
that.subAttributeData(data); that.subAttributeData(data);
}, },
complete: function() { complete: function() {
--that.asyncFetchCounter; that.decrementCounter('asyncFetchCounter');
that.initilizeElements(); that.initilizeElements();
}, },
silent: true silent: true
...@@ -334,7 +336,7 @@ define(['require', ...@@ -334,7 +336,7 @@ define(['require',
this.$('select[data-type="boolean"]').each(function(value, key) { this.$('select[data-type="boolean"]').each(function(value, key) {
var dataKey = $(key).data('key'); var dataKey = $(key).data('key');
if (that.entityData) { if (that.entityData) {
var setValue = that.entityData.get("attributes")[dataKey]; var setValue = that.entityData.get("entity").attributes[dataKey];
this.value = setValue; this.value = setValue;
} }
}); });
...@@ -417,7 +419,7 @@ define(['require', ...@@ -417,7 +419,7 @@ define(['require',
var typeName = value.typeName, var typeName = value.typeName,
entityValue = ""; entityValue = "";
if (this.guid) { if (this.guid) {
var dataValue = this.entityData.get("attributes")[value.name]; var dataValue = this.entityData.get("entity").attributes[value.name];
if (_.isObject(dataValue)) { if (_.isObject(dataValue)) {
entityValue = JSON.stringify(dataValue); entityValue = JSON.stringify(dataValue);
} else { } else {
...@@ -461,7 +463,8 @@ define(['require', ...@@ -461,7 +463,8 @@ define(['require',
var that = this; var that = this;
this.showLoader(); this.showLoader();
this.parentEntity = this.ui.entityList.val(); this.parentEntity = this.ui.entityList.val();
var entityAttribute = {}; var entity = {};
var referredEntities = {};
var extractValue = function(value) { var extractValue = function(value) {
if (_.isArray(value)) { if (_.isArray(value)) {
if (that.selectStoreCollection.length) { if (that.selectStoreCollection.length) {
...@@ -471,8 +474,10 @@ define(['require', ...@@ -471,8 +474,10 @@ define(['require',
temp['labelName'] = val; temp['labelName'] = val;
if (that.selectStoreCollection.findWhere(temp)) { if (that.selectStoreCollection.findWhere(temp)) {
var valueData = that.selectStoreCollection.findWhere(temp).toJSON(); var valueData = that.selectStoreCollection.findWhere(temp).toJSON();
valueData['guid'] = valueData.guid; if (valueData) {
parseData.push(valueData); //referredEntities[valueData.guid] = valueData;
parseData.push({ guid: valueData.guid, typeName: valueData.typeName });
}
} }
}); });
} }
...@@ -481,8 +486,11 @@ define(['require', ...@@ -481,8 +486,11 @@ define(['require',
var temp = {} // I9 support; var temp = {} // I9 support;
temp['labelName'] = value; temp['labelName'] = value;
if (that.selectStoreCollection.findWhere(temp)) { if (that.selectStoreCollection.findWhere(temp)) {
var parseData = that.selectStoreCollection.findWhere(temp).toJSON(); var valueData = that.selectStoreCollection.findWhere(temp).toJSON();
parseData['guid'] = parseData.guid; if (valueData) {
//referredEntities[valueData.guid] = valueData;
var parseData = { guid: valueData.guid, typeName: valueData.typeName };
}
} }
} }
} }
...@@ -524,14 +532,14 @@ define(['require', ...@@ -524,14 +532,14 @@ define(['require',
// Extract Data // Extract Data
if (dataTypeEnitity && datakeyEntity) { if (dataTypeEnitity && datakeyEntity) {
if (that.entityDefCollection.fullCollection.find({ name: dataTypeEnitity })) { if (that.entityDefCollection.fullCollection.find({ name: dataTypeEnitity })) {
entityAttribute[datakeyEntity] = extractValue(value); entity[datakeyEntity] = extractValue(value);
} else if (typeof dataTypeEnitity === 'string' && datakeyEntity.indexOf("Time") > -1) { } 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) { } else if (dataTypeEnitity.indexOf("map") > -1) {
try { try {
if (value && value.length) { if (value && value.length) {
parseData = JSON.parse(value); parseData = JSON.parse(value);
entityAttribute[datakeyEntity] = parseData; entity[datakeyEntity] = parseData;
} }
} catch (err) { } catch (err) {
$(this).addClass('errorClass'); $(this).addClass('errorClass');
...@@ -539,29 +547,30 @@ define(['require', ...@@ -539,29 +547,30 @@ define(['require',
return; return;
} }
} else if (dataTypeEnitity.indexOf("array") > -1 && dataTypeEnitity.indexOf("string") === -1) { } else if (dataTypeEnitity.indexOf("array") > -1 && dataTypeEnitity.indexOf("string") === -1) {
entityAttribute[datakeyEntity] = extractValue(value); entity[datakeyEntity] = extractValue(value);
} else { } else {
if (_.isString(value)) { if (_.isString(value)) {
if (value.length) { if (value.length) {
entityAttribute[datakeyEntity] = value; entity[datakeyEntity] = value;
} }
} else { } else {
entityAttribute[datakeyEntity] = value; entity[datakeyEntity] = value;
} }
} }
} }
}); });
var entityJson = { var entityJson = {
"typeName": this.guid ? this.entityData.get("typeName") : this.parentEntity, "entity": {
"attributes": entityAttribute "typeName": (this.guid ? this.entityData.get("entity").typeName : this.parentEntity),
}; "attributes": entity,
if (this.guid) { "guid": (this.guid ? this.guid : -1)
entityJson["guid"] = this.entityData.get("guid"); },
"referredEntities": referredEntities
}; };
this.entityModel.createOreditEntity(this.guid, { this.entityModel.createOreditEntity({
data: JSON.stringify(entityJson), data: JSON.stringify(entityJson),
type: this.guid ? "PUT" : "POST", type: "POST",
success: function(model, response) { success: function(model, response) {
that.modal.close(); that.modal.close();
Utils.notifySuccess({ Utils.notifySuccess({
...@@ -643,10 +652,11 @@ define(['require', ...@@ -643,10 +652,11 @@ define(['require',
$this.attr("multiple", ($this.data('type').indexOf("array") === -1 ? false : true)); $this.attr("multiple", ($this.data('type').indexOf("array") === -1 ? false : true));
if (that.guid) { if (that.guid) {
var dataValue = that.entityData.get("attributes")[keyData]; var dataValue = that.entityData.get("entity").attributes[keyData];
if (that.selectStoreCollection.length) { var selectedValue = [];
var selectedValue = []; // if (that.selectStoreCollection.length) {
} // var selectedValue = [];
// }
var setValue = function(selectValue) { var setValue = function(selectValue) {
var obj = selectValue.toJSON(); var obj = selectValue.toJSON();
if (dataValue !== null && _.isArray(dataValue)) { if (dataValue !== null && _.isArray(dataValue)) {
...@@ -692,7 +702,7 @@ define(['require', ...@@ -692,7 +702,7 @@ define(['require',
$this.select2({ $this.select2({
placeholder: placeholderName, placeholder: placeholderName,
allowClear: true, allowClear: true,
tags: true tags: ($this.data('querydata') == "string" ? true : false)
}); });
}); });
this.hideLoader(); this.hideLoader();
......
...@@ -107,7 +107,7 @@ define(['require', ...@@ -107,7 +107,7 @@ define(['require',
}, },
noLineage: function() { noLineage: function() {
this.$('.fontLoader').hide(); 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>'); 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) { generateData: function(relations, guidEntityMap) {
......
...@@ -9,6 +9,8 @@ ATLAS-1060 Add composite indexes for exact match performance improvements for al ...@@ -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) ATLAS-1127 Modify creation and modification timestamps to Date instead of Long(sumasai)
ALL CHANGES: 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-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-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) ATLAS-1542 Atlas server fails to start if duplicate types are found during Typesystem bootstrap (svimal2106)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment