Refactor hardcoded column config 21/84521/6
authorPiotr Darosz <piotr.darosz@nokia.com>
Mon, 8 Apr 2019 12:35:40 +0000 (14:35 +0200)
committerOfir Sonsino <ofir.sonsino@intl.att.com>
Tue, 30 Apr 2019 10:16:04 +0000 (10:16 +0000)
Move hardcoded GAB columns configuration to configuration.yaml file

Change-Id: Ie70a1d44c9a04a37c3ba0d3b5f64ad2989b11166
Issue-ID: SDC-2225
Signed-off-by: Piotr Darosz <piotr.darosz@nokia.com>
asdctool/sdc-cassandra-init/chef-repo/cookbooks/cassandra-actions/templates/default/configuration.yaml.erb
catalog-be/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/templates/default/BE-configuration.yaml.erb
catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
catalog-be/src/main/resources/config/configuration.yaml
catalog-ui/src/app/models/gab-config.ts [new file with mode: 0644]
catalog-ui/src/app/models/paths-and-names.ts
catalog-ui/src/app/view-models/workspace/tabs/deployment-artifacts/deployment-artifacts-view-model.ts
catalog-ui/src/assets/languages/en_US.json
common-app-api/src/main/java/org/openecomp/sdc/be/config/Configuration.java

index aabdacc..0a658bb 100644 (file)
@@ -712,6 +712,22 @@ environmentContext:
        - Useful_Non-Revenue
        - General_Non-Revenue
 
+gabConfig:
+  - artifactType: 'VES_EVENTS'
+    pathsAndNamesDefinitions:
+      -
+        friendlyName: "Action"
+        path: "event.action[2]"
+        searchable: "true"
+      -
+        friendlyName: "Comment"
+        path: "event.comment"
+        searchable: "true"
+      -
+        friendlyName: "Alarm Additional Information"
+        path: "event.structure.faultFields.structure.alarmAdditionalInformation.comment"
+        searchable: "true"
+
 dmaapConsumerConfiguration:
     hosts: localhost:3905
     consumerGroup: sdc
index df8b898..37e3d93 100644 (file)
@@ -738,6 +738,22 @@ environmentContext:
        - Useful_Non-Revenue
        - General_Non-Revenue
 
+gabConfig:
+  - artifactType: 'VES_EVENTS'
+    pathsAndNamesDefinitions:
+      -
+        friendlyName: "Action"
+        path: "event.action[2]"
+        searchable: "true"
+      -
+        friendlyName: "Comment"
+        path: "event.comment"
+        searchable: "true"
+      -
+        friendlyName: "Alarm Additional Information"
+        path: "event.structure.faultFields.structure.alarmAdditionalInformation.comment"
+        searchable: "true"
+
 dmaapConsumerConfiguration:
     active: <%= @dmaap_active %>
     hosts: localhost:3905
index eda9a61..081c9ca 100644 (file)
@@ -455,6 +455,8 @@ public class ElementServlet extends BeGenericServlet {
                 configuration.put("roles", elementBL.getAllSupportedRoles());
                 configuration.put("resourceTypes", resourceTypesMap.left().value());
                 configuration.put("environmentContext", ConfigurationManager.getConfigurationManager().getConfiguration().getEnvironmentContext());
+                configuration.put("gab", ConfigurationManager.getConfigurationManager().getConfiguration().getGabConfig());
+
                 return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), configuration);
             }
 
index 1d9a51e..d23f87e 100644 (file)
@@ -737,6 +737,22 @@ environmentContext:
        - Useful_Non-Revenue
        - General_Non-Revenue
 
+gabConfig:
+  - artifactType: 'VES_EVENTS'
+    pathsandnames:
+      -
+        friendlyName: "Action"
+        path: "event.action[2]"
+        searchable: "true"
+      -
+        friendlyName: "Comment"
+        path: "event.comment"
+        searchable: "true"
+      -
+        friendlyName: "Alarm Additional Information"
+        path: "event.structure.faultFields.structure.alarmAdditionalInformation.comment"
+        searchable: "true"
+
 dmaapConsumerConfiguration:
     active: true
     hosts: olsd004.wnsnet.ws.com:3905
