You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by ma...@apache.org on 2019/04/15 19:23:35 UTC

[atlas] branch branch-1.0 updated (bdd296e -> 84af0cb)

This is an automated email from the ASF dual-hosted git repository.

madhan pushed a change to branch branch-1.0
in repository https://gitbox.apache.org/repos/asf/atlas.git.


    from bdd296e  ATLAS-3056: updated rdbms types to remove use of ownedRef/inverseRef - #3
     new 9227797  ATLAS-3136: assigning a term to an invalid entity guid throws 500, instead of 400
     new 2caf30a  ATLAS-3139: updated basic search to include relationship attributes as well in the result
     new 1dff81a  ATLAS-3128: UI: Create entity is not working after new relationship attribute introduce
     new 84af0cb  ATLAS-3137 : UI : Create entity add element validation and design improvement

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 dashboardv2/public/css/scss/form.scss              |  93 +++++-
 dashboardv2/public/css/scss/override.scss          |  14 +-
 dashboardv2/public/css/scss/theme.scss             |  11 +-
 .../entity/CreateEntityLayoutView_tmpl.html        |   4 +-
 dashboardv2/public/js/utils/Helper.js              |   3 +
 dashboardv2/public/js/utils/Utils.js               |  80 ++++-
 .../js/views/entity/CreateEntityLayoutView.js      | 333 +++++++++++++++++----
 .../org/apache/atlas/type/AtlasStructType.java     |   6 +-
 .../atlas/discovery/EntityDiscoveryService.java    |   8 +
 .../store/graph/AtlasRelationshipStore.java        |   2 +-
 .../store/graph/v2/AtlasRelationshipStoreV2.java   |  31 +-
 .../store/graph/v2/EntityGraphRetriever.java       |   8 +-
 12 files changed, 489 insertions(+), 104 deletions(-)


[atlas] 03/04: ATLAS-3128: UI: Create entity is not working after new relationship attribute introduce

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch branch-1.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 1dff81af649b51b4607fa42262b588cc64885aba
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Wed Apr 10 14:09:53 2019 -0700

    ATLAS-3128: UI: Create entity is not working after new relationship attribute introduce
    
    Signed-off-by: Sarath Subramanian <ss...@hortonworks.com>
    (cherry picked from commit 39b059e03d3cc728745e7b1c90a7be774ebca0fa)
---
 dashboardv2/public/css/scss/form.scss              |  87 +++++++
 dashboardv2/public/css/scss/override.scss          |   2 +-
 dashboardv2/public/css/scss/theme.scss             |  11 +-
 .../entity/CreateEntityLayoutView_tmpl.html        |   2 +-
 dashboardv2/public/js/utils/Helper.js              |   3 +
 dashboardv2/public/js/utils/Utils.js               |  79 ++++--
 .../js/views/entity/CreateEntityLayoutView.js      | 272 +++++++++++++++++----
 7 files changed, 385 insertions(+), 71 deletions(-)

diff --git a/dashboardv2/public/css/scss/form.scss b/dashboardv2/public/css/scss/form.scss
index b7ade88..3e63e8b 100644
--- a/dashboardv2/public/css/scss/form.scss
+++ b/dashboardv2/public/css/scss/form.scss
@@ -23,10 +23,12 @@
     .control-label-sm {
         padding-top: 3px;
     }
+
     .control-label-sm-pl {
         @extend .control-label-sm;
         padding-left: 10px;
     }
