aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/DataTypeImportManager.java6
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java1
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/cache/ApplicationDataTypeCache.java18
-rw-r--r--catalog-ui/src/app/services/components/component-service.ts4
-rw-r--r--catalog-ui/src/app/services/components/resource-service.ts5
-rw-r--r--catalog-ui/src/app/services/components/service-service.ts5
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<String> getDependencyTypes(final DataTypeDefinition dataType) {
+ private Collection<String> getDependencyTypes(final DataTypeDefinition dataType, final List<DataTypeDefinition> dataTypes) {
final Set<String> 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<String, DataTypeDefinition> 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<DataTypeDefini
@Override
public void run() {
try {
- final long startTime = System.currentTimeMillis();
- log.trace("Starting refresh data types cache job");
- if (hasDataTypesChanged()) {
- log.info("Detected changes in the data types, updating the data type cache.");
- refreshDataTypesCache();
- }
- log.trace("Finished refresh data types cache job. Finished in {}ms", (System.currentTimeMillis() - startTime));
+ refreshDataTypesCacheIfStale();
} catch (final Exception e) {
var errorMsg = "Failed to run refresh data types cache job";
log.error(EcompLoggerErrorCode.UNKNOWN_ERROR, ApplicationDataTypeCache.class.getName(), errorMsg, e);
@@ -291,6 +285,16 @@ public class ApplicationDataTypeCache implements ApplicationCache<DataTypeDefini
readWriteLock.readLock().unlock();
}
}
+
+ public void refreshDataTypesCacheIfStale() {
+ final long startTime = System.currentTimeMillis();
+ log.trace("Starting refresh data types cache");
+ if (hasDataTypesChanged()) {
+ log.info("Detected changes in the data types, updating the data type cache.");
+ refreshDataTypesCache();
+ }
+ log.trace("Finished refresh data types cache. Finished in {}ms", (System.currentTimeMillis() - startTime));
+ }
private void refreshDataTypesCache() {
final Map<String, Map<String, DataTypeDefinition>> 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<PropertyModel>):ng.IPromise<Array<PropertyModel>>
@@ -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<Array<Distribution>>;
@@ -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");
}