diff --git a/catalog-ui/src/app/models/gab-config.ts b/catalog-ui/src/app/models/gab-config.ts
new file mode 100644 (file)
index 0000000..8554718
--- /dev/null
@@ -0,0 +1,7 @@
+import {PathsAndNamesDefinition} from "./paths-and-names";
+
+export class GabConfig {
+  constructor(public artifactType: string, public pathsAndNamesDefinitions: PathsAndNamesDefinition[]) {
+
+  }
+}
\ No newline at end of file
index afab4d0..4313637 100644 (file)
@@ -19,5 +19,5 @@
  */
 
 export class PathsAndNamesDefinition {
-  constructor(public path: string, public friendlyName: string) {}
+  constructor(public path: string, public friendlyName: string, public searchable: boolean) {}
 }
\ No newline at end of file
index 73273e0..5e78301 100644 (file)
@@ -31,6 +31,8 @@ import {GenericArtifactBrowserComponent} from "../../../../ng2/components/logic/
 import {PathsAndNamesDefinition} from "../../../../models/paths-and-names";
 import {ModalService as ModalServiceSdcUI} from "sdc-ui/lib/angular/modals/modal.service";
 import {IModalConfig} from "sdc-ui/lib/angular/modals/models/modal-config";
+import {CacheService} from "../../../../services/cache-service";
+import {GabConfig} from "../../../../models/gab-config";
 
 interface IDeploymentArtifactsViewModelScope extends IWorkspaceViewModelScope {
     tableHeadersList:Array<any>;
@@ -66,6 +68,7 @@ export class DeploymentArtifactsViewModel {
         '$scope',
         '$templateCache',
         '$filter',
+        'Sdc.Services.CacheService',
         'ValidationUtils',
         'ArtifactsUtils',
         'ModalsHandler',
@@ -76,6 +79,7 @@ export class DeploymentArtifactsViewModel {
     constructor(private $scope:IDeploymentArtifactsViewModelScope,
                 private $templateCache:ng.ITemplateCacheService,
                 private $filter:ng.IFilterService,
+                private cacheService:CacheService,
                 private validationUtils:ValidationUtils,
                 private artifactsUtils:ArtifactsUtils,
                 private ModalsHandler:ModalsHandler,
@@ -278,9 +282,11 @@ export class DeploymentArtifactsViewModel {
         };
 
         this.$scope.openGenericArtifactBrowserModal = (artifact:ArtifactModel):void => {
+            let self = this;
+            const title = 'Generic Artifact Browser';
             let modalConfig: IModalConfig = {
                 size: 'xl',
-                title: 'Generic Artifact Browser',
+                title: title,
                 type: 'custom',
                 buttons: [{
                         id: 'okButton',
@@ -291,13 +297,28 @@ export class DeploymentArtifactsViewModel {
                     {text: "Cancel", size: "'x-small'", closeModal: true}]
             };
 
-            let pathsandnames: PathsAndNamesDefinition[] = [
-                {friendlyName: 'Action', path: 'event.action[2]'},
-                {friendlyName: 'Comment', path: 'event.comment'},
-                {friendlyName: 'Alarm Additional Information',
-                    path: 'event.structure.faultFields.structure.alarmAdditionalInformation.comment'}];
+            const uiConfiguration: any = this.cacheService.get('UIConfiguration');
+            let noConfig: boolean = false;
+            let pathsandnames: PathsAndNamesDefinition[] = [];
+
+            if(typeof uiConfiguration.gab === 'undefined') {
+                noConfig = true
+            } else {
+                const gabConfig: GabConfig = uiConfiguration.gab
+                    .find(config => config.artifactType === artifact.artifactType);
+                if(typeof gabConfig === 'undefined') {
+                    noConfig = true;
+                } else {
+                    pathsandnames = gabConfig.pathsAndNamesDefinitions;
+                }
+            }
+
+            if(noConfig) {
+                const msg = self.$filter('translate')("DEPLOYMENT_ARTIFACT_GAB_NO_CONFIG");
+                this.ModalServiceSdcUI.openAlertModal(title, msg);
+            }
 
-            let modalInputs = {
+            const modalInputs = {
                 pathsandnames: pathsandnames,
                 artifactid: artifact.esId,
                 resourceid: this.$scope.component.uniqueId
index b430217..72f320d 100644 (file)
     "DEPLOYMENT_ARTIFACT_BUTTON_ADD_BASE_HEAT": "Add Base HEAT Artifact",
     "DEPLOYMENT_ARTIFACT_BUTTON_ADD_NETWORK_HEAT": "Add Network HEAT Artifact",
     "DEPLOYMENT_ARTIFACT_BUTTON_ADD_VOLUME_HEAT": "Add Volume HEAT Artifact",
-    "DEPLOYMENT_ARTIFACT_BUTTON_ADD_OTHER": "Add Other Artifact"
+    "DEPLOYMENT_ARTIFACT_BUTTON_ADD_OTHER": "Add Other Artifact",
+    "DEPLOYMENT_ARTIFACT_GAB_NO_CONFIG": "Generic Artifact Browser has no columns configured"
 
 ,"=========== IMPORT VF ===========": "",
     "IMPORT_VF_MESSAGE_CREATE_TAKES_LONG_TIME_TITLE": "Create VF",
index 6325f00..a9c4ed3 100644 (file)
@@ -234,6 +234,8 @@ public class Configuration extends BasicConfiguration {
 
     private EnvironmentContext environmentContext;
 
+    private List<GabConfig> gabConfig;
+
     public Map<String, String> getGenericAssetNodeTypes() {
         return genericAssetNodeTypes;
     }
@@ -617,6 +619,14 @@ public class Configuration extends BasicConfiguration {
         this.environmentContext = environmentContext;
     }
 
+    public List<GabConfig> getGabConfig() {
+        return gabConfig;
+    }
+
+    public void setGabConfig(List<GabConfig> gabConfig) {
+        this.gabConfig = gabConfig;
+    }
+
     public static class ElasticSearchConfig {
 
         List<IndicesTimeFrequencyEntry> indicesTimeFrequency;
@@ -1585,4 +1595,55 @@ public class Configuration extends BasicConfiguration {
         this.healthStatusExclude = healthStatusExclude;
     }
 
+
+    public static class PathsAndNamesDefinition {
+        private String friendlyName;
+        private String path;
+        private String searchable;
+
+        public String getFriendlyName() {
+            return friendlyName;
+        }
+
+        public String getPath() {
+            return path;
+        }
+
+        public String getSearchable() {
+            return searchable;
+        }
+
+        public void setFriendlyName(String friendlyName) {
+            this.friendlyName = friendlyName;
+        }
+
+        public void setPath(String path) {
+            this.path = path;
+        }
+
+        public void setSearchable(String searchable) {
+            this.searchable = searchable;
+        }
+    }
+
+    public static class GabConfig {
+        private String artifactType;
+        private List<PathsAndNamesDefinition> pathsAndNamesDefinitions;
+
+        public String getArtifactType() {
+            return artifactType;
+        }
+
+        public List<PathsAndNamesDefinition> getPathsAndNamesDefinitions() {
+            return pathsAndNamesDefinitions;
+        }
+
+        public void setArtifactType(String artifactType) {
+            this.artifactType = artifactType;
+        }
+
+        public void setPathsAndNamesDefinitions(List<PathsAndNamesDefinition> pathsAndNamesDefinitions) {
+            this.pathsAndNamesDefinitions = pathsAndNamesDefinitions;
+        }
+    }
 }