summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--catalog-be/src/main/java/org/openecomp/sdc/be/servlets/TypesFetchServlet.java21
-rw-r--r--catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java19
-rw-r--r--catalog-ui/src/app/ng2/services/catalog.service.ts2
-rw-r--r--catalog-ui/src/app/services/data-types-service.ts4
4 files changed, 23 insertions, 23 deletions
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 fe08b5cd74..fd8b61887a 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
@@ -37,6 +37,7 @@ import java.util.stream.Collectors;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Consumes;
+import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.Path;
@@ -47,7 +48,6 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.commons.collections4.ListUtils;
import org.openecomp.sdc.be.components.impl.ArtifactTypeBusinessLogic;
-import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic;
import org.openecomp.sdc.be.components.impl.CapabilitiesBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentBusinessLogic;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
@@ -73,6 +73,7 @@ import org.openecomp.sdc.be.model.Model;
import org.openecomp.sdc.be.model.RelationshipTypeDefinition;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.operations.impl.ModelOperation;
+import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
import org.openecomp.sdc.common.api.Constants;
import org.openecomp.sdc.common.datastructure.Wrapper;
import org.openecomp.sdc.common.log.enums.EcompLoggerErrorCode;
@@ -165,24 +166,29 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
@ApiResponse(responseCode = "404", description = "Data types not found")})
@PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
public Response getAllDataTypesFromAllModels(@Context final HttpServletRequest request,
- @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
+ @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
+ @QueryParam("excludePrimitives") @DefaultValue("false") String excludePrimitives) {
Wrapper<Response> responseWrapper = new Wrapper<>();
Wrapper<User> userWrapper = new Wrapper<>();
init();
validateUserExist(responseWrapper, userWrapper, userId);
if (responseWrapper.isEmpty()) {
+ final boolean exclude = Boolean.parseBoolean(excludePrimitives);
String url = request.getMethod() + " " + request.getRequestURI();
log.debug("Start handle request of {} - modifier id is {}", url, userId);
resourceBusinessLogic.getApplicationDataTypeCache().refreshDataTypesCacheIfStale();
final List<Map<String, DataTypeDefinition>> dataTypesList = new ArrayList<>();
List<Model> models = modelOperation.findAllModels();
- Model defaultModel = new Model();
- defaultModel.setName(null);
- models.add(defaultModel);
+ models.add(new Model(null));
models.forEach(model -> {
final Map<String, DataTypeDefinition> dataTypes = resourceBusinessLogic.getComponentsUtils()
.getAllDataTypes(resourceBusinessLogic.getApplicationDataTypeCache(), model.getName());
- dataTypesList.add(dataTypes);
+ if (exclude) {
+ dataTypesList.add(dataTypes.entrySet().stream().filter(entry -> !ToscaPropertyType.isScalarType(entry.getKey()))
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)));
+ } else {
+ dataTypesList.add(dataTypes);
+ }
});
String dataTypeJson = gson.toJson(dataTypesList);
Response okResponse = buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), dataTypeJson);
@@ -382,7 +388,8 @@ public class TypesFetchServlet extends AbstractValidationsServlet {
public Response getAllToscaArtifactTypes(@Parameter(description = "Model name") @QueryParam("model") String model,
@Context final HttpServletRequest request, @HeaderParam(Constants.USER_ID_HEADER) String creator) {
try {
- return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK), artifactTypeBusinessLogic.getAllToscaArtifactTypes(model));
+ return buildOkResponse(getComponentsUtils().getResponseFormat(ActionStatus.OK),
+ artifactTypeBusinessLogic.getAllToscaArtifactTypes(model));
} catch (final BusinessException e) {
throw e;
} catch (final Exception e) {
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
index d68a7706b6..9dc28cb2b4 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
@@ -1086,10 +1086,7 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
}
private boolean checkFirstItem(String left, String right) {
- if (left != null && left.equals(right)) {
- return true;
- }
- return false;
+ return left != null && left.equals(right);
}
private String buildStringForMatch(List<String> pathOfInstances, int level) {
@@ -1565,10 +1562,10 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
if (dataTypeUidstoModels != null) {
log.trace("Number of data types to load is {}", dataTypeUidstoModels.size());
- for (Map.Entry<String, List<String>> entry : dataTypeUidstoModels.entrySet()) {
- log.trace("Going to fetch data type with uid {}", entry.getKey());
- Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeByUid = this
- .getAndAddDataTypeByUid(entry.getKey(), allDataTypesFound);
+ for (final Map.Entry<String, List<String>> entry : dataTypeUidstoModels.entrySet()) {
+ final String key = entry.getKey();
+ log.trace("Going to fetch data type with uid {}", key);
+ final Either<DataTypeDefinition, JanusGraphOperationStatus> dataTypeByUid = this.getAndAddDataTypeByUid(key, allDataTypesFound);
if (dataTypeByUid.isRight()) {
JanusGraphOperationStatus status = dataTypeByUid.right().value();
if (status == JanusGraphOperationStatus.NOT_FOUND) {
@@ -1578,13 +1575,12 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
}
for (final String model : entry.getValue()) {
if (!dataTypes.containsKey(model)) {
- dataTypes.put(model, new HashMap<String, DataTypeDefinition>());
+ dataTypes.put(model, new HashMap<>());
}
DataTypeDefinition dataTypeDefinition = allDataTypesFound.get(entry.getKey());
dataTypes.get(model).put(dataTypeDefinition.getName(), dataTypeDefinition);
}
}
-
}
if (log.isTraceEnabled()) {
if (result.isRight()) {
@@ -1766,9 +1762,6 @@ public class PropertyOperation extends AbstractOperation implements IPropertyOpe
return getDerivedResult == StorageOperationStatus.NOT_FOUND;
}
- /*
- * @Override public PropertyOperation getPropertyOperation() { return this; }
- */
public JanusGraphOperationStatus fillPropertiesList(String uniqueId, NodeTypeEnum nodeType, Consumer<List<PropertyDefinition>> propertySetter) {
Either<Map<String, PropertyDefinition>, JanusGraphOperationStatus> findPropertiesRes = findPropertiesifExist(uniqueId, nodeType);
if (findPropertiesRes.isRight()) {
diff --git a/catalog-ui/src/app/ng2/services/catalog.service.ts b/catalog-ui/src/app/ng2/services/catalog.service.ts
index fcb9dd4006..02ba33088f 100644
--- a/catalog-ui/src/app/ng2/services/catalog.service.ts
+++ b/catalog-ui/src/app/ng2/services/catalog.service.ts
@@ -51,7 +51,7 @@ export class CatalogService {
let searchParams = new HttpParams();
searchParams = searchParams.append('excludeTypes', ResourceType.VFCMT).append('excludeTypes', ResourceType.CONFIGURATION);
const observableComponents = this.http.get<IComponentsArray>(this.baseMicroServiceUrl + this.api.GET_uicache_catalog, {params: searchParams});
- const observableDataTypes = this.dataTypesService.getDataTypesFromAllModel();
+ const observableDataTypes = this.dataTypesService.getDataTypesFromAllModelExcludePrimitives();
return zip(observableComponents, observableDataTypes)
.pipe(map(res => this.processComponentsResponse(res, true)));
}
diff --git a/catalog-ui/src/app/services/data-types-service.ts b/catalog-ui/src/app/services/data-types-service.ts
index b27f4222c4..f3d02a20c0 100644
--- a/catalog-ui/src/app/services/data-types-service.ts
+++ b/catalog-ui/src/app/services/data-types-service.ts
@@ -98,9 +98,9 @@ export class DataTypesService implements IDataTypesService {
return this.dataTypes;
}
- public getDataTypesFromAllModel = (): Observable<Array<DataTypeModel>> => {
+ public getDataTypesFromAllModelExcludePrimitives = (): Observable<Array<DataTypeModel>> => {
return new Observable<Array<DataTypeModel>>(subscriber => {
- this.$http.get<List<DataTypesMap>>(this.baseUrl + "allDataTypes")
+ this.$http.get<List<DataTypesMap>>(this.baseUrl + "allDataTypes?excludePrimitives=true")
.then(promiseValue => {
const allDataTypes = this.getDataTypesItems(promiseValue.data);
subscriber.next(allDataTypes);