+
     .control-label-sm-pr {
         @extend .control-label-sm;
         padding-right: 10px;
@@ -44,6 +46,7 @@
         &.text-left {
             text-align: left;
         }
+
         &.text-right {
             text-align: right;
         }
@@ -53,6 +56,7 @@
         //Instead of the line below you could use @include border-radius($radius, $vertical-radius)
         background-color: $color_mystic_approx;
         border: 1px $color_mystic_approx solid;
+
         &:focus {
             border-color: $color_bali_hai_approx;
             outline: 0; //Instead of the line below you could use @include box-shadow($shadow-1, $shadow-2, $shadow-3, $shadow-4, $shadow-5, $shadow-6, $shadow-7, $shadow-8, $shadow-9, $shadow-10)
@@ -62,6 +66,7 @@
 }
 
 .form-color {
+
     .form-group span[class^="select2-selection select2-selection--"],
     .form-control {
         background-color: #e8e8e8 !important;
@@ -70,6 +75,7 @@
 
 .sidebar-wrapper {
     z-index: 9 !important;
+
     .form-control {
         background-color: $white;
         border: 1px $white solid;
@@ -83,6 +89,7 @@
 
 textarea {
     resize: none;
+
     &:focus {
         outline: none !important;
     }
@@ -99,6 +106,7 @@ button:focus {
 .btn {
     //Instead of the line below you could use @include border-radius($radius, $vertical-radius)
     border-radius: 4px;
+
     &:hover {
         text-decoration: none;
     }
@@ -106,6 +114,7 @@ button:focus {
 
 [class^="col-md-"],
 [class^="col-sm-"] {
+
     .btn.checkbox-inline,
     .btn.radio-inline {
         padding-left: 19px;
@@ -116,6 +125,7 @@ button:focus {
     color: $white;
     background-color: $color_blue_bayoux_approx;
     border-color: $color_blue_bayoux_approx;
+
     &:hover {
         color: $white;
         background-color: $color_pickled_bluewood_approx;
@@ -127,11 +137,13 @@ button:focus {
     color: $white;
     background-color: $color_jungle_green_approx;
     border-color: $color_jungle_green_approx;
+
     &:hover {
         color: $white;
         background-color: $color_jungle_green_approx;
         border-color: $color_jungle_green_approx;
     }
+
     &:focus {
         color: $white;
         background-color: $color_jungle_green_approx;
@@ -143,11 +155,13 @@ button:focus {
     color: $white;
     background-color: $color_picton_blue_approx;
     border-color: $color_picton_blue_approx;
+
     &:hover {
         color: $white;
         background-color: $color_curious_blue_approx;
         border-color: $color_curious_blue_approx;
     }
+
     &:focus {
         color: $white;
         background-color: $color_curious_blue_approx;
@@ -159,11 +173,13 @@ button:focus {
     color: $white;
     background-color: $color_yellow_sea_approx;
     border-color: $color_yellow_sea_approx;
+
     &:hover {
         color: $white;
         background-color: $color_gamboge_approx;
         border-color: $color_gamboge_approx;
     }
+
     &:focus {
         color: $white;
         background-color: $color_gamboge_approx;
@@ -175,11 +191,13 @@ button:focus {
     color: $white;
     background-color: $color_trinidad_approx;
     border-color: $color_trinidad_approx;
+
     &:hover {
         color: $white;
         background-color: $color_grenadier_approx;
         border-color: $color_grenadier_approx;
     }
+
     &:focus {
         color: $white;
         background-color: $color_grenadier_approx;
@@ -196,17 +214,21 @@ button:focus {
     border-radius: 4px; //Instead of the line below you could use @include transition($transition-1, $transition-2, $transition-3, $transition-4, $transition-5, $transition-6, $transition-7, $transition-8, $transition-9, $transition-10)
     transition: all .3s ease;
     margin: 2px;
+
     &:hover {
         @include btn-action-effect('default');
         background-color: $transparent;
     }
+
     &:focus {
         @include btn-action-effect('default');
         background-color: $transparent;
     }
+
     &.btn-sm {
         padding: 2px 6px;
     }
+
     &.btn-md {
         padding: 6px 10px;
     }
@@ -222,17 +244,20 @@ button:focus {
 .btn-fixed-width {
     .btn-icon {
         min-width: 100px;
+
         &.propagte-classification {
             >span {
                 width: 98px;
             }
         }
+
         >span {
             @include ellipsis();
             float: left;
             width: 76px;
             padding: 2px 5px !important;
         }
+
         >i {
             float: right;
             line-height: 15px;
@@ -246,6 +271,7 @@ button:focus {
     border-radius: 4px;
     font-size: 14px;
     background-color: $transparent;
+
     &.active {
         @include btn-action-hover-effect('default');
     }
@@ -262,33 +288,41 @@ button:focus {
     &.btn-sm {
         padding: 2px 6px;
     }
+
     &.btn-md {
         padding: 5px 10px;
     }
 
     &.btn-blue {
         @include btn-action-effect('blue');
+
         &.active {
             @include btn-action-hover-effect('blue');
         }
+
         &:hover {
             @include btn-action-hover-effect('blue');
         }
+
         &:focus {
             @include btn-action-effect('blue');
         }
+
         &.btn-icon {
             @include btn-action-effect('blue');
             color: $tag_color !important;
+
             &:hover {
                 color: $color_havelock_blue_approx;
                 background-color: $transparent;
             }
+
             >span {
                 &:hover {
                     @include btn-action-hover-effect('blue');
                 }
             }
+
             i.fa {
                 &:hover {
                     @include btn-action-hover-effect('blue');
@@ -301,10 +335,12 @@ button:focus {
         border: 1px $action_gray solid;
         color: $action_gray;
         cursor: default;
+
         i.fa {
             position: relative;
             right: -5px;
         }
+
         &:hover {
             color: $white;
             background-color: $action_gray;
@@ -315,25 +351,31 @@ button:focus {
         padding: 0px;
         overflow: hidden;
         background-color: $transparent;
+
         &:hover {
             color: $color_keppel_approx;
             background-color: $transparent;
         }
+
         >span {
             padding: 5px;
+
             &:hover {
                 @include btn-action-hover-effect('default');
             }
         }
+
         i.fa {
             position: relative;
             padding: 5px;
             cursor: pointer;
+
             &:hover {
                 @include btn-action-hover-effect('default');
             }
         }
     }
+
     &.btn-icon-pd {
         i.fa {
             padding: 5px;
@@ -343,6 +385,7 @@ button:focus {
 }
 
 .btn-group {
+
     .btn-atlas,
     .btn-action {
         margin: 0px;
@@ -353,10 +396,12 @@ button:focus {
     >a {
         background-color: $color_curious_blue_approx;
         border-color: $color_curious_blue_approx;
+
         &:focus {
             background-color: $color_curious_blue_approx;
             border-color: $color_curious_blue_approx;
         }
+
         &:hover {
             background-color: $color_curious_blue_approx;
             border-color: $color_curious_blue_approx;
@@ -366,10 +411,12 @@ button:focus {
     >span {
         background-color: $color_curious_blue_approx;
         border-color: $color_curious_blue_approx;
+
         &:focus {
             background-color: $color_curious_blue_approx;
             border-color: $color_curious_blue_approx;
         }
+
         &:hover {
             background-color: $color_curious_blue_approx;
             border-color: $color_curious_blue_approx;
@@ -382,6 +429,7 @@ button:focus {
     color: $color_mountain_mist_approx;
     cursor: default;
     margin: 5px 10px;
+
     &:hover {
         border-color: $color_mountain_mist_approx;
         color: $color_mountain_mist_approx !important;
@@ -401,4 +449,43 @@ button:focus {
 
 .list-style-disc {
     list-style: disc;
+}
+
+.create-entity-form {
+
+    &.all {
+        .attribute-dash-box {
+            &.alloptional {
+                display: block;
+            }
+        }
+    }
+
+    .attribute-dash-box {
+        border-style: dashed;
+        border-width: 2px;
+        border-spacing: 8px;
+        border-radius: 12px;
+        border-color: #cbcbcb;
+        position: relative;
+        padding: 0px 10px;
+        margin-top: 25px;
+
+        span.required:after {
+            content: "*";
+            padding-left: 1%;
+            color: $red
+        }
+
+        &.alloptional {
+            display: none;
+        }
+
+        .attribute-type-label {
+            background: $white;
+            padding: 5px 10px;
+            position: absolute;
+            top: -16px;
+        }
+    }
 }
\ No newline at end of file
diff --git a/dashboardv2/public/css/scss/override.scss b/dashboardv2/public/css/scss/override.scss
index 5754aac..f388c0b 100644
--- a/dashboardv2/public/css/scss/override.scss
+++ b/dashboardv2/public/css/scss/override.scss
@@ -50,7 +50,7 @@
 .modal-body {
     position: relative;
     padding: 15px;
-    max-height: 72vh;
+    max-height: calc(100vh - 200px);
     min-height: 70px;
     overflow: auto;
 
diff --git a/dashboardv2/public/css/scss/theme.scss b/dashboardv2/public/css/scss/theme.scss
index d603c4a..25ca868 100644
--- a/dashboardv2/public/css/scss/theme.scss
+++ b/dashboardv2/public/css/scss/theme.scss
@@ -112,7 +112,9 @@ header {
     h1 {
         &.title {
             word-break: break-all;
-        } // margin-top: 50px;
+        }
+
+        // margin-top: 50px;
         margin-bottom: 10px;
         font-weight: 600;
         @include ellipsis();
@@ -286,15 +288,18 @@ hr[size="10"] {
         .panel-title {
             display: inline-block;
         }
+
         i.ec-icon:before {
             content: "\f078"
         }
+
         &.collapsed,
         &[aria-expanded="false"] {
             i.ec-icon:before {
                 content: "\f078"
             }
         }
+
         &[aria-expanded="true"] {
             i.ec-icon:before {
                 content: "\f077"
@@ -388,10 +393,6 @@ hr[size="10"] {
     box-shadow: none !important;
 }
 
-fieldset.fieldset-child-pd>div {
-    padding-left: 12px;
-}
-
 .inline-content {
     >.inline {
         display: inline-block;
diff --git a/dashboardv2/public/js/templates/entity/CreateEntityLayoutView_tmpl.html b/dashboardv2/public/js/templates/entity/CreateEntityLayoutView_tmpl.html
index 689fa29..65ca406 100644
--- a/dashboardv2/public/js/templates/entity/CreateEntityLayoutView_tmpl.html
+++ b/dashboardv2/public/js/templates/entity/CreateEntityLayoutView_tmpl.html
@@ -37,7 +37,7 @@
                 </div>
             </div>
         </div>
-        <div class="col-sm-12 entityInputData" data-id="entityInputData"></div>
+        <div class="col-sm-12 entityInputData create-entity-form" data-id="entityInputData"></div>
     </div>
 </form>
 <div class="fontLoader-relative entityLoader" style="display:none">
diff --git a/dashboardv2/public/js/utils/Helper.js b/dashboardv2/public/js/utils/Helper.js
index 3f211e9..8a7a521 100644
--- a/dashboardv2/public/js/utils/Helper.js
+++ b/dashboardv2/public/js/utils/Helper.js
@@ -32,6 +32,9 @@ define(['require',
                 return false;
             }
         },
+        toArrayifObject: function(val) {
+            return _.isObject(val) ? [val] : val;
+        },
         startsWith: function(str, matchStr) {
             if (str && matchStr && _.isString(str) && _.isString(matchStr)) {
                 return str.lastIndexOf(matchStr, 0) === 0
diff --git a/dashboardv2/public/js/utils/Utils.js b/dashboardv2/public/js/utils/Utils.js
index 058bdbf..afbad1f 100644
--- a/dashboardv2/public/js/utils/Utils.js
+++ b/dashboardv2/public/js/utils/Utils.js
@@ -592,27 +592,56 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
         return _.uniq(superTypes);
     }
     Utils.getNestedSuperTypeObj = function(options) {
-        var flag = 0,
-            data = options.data,
-            collection = options.collection;
-        if (options.attrMerge) {
-            var attributeDefs = [];
-        } else {
-            var attributeDefs = {};
+        var mainData = options.data,
+            collection = options.collection,
+            attrMerge = options.attrMerge,
+            mergeRelationAttributes = options.mergeRelationAttributes || false,
+            seperateRelatioshipAttr = options.seperateRelatioshipAttr || false;
+        if (mergeRelationAttributes && seperateRelatioshipAttr) {
+            throw "Both mergeRelationAttributes & seperateRelatioshipAttr cannot be true!"
+        }
+        var attributeDefs = {};
+        if (attrMerge && !seperateRelatioshipAttr) {
+            attributeDefs = [];
+        } else if (options.attrMerge && seperateRelatioshipAttr) {
+            attributeDefs = {
+                attributeDefs: [],
+                relationshipAttributeDefs: []
+            }
+        }
+        var getRelationshipAttributeDef = function(data) {
+            return _.filter(
+                data.relationshipAttributeDefs,
+                function(obj, key) {
+                    return obj;
+                })
         }
         var getData = function(data, collection) {
             if (options.attrMerge) {
-                attributeDefs = attributeDefs.concat(data.attributeDefs);
+                if (seperateRelatioshipAttr) {
+                    attributeDefs.attributeDefs = attributeDefs.attributeDefs.concat(data.attributeDefs);
+                    attributeDefs.relationshipAttributeDefs = attributeDefs.relationshipAttributeDefs.concat(getRelationshipAttributeDef(data));
+                } else {
+                    attributeDefs = attributeDefs.concat(data.attributeDefs);
+                    if (mergeRelationAttributes) {
+                        attributeDefs = attributeDefs.concat(getRelationshipAttributeDef(data));
+                    }
+                }
             } else {
                 if (attributeDefs[data.name]) {
-                    if (_.isArray(attributeDefs[data.name])) {
-                        attributeDefs[data.name] = attributeDefs[data.name].concat(data.attributeDefs);
+                    attributeDefs[data.name] = _.toArrayifObject(attributeDefs[data.name]).concat(data.attributeDefs);
+                } else {
+                    if (seperateRelatioshipAttr) {
+                        attributeDefs[data.name] = {
+                            attributeDefs: data.attributeDefs,
+                            relationshipAttributeDefs: data.relationshipAttributeDefs
+                        };
                     } else {
-                        _.extend(attributeDefs[data.name], data.attributeDefs);
+                        attributeDefs[data.name] = data.attributeDefs;
+                        if (mergeRelationAttributes) {
+                            attributeDefs[data.name] = _.toArrayifObject(attributeDefs[data.name]).concat(getRelationshipAttributeDef(data));
+                        }
                     }
-
-                } else {
-                    attributeDefs[data.name] = data.attributeDefs;
                 }
             }
             if (data.superTypes && data.superTypes.length) {
@@ -631,7 +660,27 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
                 });
             }
         }
-        getData(data, collection);
+        getData(mainData, collection);
+        if (attrMerge) {
+            if (seperateRelatioshipAttr) {
+                attributeDefs = {
+                    attributeDefs: _.uniq(_.sortBy(attributeDefs.attributeDefs, 'name'), true, function(obj) {
+                        return obj.name
+                    }),
+                    relationshipAttributeDefs: _.uniq(_.sortBy(attributeDefs.relationshipAttributeDefs, 'name'), true, function(obj) {
+                        return (obj.name + obj.relationshipTypeName)
+                    })
+                }
+            } else {
+                attributeDefs = _.uniq(_.sortBy(attributeDefs, 'name'), true, function(obj) {
+                    if (obj.relationshipTypeName) {
+                        (obj.name + obj.relationshipTypeName)
+                    } else {
+                        (obj.name)
+                    }
+                });
+            }
+        }
         return attributeDefs;
     }
 
diff --git a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
index 6df1af0..a7bef78 100644
--- a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
+++ b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
@@ -236,7 +236,7 @@ define(['require',
                     var str = '<option disabled="disabled" selected>--Select entity-type--</option>';
                     this.entityDefCollection.fullCollection.each(function(val) {
                         var name = Utils.getName(val.toJSON());
-                        if (Globals.entityTypeConfList) {
+                        if (Globals.entityTypeConfList && name.indexOf("__") !== 0) {
                             if (_.isEmptyArray(Globals.entityTypeConfList)) {
                                 str += '<option>' + name + '</option>';
                             } else {
@@ -256,11 +256,13 @@ define(['require',
             },
             requiredAllToggle: function(checked) {
                 if (checked) {
+                    this.ui.entityInputData.addClass('all').removeClass('required');
                     this.ui.entityInputData.find('div.true').show();
                     this.ui.entityInputData.find('fieldset div.true').show();
                     this.ui.entityInputData.find('fieldset').show();
                     this.required = false;
                 } else {
+                    this.ui.entityInputData.addClass('required').removeClass('all');
                     this.ui.entityInputData.find('fieldset').each(function() {
                         if (!$(this).find('div').hasClass('false')) {
                             $(this).hide();
@@ -296,26 +298,111 @@ define(['require',
                     silent: true
                 });
             },
+            renderAttribute: function(object) {
+                var that = this,
+                    visitedAttr = {},
+                    attributeObj = object.attributeDefs,
+                    isAllAttributeOptinal = true,
+                    isAllRelationshipAttributeOptinal = true,
+                    attributeDefList = attributeObj.attributeDefs,
+                    relationshipAttributeDefsList = attributeObj.relationshipAttributeDefs,
+                    attributeHtml = "",
+                    relationShipAttributeHtml = "",
+                    fieldElemetHtml = '',
+                    commonInput = function(object) {
+                        var value = object.value,
+                            containerHtml = '';
+                        containerHtml += that.getContainer(object);
+                        return containerHtml;
+                    };
+                if (attributeDefList.length || relationshipAttributeDefsList.length) {
+                    _.each(attributeDefList, function(value) {
+                        if (value.isOptional === false) {
+                            isAllAttributeOptinal = false;
+                        }
+                        attributeHtml += commonInput({
+                            "value": value,
+                            "duplicateValue": false,
+                            "isAttribute": true
+                        });
+                    });
+                    _.each(relationshipAttributeDefsList, function(value) {
+                        if (value.isOptional === false) {
+                            isAllRelationshipAttributeOptinal = false;
+                        }
+                        if (visitedAttr[value.name] === null) {
+                            // on second visited set it to true;and now onwords ignore if same value come.
+                            var duplicateRelationship = _.where(relationshipAttributeDefsList, { name: value.name });
+                            var str = '<option value="">--Select a Relationship Type--</option>';
+                            _.each(duplicateRelationship, function(val, index, list) {
+                                str += '<option>' + _.escape(val.relationshipTypeName) + '</option>';
+                            });
+                            var isOptional = value.isOptional;
+                            visitedAttr[value.name] = '<div class="form-group"><select class="form-control row-margin-bottom entityInputBox ' + (value.isOptional === true ? "false" : "true") + '" data-for-key= "' + value.name + '"> ' + str + '</select></div>';
+                        } else {
+                            relationShipAttributeHtml += commonInput({
+                                "value": value,
+                                "duplicateValue": true,
+                                "isRelation": true
+                            });
+                            // once visited set it to null;
+                            visitedAttr[value.name] = null;
+                        }
+                    });
+                    if (attributeHtml.length) {
+                        fieldElemetHtml += that.getFieldElementContainer({
+                            "htmlField": attributeHtml,
+                            "attributeType": true,
+                            "alloptional": isAllAttributeOptinal
+                        });
+                    }
+                    if (relationShipAttributeHtml.length) {
+                        fieldElemetHtml += that.getFieldElementContainer({
+                            "htmlField": relationShipAttributeHtml,
+                            "relationshipType": true,
+                            "alloptional": isAllRelationshipAttributeOptinal
+                        });
+                    }
+                    if (fieldElemetHtml.length) {
+                        that.ui.entityInputData.append(fieldElemetHtml);
+                        _.each(_.keys(visitedAttr), function(key) {
+                            if (visitedAttr[key] === null) {
+                                return;
+                            }
+                            var elFound = that.ui.entityInputData.find('[data-key="' + key + '"]');
+                            elFound.parent().prepend(visitedAttr[key]);
+                        });
+                    } else {
+                        fieldElemetHtml = "<h4 class='text-center'>Defination not found</h4>";
+                        that.ui.entityInputData.append(fieldElemetHtml);
+                    }
+
+                }
+                that.ui.entityInputData.find("select[data-for-key]").select2({})
+                return false;
+            },
             subAttributeData: function(data) {
                 var that = this,
                     attributeInput = "",
                     alloptional = false,
-                    attributeDefs = Utils.getNestedSuperTypeObj({ data: data, collection: this.entityDefCollection });
-                _.each(_.sortBy(_.keys(attributeDefs)), function(key) {
-                    if (attributeDefs[key].length) {
-                        attributeInput = "";
-                        _.each(_.sortBy(attributeDefs[key], 'name'), function(value) {
-                            if (value.isOptional == true) {
-                                alloptional = true;
-                            }
-                            attributeInput += that.getContainer(value);
-                        });
-                        if (attributeInput !== "") {
-                            entityTitle = that.getFieldSet(key, alloptional, attributeInput);
-                            that.ui.entityInputData.append(entityTitle);
+                    attributeDefs = Utils.getNestedSuperTypeObj({
+                        seperateRelatioshipAttr: true,
+                        attrMerge: true,
+                        data: data,
+                        collection: this.entityDefCollection
+                    });
+                if (attributeDefs && attributeDefs.relationshipAttributeDefs.length) {
+                    attributeDefs.attributeDefs = _.filter(attributeDefs.attributeDefs, function(obj) {
+                        if (_.find(attributeDefs.relationshipAttributeDefs, { name: obj.name }) === undefined) {
+                            return true;
                         }
-                    }
+                    })
+                }
+                //make a function call.
+                this.renderAttribute({
+                    attributeDefs: attributeDefs
                 });
+
                 if (this.required) {
                     this.ui.entityInputData.find('fieldset div.true').hide()
                     this.ui.entityInputData.find('div.true').hide();
@@ -395,19 +482,35 @@ define(['require',
                     }
                 });
             },
-            getContainer: function(value) {
-                var entityLabel = this.capitalize(value.name);
-                return '<div class="row form-group ' + value.isOptional + '"><span class="col-sm-3">' +
+            getContainer: function(object) {
+                var value = object.value,
+                    entityLabel = this.capitalize(value.name);
+
+                return '<div class=" row ' + value.isOptional + '"><span class="col-sm-3">' +
                     '<label><span class="' + (value.isOptional ? 'true' : 'false required') + '">' + entityLabel + '</span><span class="center-block ellipsis text-gray" title="Data Type : ' + value.typeName + '">' + '(' + Utils.escapeHtml(value.typeName) + ')' + '</span></label></span>' +
-                    '<span class="col-sm-9">' + (this.getElement(value)) +
+                    '<span class="col-sm-9">' + (this.getElement(object)) +
                     '</input></span></div>';
             },
-            getFieldSet: function(name, alloptional, attributeInput) {
-                return '<fieldset class="form-group fieldset-child-pd ' + (alloptional ? "alloptional" : "") + '"><legend class="legend-sm">' + name + '</legend>' + attributeInput + '</fieldset>';
+            getFieldElementContainer: function(object) {
+                var htmlField = object.htmlField,
+                    attributeType = object.attributeType ? object.attributeType : false,
+                    relationshipType = object.relationshipType ? object.relationshipType : false,
+                    alloptional = object.alloptional,
+                    typeOfDefination = (relationshipType ? "Relationships" : "Attributes");
+                return '<div class="attribute-dash-box ' + (alloptional ? "alloptional" : "") + ' "><span class="attribute-type-label">' + (typeOfDefination) + '</span>' + htmlField + '</div>';
             },
-            getSelect: function(value, entityValue) {
+            getSelect: function(object) {
+                var value = object.value,
+                    entityValue = object.entityValue,
+                    isAttribute = object.isAttribute,
+                    isRelation = object.isRelation;
                 if (value.typeName === "boolean") {
-                    return '<select class="form-control row-margin-bottom ' + (value.isOptional === true ? "false" : "true") + '" data-type="' + value.typeName + '" data-key="' + value.name + '" data-id="entityInput">' +
+                    return '<select class="form-control row-margin-bottom ' + (value.isOptional === true ? "false" : "true") +
+                        '" data-type="' + value.typeName +
+                        '" data-attribute="' + isAttribute +
+                        '" data-relation="' + isRelation +
+                        '" data-key="' + value.name +
+                        '" data-id="entityInput">' +
                         '<option value="">--Select true or false--</option><option value="true">true</option>' +
                         '<option value="false">false</option></select>';
                 } else {
@@ -417,13 +520,21 @@ define(['require',
                     } else {
                         splitTypeName = value.typeName;
                     }
-                    return '<select class="form-control row-margin-bottom entityInputBox ' + (value.isOptional === true ? "false" : "true") + '" data-type="' + value.typeName +
-                        '" data-key="' + value.name + '" data-id="entitySelectData" data-queryData="' + splitTypeName + '">' + (this.guid ? entityValue : "") + '</select>';
+                    return '<select class="form-control row-margin-bottom entityInputBox ' + (value.isOptional === true ? "false" : "true") +
+                        '" data-type="' + value.typeName +
+                        '" data-attribute="' + isAttribute +
+                        '" data-relation="' + isRelation +
+                        '" data-key="' + value.name +
+                        '" data-id="entitySelectData" data-queryData="' + splitTypeName + '">' + (this.guid ? entityValue : "") + '</select>';
                 }
 
             },
-            getTextArea: function(value, entityValue, structType) {
-                var setValue = entityValue
+            getTextArea: function(object) {
+                var value = object.value,
+                    setValue = object.entityValue,
+                    isAttribute = object.isAttribute,
+                    isRelation = object.isRelation,
+                    structType = object.structType;
                 try {
                     if (structType && entityValue && entityValue.length) {
                         var parseValue = JSON.parse(entityValue);
@@ -436,20 +547,31 @@ define(['require',
                 return '<textarea class="form-control entityInputBox ' + (value.isOptional === true ? "false" : "true") + '"' +
                     ' data-type="' + value.typeName + '"' +
                     ' data-key="' + value.name + '"' +
+                    ' data-attribute="' + isAttribute + '"' +
+                    ' data-relation="' + isRelation + '"' +
                     ' placeholder="' + value.name + '"' +
                     ' data-id="entityInput">' + setValue + '</textarea>';
 
             },
-            getInput: function(value, entityValue) {
+            getInput: function(object) {
+                var value = object.value,
+                    entityValue = object.entityValue,
+                    isAttribute = object.isAttribute,
+                    isRelation = object.isRelation;
                 return '<input class="form-control entityInputBox ' + (value.isOptional === true ? "false" : "true") + '"' +
                     ' data-type="' + value.typeName + '"' +
                     ' value="' + entityValue + '"' +
                     ' data-key="' + value.name + '"' +
+                    ' data-attribute="' + isAttribute + '"' +
+                    ' data-relation="' + isRelation + '"' +
                     ' placeholder="' + value.name + '"' +
                     ' data-id="entityInput">';
             },
-            getElement: function(value) {
-                var typeName = value.typeName,
+            getElement: function(object) {
+                var value = object.value,
+                    isAttribute = object.isAttribute,
+                    isRelation = object.isRelation,
+                    typeName = value.typeName,
                     entityValue = "";
                 if (this.guid) {
                     var dataValue = this.entityData.get("entity").attributes[value.name];
@@ -469,15 +591,38 @@ define(['require',
                     }
                 }
                 if ((typeName && this.entityDefCollection.fullCollection.find({ name: typeName })) || typeName === "boolean" || typeName.indexOf("array") > -1) {
-                    return this.getSelect(value, entityValue);
+                    return this.getSelect({
+                        "value": value,
+                        "entityValue": entityValue,
+                        "isAttribute": isAttribute,
+                        "isRelation": isRelation
+
+                    });
                 } else if (typeName.indexOf("map") > -1) {
-                    return this.getTextArea(value, entityValue);
+                    return this.getTextArea({
+                        "value": value,
+                        "entityValue": entityValue,
+                        "isAttribute": isAttribute,
+                        "isRelation": isRelation,
+                        "structType": false
+                    });
                 } else {
                     var typeNameCategory = this.typeHeaders.fullCollection.findWhere({ name: typeName });
                     if (typeNameCategory && typeNameCategory.get('category') === 'STRUCT') {
-                        return this.getTextArea(value, entityValue, true);
+                        return this.getTextArea({
+                            "value": value,
+                            "entityValue": entityValue,
+                            "isAttribute": isAttribute,
+                            "isRelation": isRelation,
+                            "structType": true
+                        });
                     } else {
-                        return this.getInput(value, entityValue);
+                        return this.getInput({
+                            "value": value,
+                            "entityValue": entityValue,
+                            "isAttribute": isAttribute,
+                            "isRelation": isRelation,
+                        });
                     }
                 }
             },
@@ -485,8 +630,9 @@ define(['require',
                 var that = this;
                 this.showLoader();
                 this.parentEntity = this.ui.entityList.val();
-                var entity = {};
-                var referredEntities = {};
+                var entityAttribute = {},
+                    referredEntities = {},
+                    relationshipAttribute = {};
                 var extractValue = function(value, typeName) {
                     if (!value) {
                         return value;
@@ -503,7 +649,8 @@ define(['require',
                 }
                 try {
                     this.ui.entityInputData.find("input,select,textarea").each(function() {
-                        var value = $(this).val();
+                        var value = $(this).val(),
+                            el = this;
                         if ($(this).val() && $(this).val().trim) {
                             value = $(this).val().trim();
                         }
@@ -534,19 +681,21 @@ define(['require',
                         var dataTypeEnitity = $(this).data('type'),
                             datakeyEntity = $(this).data('key'),
                             typeName = $(this).data('querydata'),
-                            typeNameCategory = that.typeHeaders.fullCollection.findWhere({ name: dataTypeEnitity });
-
+                            attribute = $(this).data('attribute') == 'undefined' ? false : true,
+                            relation = $(this).data('relation') == 'undefined' ? false : true,
+                            typeNameCategory = that.typeHeaders.fullCollection.findWhere({ name: dataTypeEnitity }),
+                            val = null;
                         // Extract Data
                         if (dataTypeEnitity && datakeyEntity) {
                             if (that.entityDefCollection.fullCollection.find({ name: dataTypeEnitity })) {
-                                entity[datakeyEntity] = extractValue(value, typeName);
+                                val = extractValue(value, typeName);
                             } else if (dataTypeEnitity === 'date' || dataTypeEnitity === 'time') {
-                                entity[datakeyEntity] = Date.parse(value);
+                                val = Date.parse(value);
                             } else if (dataTypeEnitity.indexOf("map") > -1 || (typeNameCategory && typeNameCategory.get('category') === 'STRUCT')) {
                                 try {
                                     if (value && value.length) {
                                         parseData = JSON.parse(value);
-                                        entity[datakeyEntity] = parseData;
+                                        val = parseData;
                                     }
                                 } catch (err) {
                                     $(this).addClass('errorClass');
@@ -554,24 +703,44 @@ define(['require',
                                     return;
                                 }
                             } else if (dataTypeEnitity.indexOf("array") > -1 && dataTypeEnitity.indexOf("string") === -1) {
-                                entity[datakeyEntity] = extractValue(value, typeName);
+                                val = extractValue(value, typeName);
                             } else {
                                 if (_.isString(value)) {
                                     if (value.length) {
-                                        entity[datakeyEntity] = value;
+                                        val = value;
                                     } else {
-                                        entity[datakeyEntity] = null;
+                                        val = null;
                                     }
                                 } else {
-                                    entity[datakeyEntity] = value;
+                                    val = value;
                                 }
                             }
+                            if (attribute) {
+                                entityAttribute[datakeyEntity] = val;
+                            } else if (relation) {
+                                relationshipAttribute[datakeyEntity] = val;
+                            }
+                        } else {
+                            var dataRelEntity = $(this).data('forKey');
+                            if (dataRelEntity && relationshipAttribute[dataRelEntity]) {
+                                if (_.isArray(relationshipAttribute[dataRelEntity])) {
+                                    _.each(relationshipAttribute[dataRelEntity], function(obj) {
+                                        if (obj) {
+                                            obj["relationshipType"] = $(el).val();
+                                        }
+                                    });
+                                } else {
+                                    relationshipAttribute[dataRelEntity]["relationshipType"] = $(this).val();
+                                }
+
+                            }
                         }
                     });
                     var entityJson = {
                         "entity": {
                             "typeName": (this.guid ? this.entityData.get("entity").typeName : this.parentEntity),
-                            "attributes": entity,
+                            "attributes": entityAttribute,
+                            "relationshipAttributes": relationshipAttribute,
                             "guid": (this.guid ? this.guid : -1)
                         },
                         "referredEntities": referredEntities
@@ -628,17 +797,16 @@ define(['require',
                         queryData = $(this).data("querydata"),
                         skip = $(this).data('skip'),
                         placeholderName = "Select a " + typeData + " from the dropdown list";
-
                     $this.attr("multiple", ($this.data('type').indexOf("array") === -1 ? false : true));
 
                     // Select Value.
                     if (that.guid) {
                         var dataValue = that.entityData.get("entity").attributes[keyData],
                             entities = that.entityData.get("entity").attributes,
+                            relationshipType = that.entityData.get("entity").relationshipAttributes[keyData],
                             referredEntities = that.entityData.get("referredEntities"),
                             selectedValue = [],
                             select2Options = [];
-
                         if (dataValue) {
                             if (_.isObject(dataValue) && !_.isArray(dataValue)) {
                                 dataValue = [dataValue];
@@ -653,6 +821,12 @@ define(['require',
                                     }
                                 }
                             });
+                            if (!_.isUndefined(relationshipType)) {
+                                if (relationshipType && relationshipType.relationshipAttributes && relationshipType.relationshipAttributes.typeName) {
+                                    that.$("select[data-for-key=" + keyData + "]").val(relationshipType.relationshipAttributes.typeName).trigger("change");
+                                }
+
+                            }
                         }
 
                         // Array of string.


[atlas] 01/04: ATLAS-3136: assigning a term to an invalid entity guid throws 500, instead of 400

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch branch-1.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 9227797eaa2f5f2ea4fef786347cb31078863483
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Sun Apr 14 16:05:39 2019 -0700

    ATLAS-3136: assigning a term to an invalid entity guid throws 500, instead of 400
    
    (cherry picked from commit a910609d43b252526cf15337f891fc04c6dc4154)
---
 .../store/graph/AtlasRelationshipStore.java        |  2 +-
 .../store/graph/v2/AtlasRelationshipStoreV2.java   | 31 +++++++++++++++-------
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java
index 53e29e1..b7463dd 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/AtlasRelationshipStore.java
@@ -59,7 +59,7 @@ public interface AtlasRelationshipStore {
 
     AtlasEdge getOrCreate(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException;
 
-    AtlasEdge getRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship);
+    AtlasEdge getRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException;
 
     AtlasEdge createRelationship(AtlasVertex end1Vertex, AtlasVertex end2Vertex, AtlasRelationship relationship) throws AtlasBaseException;
 
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
index 5721ca0..e0a4605 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/AtlasRelationshipStoreV2.java
@@ -296,7 +296,7 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
     }
 
     @Override
-    public AtlasEdge getRelationship(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) {
+    public AtlasEdge getRelationship(AtlasVertex fromVertex, AtlasVertex toVertex, AtlasRelationship relationship) throws AtlasBaseException {
         String relationshipLabel = getRelationshipEdgeLabel(fromVertex, toVertex, relationship.getTypeName());
 
         return getRelationshipEdge(fromVertex, toVertex, relationshipLabel);
@@ -802,18 +802,31 @@ public class AtlasRelationshipStoreV2 implements AtlasRelationshipStore {
         return ret;
     }
 
-    private String getRelationshipEdgeLabel(AtlasVertex fromVertex, AtlasVertex toVertex, String relationshipTypeName) {
+    private String getRelationshipEdgeLabel(AtlasVertex fromVertex, AtlasVertex toVertex, String relationshipTypeName) throws AtlasBaseException {
         if (LOG.isDebugEnabled()) {
             LOG.debug("getRelationshipEdgeLabel({})", relationshipTypeName);
         }
 
-        AtlasRelationshipType   relationshipType   = typeRegistry.getRelationshipTypeByName(relationshipTypeName);
-        String                  ret                = relationshipType.getRelationshipLabel();
-        AtlasRelationshipEndDef endDef1            = relationshipType.getRelationshipDef().getEndDef1();
-        AtlasRelationshipEndDef endDef2            = relationshipType.getRelationshipDef().getEndDef2();
-        Set<String>             fromVertexTypes    = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(fromVertex));
-        Set<String>             toVertexTypes      = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(toVertex));
-        AtlasAttribute          attribute          = null;
+        AtlasRelationshipType relationshipType = typeRegistry.getRelationshipTypeByName(relationshipTypeName);
+
+        if (relationshipType == null) {
+            throw new AtlasBaseException(AtlasErrorCode.INVALID_VALUE, "unknown relationship type'" + relationshipTypeName + "'");
+        }
+
+        if (fromVertex == null) {
+            throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd1Type().getTypeName());
+        }
+
+        if (toVertex == null) {
+            throw new AtlasBaseException(AtlasErrorCode.RELATIONSHIP_END_IS_NULL, relationshipType.getEnd2Type().getTypeName());
+        }
+
+        String                  ret             = relationshipType.getRelationshipLabel();
+        AtlasRelationshipEndDef endDef1         = relationshipType.getRelationshipDef().getEndDef1();
+        AtlasRelationshipEndDef endDef2         = relationshipType.getRelationshipDef().getEndDef2();
+        Set<String>             fromVertexTypes = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(fromVertex));
+        Set<String>             toVertexTypes   = getTypeAndAllSuperTypes(AtlasGraphUtilsV2.getTypeName(toVertex));
+        AtlasAttribute          attribute       = null;
 
         // validate entity type and all its supertypes contains relationshipDefs end type
         // e.g. [hive_process -> hive_table] -> [Process -> DataSet]


[atlas] 04/04: ATLAS-3137 : UI : Create entity add element validation and design improvement

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch branch-1.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 84af0cbb0cd927709415de0572a24d2be239dbc3
Author: kevalbhatt <kb...@apache.org>
AuthorDate: Mon Apr 15 23:10:15 2019 +0530

    ATLAS-3137 : UI : Create entity add element validation and design improvement
    
    Signed-off-by: Madhan Neethiraj <ma...@apache.org>
    (cherry picked from commit 011e854660a08a6eed014d4fc5b56f55d8ca6cdd)
---
 dashboardv2/public/css/scss/form.scss              |  6 ++-
 dashboardv2/public/css/scss/override.scss          | 12 +++++
 .../entity/CreateEntityLayoutView_tmpl.html        |  4 +-
 dashboardv2/public/js/utils/Utils.js               |  9 ++--
 .../js/views/entity/CreateEntityLayoutView.js      | 63 +++++++++++++++-------
 5 files changed, 69 insertions(+), 25 deletions(-)

diff --git a/dashboardv2/public/css/scss/form.scss b/dashboardv2/public/css/scss/form.scss
index 3e63e8b..388713e 100644
--- a/dashboardv2/public/css/scss/form.scss
+++ b/dashboardv2/public/css/scss/form.scss
@@ -54,9 +54,13 @@
 
     .form-control {
         //Instead of the line below you could use @include border-radius($radius, $vertical-radius)
-        background-color: $color_mystic_approx;
+        background-color: $color_white_lilac_approx;
         border: 1px $color_mystic_approx solid;
 
+        &[disabled] {
+            background-color: $color_gallery_approx;
+        }
+
         &:focus {
             border-color: $color_bali_hai_approx;
             outline: 0; //Instead of the line below you could use @include box-shadow($shadow-1, $shadow-2, $shadow-3, $shadow-4, $shadow-5, $shadow-6, $shadow-7, $shadow-8, $shadow-9, $shadow-10)
diff --git a/dashboardv2/public/css/scss/override.scss b/dashboardv2/public/css/scss/override.scss
index f388c0b..ea5b6a7 100644
--- a/dashboardv2/public/css/scss/override.scss
+++ b/dashboardv2/public/css/scss/override.scss
@@ -210,7 +210,19 @@ td {
 }
 
 .select2-container--default {
+    &.select2-container--disabled {
+        .select2-selection--multiple {
+            background-color: $color_gallery_approx !important;
+            cursor: not-allowed;
+
+            input.select2-search__field {
+                cursor: not-allowed;
+            }
+        }
+    }
+
     .select2-selection--multiple {
+
         background-color: $color_white_lilac_approx !important;
         border: 1px $color_mystic_approx solid !important;
 
diff --git a/dashboardv2/public/js/templates/entity/CreateEntityLayoutView_tmpl.html b/dashboardv2/public/js/templates/entity/CreateEntityLayoutView_tmpl.html
index 65ca406..5645d51 100644
--- a/dashboardv2/public/js/templates/entity/CreateEntityLayoutView_tmpl.html
+++ b/dashboardv2/public/js/templates/entity/CreateEntityLayoutView_tmpl.html
@@ -16,7 +16,7 @@
 -->
 <form name="entityDefinitionform">
     <div class="clearfix">
-        <div class="col-sm-12 form-group">
+        <div class="col-sm-12 form-group" data-id="entitySelectionBox">
             <div class="row">
                 {{#if guid}}
                 <div class="col-sm-8">
@@ -37,7 +37,7 @@
                 </div>
             </div>
         </div>
-        <div class="col-sm-12 entityInputData create-entity-form" data-id="entityInputData"></div>
+        <div class="col-sm-12 entityInputData create-entity-form form-group" data-id="entityInputData"></div>
     </div>
 </form>
 <div class="fontLoader-relative entityLoader" style="display:none">
diff --git a/dashboardv2/public/js/utils/Utils.js b/dashboardv2/public/js/utils/Utils.js
index afbad1f..32015e6 100644
--- a/dashboardv2/public/js/utils/Utils.js
+++ b/dashboardv2/public/js/utils/Utils.js
@@ -595,8 +595,9 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
         var mainData = options.data,
             collection = options.collection,
             attrMerge = options.attrMerge,
-            mergeRelationAttributes = options.mergeRelationAttributes || false,
-            seperateRelatioshipAttr = options.seperateRelatioshipAttr || false;
+            seperateRelatioshipAttr = options.seperateRelatioshipAttr || false,
+            mergeRelationAttributes = options.mergeRelationAttributes || (seperateRelatioshipAttr ? false : true);
+
         if (mergeRelationAttributes && seperateRelatioshipAttr) {
             throw "Both mergeRelationAttributes & seperateRelatioshipAttr cannot be true!"
         }
@@ -674,9 +675,9 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'utils/Enums',
             } else {
                 attributeDefs = _.uniq(_.sortBy(attributeDefs, 'name'), true, function(obj) {
                     if (obj.relationshipTypeName) {
-                        (obj.name + obj.relationshipTypeName)
+                        return (obj.name + obj.relationshipTypeName)
                     } else {
-                        (obj.name)
+                        return (obj.name)
                     }
                 });
             }
diff --git a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
index a7bef78..22ce48c 100644
--- a/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
+++ b/dashboardv2/public/js/views/entity/CreateEntityLayoutView.js
@@ -56,7 +56,9 @@ define(['require',
                 entityInputData: "[data-id='entityInputData']",
                 toggleRequired: 'input[name="toggleRequired"]',
                 assetName: "[data-id='assetName']",
-                entityInput: "[data-id='entityInput']"
+                entityInput: "[data-id='entityInput']",
+                entitySelectionBox: "[data-id='entitySelectionBox']",
+
             },
             /** ui events hash */
             events: function() {
@@ -149,22 +151,18 @@ define(['require',
                     if (this.value !== "") {
                         if ($(this).data('select2')) {
                             $(this).data('select2').$container.find('.select2-selection').removeClass("errorClass");
-                            if (that.ui.entityInputData.find('.errorClass').length === 0) {
-                                that.modal.$el.find('button.ok').prop("disabled", false);
-                            }
                         } else {
                             $(this).removeClass('errorClass');
-                            if (that.ui.entityInputData.find('.errorClass').length === 0) {
-                                that.modal.$el.find('button.ok').prop("disabled", false);
-                            }
+                        }
+                        if (that.ui.entityInputData.find('.errorClass').length === 0) {
+                            that.modal.$el.find('button.ok').prop("disabled", false);
                         }
                     } else {
+                        that.modal.$el.find('button.ok').prop("disabled", true);
                         if ($(this).data('select2')) {
                             $(this).data('select2').$container.find('.select2-selection').addClass("errorClass");
-                            that.modal.$el.find('button.ok').prop("disabled", true);
                         } else {
                             $(this).addClass('errorClass');
-                            that.modal.$el.find('button.ok').prop("disabled", true);
                         }
                     }
                 });
@@ -370,6 +368,7 @@ define(['require',
                                 return;
                             }
                             var elFound = that.ui.entityInputData.find('[data-key="' + key + '"]');
+                            elFound.prop('disabled', true);
                             elFound.parent().prepend(visitedAttr[key]);
                         });
                     } else {
@@ -378,7 +377,21 @@ define(['require',
                     }
 
                 }
-                that.ui.entityInputData.find("select[data-for-key]").select2({})
+                that.ui.entityInputData.find("select[data-for-key]").select2({}).on('change', function() {
+                    var forKey = $(this).data('forKey'),
+                        forKeyEl = null;
+                    if (forKey && forKey.length) {
+                        forKeyEl = that.ui.entityInputData.find('[data-key="' + forKey + '"]');
+                        if (forKeyEl) {
+                            if (this.value == "") {
+                                forKeyEl.val(null).trigger('change');
+                                forKeyEl.prop("disabled", true);
+                            } else {
+                                forKeyEl.prop("disabled", false);
+                            }
+                        }
+                    }
+                });
                 return false;
             },
             subAttributeData: function(data) {
@@ -628,7 +641,9 @@ define(['require',
             },
             okButton: function() {
                 var that = this;
-                this.showLoader();
+                this.showLoader({
+                    editVisiblityOfEntitySelectionBox: true
+                });
                 this.parentEntity = this.ui.entityList.val();
                 var entityAttribute = {},
                     referredEntities = {},
@@ -751,7 +766,7 @@ define(['require',
                         success: function(model, response) {
                             that.modal.close();
                             Utils.notifySuccess({
-                                content: "entity " + Messages[that.guid ? 'editSuccessMessage' : 'addSuccessMessage']
+                                content: "Entity " + Messages[that.guid ? 'editSuccessMessage' : 'addSuccessMessage']
                             });
                             if (that.guid && that.callback) {
                                 that.callback();
@@ -766,7 +781,9 @@ define(['require',
                             }
                         },
                         complete: function() {
-                            that.hideLoader();
+                            that.hideLoader({
+                                editVisiblityOfEntitySelectionBox: true
+                            });
                         }
                     });
 
@@ -774,16 +791,26 @@ define(['require',
                     Utils.notifyError({
                         content: e.message
                     });
-                    that.hideLoader();
+                    that.hideLoader({
+                        editVisiblityOfEntitySelectionBox: true
+                    });
                 }
             },
-            showLoader: function() {
-                this.$('.entityLoader').show();
+            showLoader: function(options) {
+                var editVisiblityOfEntitySelectionBox = options && options.editVisiblityOfEntitySelectionBox;
+                this.$('.entityLoader').addClass('show');
                 this.$('.entityInputData').hide();
+                if (this.guid || editVisiblityOfEntitySelectionBox) {
+                    this.ui.entitySelectionBox.hide();
+                }
             },
-            hideLoader: function() {
-                this.$('.entityLoader').hide();
+            hideLoader: function(options) {
+                var editVisiblityOfEntitySelectionBox = options && options.editVisiblityOfEntitySelectionBox
+                this.$('.entityLoader').removeClass('show');
                 this.$('.entityInputData').show();
+                if (this.guid || editVisiblityOfEntitySelectionBox) {
+                    this.ui.entitySelectionBox.show();
+                }
                 // To enable scroll after selecting value from select2.
                 this.ui.entityList.select2('open');
                 this.ui.entityList.select2('close');


[atlas] 02/04: ATLAS-3139: updated basic search to include relationship attributes as well in the result

Posted by ma...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

madhan pushed a commit to branch branch-1.0
in repository https://gitbox.apache.org/repos/asf/atlas.git

commit 2caf30ae21556bd0ae3ea0b791344f50defe460d
Author: Madhan Neethiraj <ma...@apache.org>
AuthorDate: Sun Apr 14 23:42:08 2019 -0700

    ATLAS-3139: updated basic search to include relationship attributes as well in the result
    
    (cherry picked from commit 9c9eed274532391ceb57a0e17d0b2f8611530f8a)
---
 intg/src/main/java/org/apache/atlas/type/AtlasStructType.java     | 6 +++---
 .../java/org/apache/atlas/discovery/EntityDiscoveryService.java   | 8 ++++++++
 .../atlas/repository/store/graph/v2/EntityGraphRetriever.java     | 8 +++++++-
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
index 31953bd..254eee4 100644
--- a/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
+++ b/intg/src/main/java/org/apache/atlas/type/AtlasStructType.java
@@ -744,19 +744,19 @@ public class AtlasStructType extends AtlasType {
             this.inverseRefAttributeName   = inverseRefAttribute;
             this.relationshipEdgeDirection = AtlasRelationshipEdgeDirection.OUT;
 
-            switch (attributeType.getTypeCategory()) {
+            switch (this.attributeType.getTypeCategory()) {
                 case OBJECT_ID_TYPE:
                     isObjectRef = true;
                 break;
 
                 case MAP:
-                    AtlasMapType mapType = (AtlasMapType) attributeType;
+                    AtlasMapType mapType = (AtlasMapType) this.attributeType;
 
                     isObjectRef = mapType.getValueType().getTypeCategory() == OBJECT_ID_TYPE;
                 break;
 
                 case ARRAY:
-                    AtlasArrayType arrayType = (AtlasArrayType) attributeType;
+                    AtlasArrayType arrayType = (AtlasArrayType) this.attributeType;
 
                     isObjectRef = arrayType.getElementType().getTypeCategory() == OBJECT_ID_TYPE;
                 break;
diff --git a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
index 19f81d3..420e359 100644
--- a/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
+++ b/repository/src/main/java/org/apache/atlas/discovery/EntityDiscoveryService.java
@@ -451,6 +451,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
                 for (String resultAttribute : resultAttributes) {
                     AtlasAttribute  attribute  = entityType.getAttribute(resultAttribute);
 
+                    if (attribute == null) {
+                        attribute = entityType.getRelationshipAttribute(resultAttribute, null);
+                    }
+
                     if (attribute != null) {
                         AtlasType attributeType = attribute.getAttributeType();
 
@@ -536,6 +540,10 @@ public class EntityDiscoveryService implements AtlasDiscoveryService {
 
         AtlasAttribute attribute = entityType.getAttribute(relation);
 
+        if (attribute == null) {
+            attribute = entityType.getRelationshipAttribute(relation, null);
+        }
+
         if (attribute != null) {
             if (attribute.isObjectRef()) {
                 relation = attribute.getRelationshipEdgeLabel();
diff --git a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
index efcddef..3f3e95a 100644
--- a/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
+++ b/repository/src/main/java/org/apache/atlas/repository/store/graph/v2/EntityGraphRetriever.java
@@ -521,7 +521,13 @@ public class EntityGraphRetriever {
                         continue;
                     }
 
-                    Object attrValue = getVertexAttribute(entityVertex, entityType.getAttribute(nonQualifiedAttrName));
+                    AtlasAttribute attribute = entityType.getAttribute(nonQualifiedAttrName);
+
+                    if (attribute == null) {
+                        attribute = entityType.getRelationshipAttribute(nonQualifiedAttrName, null);
+                    }
+
+                    Object attrValue = getVertexAttribute(entityVertex, attribute);
 
                     if (attrValue != null) {
                         ret.setAttribute(nonQualifiedAttrName, attrValue);