From cc764ab040ec1c278d8619d2d92be638d8f585e8 Mon Sep 17 00:00:00 2001 From: MichaelMorris Date: Sat, 13 Aug 2022 09:06:08 +0100 Subject: Fix new data types not found in UI Also, fixed issue with data type sorting when there are mutliple layers in dependency hierarchy Signed-off-by: MichaelMorris Issue-ID: SDC-4129 Change-Id: I4d535420953237efd610a3fb1dd6b9d40883e514 --- .../sdc/be/components/impl/DataTypeImportManager.java | 6 ++++-- .../openecomp/sdc/be/servlets/TypesFetchServlet.java | 1 + .../sdc/be/model/cache/ApplicationDataTypeCache.java | 18 +++++++++++------- .../src/app/services/components/component-service.ts | 4 ++++ .../src/app/services/components/resource-service.ts | 5 ++++- .../src/app/services/components/service-service.ts | 5 ++++- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java index 60fdc0b3d5..943edb1b95 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java @@ -113,7 +113,7 @@ public class DataTypeImportManager { dataTypes.forEach(dataType -> { int highestDependencyIndex = -1; - for (final String dependencyName : getDependencyTypes(dataType)) { + for (final String dependencyName : getDependencyTypes(dataType, dataTypes)) { final DataTypeDefinition dependency = dataTypeDefinitionsMap.get(dependencyName); final int indexOfDependency = sortedDataTypeDefinitions.lastIndexOf(dependency); highestDependencyIndex = indexOfDependency > highestDependencyIndex ? indexOfDependency : highestDependencyIndex; @@ -126,7 +126,7 @@ public class DataTypeImportManager { return sortedDataTypeDefinitions; } - private Collection getDependencyTypes(final DataTypeDefinition dataType) { + private Collection getDependencyTypes(final DataTypeDefinition dataType, final List dataTypes) { final Set dependencies = new HashSet<>(); if (dataType.getDerivedFromName() != null) { dependencies.add(dataType.getDerivedFromName()); @@ -134,6 +134,8 @@ public class DataTypeImportManager { if (dataType.getProperties() != null) { dataType.getProperties().stream().forEach(property -> dependencies.add(property.getType())); } + dataTypes.stream().filter(dependencyCandidate -> dependencies.contains(dependencyCandidate.getName())) + .forEach(dependencyDataType -> dependencies.addAll(getDependencyTypes(dependencyDataType, dataTypes))); return dependencies; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java index 7a229c88aa..f461378637 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java @@ -132,6 +132,7 @@ public class TypesFetchServlet extends AbstractValidationsServlet { if (responseWrapper.isEmpty()) { String url = request.getMethod() + " " + request.getRequestURI(); log.debug("Start handle request of {} - modifier id is {}", url, userId); + resourceBusinessLogic.getApplicationDataTypeCache().refreshDataTypesCacheIfStale(); final Map dataTypes = resourceBusinessLogic.getComponentsUtils() .getAllDataTypes(resourceBusinessLogic.getApplicationDataTypeCache(), modelName); String dataTypeJson = gson.toJson(dataTypes); diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java index 954df91552..0b4d02a0ab 100644 --- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java +++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java @@ -206,13 +206,7 @@ public class ApplicationDataTypeCache implements ApplicationCache> dataTypesDefinitionMap = findAllDataTypesEager(); diff --git a/catalog-ui/src/app/services/components/component-service.ts b/catalog-ui/src/app/services/components/component-service.ts index 47eec26a77..35a49b209e 100644 --- a/catalog-ui/src/app/services/components/component-service.ts +++ b/catalog-ui/src/app/services/components/component-service.ts @@ -41,6 +41,7 @@ import { import {ComponentInstanceFactory, CommonUtils} from "app/utils"; import {SharingService} from "app/services-ng2"; import {ComponentMetadata} from "../../models/component-metadata"; +import { DataTypesService } from "app/services"; export interface IComponentService { @@ -99,6 +100,7 @@ export class ComponentService implements IComponentService { 'Restangular', 'sdcConfig', 'Sdc.Services.SharingService', + 'Sdc.Services.DataTypesService', '$q', '$base64' ]; @@ -106,6 +108,7 @@ export class ComponentService implements IComponentService { constructor(protected restangular:restangular.IElement, protected sdcConfig:IAppConfigurtaion, protected sharingService:SharingService, + protected dataTypeService:DataTypesService, protected $q:ng.IQService, protected $base64:any ) { @@ -233,6 +236,7 @@ export class ComponentService implements IComponentService { let headerObj = this.getHeaderMd5(component); this.restangular.customPOST(JSON.stringify(component), 'importService', {}, headerObj).then((response: Component) => { let component: Component = this.createComponentObject(response); + this.dataTypeService.loadDataTypesCache(component.model); deferred.resolve(component); }, (err) => { deferred.reject(err); diff --git a/catalog-ui/src/app/services/components/resource-service.ts b/catalog-ui/src/app/services/components/resource-service.ts index 9481736152..a1e95de199 100644 --- a/catalog-ui/src/app/services/components/resource-service.ts +++ b/catalog-ui/src/app/services/components/resource-service.ts @@ -26,6 +26,7 @@ import * as _ from "lodash"; import {IComponentService, ComponentService} from "./component-service"; import {PropertyModel, IAppConfigurtaion, Resource, Component} from "../../models"; import {SharingService} from "app/services-ng2"; +import { DataTypesService } from "app/services"; export interface IResourceService extends IComponentService { updateResourceGroupProperties(uniqueId:string, groupId:string, properties:Array):ng.IPromise> @@ -37,6 +38,7 @@ export class ResourceService extends ComponentService implements IResourceServic 'Restangular', 'sdcConfig', 'Sdc.Services.SharingService', + 'Sdc.Services.DataTypesService', '$q', '$base64' ]; @@ -44,10 +46,11 @@ export class ResourceService extends ComponentService implements IResourceServic constructor(protected restangular:restangular.IElement, protected sdcConfig:IAppConfigurtaion, protected sharingService:SharingService, + protected dataTypeService:DataTypesService, protected $q:ng.IQService, protected $base64:any ) { - super(restangular, sdcConfig, sharingService, $q, $base64); + super(restangular, sdcConfig, sharingService, dataTypeService, $q, $base64); this.restangular = restangular.one("resources"); } diff --git a/catalog-ui/src/app/services/components/service-service.ts b/catalog-ui/src/app/services/components/service-service.ts index 25811b2fdf..fdcdfb8f43 100644 --- a/catalog-ui/src/app/services/components/service-service.ts +++ b/catalog-ui/src/app/services/components/service-service.ts @@ -26,6 +26,7 @@ import * as _ from "lodash"; import {IComponentService, ComponentService} from "./component-service"; import {Distribution, DistributionComponent, Service, PropertyModel, Component, IAppConfigurtaion} from "app/models"; import {SharingService} from "app/services-ng2"; +import { DataTypesService } from "app/services"; export interface IServiceService extends IComponentService { getDistributionsList(uuid:string):ng.IPromise>; @@ -40,6 +41,7 @@ export class ServiceService extends ComponentService implements IServiceService 'Restangular', 'sdcConfig', 'Sdc.Services.SharingService', + 'Sdc.Services.DataTypesService', '$q', '$base64' ]; @@ -49,9 +51,10 @@ export class ServiceService extends ComponentService implements IServiceService constructor(protected restangular:restangular.IElement, protected sdcConfig:IAppConfigurtaion, protected sharingService:SharingService, + protected dataTypeService:DataTypesService, protected $q:ng.IQService, protected $base64:any) { - super(restangular, sdcConfig, sharingService, $q, $base64); + super(restangular, sdcConfig, sharingService, dataTypeService, $q, $base64); this.restangular = restangular.one("services"); } -- cgit 1.2.3-korg