Update base types based on model 41/123241/3
authorMichaelMorris <michael.morris@est.tech>
Fri, 30 Jul 2021 12:06:11 +0000 (13:06 +0100)
committerAndr� Schmid <andre.schmid@est.tech>
Thu, 12 Aug 2021 09:47:01 +0000 (09:47 +0000)
Also made some changes where model was not being considered

Signed-off-by: MichaelMorris <michael.morris@est.tech>
Issue-ID: SDC-3666
Change-Id: I450c5261239cf4104c494abe6711cb61368a2b4a

34 files changed:
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/GroupTypeImportManager.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/PolicyTypeImportManager.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ResourceImportManager.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/components/impl/generic/GenericTypeBusinessLogic.java
catalog-be/src/main/java/org/openecomp/sdc/be/servlets/ElementServlet.java
catalog-be/src/main/java/org/openecomp/sdc/be/tosca/ToscaExportHandler.java
catalog-be/src/test/java/org/openecomp/sdc/ElementOperationMock.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/ResourceImportManagerTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ComponentInstanceBusinessLogicTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ElementBusinessLogicTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ResourceBusinessLogicTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/impl/ServiceImportParseLogicTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/ForwardingPathToscaOperationFacade.java
catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ElementServletTest.java
catalog-be/src/test/java/org/openecomp/sdc/be/tosca/ToscaExportHandlerTest.java
catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/JanusGraphDao.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/NodeTypeOperation.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacade.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/IElementOperation.java
catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ElementOperation.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/jsonjanusgraph/operations/ToscaOperationFacadeTest.java
catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ElementOperationTest.java
catalog-ui/src/app/models/components/component.ts
catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts
catalog-ui/src/app/ng2/services/element.service.ts
catalog-ui/src/app/ng2/services/responses/component-generic-response.ts
catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts
catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts
catalog-ui/src/app/view-models/workspace/tabs/general/general-view-model.ts
catalog-ui/src/app/view-models/workspace/tabs/general/general-view.html

index e2c3df1..f4daea7 100644 (file)
@@ -446,7 +446,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
         }
         final Component service = getServiceResult.left().value();
         final Either<Component, StorageOperationStatus> getServiceDerivedFromTypeResult = toscaOperationFacade
-            .getLatestByToscaResourceName(service.getDerivedFromGenericType());
+            .getLatestByToscaResourceName(service.getDerivedFromGenericType(), service.getModel());
         if (getServiceDerivedFromTypeResult.isRight()) {
             throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getServiceResult.right().value()));
         }
@@ -2835,7 +2835,7 @@ public class ComponentInstanceBusinessLogic extends BaseBusinessLogic {
                     final Component service = getServiceResult.left().value();
 
                     final Either<Component, StorageOperationStatus> getServiceDerivedFromTypeResult = toscaOperationFacade
-                        .getLatestByToscaResourceName(service.getDerivedFromGenericType());
+                        .getLatestByToscaResourceName(service.getDerivedFromGenericType(), service.getModel());
                     if (getServiceDerivedFromTypeResult.isRight()) {
                         throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(getServiceResult.right().value()));
                     }
index 3b92e62..1bffb4e 100644 (file)
@@ -1288,11 +1288,11 @@ public class ElementBusinessLogic extends BaseBusinessLogic {
         }
     }
     
-    public Either<List<BaseType>, ActionStatus> getBaseTypes(final String categoryName, final String userId) {
+    public Either<List<BaseType>, ActionStatus> getBaseTypes(final String categoryName, final String userId, final String modelName) {
         final ActionStatus status = validateUserExistsActionStatus(userId);
         if (ActionStatus.OK != status) {
             return Either.right(status);
         }
-        return Either.left(elementOperation.getBaseTypes(categoryName));
+        return Either.left(elementOperation.getBaseTypes(categoryName, modelName));
     }
 }
