@javax.annotation.Resource
private ComponentsUtils componentsUtils;
- public Either<Map<String, List<CategoryDefinition>>, ResponseFormat> createCategories(String categoriesTypesYml) {
+ public Either<Map<String, List<CategoryDefinition>>, ResponseFormat> createCategories(final String categoriesTypesYml) {
Map<String, List<CategoryDefinition>> allCategories = createCategoriesFromYml(categoriesTypesYml);
return createCategoriesByDao(allCategories);
}
nodeTypeCategory, nodeTypeSubCategory, nodeTypeGroup);
List<CategoryDefinition> newCategoriesvalue = new ArrayList<>();
for (CategoryDefinition category : entry.getValue()) {
- Either<CategoryDefinition, ResponseFormat> createdCategoryRes = createCategorieDeo(entry, category, nodeTypeCategory);
+ Either<CategoryDefinition, ResponseFormat> createdCategoryRes = createCategoriesDao(entry, category, nodeTypeCategory);
if (createdCategoryRes.isRight()) {
return Either.right(createdCategoryRes.right().value());
}
NodeTypeEnum nodeTypeGroup, CategoryDefinition category, CategoryDefinition newcategory,
List<SubCategoryDefinition> newsubcategories, List<SubCategoryDefinition> subcategories) {
for (SubCategoryDefinition subcategory : subcategories) {
- Either<SubCategoryDefinition, ResponseFormat> createdSubCategory = createSubCategorieDeo(entry, newcategory, subcategory,
+ Either<SubCategoryDefinition, ResponseFormat> createdSubCategory = createSubCategoriesDao(entry, newcategory, subcategory,
nodeTypeSubCategory);
if (createdSubCategory.isRight()) {
return false;
if (groupings != null) {
List<GroupingDefinition> newgroupings = new ArrayList<>();
for (GroupingDefinition grouping : groupings) {
- Either<GroupingDefinition, ResponseFormat> createdGrouping = createGroupingDeo(entry, grouping, subcategory, category,
+ Either<GroupingDefinition, ResponseFormat> createdGrouping = createGroupingDao(entry, grouping, subcategory, category,
nodeTypeGroup);
if (createdGrouping.isRight()) {
return false;
return true;
}
- private Either<GroupingDefinition, ResponseFormat> createGroupingDeo(Map.Entry<String, List<CategoryDefinition>> entry,
+ private Either<GroupingDefinition, ResponseFormat> createGroupingDao(Map.Entry<String, List<CategoryDefinition>> entry,
GroupingDefinition grouping, SubCategoryDefinition subcategory,
CategoryDefinition category, NodeTypeEnum nodeTypeGroup) {
log.debug("createGroupingDeo: creating grouping {}", grouping);
return Either.left(createdGrouping.left().value());
}
- private Either<SubCategoryDefinition, ResponseFormat> createSubCategorieDeo(Map.Entry<String, List<CategoryDefinition>> entry,
- CategoryDefinition newcategory, SubCategoryDefinition subcategory,
- NodeTypeEnum nodeTypeSubCategory) {
+ private Either<SubCategoryDefinition, ResponseFormat> createSubCategoriesDao(Map.Entry<String, List<CategoryDefinition>> entry,
+ CategoryDefinition newcategory, SubCategoryDefinition subcategory,
+ NodeTypeEnum nodeTypeSubCategory) {
log.debug("createSubCategorieDeo: creating subcategory {}", subcategory);
Either<SubCategoryDefinition, ActionStatus> createdSubCategory = elementOperation
.createSubCategory(newcategory.getUniqueId(), subcategory, nodeTypeSubCategory);
return Either.left(createdSubCategory.left().value());
}
- private Either<CategoryDefinition, ResponseFormat> createCategorieDeo(Map.Entry<String, List<CategoryDefinition>> entry,
- CategoryDefinition category, NodeTypeEnum nodeTypeCategory) {
+ private Either<CategoryDefinition, ResponseFormat> createCategoriesDao(Map.Entry<String, List<CategoryDefinition>> entry,
+ CategoryDefinition category, NodeTypeEnum nodeTypeCategory) {
log.debug("createCategorieDeo: creating category {}", category);
Either<CategoryDefinition, ActionStatus> createdCategory = elementOperation.createCategory(category, nodeTypeCategory);
if (createdCategory.isRight() && ActionStatus.COMPONENT_CATEGORY_ALREADY_EXISTS == createdCategory.right().value()) {
return Either.left(createdCategory.left().value());
}
- private Map<String, List<CategoryDefinition>> createCategoriesFromYml(String categoriesTypesYml) {
- Map<String, Object> toscaJson = (Map<String, Object>) new Yaml().load(categoriesTypesYml);
+ private Map<String, List<CategoryDefinition>> createCategoriesFromYml(final String categoriesTypesYml) {
+ Map<String, Object> toscaJson = new Yaml().load(categoriesTypesYml);
Map<String, List<CategoryDefinition>> allCategories = new HashMap<>();
Iterator<Entry<String, Object>> categoryEntryItr = toscaJson.entrySet().iterator();
while (categoryEntryItr.hasNext()) {
return allCategories;
}
- private List<CategoryDefinition> createServiceCategories(Map<String, Object> categories) {
+ private List<CategoryDefinition> createServiceCategories(final Map<String, Object> categories) {
List<CategoryDefinition> categoriesDef = new ArrayList<>();
String catName = null;
List<String> icons = null;
catDef.setIcons(icons);
String normalizedName = ValidationUtils.normalizeCategoryName4Uniqueness(catName);
catDef.setNormalizedName(normalizedName);
+ catDef.setModels((List<String>) category.get("models"));
final Object useServiceSubstitutionForNestedServicesProperty = category.get("useServiceSubstitutionForNestedServices");
final boolean useServiceSubstitutionForNestedServices =
useServiceSubstitutionForNestedServicesProperty == null ? false : (Boolean) useServiceSubstitutionForNestedServicesProperty;
return metadataKeyDefs;
}
- private List<CategoryDefinition> createResourceCategories(Map<String, Object> categoryPerType) {
+ private List<CategoryDefinition> createResourceCategories(final Map<String, Object> categoryPerType) {
List<CategoryDefinition> categroiesDef = new ArrayList<>();
for (Map.Entry<String, Object> entry : categoryPerType.entrySet()) {
Map<String, Object> category = (Map<String, Object>) entry.getValue();
Mobility:
name: "Mobility"
icons: ['mobility']
+ models: [
+ "SDC AID"
+ ]
Network_L1_3:
name: "Network L1-3"
icons: ['network_l_1-3']
+ models: [
+ "SDC AID"
+ ]
Network_L4:
name: "Network L4+"
icons: ['network_l_4']
+ models: [
+ "SDC AID"
+ ]
VoIP_Call_Control:
name: "VoIP Call Control"
icons: ['call_controll']
+ models: [
+ "SDC AID"
+ ]
E2E_Service:
name: "E2E Service"
icons: ['network_l_1-3']
+ models: [
+ "SDC AID"
+ ]
Network_Service:
name: "Network Service"
icons: ['network_l_1-3']
+ models: [
+ "SDC AID"
+ ]
Partner_Domain_Service:
name: "Partner Domain Service"
icons: ['partner_domain_service']
+ models: [
+ "SDC AID"
+ ]
ETSI_NFV_Network_Service:
name: "ETSI NFV Network Service"
icons: ['etsi_nfv_network_service']
validValues: [ '3.3.1', '2.7.1', '2.5.1' ]
default: '2.5.1'
mandatory: true
+ models: [
+ "ETSI SOL001 v2.5.1",
+ "SDC AID"
+ ]
resources:
NetworkLayer23:
name: "Network L2-3"
- subcategories:
+ subcategories:
Router:
name: "Router"
icons: ['router','vRouter']
icons: ['ucpe']
NetworkLayer4:
name: "Network L4+"
- subcategories:
+ subcategories:
Common_Network_Resources:
name: "Common Network Resources"
icons: ['network']
ApplicationLayer4:
name: "Application L4+"
- subcategories:
+ subcategories:
Border_Element:
name: "Border Element"
icons: ['borderElement']
icons: ['firewall']
Generic:
name: "Generic"
- subcategories:
+ subcategories:
Infrastructure:
name: "Infrastructure"
icons: ['connector']
icons: ['allotted_resource']
TunnelXConnect:
name: "TunnelXConn"
- icons: ['tunnel_x_connect']
+ icons: ['tunnel_x_connect']
BRG:
name: "BRG"
- icons: ['brg']
+ icons: ['brg']
IpMuxDemux:
name: "IP Mux Demux"
- icons: ['ip_mux_demux']
+ icons: ['ip_mux_demux']
ServiceAdmin:
name: "Service Admin"
- icons: ['service_admin']
+ icons: ['service_admin']
ContrailRoute:
name: "Contrail Route"
icons: ['contrail_route']
package org.openecomp.sdc.be.components.impl;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openecomp.sdc.be.model.operations.api.IElementOperation;
import org.openecomp.sdc.exception.ResponseFormat;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import java.util.stream.Stream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.when;
-
public class CategoriesImportManagerTest {
@InjectMocks
static CategoriesImportManager importManager = new CategoriesImportManager();
package org.openecomp.sdc.be.components.path;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import com.google.common.collect.Lists;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
import org.junit.Before;
import org.openecomp.sdc.be.components.BeConfDependentTest;
import org.openecomp.sdc.be.components.impl.ComponentInstanceBusinessLogic;
import org.openecomp.sdc.be.components.validation.service.ServiceValidator;
import org.openecomp.sdc.be.dao.api.ActionStatus;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphClient;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.ForwardingPathElementDataDefinition;
import org.openecomp.sdc.exception.ResponseFormat;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
public abstract class BaseForwardingPathTest extends BeConfDependentTest implements ForwardingPathTestUtils {
}.getType();
List<String> iconsfromJson = getGson().fromJson((String) properties.get(GraphPropertiesDictionary.ICONS.getProperty()), listType);
categoryDataDefinition.setIcons(iconsfromJson);
+ categoryDataDefinition.setModels(getGson().fromJson((String) properties.get(GraphPropertiesDictionary.MODEL.getProperty()), listType));
final Type metadataKeylistType = new TypeToken<List<MetadataKeyDataDefinition>>() {
}.getType();
final List<MetadataKeyDataDefinition> metadataKeysfromJson = getGson()
addIfExists(map, GraphPropertiesDictionary.UNIQUE_ID, categoryDataDefinition.getUniqueId());
addIfExists(map, GraphPropertiesDictionary.NAME, categoryDataDefinition.getName());
addIfExists(map, GraphPropertiesDictionary.NORMALIZED_NAME, categoryDataDefinition.getNormalizedName());
- // String icons=getGson().toJson(categoryDataDefinition.getIcons());
-
- // addIfExists(map, GraphPropertiesDictionary.ICONS, icons);
+ addIfExists(map, GraphPropertiesDictionary.MODEL, categoryDataDefinition.getModels());
addIfExists(map, GraphPropertiesDictionary.ICONS, categoryDataDefinition.getIcons());
addIfExists(map, GraphPropertiesDictionary.USE_SERVICE_SUBSTITUTION_FOR_NESTED_SERVICES,
categoryDataDefinition.isUseServiceSubstitutionForNestedServices());
private StorageOperationStatus associateServiceMetadataToCategory(GraphVertex nodeTypeVertex, TopologyTemplate topologyTemplate) {
String categoryName = topologyTemplate.getCategories().get(0).getName();
- Either<GraphVertex, StorageOperationStatus> category = categoryOperation.getCategory(categoryName, VertexTypeEnum.SERVICE_CATEGORY);
+ Either<GraphVertex, StorageOperationStatus> category = categoryOperation.getCategory(categoryName,
+ VertexTypeEnum.SERVICE_CATEGORY);
if (category.isRight()) {
log.trace("NO category {} for service {}", categoryName, topologyTemplate.getUniqueId());
return StorageOperationStatus.CATEGORY_NOT_FOUND;
}.getType();
List<String> iconsfromJsonCat = getGson().fromJson((String) metadataProperties.get(GraphPropertyEnum.ICONS.getProperty()), listTypeCat);
category.setIcons(iconsfromJsonCat);
+ category.setModels((getGson().fromJson((String) metadataProperties.get(GraphPropertyEnum.MODEL.getProperty()), listTypeCat)));
final Type metadataKeysTypeCat = new TypeToken<List<MetadataKeyDataDefinition>>() {
}.getType();
final List<MetadataKeyDataDefinition> metadataKeysfromJsonCat = getGson()
CategoryDefinition category = new CategoryDefinition();
category.setUniqueId((String) categoryV.property(GraphPropertyEnum.UNIQUE_ID.getProperty()).value());
category.setNormalizedName(categoryNormalizedName);
+ category.setModels(categoryV.property(GraphPropertyEnum.MODEL.getProperty()).isPresent() ? getGson()
+ .fromJson((String) categoryV.property(GraphPropertyEnum.MODEL.getProperty()).value(), new TypeToken<List<String>>() {
+ }.getType()) : Collections.emptyList());
category.setName((String) categoryV.property(GraphPropertyEnum.NAME.getProperty()).value());
category.setUseServiceSubstitutionForNestedServices(
(Boolean) categoryV.property(GraphPropertyEnum.USE_SUBSTITUTION_FOR_NESTED_SERVICES.getProperty()).orElse(false));
package org.openecomp.sdc.be.model.operations.impl;
-import org.janusgraph.core.JanusGraph;
-import org.janusgraph.core.JanusGraphVertex;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import fj.data.Either;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
-import org.junit.*;
+import org.janusgraph.core.JanusGraph;
+import org.janusgraph.core.JanusGraphVertex;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
+import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.janusgraph.JanusGraphOperationStatus;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.janusgraph.JanusGraphDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.util.*;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:application-context-test.xml")
public class ToscaElementLifecycleOperationTest extends ModelTestBase {
metadataProperties.put(GraphPropertyEnum.NAME, categoryName);
metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
metadataProperties.put(GraphPropertyEnum.METADATA_KEYS, "[]");
+ metadataProperties.put(GraphPropertyEnum.MODEL, "[]");
cat.setMetadataProperties(metadataProperties);
cat.updateMetadataJsonWithCurrentMetadataProperties();
metadataProperties.put(GraphPropertyEnum.NAME, categoryName);
metadataProperties.put(GraphPropertyEnum.NORMALIZED_NAME, ValidationUtils.normalizeCategoryName4Uniqueness(categoryName));
metadataProperties.put(GraphPropertyEnum.METADATA_KEYS, "[]");
+ metadataProperties.put(GraphPropertyEnum.MODEL, "[]");
cat.setMetadataProperties(metadataProperties);
cat.updateMetadataJsonWithCurrentMetadataProperties();
categoryData.getCategoryDataDefinition()
.setNormalizedName(ValidationUtils.normalizeCategoryName4Uniqueness(category));
categoryData.getCategoryDataDefinition().setUniqueId(UniqueIdBuilder.buildCategoryUid(
- ValidationUtils.normalizeCategoryName4Uniqueness(category), NodeTypeEnum.ServiceNewCategory));
+ ValidationUtils.normalizeCategoryName4Uniqueness(category), NodeTypeEnum.ServiceNewCategory));
janusGraphDao.deleteNode(categoryData, CategoryData.class);
Either<CategoryData, JanusGraphOperationStatus> createNode = janusGraphDao.createNode(categoryData, CategoryData.class);
return (String) createNode.left().value().getUniqueId();
name:string;
normalizedName:string;
uniqueId:string;
+ models:Array<string>;
icons:Array<string>;
metadataKeys: IMetadataKey[];
import {CacheService, ElementService, ModelService, ImportVSPService, OnboardingService} from "app/services-ng2";
import {Component, IAppConfigurtaion, ICsarComponent, IMainCategory, IMetadataKey, ISubCategory, IValidate, Resource, Service} from "app/models";
import {IWorkspaceViewModelScope} from "app/view-models/workspace/workspace-view-model";
-import {CATEGORY_SERVICE_METADATA_KEYS, PREVIOUS_CSAR_COMPONENT} from "../../../../utils/constants";
+import {CATEGORY_SERVICE_METADATA_KEYS, PREVIOUS_CSAR_COMPONENT, DEFAULT_MODEL_NAME} from "../../../../utils/constants";
import {Observable} from "rxjs";
import {Model} from "../../../../models/model";
convertCategoryStringToOneArray(category:string, subcategory:string):Array<IMainCategory>;
onCategoryChange():void;
onEcompGeneratedNamingChange():void;
+ onModelChange():void;
onBaseTypeChange():void;
openOnBoardingModal():void;
- initCategoreis():void;
+ initCategories():void;
initEnvironmentContext():void;
initInstantiationTypes():void;
initBaseTypes():void;
this.$scope.component.tags = _.without(this.$scope.component.tags, this.$scope.component.name);
// Init categories
- this.$scope.initCategoreis();
+ this.$scope.initCategories();
// Init Environment Context
this.$scope.initEnvironmentContext();
if (this.$scope.component.isResource() &&
(this.$scope.component as Resource).resourceType === ResourceType.VF ||
- (this.$scope.component as Resource).resourceType === ResourceType.PNF && (this.$scope.component as Resource).csarUUID) {
+ (this.$scope.component as Resource).resourceType === ResourceType.PNF && (this.$scope.component as Resource).csarUUID) {
this.$scope.isShowOnboardingSelectionBrowse = true;
this.setImportedFileText();
} else {
});
return tempCategories;
- };
-
+ };
+
private initScopeMethods = ():void => {
- this.$scope.initCategoreis = ():void => {
+ this.$scope.initCategories = ():void => {
if (this.$scope.componentType === ComponentType.RESOURCE) {
this.$scope.categories = this.cacheService.get('resourceCategories');
//Flag to disbale category if service is created through External API
this.$scope.isHiddenCategorySelected = this.isHiddenCategory(this.$scope.component.selectedCategory);
}
-
+
}
};
this.$scope.initBaseTypes = ():void => {
if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component && this.$scope.component.categories) {
- let modelName = this.$scope.component.model ? this.$scope.component.model : null;
- this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
- this.$scope.baseTypes = []
- this.$scope.baseTypeVersions = []
- data.forEach(baseType => {
- this.$scope.baseTypes.push(baseType.toscaResourceName)
- if (baseType.toscaResourceName === this.$scope.component.derivedFromGenericType){
- baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
- }});
- })
+ let modelName = this.$scope.component.model ? this.$scope.component.model : null;
+ this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
+ this.$scope.baseTypes = []
+ this.$scope.baseTypeVersions = []
+ data.forEach(baseType => {
+ this.$scope.baseTypes.push(baseType.toscaResourceName)
+ if (baseType.toscaResourceName === this.$scope.component.derivedFromGenericType){
+ baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
+ }});
+ })
}
};
this.$scope.initModel = ():void => {
this.$scope.isModelRequired = false;
this.$scope.models = [];
- this.$scope.defaultModelOption = 'SDC AID';
+ this.$scope.defaultModelOption = DEFAULT_MODEL_NAME;
this.$scope.showDefaultModelOption = true;
+ if (this.$scope.componentType === ComponentType.SERVICE) {
+ this.filterCategoriesByModel(this.$scope.component.model);
+ }
if (this.$scope.isCreateMode() && this.$scope.isVspImport()) {
if (this.$scope.component.componentMetadata.models) {
this.$scope.isModelRequired = true;
this.importVSPService.openOnboardingModal(csarUUID, csarVersion).subscribe((result) => {
this.ComponentFactory.getComponentWithMetadataFromServer(result.type.toUpperCase(), result.previousComponent.uniqueId).then(
(component:Component)=> {
- if (result.componentCsar && component.isResource()){
- this.cacheService.set(PREVIOUS_CSAR_COMPONENT, angular.copy(component));
- component = this.ComponentFactory.updateComponentFromCsar(result.componentCsar, <Resource>component);
- }
- this.$scope.setComponent(component);
- this.$scope.save();
- this.setImportedFileText();
- }, ()=> {
- // ERROR
- });
+ if (result.componentCsar && component.isResource()){
+ this.cacheService.set(PREVIOUS_CSAR_COMPONENT, angular.copy(component));
+ component = this.ComponentFactory.updateComponentFromCsar(result.componentCsar, <Resource>component);
+ }
+ this.$scope.setComponent(component);
+ this.$scope.save();
+ this.setImportedFileText();
+ }, ()=> {
+ // ERROR
+ });
})
};
return;
}
-
+
let subtype:string = ComponentType.RESOURCE == this.$scope.componentType ? this.$scope.component.getComponentSubType() : undefined;
if (subtype == "SRVC") {
subtype = "VF"
this.$scope.onCategoryChange = (): void => {
this.$scope.component.selectedCategory = this.$scope.componentCategories.selectedCategory;
- this.$scope.component.categories = this.convertCategoryStringToOneArray();
- this.$scope.component.icon = DEFAULT_ICON;
- if (this.$scope.component.categories[0].metadataKeys) {
- for (let metadataKey of this.$scope.component.categories[0].metadataKeys) {
- if (!this.$scope.component.categorySpecificMetadata[metadataKey.name]) {
- this.$scope.component.categorySpecificMetadata[metadataKey.name] = metadataKey.defaultValue ? metadataKey.defaultValue : "";
- }
+ if (this.$scope.component.selectedCategory) {
+ this.$scope.component.categories = this.convertCategoryStringToOneArray();
+ this.$scope.component.icon = DEFAULT_ICON;
+ if (this.$scope.component.categories[0].metadataKeys) {
+ for (let metadataKey of this.$scope.component.categories[0].metadataKeys) {
+ if (!this.$scope.component.categorySpecificMetadata[metadataKey.name]) {
+ this.$scope.component.categorySpecificMetadata[metadataKey.name] = metadataKey.defaultValue ? metadataKey.defaultValue : "";
+ }
+ }
}
- }
- if (this.$scope.component.categories[0].subcategories && this.$scope.component.categories[0].subcategories[0].metadataKeys) {
- for (let metadataKey of this.$scope.component.categories[0].subcategories[0].metadataKeys) {
- if (!this.$scope.component.categorySpecificMetadata[metadataKey.name]) {
- this.$scope.component.categorySpecificMetadata[metadataKey.name] = metadataKey.defaultValue ? metadataKey.defaultValue : "";
- }
+ if (this.$scope.component.categories[0].subcategories && this.$scope.component.categories[0].subcategories[0].metadataKeys) {
+ for (let metadataKey of this.$scope.component.categories[0].subcategories[0].metadataKeys) {
+ if (!this.$scope.component.categorySpecificMetadata[metadataKey.name]) {
+ this.$scope.component.categorySpecificMetadata[metadataKey.name] = metadataKey.defaultValue ? metadataKey.defaultValue : "";
+ }
+ }
+ }
+ if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component.categories[0]) {
+ let modelName : string = this.$scope.component.model ? this.$scope.component.model : null;
+ this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
+
+ if(this.$scope.isCreateMode()){
+ this.loadBaseTypes(data);
+ } else {
+ var isValidForBaseType:boolean = false;
+ data.forEach(baseType => {if (!this.$scope.component.derivedFromGenericType || baseType.toscaResourceName === this.$scope.component.derivedFromGenericType){
+ isValidForBaseType = true;
+ };});
+ this.$scope.editForm['category'].$setValidity('validForBaseType', isValidForBaseType);
+ }
+ });
}
+ } else {
+ this.$scope.baseTypes = [];
}
- if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component.categories[0]) {
- let modelName : string = this.$scope.component.model ? this.$scope.component.model : null;
- this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
-
- if(this.$scope.isCreateMode()){
- this.$scope.baseTypes = []
- this.$scope.baseTypeVersions = []
- data.forEach(baseType => this.$scope.baseTypes.push(baseType.toscaResourceName));
- data[0].versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
- this.$scope.component.derivedFromGenericType = data[0].toscaResourceName;
- this.$scope.component.derivedFromGenericVersion = data[0].versions[0];
- } else {
- var isValidForBaseType:boolean = false;
- data.forEach(baseType => {if (!this.$scope.component.derivedFromGenericType || baseType.toscaResourceName === this.$scope.component.derivedFromGenericType){
- isValidForBaseType = true;
- };});
- this.$scope.editForm['category'].$setValidity('validForBaseType', isValidForBaseType);
- }
- });
- }
};
this.$scope.onEcompGeneratedNamingChange = (): void => {
};
this.$scope.onBaseTypeChange = (): void => {
- let modelName : string = this.$scope.component.model ? this.$scope.component.model : null;
+ let modelName : string = this.$scope.component.model ? this.$scope.component.model : null;
this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
- this.$scope.baseTypeVersions = []
- data.forEach(baseType => {
- if(baseType.toscaResourceName === this.$scope.component.derivedFromGenericType) {
- baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
- this.$scope.component.derivedFromGenericVersion = baseType.versions[0];
- };
- });
- })
+ this.$scope.baseTypeVersions = []
+ data.forEach(baseType => {
+ if(baseType.toscaResourceName === this.$scope.component.derivedFromGenericType) {
+ baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
+ this.$scope.component.derivedFromGenericVersion = baseType.versions[0];
+ };
+ });
+ })
};
this.$scope.onModelChange = (): void => {
- if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component && this.$scope.component.categories) {
+ if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component && this.$scope.categories) {
let modelName = this.$scope.component.model ? this.$scope.component.model : null;
- this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
- this.$scope.baseTypes = []
- this.$scope.baseTypeVersions = []
- data.forEach(baseType => this.$scope.baseTypes.push(baseType.toscaResourceName));
- data[0].versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
- this.$scope.component.derivedFromGenericType = data[0].toscaResourceName;
- this.$scope.component.derivedFromGenericVersion = data[0].versions[0];
- });
+ this.filterCategoriesByModel(modelName);
+ this.filterBaseTypesByModelAndCategory(modelName)
}
};
if (metadataKey) {
return metadataKey.validValues;
}
- return [];
+ return [];
}
this.$scope.isMetadataKeyForComponentCategory = (key: string): boolean => {
this.$scope.component[attribute] = metadatakey.defaultValue;
}
return metadatakey != null;
- }
+ }
+ }
+
+ private filterCategoriesByModel(modelName:string) {
+ // reload categories
+ this.$scope.initCategories();
+ this.$scope.categories = this.$scope.categories.filter(category =>
+ !modelName ? category.models.indexOf(DEFAULT_MODEL_NAME) !== -1 : category.models !== null && category.models.indexOf(modelName) !== -1);
+ }
+
+
+ private filterBaseTypesByModelAndCategory(modelName:string) {
+ let categories = this.$scope.component.categories;
+ if (categories) {
+ this.elementService.getCategoryBasetypes(categories[0].name, modelName).subscribe((data: BaseTypeResponse[]) => {
+ this.loadBaseTypes(data);
+ });
+ }
+ }
+
+ private loadBaseTypes(data:BaseTypeResponse[]) {
+ this.$scope.baseTypes = [];
+ this.$scope.baseTypeVersions = [];
+ data.forEach(baseType => this.$scope.baseTypes.push(baseType.toscaResourceName));
+ let baseType = data[0];
+ if (baseType) {
+ baseType.versions.reverse().forEach(version => this.$scope.baseTypeVersions.push(version));
+ this.$scope.component.derivedFromGenericType = baseType.toscaResourceName;
+ this.$scope.component.derivedFromGenericVersion = baseType.versions[0];
+ }
}
private setUnsavedChanges = (hasChanges: boolean): void => {
}
private getSubcategoryMetadataKey(categories: IMainCategory[], key: string) : IMetadataKey {
- if (categories[0].subcategories && categories[0].subcategories[0].metadataKeys && categories[0].subcategories[0].metadataKeys.some(metadataKey => metadataKey.name == key)) {
+ if (categories[0].subcategories && categories[0].subcategories[0].metadataKeys && categories[0].subcategories[0].metadataKeys.some(metadataKey => metadataKey.name == key)) {
return categories[0].subcategories[0].metadataKeys.find(metadataKey => metadataKey.name == key);
}
return null;
}
private getCategoryMetadataKey(categories: IMainCategory[], key: string) : IMetadataKey {
- if (categories[0].metadataKeys && categories[0].metadataKeys.some(metadataKey => metadataKey.name == key)) {
+ if (categories[0].metadataKeys && categories[0].metadataKeys.some(metadataKey => metadataKey.name == key)) {
return categories[0].metadataKeys.find(metadataKey => metadataKey.name == key);
}
return null;
}
}
-
public static final String HC_COMPONENT_ECOMP_PORTAL = "PORTAL";
//Plugin BL
public static final String PLUGIN_BL_COMPONENT = "pluginStatusBL";
+ public static final String DEFAULT_MODEL_NAME = "SDC AID";
+
+
private Constants() {
}
private String name;
private String normalizedName;
+ private List<String> models;
private String uniqueId;
private List<String> icons;
private boolean useServiceSubstitutionForNestedServices = false;
public CategoryDataDefinition(CategoryDataDefinition c) {
this.name = c.name;
this.normalizedName = c.normalizedName;
+ this.models = c.models;
this.uniqueId = c.uniqueId;
this.icons = c.icons;
this.useServiceSubstitutionForNestedServices = c.useServiceSubstitutionForNestedServices;
public enum ResourceMetadataEnum {
RESOURCE_NAME("name"),
DESCRIPTION("description"),
+ MODEL("selectModelName"),
CATEGORY("selectGeneralCategory"),
VENDOR_NAME("vendorName"),
VENDOR_RELEASE("vendorRelease"),
return GeneralUIUtils.getWebElementByTestID(DataTestIdEnum.ServiceMetadataEnum.DESCRIPTION.getValue());
}
+ public static String getModelDataTestsIdAttribute() {
+ return DataTestIdEnum.ResourceMetadataEnum.MODEL.getValue();
+ }
+
public static String getCategoryDataTestsIdAttribute() {
return DataTestIdEnum.ResourceMetadataEnum.CATEGORY.getValue();
}
*/
public void fillForm(final ServiceCreateData serviceCreateData) {
fillName(serviceCreateData.getName());
+ setModel(serviceCreateData.getModel());
setCategory(serviceCreateData.getCategory());
setEtsiVersion(serviceCreateData.getEtsiVersion());
fillDescription(serviceCreateData.getDescription());
categorySelect.selectByVisibleText(etsiVersion);
}
+ private void setModel(final String model) {
+ if (model == null) {
+ return;
+ }
+ final Select modelSelect = new Select(findElement(By.xpath(XpathSelector.MODEL_SELECT.getXpath())));
+ modelSelect.selectByVisibleText(model);
+ }
+
private void setCategory(final String category) {
if (category == null) {
return;
@AllArgsConstructor
private enum XpathSelector {
NAME_INPUT("name", "//input[@data-tests-id='%s']"),
+ MODEL_SELECT("selectModelName", "//select[@data-tests-id='%s']"),
CATEGORY_SELECT("selectGeneralCategory", "//select[@data-tests-id='%s']"),
ETSI_VERSION_SELECT("ETSI Version", "//select[@data-tests-id='%s']"),
DESCRIPTION_TEXT_AREA("description", "//textarea[@data-tests-id='%s']");
namingPolicyTextbox.sendKeys(namingPolicyText);
}
+ public static void defineModel(final String model) {
+ GeneralUIUtils.getSelectList(model, getModelDataTestsIdAttribute());
+ }
+
public static String getServiceFunctionText(){
return getServiceFunctionField().getAttribute("value");
}