index 4983c01..321ed99 100644 (file)
@@ -107,7 +107,7 @@ public class GroupTypeImportManager {
                 for (String member : groupType.getMembers()) {
                     // Verify that such Resource exist
                     Either<org.openecomp.sdc.be.model.Resource, StorageOperationStatus> eitherMemberExist = toscaOperationFacade
-                        .getLatestByToscaResourceName(member);
+                        .getLatestByToscaResourceName(member, groupType.getModel());
                     if (eitherMemberExist.isRight()) {
                         StorageOperationStatus operationStatus = eitherMemberExist.right().value();
                         log.debug("Error when fetching parent resource {}, error: {}", member, operationStatus);
index d10680d..9fa8e30 100644 (file)
@@ -105,7 +105,7 @@ public class PolicyTypeImportManager {
             }
             if (result.isLeft()) {
                 for (String targetId : policyType.getTargets()) {
-                    boolean isValid = toscaOperationFacade.getLatestByToscaResourceName(targetId).isLeft();
+                    boolean isValid = toscaOperationFacade.getLatestByToscaResourceName(targetId, policyType.getModel()).isLeft();
                     if (!isValid) { // check if it is a groupType
                         final Either<GroupTypeDefinition, StorageOperationStatus> groupTypeFound = groupTypeOperation
                             .getLatestGroupTypeByType(targetId, policyType.getModel(), false);
index c401948..152b78b 100644 (file)
@@ -802,7 +802,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
             componentsUtils.auditResource(responseFormat, csarInfo.getModifier(), resource, AuditingActionEnum.CREATE_RESOURCE);
             throw new ByActionStatusComponentException(componentsUtils.convertFromStorageResponse(status), csarInfo.getCsarUUID());
         } else if (StringUtils.isNotEmpty(currVfcToscaName)) {
-            return (Resource) toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName).left()
+            return (Resource) toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName, resource.getModel()).left()
                 .on(st -> findVfcResource(csarInfo, resource, previousVfcToscaName, null, st));
         }
         return null;
@@ -1969,7 +1969,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
                                  String nodeName, String substitutableAsNodeType) {
         try {
             for (Entry<String, NodeTypeInfo> nodeTypeEntry : nodeTypesInfo.entrySet()) {
-                if (nodeTypeEntry.getValue().isNested() && !nodeTypeAlreadyExists(nodeTypeEntry.getKey())) {
+                if (nodeTypeEntry.getValue().isNested() && !nodeTypeAlreadyExists(nodeTypeEntry.getKey(), resource.getModel())) {
                     handleNestedVfc(resource, nodeTypesArtifactsToHandle, nodeTypesNewCreatedArtifacts, nodeTypesInfo, csarInfo,
                         nodeTypeEntry.getKey());
                     log.trace("************* finished to create node {}", nodeTypeEntry.getKey());
@@ -1997,8 +1997,8 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
         }
     }
 
-    private boolean nodeTypeAlreadyExists(final String toscaResourceName) {
-        return toscaOperationFacade.getLatestByToscaResourceName(toscaResourceName).isLeft();
+    private boolean nodeTypeAlreadyExists(final String toscaResourceName, String modelName) {
+        return toscaOperationFacade.getLatestByToscaResourceName(toscaResourceName, modelName).isLeft();
     }
 
     private Either<Resource, ResponseFormat> handleVfCsarArtifacts(Resource resource, CsarInfo csarInfo, List<ArtifactDefinition> createdArtifacts,
@@ -3490,7 +3490,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
                                                                                final CsarInfo csarInfo, final boolean isNested,
                                                                                final String nodeName) {
         final Either<Component, StorageOperationStatus> latestByToscaName = toscaOperationFacade.getLatestByToscaResourceName(
-            buildNestedToscaResourceName(resource.getResourceType().name(), csarInfo.getVfResourceName(), nodeName).getRight());
+            buildNestedToscaResourceName(resource.getResourceType().name(), csarInfo.getVfResourceName(), nodeName).getRight(), resource.getModel());
         if (latestByToscaName.isLeft()) {
             final Resource nestedResource = (Resource) latestByToscaName.left().value();
             log.debug(VALIDATE_DERIVED_BEFORE_UPDATE);
@@ -3676,7 +3676,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
     private Component getParentComponent(Resource newResource) {
         String toscaResourceNameDerivedFrom = newResource.getDerivedFrom().get(0);
         Either<Component, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade
-            .getLatestByToscaResourceName(toscaResourceNameDerivedFrom);
+            .getLatestByToscaResourceName(toscaResourceNameDerivedFrom, newResource.getModel());
         if (latestByToscaResourceName.isRight()) {
             BeEcompErrorManager.getInstance()
                 .logInternalDataError("mergeOldResourceMetadataWithNew", "derived from resource not found", ErrorSeverity.ERROR);
@@ -4601,7 +4601,7 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
         String currentTemplateName = currentResource.getDerivedFrom().get(0);
         String updatedTemplateName = updateInfoResource.getDerivedFrom().get(0);
         Either<Boolean, StorageOperationStatus> dataModelResponse = toscaOperationFacade
-            .validateToscaResourceNameExtends(currentTemplateName, updatedTemplateName);
+            .validateToscaResourceNameExtends(currentTemplateName, updatedTemplateName, currentResource.getModel());
         if (dataModelResponse.isRight()) {
             StorageOperationStatus storageStatus = dataModelResponse.right().value();
             BeEcompErrorManager.getInstance().logBeDaoSystemError("Create/Update Resource - validateDerivingFromExtendingType");
@@ -4905,20 +4905,20 @@ public class ResourceBusinessLogic extends ComponentBusinessLogic {
         log.debug("validate resource properties default values");
         List<PropertyDefinition> properties = resource.getProperties();
         if (properties != null) {
-            iterateOverProperties(properties);
+            iterateOverProperties(properties, resource.getModel());
         }
         return true;
     }
 
-    public void iterateOverProperties(List<PropertyDefinition> properties) {
+    public void iterateOverProperties(List<PropertyDefinition> properties, String model) {
         String type = null;
         String innerType = null;
         for (PropertyDefinition property : properties) {
-            if (!propertyOperation.isPropertyTypeValid(property, null)) {
+            if (!propertyOperation.isPropertyTypeValid(property, model)) {
                 log.info("Invalid type for property {}", property);
                 throw new ByActionStatusComponentException(ActionStatus.INVALID_PROPERTY_TYPE, property.getType(), property.getName());
             }
-            Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, property.getModel());
+            Map<String, DataTypeDefinition> allDataTypes = componentsUtils.getAllDataTypes(applicationDataTypeCache, model);
             type = property.getType();
             if (type.equals(ToscaPropertyType.LIST.getType()) || type.equals(ToscaPropertyType.MAP.getType())) {
                 ResponseFormat responseFormat = validateMapOrListPropertyType(property, innerType, allDataTypes);
index 9f1669c..4f65230 100644 (file)
@@ -215,7 +215,7 @@ public class ResourceImportManager {
         }
         final Either<Resource, StorageOperationStatus> resourceEither =
             toscaOperationFacade.getComponentByNameAndVendorRelease(resource.getComponentType(), resource.getName(),
-                resource.getVendorRelease(), JsonParseFlagEnum.ParseAll);
+                resource.getVendorRelease(), JsonParseFlagEnum.ParseAll, resource.getModel());
         if (resourceEither.isLeft() && toscaOperationFacade.isNodeAssociatedToModel(resource.getModel(), resource)) {
             if (resource.getModel() == null) {
                 throw new ByActionStatusComponentException(ActionStatus.COMPONENT_WITH_VENDOR_RELEASE_ALREADY_EXISTS,
@@ -528,7 +528,7 @@ public class ResourceImportManager {
             String derivedFrom = toscaDerivedFromElement.left().value();
             log.debug("Derived from TOSCA name is {}", derivedFrom);
             resource.setDerivedFrom(Arrays.asList(new String[]{derivedFrom}));
-            Either<Resource, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade.getLatestByToscaResourceName(derivedFrom);
+            Either<Resource, StorageOperationStatus> latestByToscaResourceName = toscaOperationFacade.getLatestByToscaResourceName(derivedFrom, resource.getModel());
             if (latestByToscaResourceName.isRight()) {
                 StorageOperationStatus operationStatus = latestByToscaResourceName.right().value();
                 if (operationStatus == StorageOperationStatus.NOT_FOUND) {
index 3404323..9940929 100644 (file)
@@ -313,7 +313,7 @@ public class ServiceImportParseLogic {
             log.debug("Error occured during fetching node type with tosca name {}, error: {}", currVfcToscaName, status);
             throw new ComponentException(componentsUtils.convertFromStorageResponse(status), csarInfo.getCsarUUID());
         } else if (org.apache.commons.lang.StringUtils.isNotEmpty(currVfcToscaName)) {
-            return (Resource) toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName).left()
+            return (Resource) toscaOperationFacade.getLatestByToscaResourceName(currVfcToscaName, resource.getModel()).left()
                 .on(st -> findVfcResource(csarInfo, resource, previousVfcToscaName, null, st));
         }
         return null;
@@ -1504,7 +1504,7 @@ public class ServiceImportParseLogic {
         String currentTemplateName = currentResource.getDerivedFrom().get(0);
         String updatedTemplateName = updateInfoResource.getDerivedFrom().get(0);
         Either<Boolean, StorageOperationStatus> dataModelResponse = toscaOperationFacade
-            .validateToscaResourceNameExtends(currentTemplateName, updatedTemplateName);
+            .validateToscaResourceNameExtends(currentTemplateName, updatedTemplateName, currentResource.getModel());
         if (dataModelResponse.isRight()) {
             StorageOperationStatus storageStatus = dataModelResponse.right().value();
             BeEcompErrorManager.getInstance().logBeDaoSystemError("Create/Update Resource - validateDerivingFromExtendingType");
index 6cf4327..07d71ea 100644 (file)
@@ -72,7 +72,7 @@ public class GenericTypeBusinessLogic {
                 return Either.right(componentsUtils.getResponseFormat(ActionStatus.GENERIC_TYPE_NOT_FOUND, component.assetType(), genericTypeToscaName));
             }
         } else {
-            genericType = toscaOperationFacade.getByToscaResourceNameAndVersion(genericTypeToscaName, component.getDerivedFromGenericVersion());
+            genericType = toscaOperationFacade.getByToscaResourceNameAndVersion(genericTypeToscaName, component.getDerivedFromGenericVersion(), component.getModel());
         }
 
         Resource genericTypeResource = genericType.left().value();
index 4efca8a..f79650d 100644 (file)
@@ -202,11 +202,11 @@ public class ElementServlet extends BeGenericServlet {
     @PermissionAllowed(AafPermission.PermNames.INTERNAL_ALL_VALUE)
     public Response getCategoryBaseTypes(@PathParam(value = "categoryName") final String categoryName,
             @PathParam(value = "componentType") final String componentType, @Context final HttpServletRequest request,
-            @HeaderParam(value = Constants.USER_ID_HEADER) String userId) {
-
+            @HeaderParam(value = Constants.USER_ID_HEADER) String userId,
+            @Parameter(description = "model", required = false) @QueryParam("model") String modelName) {
         try {
             final ElementBusinessLogic elementBL = getElementBL(request.getSession().getServletContext());
-            final Either<List<BaseType>, ActionStatus> either = elementBL.getBaseTypes(categoryName, userId);
+            final Either<List<BaseType>, ActionStatus> either = elementBL.getBaseTypes(categoryName, userId, modelName);
             
             if (either.isRight() || either.left().value() == null) {
                 log.debug("No base types were found");
index ef5192c..8b8c315 100644 (file)
@@ -220,7 +220,7 @@ public class ToscaExportHandler {
         if (component.getDerivedFromGenericType() != null && !component.getDerivedFromGenericType()
             .startsWith("org.openecomp.resource.abstract.nodes.")) {
             final Either<Component, StorageOperationStatus> baseType = toscaOperationFacade
-                .getByToscaResourceNameAndVersion(component.getDerivedFromGenericType(), component.getDerivedFromGenericVersion());
+                .getByToscaResourceNameAndVersion(component.getDerivedFromGenericType(), component.getDerivedFromGenericVersion(), component.getModel());
             if (baseType.isLeft() && baseType.left().value() != null) {
                 addDependencies(imports, dependencies, baseType.left().value());
             } else {
index 5d05e65..117ef9c 100644 (file)
@@ -282,7 +282,7 @@ public class ElementOperationMock implements IElementOperation {
     }
 
     @Override
-    public List<BaseType> getBaseTypes(String categoryName) {
+    public List<BaseType> getBaseTypes(String categoryName, String modelName) {
         // TODO Auto-generated method stub
         return null;
     }
index 00e0681..1609299 100644 (file)
@@ -110,7 +110,7 @@ public class ResourceImportManagerTest {
     public static void beforeClass() {
         importManager = new ResourceImportManager(componentsUtils, capabilityTypeOperation, interfaceDefinitionHandler);
         importManager.setAuditingManager(auditingManager);
-        when(toscaOperationFacade.getLatestByToscaResourceName(Mockito.anyString())).thenReturn(Either.left(null));
+        when(toscaOperationFacade.getLatestByToscaResourceName(Mockito.anyString(), Mockito.any())).thenReturn(Either.left(null));
         when(toscaOperationFacade.getLatestByToscaResourceNameAndModel(Mockito.anyString(), Mockito.any())).thenReturn(Either.left(null));
         importManager.setResponseFormatManager(responseFormatManager);
         importManager.setResourceBusinessLogic(resourceBusinessLogic);
@@ -130,7 +130,7 @@ public class ResourceImportManagerTest {
         Mockito.reset(auditingManager, responseFormatManager, resourceBusinessLogic, userAdmin);
         Either<Component, StorageOperationStatus> notFound = Either.right(StorageOperationStatus.NOT_FOUND);
         when(toscaOperationFacade.getComponentByNameAndVendorRelease(any(ComponentTypeEnum.class), anyString(), anyString(),
-            any(JsonParseFlagEnum.class))).thenReturn(notFound);
+            any(JsonParseFlagEnum.class), any())).thenReturn(notFound);
     }
 
     @Test
@@ -308,7 +308,7 @@ public class ResourceImportManagerTest {
         setResourceBusinessLogicMock();
         final Either<Component, StorageOperationStatus> foundResourceEither = Either.left(Mockito.mock(Resource.class));
         when(toscaOperationFacade.getComponentByNameAndVendorRelease(any(ComponentTypeEnum.class), anyString(), anyString(),
-            any(JsonParseFlagEnum.class))).thenReturn(foundResourceEither);
+            any(JsonParseFlagEnum.class), any())).thenReturn(foundResourceEither);
         when(toscaOperationFacade.isNodeAssociatedToModel(eq(null), any(Resource.class))).thenReturn(true);
 
         String jsonContent = ImportUtilsTest.loadFileNameToJsonString("normative-types-new-blockStorage.yml");
index a2996c5..3029bf7 100644 (file)
@@ -33,6 +33,7 @@ import static org.junit.jupiter.api.DynamicTest.dynamicTest;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anySet;
 import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
@@ -1851,7 +1852,7 @@ class ComponentInstanceBusinessLogicTest {
             .thenReturn(Either.left(service));
         when(toscaOperationFacade.getToscaFullElement(eq(ORIGIN_COMPONENT_ID)))
             .thenReturn(Either.left(originService));
-        when(toscaOperationFacade.getLatestByToscaResourceName(eq(originService.getDerivedFromGenericType())))
+        when(toscaOperationFacade.getLatestByToscaResourceName(eq(originService.getDerivedFromGenericType()), isNull()))
             .thenReturn(Either.left(serviceBaseComponent));
         when(toscaOperationFacade.getToscaElement(eq(ORIGIN_COMPONENT_ID), any(ComponentParametersView.class)))
             .thenReturn(Either.left(originService));
index 36eee96..f52ae20 100644 (file)
@@ -312,16 +312,17 @@ public class ElementBusinessLogicTest extends BaseBusinessLogicMock {
         List<BaseType> baseTypes = new ArrayList<>();
         baseTypes.add(new BaseType("org.openecomp.type"));
         String categoryName = "CAT01";
+        String modelName = "MODEL01";
 
         when(userValidations.validateUserExistsActionStatus(eq(user.getUserId()))).thenReturn(ActionStatus.OK);
-        when(elementDao.getBaseTypes(categoryName)).thenReturn(baseTypes);
-        Assert.assertTrue(elementBusinessLogic.getBaseTypes(categoryName, user.getUserId())
+        when(elementDao.getBaseTypes(categoryName, modelName)).thenReturn(baseTypes);
+        Assert.assertTrue(elementBusinessLogic.getBaseTypes(categoryName, user.getUserId(), modelName)
         .isLeft());
     }
     
     @Test
     public void testGetBaseTypes_givenUserValidationFails_thenReturnsException() {
         when(userValidations.validateUserExistsActionStatus(eq(user.getUserId()))).thenReturn(ActionStatus.RESTRICTED_OPERATION);
-        Assert.assertTrue(elementBusinessLogic.getBaseTypes("CAT01", user.getUserId()).isRight());
+        Assert.assertTrue(elementBusinessLogic.getBaseTypes("CAT01", user.getUserId(), null).isRight());
     }
 }
\ No newline at end of file
index a2893af..cfbd633 100644 (file)
@@ -1460,7 +1460,7 @@ public class ResourceBusinessLogicTest {
        YamlTemplateParsingHandler yamlTemplateParser = new YamlTemplateParsingHandler(mockJanusGraphDao, null, Mockito.mock(AnnotationBusinessLogic.class), null);
        final ParsedToscaYamlInfo parsedToscaYamlInfo =  yamlTemplateParser.parseResourceInfoFromYAML("Definitions/my_vnf.yml", resourceYml, Collections.EMPTY_MAP, Collections.EMPTY_MAP, "myVnf", resourceResponse);
 
-        when(toscaOperationFacade.getLatestByToscaResourceName(anyString())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
+        when(toscaOperationFacade.getLatestByToscaResourceName(anyString(), any())).thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
         Resource vduCp = new Resource();
         vduCp.setToscaResourceName("tosca.nodes.nfv.VduCp");
         vduCp.setState(LifecycleStateEnum.CERTIFIED);
@@ -1673,7 +1673,7 @@ public class ResourceBusinessLogicTest {
                when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
 
                Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(true);
-               when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString()))
+               when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString(), anyString()))
                                .thenReturn(isToscaNameExtending);
 
                Either<Map<String, PropertyDefinition>, StorageOperationStatus> findPropertiesOfNode = Either
@@ -1703,7 +1703,7 @@ public class ResourceBusinessLogicTest {
                when(toscaOperationFacade.getToscaElement(resource.getUniqueId())).thenReturn(eitherUpdate);
 
                Either<Boolean, StorageOperationStatus> isToscaNameExtending = Either.left(false);
-               when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString()))
+               when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString(), anyString()))
                                .thenReturn(isToscaNameExtending);
 
                resource.setVersion("1.0");
@@ -1740,7 +1740,7 @@ public class ResourceBusinessLogicTest {
                assertThat(createdResource).isNotNull();
                Either<Resource, StorageOperationStatus> getLatestResult = Either.left(createdResource);
                Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(createdResource);
-               when(toscaOperationFacade.getLatestByToscaResourceName(resourceExist.getToscaResourceName()))
+               when(toscaOperationFacade.getLatestByToscaResourceName(resourceExist.getToscaResourceName(), null))
                                .thenReturn(getCompLatestResult);
                when(toscaOperationFacade.getLatestByToscaResourceNameAndModel(resourceExist.getToscaResourceName(), null))
                        .thenReturn(getCompLatestResult);
@@ -1851,9 +1851,9 @@ public class ResourceBusinessLogicTest {
                                .getRight();
                when(toscaOperationFacade.getLatestByName(resourceToUpdate.getName(), null))
                                .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
-               when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdate.getToscaResourceName()))
+               when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdate.getToscaResourceName(), null))
                                .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
-               when(toscaOperationFacade.getLatestByToscaResourceName(nestedResourceName))
+               when(toscaOperationFacade.getLatestByToscaResourceName(nestedResourceName, null))
                                .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
 
                when(toscaOperationFacade.getLatestByToscaResourceNameAndModel(resourceToUpdate.getToscaResourceName(), null))
@@ -1889,11 +1889,11 @@ public class ResourceBusinessLogicTest {
                                .getRight();
                when(toscaOperationFacade.getLatestByName(resourceToUpdate.getName(), null))
                                .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
-               when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdate.getToscaResourceName()))
+               when(toscaOperationFacade.getLatestByToscaResourceName(resourceToUpdate.getToscaResourceName(), null))
                                .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
                when(toscaOperationFacade.getLatestByToscaResourceNameAndModel(resourceToUpdate.getToscaResourceName(), null))
                        .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
-               when(toscaOperationFacade.getLatestByToscaResourceName(nestedResourceName))
+               when(toscaOperationFacade.getLatestByToscaResourceName(nestedResourceName, null))
                                .thenReturn(Either.left(resourceResponse));
                when(toscaOperationFacade.overrideComponent(any(Resource.class), any(Resource.class)))
                                .thenReturn(Either.left(resourceResponse));
@@ -2283,7 +2283,7 @@ public class ResourceBusinessLogicTest {
 
        private Resource createRoot() {
                rootType = setupGenericTypeMock(GENERIC_ROOT_NAME);
-               when(toscaOperationFacade.getLatestByToscaResourceName(GENERIC_ROOT_NAME))
+               when(toscaOperationFacade.getLatestByToscaResourceName(GENERIC_ROOT_NAME, null))
                                .thenReturn(Either.left(rootType));
                return rootType;
        }
index a3232f6..ccc7139 100644 (file)
@@ -203,7 +203,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
         final Service service = createServiceObject(false);
         Resource resource = new Resource();
         Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(resource);
-        when(toscaOperationFacade.getLatestByToscaResourceName(anyString()))
+        when(toscaOperationFacade.getLatestByToscaResourceName(anyString(), any()))
             .thenReturn(getCompLatestResult);
 
         final CsarInfo csarInfo = getCsarInfo();
@@ -229,7 +229,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
         final Service service = createServiceObject(false);
         Resource resource = new Resource();
         Either<Component, StorageOperationStatus> getCompLatestResult = Either.left(resource);
-        when(toscaOperationFacade.getLatestByToscaResourceName(anyString()))
+        when(toscaOperationFacade.getLatestByToscaResourceName(anyString(), any()))
             .thenReturn(getCompLatestResult);
         Assertions.assertNotNull(extractedVfcsArtifacts);
         testSubject.findAddNodeTypeArtifactsToHandle(getCsarInfo(), nodeTypesArtifactsToHandle, service,
@@ -1205,7 +1205,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
         updatedDerivedFromList.add("23344567778");
         updateInfoResource.setDerivedFrom(updatedDerivedFromList);
 
-        when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString()))
+        when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString(), any()))
             .thenReturn(Either.right(StorageOperationStatus.NOT_FOUND));
 
         Assertions.assertNotNull(
@@ -1218,7 +1218,7 @@ class ServiceImportParseLogicTest extends ServiceImportBussinessLogicBaseTestSet
         Resource currentResource = createParseResourceObject(true);
         Resource updateInfoResource = createParseResourceObject(true);
 
-        when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString()))
+        when(toscaOperationFacade.validateToscaResourceNameExtends(anyString(), anyString(), any()))
             .thenReturn(Either.left(false));
 
         Assertions.assertNotNull(
index 3774332..3fbd84f 100644 (file)
@@ -55,12 +55,12 @@ public class ForwardingPathToscaOperationFacade extends ToscaOperationFacade {
     }
 
     @Override
-    public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName) {
+    public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName, String model) {
         if(toscaResourceName.equals(ForwardingPathUtils.FORWARDING_PATH_NODE_NAME) || toscaResourceName.equals(ForwardingPathUtils.FORWARDER_CAPABILITY)){
             Resource component = new Resource();
             component.setToscaResourceName(GENERIC_SERVICE_NAME);
             return Either.left((T)component);
         }
-        return super.getLatestByToscaResourceName(toscaResourceName);
+        return super.getLatestByToscaResourceName(toscaResourceName, model);
     }
 }
index 4d2c362..c183784 100644 (file)
@@ -1110,7 +1110,7 @@ class ElementServletTest extends JerseyTest {
     void getBaseTypesTest() {
         String path = "/v1/category/services/CAT1/baseTypes";
         Either<List<BaseType>, ActionStatus> baseTypesEither = Either.left(new ArrayList<>());
-        when(elementBusinessLogic.getBaseTypes("CAT1", designerUser.getUserId()))
+        when(elementBusinessLogic.getBaseTypes("CAT1", designerUser.getUserId(), null))
             .thenReturn(baseTypesEither);
 
         Response response = target()
@@ -1128,7 +1128,7 @@ class ElementServletTest extends JerseyTest {
         String path = "/v1/category/services/CAT1/baseTypes";
         Either<List<BaseType>, ActionStatus> baseTypesEither = Either.right(ActionStatus.NO_CONTENT);
 
-        when(elementBusinessLogic.getBaseTypes("CAT1", designerUser.getUserId()))
+        when(elementBusinessLogic.getBaseTypes("CAT1", designerUser.getUserId(), null))
             .thenReturn(baseTypesEither);
 
         Response response = target()
index 38c7292..325a003 100644 (file)
@@ -529,7 +529,7 @@ public class ToscaExportHandlerTest extends BeConfDependentTest {
 
         component.setDerivedFromGenericType("org.typeA");
         component.setDerivedFromGenericVersion("1.0");
-        when(toscaOperationFacade.getByToscaResourceNameAndVersion("org.typeA", "1.0")).thenReturn(Either.left(baseType));
+        when(toscaOperationFacade.getByToscaResourceNameAndVersion("org.typeA", "1.0", null)).thenReturn(Either.left(baseType));
 
         // default test
         result = Deencapsulation.invoke(testSubject, "fillImports", component, toscaTemplate);
index 3e10c79..76fddc0 100644 (file)
@@ -29,8 +29,12 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
 import java.util.Optional;
 import org.apache.commons.collections.MapUtils;
+import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.tinkerpop.gremlin.structure.Direction;
 import org.apache.tinkerpop.gremlin.structure.Edge;
@@ -52,6 +56,7 @@ import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
 import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
 import org.openecomp.sdc.be.dao.jsongraph.utils.JsonParserUtils;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
 import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
 import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
@@ -441,20 +446,23 @@ public class JanusGraphDao {
 
     public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type, Map<GraphPropertyEnum, Object> props,
                                                                               Map<GraphPropertyEnum, Object> hasNotProps,
-                                                                              JsonParseFlagEnum parseFlag) {
-        return getByCriteria(type, props, hasNotProps, null, parseFlag);
+                                                                              JsonParseFlagEnum parseFlag,
+                                                                              String model) {
+        return getByCriteria(type, props, hasNotProps, null, parseFlag, model);
     }
 
     public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(final VertexTypeEnum type,
                                                                               final Map<GraphPropertyEnum, Object> hasProps,
                                                                               final Map<GraphPropertyEnum, Object> hasNotProps,
                                                                               final Map<String, Entry<JanusGraphPredicate, Object>> predicates,
-                                                                              final JsonParseFlagEnum parseFlag) {
+                                                                              final JsonParseFlagEnum parseFlag,
+                                                                              final String model) {
         Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
         if (graph.isLeft()) {
             try {
                 JanusGraph tGraph = graph.left().value();
                 JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
+                
                 if (type != null) {
                     query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
                 }
@@ -484,7 +492,14 @@ public class JanusGraphDao {
                     return Either.right(JanusGraphOperationStatus.NOT_FOUND);
                 }
                 List<GraphVertex> result = new ArrayList<>();
-                vertices.forEach(vertex -> result.add(createAndFill(vertex, parseFlag)));
+
+                final Predicate<? super JanusGraphVertex> filterPredicate = StringUtils.isEmpty(model) ? this::vertexNotConnectedToAnyModel : vertex -> vertexValidForModel(vertex, model);
+                final List<JanusGraphVertex> verticesForModel = StreamSupport.stream(vertices.spliterator(), false).filter(filterPredicate).collect(Collectors.toList());
+                if (verticesForModel == null || verticesForModel.size() == 0) {
+                    return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+                }
+                
+                verticesForModel.forEach(vertex ->  result.add(createAndFill(vertex, parseFlag)));
                 if (logger.isDebugEnabled()) {
                     logger.debug("Number of fetched nodes in graph for criteria : from type '{}' and properties '{}' is '{}'", type, hasProps,
                         result.size());
@@ -503,6 +518,116 @@ public class JanusGraphDao {
             return Either.right(graph.right().value());
         }
     }
+    
+    public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(VertexTypeEnum type,
+            Map<GraphPropertyEnum, Object> props, Map<GraphPropertyEnum, Object> hasNotProps,
+            JsonParseFlagEnum parseFlag) {
+        return getByCriteria(type, props, hasNotProps, null, parseFlag);
+    }
+
+    public Either<List<GraphVertex>, JanusGraphOperationStatus> getByCriteria(final VertexTypeEnum type,
+            final Map<GraphPropertyEnum, Object> hasProps, final Map<GraphPropertyEnum, Object> hasNotProps,
+            final Map<String, Entry<JanusGraphPredicate, Object>> predicates, final JsonParseFlagEnum parseFlag) {
+        Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
+        if (graph.isLeft()) {
+            try {
+                JanusGraph tGraph = graph.left().value();
+                JanusGraphQuery<? extends JanusGraphQuery> query = tGraph.query();
+
+                if (type != null) {
+                    query = query.has(GraphPropertyEnum.LABEL.getProperty(), type.getName());
+                }
+                if (hasProps != null && !hasProps.isEmpty()) {
+                    for (Map.Entry<GraphPropertyEnum, Object> entry : hasProps.entrySet()) {
+                        query = query.has(entry.getKey().getProperty(), entry.getValue());
+                    }
+                }
+                if (hasNotProps != null && !hasNotProps.isEmpty()) {
+                    for (Map.Entry<GraphPropertyEnum, Object> entry : hasNotProps.entrySet()) {
+                        if (entry.getValue() instanceof List) {
+                            buildMultipleNegateQueryFromList(entry, query);
+                        } else {
+                            query = query.hasNot(entry.getKey().getProperty(), entry.getValue());
+                        }
+                    }
+                }
+                if (predicates != null && !predicates.isEmpty()) {
+                    for (Map.Entry<String, Entry<JanusGraphPredicate, Object>> entry : predicates.entrySet()) {
+                        JanusGraphPredicate predicate = entry.getValue().getKey();
+                        Object object = entry.getValue().getValue();
+                        query = query.has(entry.getKey(), predicate, object);
+                    }
+                }
+                Iterable<JanusGraphVertex> vertices = query.vertices();
+                if (vertices == null || !vertices.iterator().hasNext()) {
+                    return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+                }
+                List<GraphVertex> result = new ArrayList<>();
+
+                vertices.forEach(vertex -> result.add(createAndFill(vertex, parseFlag)));
+                if (logger.isDebugEnabled()) {
+                    logger.debug(
+                            "Number of fetched nodes in graph for criteria : from type '{}' and properties '{}' is '{}'",
+                            type, hasProps, result.size());
+                }
+                return Either.left(result);
+            } catch (Exception e) {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Failed to get by criteria for type '{}' and properties '{}'", type, hasProps, e);
+                }
+                return Either.right(JanusGraphClient.handleJanusGraphException(e));
+            }
+        } else {
+            if (logger.isDebugEnabled()) {
+                logger.debug("Failed to get by criteria for type '{}' and properties '{}'. Error : '{}'", type,
+                        hasProps, graph.right().value());
+            }
+            return Either.right(graph.right().value());
+        }
+    }
+
+    private boolean vertexValidForModel(final JanusGraphVertex vertex, final String model) {
+        final Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> modelVertices = getParentVerticies(vertex, GraphEdgeLabels.MODEL_ELEMENT);
+
+        if (modelVertices.isLeft()) {
+            for (ImmutablePair<JanusGraphVertex, Edge> vertexPair : modelVertices.left().value()) {
+                if (model.equals((String)vertexPair.getLeft().property("name").value())) {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+    
+    private Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getParentVerticies(
+            final JanusGraphVertex rootVertex, final GraphEdgeLabels edgeType) {
+        return getEdgeVerticies(rootVertex, Direction.IN, edgeType);
+    }
+    
+    private Either<List<ImmutablePair<JanusGraphVertex, Edge>>, JanusGraphOperationStatus> getEdgeVerticies(
+            final JanusGraphVertex rootVertex, final Direction direction, final GraphEdgeLabels edgeType) {
+        final List<ImmutablePair<JanusGraphVertex, Edge>> immutablePairs = new ArrayList<>();
+        final Iterator<Edge> edgesCreatorIterator = rootVertex.edges(direction, edgeType.getProperty());
+        if (edgesCreatorIterator != null) {
+            while (edgesCreatorIterator.hasNext()) {
+                Edge edge = edgesCreatorIterator.next();
+                JanusGraphVertex vertex = Direction.OUT.equals(direction)? (JanusGraphVertex) edge.inVertex() : (JanusGraphVertex) edge.outVertex();
+                ImmutablePair<JanusGraphVertex, Edge> immutablePair = new ImmutablePair<>(vertex, edge);
+                immutablePairs.add(immutablePair);
+            }
+        }
+        if (immutablePairs.isEmpty()) {
+            return Either.right(JanusGraphOperationStatus.NOT_FOUND);
+        }
+        return Either.left(immutablePairs);
+    }
+    
+    private boolean vertexNotConnectedToAnyModel(final JanusGraphVertex vertex) {
+        String vt = (String)vertex.property(GraphPropertyEnum.LABEL.getProperty()).value();
+        VertexTypeEnum vertexType = VertexTypeEnum.getByName(vt);
+        EdgeLabelEnum edgeLabel = vertexType.equals(VertexTypeEnum.TOPOLOGY_TEMPLATE) ? EdgeLabelEnum.MODEL : EdgeLabelEnum.MODEL_ELEMENT;
+        return !vertex.edges(Direction.IN, edgeLabel.name()).hasNext();
+    }
 
     public Either<Iterator<Vertex>, JanusGraphOperationStatus> getCatalogOrArchiveVerticies(boolean isCatalog) {
         Either<JanusGraph, JanusGraphOperationStatus> graph = janusGraphClient.getGraph();
index b74b290..76d8e71 100644 (file)
@@ -934,7 +934,7 @@ public class NodeTypeOperation extends ToscaElementOperation {
         Map<GraphPropertyEnum, Object> propsHasNot = new HashMap<>();
         propsHasNot.put(GraphPropertyEnum.IS_DELETED, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> byCriteria = janusGraphDao
-            .getByCriteria(VertexTypeEnum.NODE_TYPE, props, propsHasNot, JsonParseFlagEnum.NoParse);
+            .getByCriteria(VertexTypeEnum.NODE_TYPE, props, propsHasNot, JsonParseFlagEnum.NoParse, nodeType.getModel());
         if (byCriteria.isRight()) {
             log.debug("Failed to fetch derived by props {} error {}", props, byCriteria.right().value());
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(byCriteria.right().value()));
index faedba5..6466683 100644 (file)
@@ -364,10 +364,9 @@ public class ToscaOperationFacade {
         final Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesToMatch.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, nodeName);
         propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
-        propertiesToMatch.put(GraphPropertyEnum.MODEL, model);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         final Either<List<GraphVertex>, JanusGraphOperationStatus> highestResources = janusGraphDao
-            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag);
+            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag, model);
         if (highestResources.isRight()) {
             final JanusGraphOperationStatus status = highestResources.right().value();
             log.debug("failed to find resource with name {}. status={} ", nodeName, status);
@@ -388,8 +387,8 @@ public class ToscaOperationFacade {
         return getToscaElementByOperation(highestResource, filter);
     }
 
-    public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName) {
-        return getLatestByName(GraphPropertyEnum.TOSCA_RESOURCE_NAME, toscaResourceName, null);
+    public <T extends Component> Either<T, StorageOperationStatus> getLatestByToscaResourceName(String toscaResourceName, String modelName) {
+        return getLatestByName(GraphPropertyEnum.TOSCA_RESOURCE_NAME, toscaResourceName, modelName);
     }
 
     public <T extends Component> Either<T, StorageOperationStatus> getFullLatestComponentByToscaResourceName(String toscaResourceName) {
@@ -459,7 +458,7 @@ public class ToscaOperationFacade {
         props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
         Map<String, Entry<JanusGraphPredicate, Object>> predicateCriteria = getVendorVersionPredicate(vendorRelease);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getLatestRes = janusGraphDao
-            .getByCriteria(vertexType, props, null, predicateCriteria, parseFlag);
+            .getByCriteria(vertexType, props, null, predicateCriteria, parseFlag, null);
         if (getLatestRes.isRight() || CollectionUtils.isEmpty(getLatestRes.left().value())) {
             getLatestRes = janusGraphDao.getByCriteria(vertexType, props, parseFlag);
         }
@@ -486,7 +485,7 @@ public class ToscaOperationFacade {
         });
     }
 
-    public <T extends Component> Either<T, StorageOperationStatus> getByToscaResourceNameAndVersion(final String toscaResourceName, final String version) {
+    public <T extends Component> Either<T, StorageOperationStatus> getByToscaResourceNameAndVersion(final String toscaResourceName, final String version, final String model) {
         Either<T, StorageOperationStatus> result;
 
         Map<GraphPropertyEnum, Object> hasProperties = new EnumMap<>(GraphPropertyEnum.class);
@@ -497,7 +496,7 @@ public class ToscaOperationFacade {
         hasNotProperties.put(GraphPropertyEnum.IS_DELETED, true);
 
         Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceRes = janusGraphDao
-            .getByCriteria(VertexTypeEnum.NODE_TYPE, hasProperties, hasNotProperties, JsonParseFlagEnum.ParseAll);
+            .getByCriteria(VertexTypeEnum.NODE_TYPE, hasProperties, hasNotProperties, JsonParseFlagEnum.ParseAll, model);
         if (getResourceRes.isRight()) {
             JanusGraphOperationStatus status = getResourceRes.right().value();
             log.debug("failed to find resource with toscaResourceName {}, version {}. Status is {} ", toscaResourceName, version, status);
@@ -807,10 +806,9 @@ public class ToscaOperationFacade {
         Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesToMatch.put(property, nodeName);
         propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
-        propertiesToMatch.put(GraphPropertyEnum.MODEL, model);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> highestResources = janusGraphDao
-            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag);
+            .getByCriteria(null, propertiesToMatch, propertiesNotToMatch, parseFlag, model);
         if (highestResources.isRight()) {
             JanusGraphOperationStatus status = highestResources.right().value();
             log.debug("failed to find resource with name {}. status={} ", nodeName, status);
@@ -905,7 +903,7 @@ public class ToscaOperationFacade {
 
     public <T extends Component> Either<T, StorageOperationStatus> getComponentByNameAndVendorRelease(final ComponentTypeEnum componentType,
         final String name, final String vendorRelease,
-        final JsonParseFlagEnum parseFlag) {
+        final JsonParseFlagEnum parseFlag, final String modelName) {
         Map<GraphPropertyEnum, Object> hasProperties = new EnumMap<>(GraphPropertyEnum.class);
         Map<GraphPropertyEnum, Object> hasNotProperties = new EnumMap<>(GraphPropertyEnum.class);
         hasProperties.put(GraphPropertyEnum.NAME, name);
@@ -915,7 +913,7 @@ public class ToscaOperationFacade {
         }
         Map<String, Entry<JanusGraphPredicate, Object>> predicateCriteria = getVendorVersionPredicate(vendorRelease);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceRes = janusGraphDao.getByCriteria(null, hasProperties, hasNotProperties,
-            predicateCriteria, parseFlag);
+            predicateCriteria, parseFlag, modelName);
         if (getResourceRes.isRight()) {
             JanusGraphOperationStatus status = getResourceRes.right().value();
             log.debug("failed to find resource with name {}, version {}. Status is {} ", name, predicateCriteria, status);
@@ -1947,7 +1945,7 @@ public class ToscaOperationFacade {
         Map<GraphPropertyEnum, Object> hasNotProps = new EnumMap<>(GraphPropertyEnum.class);
         fillPropsMap(hasProps, hasNotProps, internalComponentType, componentTypeEnum, isAbstract, vertexType, modelName);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getRes = janusGraphDao
-            .getByCriteria(vertexType, hasProps, hasNotProps, JsonParseFlagEnum.ParseMetadata);
+            .getByCriteria(vertexType, hasProps, hasNotProps, JsonParseFlagEnum.ParseMetadata, modelName);
         if (getRes.isRight() && !JanusGraphOperationStatus.NOT_FOUND.equals(getRes.right().value())) {
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getRes.right().value()));
         }
@@ -1969,7 +1967,7 @@ public class ToscaOperationFacade {
         ComponentParametersView params = new ComponentParametersView(true);
         params.setIgnoreAllVersions(false);
         if (getRes.isLeft()) {
-            for (GraphVertex vertexComponent : getVerticesForModel(modelName, getRes.left().value())) {
+            for (GraphVertex vertexComponent : getRes.left().value()) {
                 Either<ToscaElement, StorageOperationStatus> componentRes = topologyTemplateOperation
                     .getLightComponent(vertexComponent, componentTypeEnum, params);
                 if (componentRes.isRight()) {
@@ -2129,13 +2127,13 @@ public class ToscaOperationFacade {
                                                                                             final ComponentTypeEnum componentType) {
         final String normalizedName = ValidationUtils.normaliseComponentName(resourceName);
         final Either<List<GraphVertex>, JanusGraphOperationStatus> vertexEither = janusGraphDao
-            .getByCriteria(getVertexTypeEnum(resourceType), propertiesToMatch(normalizedName, componentType), null, null, JsonParseFlagEnum.NoParse);
+            .getByCriteria(getVertexTypeEnum(resourceType), propertiesToMatch(normalizedName, componentType), null, null, JsonParseFlagEnum.NoParse, modelName);
         if (vertexEither.isRight() && vertexEither.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
             log.debug("failed to get vertex from graph with property normalizedName: {} and model: {}", normalizedName, modelName);
             return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(vertexEither.right().value()));
         }
         return Either.left(CollectionUtils.isEmpty(vertexEither.isLeft() ? vertexEither.left().value().stream()
-            .filter(graphVertex -> graphVertex.getMetadataProperty(GraphPropertyEnum.NAME).equals(modelName)).collect(Collectors.toList()) : null));
+            .collect(Collectors.toList()) : null));
     }
 
     private VertexTypeEnum getVertexTypeEnum(final ResourceTypeEnum resourceType) {
@@ -2359,7 +2357,7 @@ public class ToscaOperationFacade {
     }
 
     public <T extends Component> Either<T, StorageOperationStatus> getLatestByNameAndVersion(String name, String version,
-                                                                                             JsonParseFlagEnum parseFlag) {
+                                                                                             JsonParseFlagEnum parseFlag, String model) {
         Either<T, StorageOperationStatus> result;
         Map<GraphPropertyEnum, Object> hasProperties = new EnumMap<>(GraphPropertyEnum.class);
         Map<GraphPropertyEnum, Object> hasNotProperties = new EnumMap<>(GraphPropertyEnum.class);
@@ -2368,7 +2366,7 @@ public class ToscaOperationFacade {
         hasProperties.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
         hasNotProperties.put(GraphPropertyEnum.IS_DELETED, true);
         Either<List<GraphVertex>, JanusGraphOperationStatus> getResourceRes = janusGraphDao
-            .getByCriteria(null, hasProperties, hasNotProperties, parseFlag);
+            .getByCriteria(null, hasProperties, hasNotProperties, parseFlag, model);
         if (getResourceRes.isRight()) {
             JanusGraphOperationStatus status = getResourceRes.right().value();
             log.debug("failed to find resource with name {}, version {}. Status is {} ", name, version, status);
@@ -2471,10 +2469,10 @@ public class ToscaOperationFacade {
         return null;
     }
 
-    public Either<Boolean, StorageOperationStatus> validateToscaResourceNameExtends(String templateNameCurrent, String templateNameExtends) {
+    public Either<Boolean, StorageOperationStatus> validateToscaResourceNameExtends(String templateNameCurrent, String templateNameExtends, String model) {
         String currentTemplateNameChecked = templateNameExtends;
         while (currentTemplateNameChecked != null && !currentTemplateNameChecked.equalsIgnoreCase(templateNameCurrent)) {
-            Either<Resource, StorageOperationStatus> latestByToscaResourceName = getLatestByToscaResourceName(currentTemplateNameChecked);
+            Either<Resource, StorageOperationStatus> latestByToscaResourceName = getLatestByToscaResourceName(currentTemplateNameChecked, model);
             if (latestByToscaResourceName.isRight()) {
                 return latestByToscaResourceName.right().value() == StorageOperationStatus.NOT_FOUND ? Either.left(false)
                     : Either.right(latestByToscaResourceName.right().value());
@@ -2593,7 +2591,7 @@ public class ToscaOperationFacade {
                                                                                   Map<GraphPropertyEnum, Object> propertiesNotToMatch,
                                                                                   String modelName) {
         Either<List<GraphVertex>, JanusGraphOperationStatus> getRes = janusGraphDao
-            .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll);
+            .getByCriteria(VertexTypeEnum.TOPOLOGY_TEMPLATE, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll, modelName);
         if (getRes.isRight()) {
             if (getRes.right().value() != JanusGraphOperationStatus.NOT_FOUND) {
                 CommonUtility.addRecordToLog(log, LogLevelEnum.DEBUG,
@@ -2602,7 +2600,7 @@ public class ToscaOperationFacade {
                 return Either.right(DaoStatusConverter.convertJanusGraphStatusToStorageStatus(getRes.right().value()));
             }
         } else {
-            for (final GraphVertex vertex : getVerticesForModel(modelName, getRes.left().value())) {
+            for (final GraphVertex vertex : getRes.left().value()) {
                 Either<ToscaElement, StorageOperationStatus> getServiceRes = topologyTemplateOperation
                     .getLightComponent(vertex, ComponentTypeEnum.SERVICE, new ComponentParametersView(true));
                 if (getServiceRes.isRight()) {
index aac1462..7457ed7 100644 (file)
@@ -86,7 +86,7 @@ public interface IElementOperation {
 
     Either<List<CategoryDefinition>, ActionStatus> getAllCategories(NodeTypeEnum nodeType, boolean inTransaction);
     
-    List<BaseType> getBaseTypes(String categoryName);
+    List<BaseType> getBaseTypes(String categoryName, String modelName);
 
     Either<CategoryDefinition, ActionStatus> getCategory(NodeTypeEnum nodeType, String categoryId);
 
index 054788a..42f1b03 100644 (file)
@@ -380,7 +380,7 @@ public class ElementOperation implements IElementOperation {
     }
 
     @Override
-    public List<BaseType> getBaseTypes(final String categoryName){
+    public List<BaseType> getBaseTypes(final String categoryName, final String modelName){
         final ArrayList<BaseType> baseTypes = new ArrayList<>();
         final Map<String, String> categoriesSpecificBaseTypes = ConfigurationManager.getConfigurationManager().getConfiguration().getServiceNodeTypes();
         final String categorySpecificBaseType = categoriesSpecificBaseTypes == null ? null : categoriesSpecificBaseTypes.get(categoryName);
@@ -391,8 +391,8 @@ public class ElementOperation implements IElementOperation {
         props.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, baseToscaResourceName);
         props.put(GraphPropertyEnum.STATE, LifecycleStateEnum.CERTIFIED.name());
         final Either<List<GraphVertex>, JanusGraphOperationStatus> baseTypeVertex = janusGraphDao
-                .getByCriteria(VertexTypeEnum.NODE_TYPE, props, JsonParseFlagEnum.ParseAll);
-
+                .getByCriteria(VertexTypeEnum.NODE_TYPE, props, null, JsonParseFlagEnum.ParseAll, modelName);
+        
         if (baseTypeVertex.isLeft()) {
             BaseType baseType = new BaseType(baseToscaResourceName);
             baseTypes.add(baseType);
index a19e7c4..b88eec2 100644 (file)
@@ -263,10 +263,9 @@ public class ToscaOperationFacadeTest {
         Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesToMatch.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, "toscaResourceName");
         propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
-        propertiesToMatch.put(GraphPropertyEnum.MODEL, null);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
 
-        when(janusGraphDaoMock.getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll))
+        when(janusGraphDaoMock.getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseAll, null))
             .thenReturn(Either.left(list));
         when(topologyTemplateOperationMock.getToscaElement(ArgumentMatchers.eq(graphVertex), any(ComponentParametersView.class)))
             .thenReturn(Either.left(toscaElement));
@@ -437,12 +436,12 @@ public class ToscaOperationFacadeTest {
     public void testGetLatestByToscaResourceName() {
         Either<Component, StorageOperationStatus> result;
         String toscaResourceName = "name";
+        String model = "testModel";
         ToscaElement toscaElement = getToscaElementForTest();
 
         Map<GraphPropertyEnum, Object> propertiesToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesToMatch.put(GraphPropertyEnum.TOSCA_RESOURCE_NAME, toscaResourceName);
         propertiesToMatch.put(GraphPropertyEnum.IS_HIGHEST_VERSION, true);
-        propertiesToMatch.put(GraphPropertyEnum.MODEL, null);
         Map<GraphPropertyEnum, Object> propertiesNotToMatch = new EnumMap<>(GraphPropertyEnum.class);
         propertiesNotToMatch.put(GraphPropertyEnum.IS_DELETED, true);
 
@@ -454,11 +453,11 @@ public class ToscaOperationFacadeTest {
         graphVertex.setMetadataProperties(props);
         graphVertexList.add(graphVertex);
 
-        when(janusGraphDaoMock.getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseMetadata))
+        when(janusGraphDaoMock.getByCriteria(null, propertiesToMatch, propertiesNotToMatch, JsonParseFlagEnum.ParseMetadata, model))
             .thenReturn(Either.left(graphVertexList));
         when(topologyTemplateOperationMock.getToscaElement(any(GraphVertex.class), any(ComponentParametersView.class)))
             .thenReturn(Either.left(toscaElement));
-        result = testInstance.getLatestByToscaResourceName(toscaResourceName);
+        result = testInstance.getLatestByToscaResourceName(toscaResourceName, model);
         assertTrue(result.isLeft());
     }
 
index 230fbe1..d8b7e53 100644 (file)
@@ -490,7 +490,7 @@ public class ElementOperationTest extends ModelTestBase {
 
             GraphVertex baseTypeVertex = mock(GraphVertex.class);
             when(baseTypeVertex.getMetadataProperty(GraphPropertyEnum.VERSION)).thenReturn("1.0");
-            when(healingJanusGraphDao.getByCriteria(any(), any(), any()))
+            when(healingJanusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), any(), isNull(), eq(JsonParseFlagEnum.ParseAll), any()))
                     .thenReturn(Either.left(Collections.singletonList(baseTypeVertex)));
 
             GraphVertex derivedTypeVertex = mock(GraphVertex.class);
@@ -508,7 +508,7 @@ public class ElementOperationTest extends ModelTestBase {
             when(derivedTypeVertex.getMetadataProperty(GraphPropertyEnum.TOSCA_RESOURCE_NAME))
                     .thenReturn("org.parent.type");
 
-            List<BaseType> baseTypes = elementOperation.getBaseTypes("serviceCategoryA");
+            List<BaseType> baseTypes = elementOperation.getBaseTypes("serviceCategoryA", null);
 
             assertEquals(2, baseTypes.size());
             assertEquals("org.base.type", baseTypes.get(0).getToscaResourceName());
@@ -539,13 +539,13 @@ public class ElementOperationTest extends ModelTestBase {
 
             GraphVertex baseTypeVertex = mock(GraphVertex.class);
             when(baseTypeVertex.getMetadataProperty(GraphPropertyEnum.VERSION)).thenReturn("1.0");
-            when(healingJanusGraphDao.getByCriteria(any(), any(), any()))
+            when(healingJanusGraphDao.getByCriteria(eq(VertexTypeEnum.NODE_TYPE), any(), isNull(), eq(JsonParseFlagEnum.ParseAll), any()))
                     .thenReturn(Either.left(Collections.singletonList(baseTypeVertex)));
 
             when(healingJanusGraphDao.getParentVertices(baseTypeVertex, EdgeLabelEnum.DERIVED_FROM,
                     JsonParseFlagEnum.ParseAll)).thenReturn(Either.right(JanusGraphOperationStatus.NOT_FOUND));
 
-            List<BaseType> baseTypes = elementOperation.getBaseTypes("serviceCategoryA");
+            List<BaseType> baseTypes = elementOperation.getBaseTypes("serviceCategoryA", null);
 
             assertEquals(1, baseTypes.size());
             assertEquals("org.service.default", baseTypes.get(0).getToscaResourceName());
index a2d28eb..6d176df 100644 (file)
@@ -147,7 +147,7 @@ export abstract class Component implements IComponent {
     public categorySpecificMetadata: Metadata = new Metadata();
     public derivedFromGenericType: string;
     public derivedFromGenericVersion: string;
-    public model: Model;
+    public model: string;
 
     constructor(componentService:IComponentService, protected $q:ng.IQService, component?:Component) {
         if (component) {
index fbbc4d8..8e483ea 100644 (file)
@@ -1146,7 +1146,7 @@ export class PropertiesAssignmentComponent {
     }
 
     /*** addProperty ***/
-    addProperty = (model: Model) => {
+    addProperty = (model: string) => {
         this.loadDataTypesByComponentModel(model)
         let modalTitle = 'Add Property';
         let modal = this.ModalService.createCustomModal(new ModalModel(
@@ -1251,9 +1251,8 @@ export class PropertiesAssignmentComponent {
         return instanceType === ResourceType.VF || instanceType === ResourceType.PNF || instanceType === ResourceType.CVFC || instanceType === ResourceType.CR;
     }
 
-    loadDataTypesByComponentModel(model:Model) {
-        let modelName = new Model(model).name;
-        this.propertyCreatorComponent.filterDataTypesByModel(modelName);
+    loadDataTypesByComponentModel(model:string) {
+        this.propertyCreatorComponent.filterDataTypesByModel(model);
     }
 
 }
index 97efbcc..b3cf8c3 100644 (file)
@@ -33,8 +33,9 @@ export class ElementService {
         this.baseUrl = sdcConfig.api.root;
     }
 
-    getCategoryBasetypes(categoryName:string):Observable<BaseTypeResponse[]> {
-        return this.http.get<ListBaseTypesResponse>(this.baseUrl + "/v1/category/services/" + categoryName + "/baseTypes")
+    getCategoryBasetypes(categoryName:string, modelName:string):Observable<BaseTypeResponse[]> {
+           let modelQueryParam: string = modelName ? '?model=' + modelName : '';
+        return this.http.get<ListBaseTypesResponse>(this.baseUrl + "/v1/category/services/" + categoryName + "/baseTypes" + modelQueryParam)
             .pipe(map(response => response.baseTypes));
     }
 
index fa3de88..aaf1054 100644 (file)
@@ -62,7 +62,7 @@ export class ComponentGenericResponse  implements Serializable<ComponentGenericR
     public substitutionFilters: any;
     public derivedFromGenericType;
     public derivedFromGenericVersion;
-    public model:Model;
+    public model:string;
 
     deserialize (response): ComponentGenericResponse {
 
index 5e48dc8..fe578b6 100644 (file)
@@ -135,7 +135,7 @@ export abstract class PropertyFormBaseView {
         this.$scope.property = new PropertyModel(this.originalProperty); //we create a new Object so if user press cance we won't update the property
         this.$scope.types = PROPERTY_DATA.TYPES; //All types - simple type + map + list
         this.$scope.simpleTypes = PROPERTY_DATA.SIMPLE_TYPES; //All simple types
-        this.$scope.dataTypes = this.DataTypesService.getAllDataTypesFromModel(this.component.model.name); //Get all data types in service
+        this.$scope.dataTypes = this.DataTypesService.getAllDataTypesFromModel(this.component.model); //Get all data types in service
         this.$scope.modalPropertyFormBase = this.$uibModalInstance;
         this.$scope.isNew = !angular.isDefined(this.$scope.property.name);
 
index 9be3b64..2e8788f 100644 (file)
@@ -63,7 +63,7 @@ export class SelectDataTypeViewModel extends PropertyFormBaseView {
 
         this.$templateCache.put("select-datatype-modal-view.html", require('app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html'));
         this.$scope.innerViewSrcUrl = "select-datatype-modal-view.html";
-        this.$scope.modelNameFilter = this.component.model.name;
+        this.$scope.modelNameFilter = this.component.model;
         this.initChildScope();
     }
 
index 20eaec6..c78852d 100644 (file)
@@ -451,7 +451,8 @@ export class GeneralViewModel {
 
         this.$scope.initBaseTypes = ():void => {
             if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component && this.$scope.component.categories) {
-                 this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name).subscribe((data: BaseTypeResponse[]) => {
+                    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 => {
@@ -682,7 +683,8 @@ export class GeneralViewModel {
                 }
             }
             if (this.$scope.componentType === ComponentType.SERVICE && this.$scope.component.categories[0]) {
-                   this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name).subscribe((data: BaseTypeResponse[]) => {
+                   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 = []
@@ -709,7 +711,8 @@ export class GeneralViewModel {
         };
 
         this.$scope.onBaseTypeChange = (): void => {
-            this.elementService.getCategoryBasetypes(this.$scope.component.categories[0].name).subscribe((data: BaseTypeResponse[]) => {
+               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) {
@@ -720,6 +723,20 @@ export class GeneralViewModel {
              })
         };
 
+        this.$scope.onModelChange = (): 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));
+                        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.$scope.onVendorNameChange = (oldVendorName: string): void => {
             if (this.$scope.component.icon === oldVendorName) {
                 this.$scope.component.icon = DEFAULT_ICON;
index d84f4c8..fa4af6d 100644 (file)
                             data-ng-class="{'view-mode': isViewMode()}"
                             data-ng-disabled="component.isCsarComponent() || !isCreateMode()"
                             data-ng-model="component.model"
+                            data-ng-change="onModelChange()"
                             data-tests-id="modelName">
                       <option value="">SDC AID</option>
                       <option ng-repeat="model in models | orderBy:[name]">{{model}}</option>