Heal Vertex Data
Enable healing of vertex information when reading it.
Issue-ID: SDC-2213
Change-Id: I907beeb25bd231d9e05d3a5b8e070d6bdf9cb781
Signed-off-by: shrek2000 <orenkle@amdocs.com>
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/filters/BeServletFilter.java b/catalog-be/src/main/java/org/openecomp/sdc/be/filters/BeServletFilter.java
index bdee21e..3a823de 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/be/filters/BeServletFilter.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/be/filters/BeServletFilter.java
@@ -25,7 +25,7 @@
import org.openecomp.sdc.be.config.Configuration;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.api.ActionStatus;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.common.api.Constants;
@@ -146,7 +146,7 @@
private void writeToTitan(ContainerResponseContext responseContext) {
log.debug("Close transaction from filter");
- TitanDao titanDao = getTitanDao();
+ HealingTitanDao titanDao = getTitanDao();
if (titanDao != null) {
int status = responseContext.getStatus();
if (status == Response.Status.OK.getStatusCode() ||
@@ -202,12 +202,12 @@
return webApplicationContext.getBean(ComponentsUtils.class);
}
- private TitanDao getTitanDao() {
+ private HealingTitanDao getTitanDao() {
ServletContext context = this.sr.getSession().getServletContext();
WebAppContextWrapper webApplicationContextWrapper = (WebAppContextWrapper) context.getAttribute(Constants.WEB_APPLICATION_CONTEXT_WRAPPER_ATTR);
WebApplicationContext webApplicationContext = webApplicationContextWrapper.getWebAppContext(context);
- return webApplicationContext.getBean(TitanDao.class);
+ return webApplicationContext.getBean(HealingTitanDao.class);
}
// Extracted for purpose of clear method name, for logback %M parameter
diff --git a/catalog-be/src/main/java/org/openecomp/sdc/config/CatalogBESpringConfig.java b/catalog-be/src/main/java/org/openecomp/sdc/config/CatalogBESpringConfig.java
index 6c6d2cb..aa5cdac 100644
--- a/catalog-be/src/main/java/org/openecomp/sdc/config/CatalogBESpringConfig.java
+++ b/catalog-be/src/main/java/org/openecomp/sdc/config/CatalogBESpringConfig.java
@@ -25,8 +25,7 @@
"org.openecomp.sdc.be.components.csar",
"org.openecomp.sdc.be.components.property",
"org.openecomp.sdc.be.datamodel.utils",
- "org.openecomp.sdc.be.components.upgrade"
-})
+ "org.openecomp.sdc.be.components.upgrade"})
public class CatalogBESpringConfig {
private static final int BEFORE_TRANSACTION_MANAGER = 0;
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/HealStatusDaoMock.java b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/HealStatusDaoMock.java
new file mode 100644
index 0000000..1c9bd0e
--- /dev/null
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/components/path/beans/HealStatusDaoMock.java
@@ -0,0 +1,23 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.be.components.path.beans;
+
+
+
+public class HealStatusDaoMock {
+
+
+}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java
index f7e59e6..7d949a1 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/externalapi/servlet/ExternalRefServletTest.java
@@ -20,6 +20,7 @@
package org.openecomp.sdc.be.externalapi.servlet;
+import com.google.common.collect.ImmutableListMultimap;
import fj.data.Either;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
@@ -36,8 +37,14 @@
import org.openecomp.sdc.be.dao.DAOTitanStrategy;
import org.openecomp.sdc.be.dao.TitanClientStrategy;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
@@ -63,10 +70,12 @@
import org.openecomp.sdc.common.impl.ExternalConfiguration;
import org.openecomp.sdc.common.impl.FSConfigurationSource;
import org.openecomp.sdc.exception.ResponseFormat;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpStatus;
import org.springframework.web.context.WebApplicationContext;
@@ -105,11 +114,10 @@
private static final ToscaOperationFacade toscaOperationFacadeMock = Mockito.mock(ToscaOperationFacade.class);
private static final AccessValidations accessValidationsMock = Mockito.mock(AccessValidations.class);
private static final ComponentLocker componentLocker = Mockito.mock(ComponentLocker.class);
- private static final TitanGenericDao titanGenericDao = Mockito.mock(TitanGenericDao.class);
+ private static final HealingTitanGenericDao titanGenericDao = Mockito.mock(HealingTitanGenericDao.class);
private static final ICacheMangerOperation cacheManagerOperation = Mockito.mock(ICacheMangerOperation.class);
private static final IGraphLockOperation graphLockOperation = Mockito.mock(IGraphLockOperation.class);
-
private static final String COMPONENT_ID = "ci-MyComponentName";
private static final String FAKE_COMPONENT_ID = "ci-MyFAKEComponentName";
@@ -126,12 +134,13 @@
private static final String REF_6 = "ref6";
@Configuration
+ @PropertySource("classpath:dao.properties")
static class TestSpringConfig {
private GraphVertex serviceVertex;
private GraphVertex resourceVertex;
private ExternalReferencesOperation externalReferenceOperation;
- private TitanDao titanDao;
+ private HealingTitanDao titanDao;
private OperationUtils operationUtils;
@Bean
@@ -170,6 +179,7 @@
@Bean
ExternalReferencesOperation externalReferencesOperation() {
this.externalReferenceOperation = new ExternalReferencesOperation(titanDao(), nodeTypeOpertaion(), topologyTemplateOperation(), idMapper());
+ this.externalReferenceOperation.setHealingPipelineDao(healingPipelineDao());
GraphTestUtils.clearGraph(titanDao);
initGraphForTest();
return this.externalReferenceOperation;
@@ -191,7 +201,7 @@
@Bean
TopologyTemplateOperation topologyTemplateOperation() {
- return new TopologyTemplateOperation();
+ return new TopologyTemplateOperation();
}
@Bean
@@ -225,8 +235,8 @@
}
@Bean
- TitanDao titanDao() {
- this.titanDao = new TitanDao(titanGraphClient());
+ HealingTitanDao titanDao() {
+ this.titanDao = new HealingTitanDao(titanGraphClient());
return titanDao;
}
@@ -255,6 +265,15 @@
return titanGenericDao;
}
+ @Bean("healingPipelineDao")
+ HealingPipelineDao healingPipelineDao() {
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao() ;
+ healingPipelineDao.setHealVersion(1);
+ healingPipelineDao.initHealVersion();
+ return healingPipelineDao;
+ }
+
+
private void initGraphForTest() {
if (!setupDone) {
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java
index 2c3d411..aea9908 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/ArchiveEndpointTest.java
@@ -20,11 +20,29 @@
package org.openecomp.sdc.be.servlets;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import fj.data.Either;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.client.Entity;
+import javax.ws.rs.core.Application;
+import javax.ws.rs.core.GenericType;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.openecomp.sdc.be.components.impl.ArchiveBusinessLogic;
import org.openecomp.sdc.be.components.impl.exceptions.ComponentException;
@@ -35,20 +53,32 @@
import org.openecomp.sdc.be.dao.DAOTitanStrategy;
import org.openecomp.sdc.be.dao.TitanClientStrategy;
import org.openecomp.sdc.be.dao.api.ActionStatus;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.*;
+import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.JsonPresentationFields;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
import org.openecomp.sdc.be.impl.ComponentsUtils;
import org.openecomp.sdc.be.impl.ServletUtils;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.model.LifecycleStateEnum;
import org.openecomp.sdc.be.model.User;
import org.openecomp.sdc.be.model.catalog.CatalogComponent;
-import org.openecomp.sdc.be.model.jsontitan.operations.*;
+import org.openecomp.sdc.be.model.jsontitan.operations.ArchiveOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.CategoryOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.GroupsOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.NodeTemplateOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.NodeTypeOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.TopologyTemplateOperation;
+import org.openecomp.sdc.be.model.jsontitan.operations.ToscaOperationFacade;
import org.openecomp.sdc.be.model.operations.api.ICacheMangerOperation;
import org.openecomp.sdc.be.model.operations.api.IGraphLockOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
@@ -66,27 +96,10 @@
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
import org.springframework.http.HttpStatus;
import org.springframework.web.context.WebApplicationContext;
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.client.Entity;
-import javax.ws.rs.core.Application;
-import javax.ws.rs.core.GenericType;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.*;
-
public class ArchiveEndpointTest extends JerseyTest {
private static final ServletContext servletContext = mock(ServletContext.class);
@@ -105,16 +118,17 @@
private static final AccessValidations accessValidationsMock = mock(AccessValidations.class);
private static final ComponentValidations componentValidationsMock = mock(ComponentValidations.class);
private static final IGraphLockOperation graphLockOperation = mock(IGraphLockOperation.class);
- private static final TitanGenericDao titanGenericDao = mock(TitanGenericDao.class);
-
+ private static final HealingTitanGenericDao titanGenericDao = mock(HealingTitanGenericDao.class);
+ private static final HealingPipelineDao HEALING_PIPELINE_DAO = mock(HealingPipelineDao.class);
private static final ICacheMangerOperation cacheManagerOperation = mock(ICacheMangerOperation.class);
private static GraphVertex serviceVertex;
private static GraphVertex resourceVertex;
private static GraphVertex resourceVertexVspArchived;
- private static TitanDao titanDao;
+ private static HealingTitanDao titanDao;
@Configuration
+ @PropertySource("classpath:dao.properties")
static class TestSpringConfig {
private ArchiveOperation archiveOperation;
private GraphVertex catalogVertex;
@@ -193,8 +207,8 @@
}
@Bean
- TitanDao titanDao() {
- titanDao = new TitanDao(titanGraphClient());
+ HealingTitanDao titanDao() {
+ titanDao = new HealingTitanDao(titanGraphClient());
return titanDao;
}
@@ -223,6 +237,11 @@
return titanGenericDao;
}
+ @Bean
+ HealingPipelineDao healingPipelineDao(){
+ return HEALING_PIPELINE_DAO;
+ }
+
private void initGraphForTest() {
//Create Catalog Root
catalogVertex = GraphTestUtils.createRootCatalogVertex(titanDao);
@@ -264,7 +283,7 @@
/* Users */
private static final User adminUser = new User("admin", "admin", "admin", "admin@email.com", Role.ADMIN.name(), System.currentTimeMillis());
private static final User designerUser = new User("designer", "designer", "designer", "designer@email.com", Role.DESIGNER.name(), System
- .currentTimeMillis());
+ .currentTimeMillis());
private static final User otherUser = new User("other", "other", "other", "other@email.com", Role.OPS.name(), System.currentTimeMillis());
@BeforeClass
@@ -336,11 +355,11 @@
csarIds.add("123456");
csarIds.add(CSAR_UUID2); //An archived CSAR ID
Response response = target()
- .path(path)
- .request(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON)
- .header(Constants.USER_ID_HEADER, designerUser.getUserId())
- .post(Entity.json(csarIds));
+ .path(path)
+ .request(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+ .post(Entity.json(csarIds));
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertOnVertexProp(resourceVertexVspArchived.getUniqueId(), true);
@@ -353,11 +372,11 @@
csarIds.add("123456");
csarIds.add(CSAR_UUID1); //Non archived CSAR_ID
Response response = target()
- .path(path)
- .request(MediaType.APPLICATION_JSON)
- .accept(MediaType.APPLICATION_JSON)
- .header(Constants.USER_ID_HEADER, designerUser.getUserId())
- .post(Entity.json(csarIds));
+ .path(path)
+ .request(MediaType.APPLICATION_JSON)
+ .accept(MediaType.APPLICATION_JSON)
+ .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+ .post(Entity.json(csarIds));
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
assertOnVertexProp(resourceVertex.getUniqueId(), false);
@@ -380,11 +399,11 @@
public void archiveWithTester() {
String path = String.format("/v1/catalog/services/%s/%s", serviceVertex.getUniqueId(), "archive");
Response response = target()
- .path(path)
- .request()
- .accept(MediaType.APPLICATION_JSON)
- .header(Constants.USER_ID_HEADER, otherUser.getUserId())
- .post(null);
+ .path(path)
+ .request()
+ .accept(MediaType.APPLICATION_JSON)
+ .header(Constants.USER_ID_HEADER, otherUser.getUserId())
+ .post(null);
assertThat(response.getStatus()).isEqualTo(HttpStatus.UNAUTHORIZED.value());
}
@@ -410,11 +429,11 @@
private void archiveOrRestoreComponent(String compUid, ArchiveOperation.Action action, int expectedStatus) {
String path = String.format("/v1/catalog/services/%s/%s", compUid, action.name().toLowerCase());
Response response = target()
- .path(path)
- .request()
- .accept(MediaType.APPLICATION_JSON)
- .header(Constants.USER_ID_HEADER, designerUser.getUserId())
- .post(null);
+ .path(path)
+ .request()
+ .accept(MediaType.APPLICATION_JSON)
+ .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+ .post(null);
assertThat(response.getStatus()).isEqualTo(expectedStatus);
}
@@ -423,11 +442,11 @@
String path = "/v1/catalog/archive";
Response response = target()
- .path(path)
- .request()
- .accept(MediaType.APPLICATION_JSON)
- .header(Constants.USER_ID_HEADER, designerUser.getUserId())
- .get();
+ .path(path)
+ .request()
+ .accept(MediaType.APPLICATION_JSON)
+ .header(Constants.USER_ID_HEADER, designerUser.getUserId())
+ .get();
Map<String, List<CatalogComponent>> archivedComponents = response.readEntity(new GenericType<Map<String, List<CatalogComponent>>>() { });
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
@@ -444,9 +463,9 @@
protected Application configure() {
ApplicationContext context = new AnnotationConfigApplicationContext(TestSpringConfig.class);
return new ResourceConfig(ArchiveEndpoint.class)
- .register(DefaultExceptionMapper.class)
- .register(ComponentExceptionMapper.class)
- .register(StorageExceptionMapper.class)
- .property("contextConfig", context);
+ .register(DefaultExceptionMapper.class)
+ .register(ComponentExceptionMapper.class)
+ .register(StorageExceptionMapper.class)
+ .property("contextConfig", context);
}
}
diff --git a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java
index 8638de3..5eecc77 100644
--- a/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java
+++ b/catalog-be/src/test/java/org/openecomp/sdc/be/servlets/TypesUploadEndpointTest.java
@@ -18,6 +18,7 @@
import org.mockito.Mockito;
import org.openecomp.sdc.be.components.impl.CommonImportManager;
import org.openecomp.sdc.be.components.validation.AccessValidations;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -55,7 +56,7 @@
static final String userId = "jh0003";
private static AccessValidations accessValidations;
- private static TitanGenericDao titanGenericDao;
+ private static HealingTitanGenericDao titanGenericDao;
private static PropertyOperation propertyOperation;
private static ComponentsUtils componentUtils;
private static OperationUtils operationUtils;
@@ -87,7 +88,7 @@
@BeforeClass
public static void initClass() {
- titanGenericDao = mock(TitanGenericDao.class);
+ titanGenericDao = mock(HealingTitanGenericDao.class);
accessValidations = mock(AccessValidations.class);
propertyOperation = mock(PropertyOperation.class);
componentUtils = Mockito.mock(ComponentsUtils.class);
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
index 99979ba..99acb3b 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/DAOSpringConfig.java
@@ -23,6 +23,7 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
+import org.springframework.context.annotation.PropertySource;
@Configuration
@Import({TitanSpringConfig.class})
@@ -33,10 +34,7 @@
"org.openecomp.sdc.be.dao.impl",
"org.openecomp.sdc.be.resources.impl"
})
+@PropertySource("classpath:dao.properties")
public class DAOSpringConfig {
-
-
-
-
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
index 6360af8..34a860d 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/config/TitanSpringConfig.java
@@ -2,7 +2,8 @@
import org.openecomp.sdc.be.dao.DAOTitanStrategy;
import org.openecomp.sdc.be.dao.TitanClientStrategy;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
import org.openecomp.sdc.be.dao.titan.transactions.SimpleTitanTransactionManager;
import org.springframework.beans.factory.annotation.Qualifier;
@@ -22,8 +23,8 @@
@Bean(name = "titan-generic-dao")
@Primary
- public TitanGenericDao titanGenericDao(@Qualifier("titan-client") TitanGraphClient titanGraphClient) {
- return new TitanGenericDao(titanGraphClient);
+ public HealingTitanGenericDao titanGenericDao(@Qualifier("titan-client") TitanGraphClient titanGraphClient) {
+ return new HealingTitanGenericDao(titanGraphClient);
}
@Bean(name = "titan-client", initMethod = "createGraph")
@@ -41,4 +42,12 @@
public PlatformTransactionManager txManager() {
return new SimpleTitanTransactionManager(titanGraphClient(titanClientStrategy()));
}
+
+ @Bean(name = "healingPipelineDao")
+ public HealingPipelineDao healingPipeline(){
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(1);
+ healingPipelineDao.initHealVersion();
+ return healingPipelineDao;
+ }
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
index 35ab30c..3375719 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/graph/datatype/GraphNode.java
@@ -21,12 +21,13 @@
package org.openecomp.sdc.be.dao.graph.datatype;
import com.google.gson.Gson;
-import org.apache.commons.lang3.tuple.ImmutablePair;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-
import java.util.List;
import java.util.Map;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
+import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
public abstract class GraphNode extends GraphElement {
@@ -61,15 +62,39 @@
}
}
+
+
+ public abstract String getUniqueId();
+
+
public String getUniqueIdKey() {
return GraphPropertiesDictionary.UNIQUE_ID.getProperty();
}
- public abstract String getUniqueId();
+ public String getHealingVersionKey() {
+ return GraphPropertyEnum.HEALING_VERSION.getProperty();
+ }
+
+ /**
+ * Must be overridden in implelemting classes
+ * @return current heal version. Default heal version if function not implemented.
+ */
+ public Integer getHealingVersion(){
+ return HealConstants.DEFAULT_HEAL_VERSION;
+ }
+
+ /**
+ * Must be overriden in implementing classes
+ * @param version healing version number
+ */
+ public void setHealingVersion(Integer version){
+
+ }
@Override
public String toString() {
return "GraphNode [label=" + label + ", parent: " + super.toString() + "]";
}
+
}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
new file mode 100644
index 0000000..5b219b2
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/HealingPipelineDao.java
@@ -0,0 +1,172 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.dao.impl;
+
+import static java.util.stream.Collectors.joining;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableListMultimap;
+import com.thinkaurelius.titan.core.TitanVertex;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Objects;
+import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
+import javax.annotation.PostConstruct;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphElement;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
+import org.openecomp.sdc.be.dao.impl.heal.HealGraphDao;
+import org.openecomp.sdc.be.dao.impl.heal.HealNodeGraphDao;
+import org.openecomp.sdc.be.dao.impl.heal.HealTitanGraphDao;
+import org.openecomp.sdc.be.dao.impl.heal.HealVertexGraphDao;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+@Component("healingPipelineDao")
+public class HealingPipelineDao {
+
+ private static Logger logger = Logger.getLogger(HealingPipelineDao.class.getName());
+
+ private HealVersion<Integer> currentHealVersion;
+
+ @Value("${current.heal.version}")
+ private Integer healVersion;
+
+ private ImmutableListMultimap<String, Heal> healingPipeline;
+
+ private HealGraphDao healNodeGraphDao;
+ private HealGraphDao healVertexGraphDao;
+ private HealGraphDao healTitanVertexGraphDao;
+
+ public HealingPipelineDao() {
+ healingPipeline = ImmutableListMultimap.of();
+ checkValidation(healingPipeline);
+ }
+
+ @PostConstruct
+ public void initHealVersion() {
+ currentHealVersion = HealVersionBuilder.build(healVersion);
+ }
+
+ @PostConstruct
+ public void initGraphHealers() {
+ healNodeGraphDao = new HealNodeGraphDao(this);
+ healVertexGraphDao = new HealVertexGraphDao(this);
+ healTitanVertexGraphDao = new HealTitanGraphDao(this);
+ }
+
+
+ private HealGraphDao supplyHealer(Object graphNode) {
+ if (graphNode instanceof GraphVertex) {
+ return healVertexGraphDao;
+ }
+ if (graphNode instanceof GraphElement) {
+ return healNodeGraphDao;
+ }
+ if (graphNode instanceof TitanVertex) {
+ return healTitanVertexGraphDao;
+ }
+
+ return null;
+ }
+
+
+ public ImmutableListMultimap<String, Heal> getHealingPipeline() {
+ return healingPipeline;
+ }
+
+ public boolean shouldHeal(HealVersion<Integer> healerVersion, HealVersion<Integer> vertexVersion) {
+ Objects.requireNonNull(healerVersion);
+ Objects.requireNonNull(vertexVersion);
+ if (healerVersion.compareTo(currentHealVersion) >= 0) {
+ return false;
+ }
+ return healerVersion.compareTo(vertexVersion) >= 0;
+ }
+
+ public void setHealVersion(Integer healVersion) {
+ this.healVersion = healVersion;
+ }
+
+
+ public ImmutableList<Heal> getHealersForVertex(String edgeLabelEnum, HealVersion<Integer> vertexVersion) {
+ final ImmutableList<Heal> vertexHeals = getHealingPipeline().get(edgeLabelEnum);
+ List<Heal> list = new ArrayList<>();
+ for (Heal heal : vertexHeals) {
+ if (shouldHeal(heal.fromVersion(), vertexVersion)) {
+ list.add(heal);
+ }
+ }
+ return ImmutableList.copyOf(list);
+ }
+
+
+ public void setHealingPipeline(ImmutableListMultimap<String, Heal> healingPipeline) {
+ checkValidation(healingPipeline);
+ this.healingPipeline = healingPipeline;
+ }
+
+
+ public void setHealingVersion(final GraphVertex graphVertex) {
+ graphVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, currentHealVersion.getVersion());
+ }
+
+ public void setHealingVersion(TitanVertex graphVertex) {
+ graphVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), currentHealVersion.getVersion());
+ }
+
+ public void setHealingVersion(GraphNode graphNode) {
+ graphNode.setHealingVersion(currentHealVersion.getVersion());
+ }
+
+ public HealVersion<Integer> getCurrentHealVersion() {
+ return currentHealVersion;
+ }
+
+ public Optional performGraphReadHealing(Object graphNode, Object edgeLabel) {
+ HealGraphDao healGraphDao = supplyHealer(graphNode);
+ if (healGraphDao == null) {
+ logger.error("Unexpected graph node : {}", graphNode.getClass().getCanonicalName());
+ return Optional.empty();
+ }
+ return Optional.of(healGraphDao.performGraphReadHealing(graphNode, edgeLabel));
+ }
+
+ /**
+ * prevent duplicated healing version for same edge label.
+ */
+ private void checkValidation(ImmutableListMultimap<String, Heal> listMultimap) {
+ listMultimap.keySet().forEach(key -> this.validNoDuplicates(key, listMultimap.get(key)));
+ }
+
+ private void validNoDuplicates(String key, List<Heal> heals) {
+ Set<Integer> duplicatedVersionSet = new HashSet<>();
+ Set<Integer> duplicatedNumbersSet = heals.stream().map(heal -> ((HealVersion<Integer>) heal.fromVersion()).getVersion()).filter(n -> !duplicatedVersionSet.add(n)).collect(Collectors.toSet());
+ if (!duplicatedNumbersSet.isEmpty()) {
+ throw new IllegalStateException(String.format("Edge label %s , contains multiple healing with same version %s", key, duplicatedNumbersSet.stream().map(Object::toString).collect(joining(" , ", "[ ", " ]"))));
+ }
+ }
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealGraphDao.java
new file mode 100644
index 0000000..b8e5a3c
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealGraphDao.java
@@ -0,0 +1,6 @@
+package org.openecomp.sdc.be.dao.impl.heal;
+
+@FunctionalInterface
+public interface HealGraphDao<G,L> {
+ G performGraphReadHealing(G childVertex, L edgeLabelEnum);
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
new file mode 100644
index 0000000..2fc5c8f
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealNodeGraphDao.java
@@ -0,0 +1,35 @@
+package org.openecomp.sdc.be.dao.impl.heal;
+
+import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
+
+public class HealNodeGraphDao implements HealGraphDao<GraphNode, GraphEdge> {
+
+ private HealingPipelineDao healingPipelineDao;
+
+
+ public HealNodeGraphDao(HealingPipelineDao healingPipelineDao) {
+ this.healingPipelineDao = healingPipelineDao;
+ }
+
+ @Override
+ public GraphNode performGraphReadHealing(GraphNode childVertex, GraphEdge graphEdge) {
+ Integer healingVersionInt = childVertex.getHealingVersion();
+ HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
+ healingPipelineDao.getHealersForVertex(graphEdge.getEdgeType().getProperty(), healingVersion).forEach(heal -> healTitanVertex(childVertex, heal));
+ childVertex.setHealingVersion(healingPipelineDao.getCurrentHealVersion().getVersion());
+ return childVertex;
+ }
+
+ private GraphNode healTitanVertex(GraphNode childVertex, Heal<GraphNode> heal) {
+ heal.healData(childVertex);
+ final HealVersion<Integer> healVersion = heal.fromVersion();
+ HealVersion<Integer> newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
+ childVertex.setHealingVersion(newerVersion.getVersion());
+ return childVertex;
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java
new file mode 100644
index 0000000..1e33c61
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealTitanGraphDao.java
@@ -0,0 +1,38 @@
+package org.openecomp.sdc.be.dao.impl.heal;
+
+import com.thinkaurelius.titan.core.TitanVertex;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+
+public class HealTitanGraphDao implements HealGraphDao<TitanVertex, GraphEdgeLabels> {
+
+ private HealingPipelineDao healingPipelineDao;
+
+ public HealTitanGraphDao(HealingPipelineDao healingPipelineDao) {
+ this.healingPipelineDao = healingPipelineDao;
+ }
+
+ @Override
+ public TitanVertex performGraphReadHealing(TitanVertex childVertex, GraphEdgeLabels graphEdgeLabels) {
+ final Integer healingVersionInt = (Integer) childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty()).orElse(HealConstants.DEFAULT_HEAL_VERSION);
+ HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
+ healingPipelineDao.getHealersForVertex(graphEdgeLabels.name(), healingVersion).forEach(heal -> healGraphVertex(childVertex, heal));
+ childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), healingPipelineDao.getCurrentHealVersion().getVersion());
+ return childVertex;
+ }
+
+
+ private TitanVertex healGraphVertex(TitanVertex childVertex, Heal<TitanVertex> heal) {
+ heal.healData(childVertex);
+ final HealVersion<Integer> healVersion = heal.fromVersion();
+ HealVersion newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
+ childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty(), newerVersion);
+ heal.healData(childVertex);
+ return childVertex;
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealVertexGraphDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealVertexGraphDao.java
new file mode 100644
index 0000000..b8eb670
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/impl/heal/HealVertexGraphDao.java
@@ -0,0 +1,39 @@
+package org.openecomp.sdc.be.dao.impl.heal;
+
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+
+public class HealVertexGraphDao implements HealGraphDao<GraphVertex, EdgeLabelEnum> {
+
+ private HealingPipelineDao healingPipelineDao;
+
+ public HealVertexGraphDao(HealingPipelineDao healingPipelineDao) {
+ this.healingPipelineDao = healingPipelineDao;
+ }
+
+ @Override
+ public GraphVertex performGraphReadHealing( GraphVertex childVertex, EdgeLabelEnum edgeLabelEnum) {
+ final Integer healingVersionInt = (Integer) childVertex.getMetadataProperties()
+ .getOrDefault(GraphPropertyEnum.HEALING_VERSION, HealConstants.DEFAULT_HEAL_VERSION);
+ HealVersion<Integer> healingVersion = HealVersionBuilder.build(healingVersionInt);
+ healingPipelineDao.getHealersForVertex(edgeLabelEnum.name(), healingVersion).forEach(heal -> healGraphVertex(childVertex, heal));
+ childVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, healingPipelineDao.getCurrentHealVersion().getVersion());
+ return childVertex;
+ }
+
+
+ private GraphVertex healGraphVertex(GraphVertex childVertex, Heal<GraphVertex> heal) {
+ heal.healData(childVertex);
+ final HealVersion<Integer> healVersion = heal.fromVersion();
+ HealVersion newerVersion = HealVersionBuilder.build(healVersion.getVersion() + 1);
+ childVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, newerVersion);
+ heal.healData(childVertex);
+ return childVertex;
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java
new file mode 100644
index 0000000..fb6b9d8
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/HealingTitanDao.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.dao.jsongraph;
+
+import fj.data.Either;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
+import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component("titan-dao")
+public class HealingTitanDao extends TitanDao {
+
+
+ @Autowired
+ private HealingPipelineDao healingPipelineDao;
+
+
+ public HealingTitanDao(TitanGraphClient titanClient) {
+ super(titanClient);
+ }
+
+ @Override
+ public Either<List<GraphVertex>, TitanOperationStatus> getChildrenVertecies(GraphVertex parentVertex,
+ EdgeLabelEnum edgeLabel, JsonParseFlagEnum parseFlag) {
+ Either<List<GraphVertex>, TitanOperationStatus> childrenVertecies =
+ super.getChildrenVertecies(parentVertex, edgeLabel, parseFlag);
+ return Either.iif(childrenVertecies.isRight(), () -> childrenVertecies.right().value(),
+ () -> childrenVertecies.left().value().stream()
+ .map(graphVertex -> transformVertex(graphVertex, edgeLabel))
+ .collect(Collectors.toList()));
+ }
+
+ private GraphVertex transformVertex(GraphVertex graphVertex, EdgeLabelEnum edgeLabelEnum) {
+ Optional<GraphVertex> optional = healingPipelineDao.performGraphReadHealing(graphVertex, edgeLabelEnum);
+ return optional.orElse(graphVertex);
+ }
+
+
+ public void setHealingPipelineDao(HealingPipelineDao healingPipelineDao) {
+ this.healingPipelineDao = healingPipelineDao;
+ }
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
index e01cddc..a31900a 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/TitanDao.java
@@ -48,7 +48,7 @@
import static org.apache.commons.collections.CollectionUtils.isEmpty;
-@Component("titan-dao")
+
public class TitanDao {
TitanGraphClient titanClient;
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractGraphVertexHeal.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractGraphVertexHeal.java
new file mode 100644
index 0000000..9be730c
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractGraphVertexHeal.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.be.dao.jsongraph.heal;
+
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+
+public abstract class AbstractGraphVertexHeal implements Heal<GraphVertex> {
+
+ protected Logger logger = Logger.getLogger(AbstractGraphVertexHeal.class);
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java
new file mode 100644
index 0000000..e01ddab
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/AbstractTitanVertexHeal.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.be.dao.jsongraph.heal;
+
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
+
+public abstract class AbstractTitanVertexHeal implements Heal<GraphNode> {
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/Heal.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/Heal.java
new file mode 100644
index 0000000..6c60772
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/Heal.java
@@ -0,0 +1,27 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.be.dao.jsongraph.heal;
+
+public interface Heal<V> {
+
+
+ HealVersion fromVersion();
+
+ void healData(V parentV);
+
+
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealConstants.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealConstants.java
new file mode 100644
index 0000000..ce1b24a
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealConstants.java
@@ -0,0 +1,10 @@
+package org.openecomp.sdc.be.dao.jsongraph.heal;
+
+public class HealConstants {
+
+ public static final Integer DEFAULT_HEAL_VERSION = 0;
+ private HealConstants() {
+ }
+
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersion.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersion.java
new file mode 100644
index 0000000..55d3f43
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersion.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.dao.jsongraph.heal;
+
+public interface HealVersion<T> extends Comparable<HealVersion> {
+
+ T getVersion();
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionBuilder.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionBuilder.java
new file mode 100644
index 0000000..3a7b064
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionBuilder.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.dao.jsongraph.heal;
+
+public class HealVersionBuilder {
+
+ private HealVersionBuilder() {
+ }
+
+ public static HealVersion<Integer> build(Integer version) {
+ return new HealVersionImpl(version);
+ }
+
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionImpl.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionImpl.java
new file mode 100644
index 0000000..4ce28de
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/jsongraph/heal/HealVersionImpl.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.dao.jsongraph.heal;
+
+import com.google.common.base.MoreObjects;
+import java.util.Objects;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+
+class HealVersionImpl<T extends Comparable> implements HealVersion<T> {
+
+ private final T version;
+
+ public HealVersionImpl(T version) {
+ Objects.requireNonNull(version, "Version cannot be null");
+ this.version = version;
+ }
+
+ public T getVersion() {
+ return version;
+ }
+
+
+ @Override
+ public int compareTo(HealVersion o) {
+ return this.version.compareTo( o.getVersion());
+ }
+
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+
+ if (!(o instanceof HealVersionImpl)) {
+ return false;
+ }
+
+ HealVersionImpl that = (HealVersionImpl) o;
+
+ return new EqualsBuilder().append(getVersion(), that.getVersion()).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder(17, 37).append(getVersion()).toHashCode();
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this).add("version", version).toString();
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java
new file mode 100644
index 0000000..37546a5
--- /dev/null
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/HealingTitanGenericDao.java
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.openecomp.sdc.be.dao.titan;
+
+import com.thinkaurelius.titan.core.TitanVertex;
+import fj.data.Either;
+import java.util.List;
+import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
+import org.apache.tinkerpop.gremlin.structure.VertexProperty;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.jsongraph.heal.Heal;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealConstants;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Component("titan-generic-dao")
+public class HealingTitanGenericDao extends TitanGenericDao {
+
+ @Autowired
+ private HealingPipelineDao healingPipelineDao;
+
+ public HealingTitanGenericDao(TitanGraphClient titanClient) {
+ super(titanClient);
+ }
+
+ @Override
+ public ImmutablePair<TitanVertex, Edge> getChildVertex(TitanVertex childVertex, GraphEdgeLabels edgeType) {
+ ImmutablePair<TitanVertex, Edge> childVertexEdgeImmutablePair = super.getChildVertex(childVertex, edgeType);
+ final TitanVertex graphVertex = childVertexEdgeImmutablePair.left;
+ healingPipelineDao.performGraphReadHealing(graphVertex, edgeType);
+ healingPipelineDao.setHealingVersion(graphVertex);
+ return childVertexEdgeImmutablePair;
+ }
+
+ @Override
+ public <T extends GraphNode> Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> getChildrenNodes(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz, boolean withEdges) {
+ Either<List<ImmutablePair<T, GraphEdge>>, TitanOperationStatus> either = super.getChildrenNodes(key, uniqueId, edgeType, nodeTypeEnum, clazz, withEdges);
+ if (either.isRight()) {
+ return either;
+ }
+ List<ImmutablePair<T, GraphEdge>> list = either.left().value();
+ list.forEach(this::transformPair);
+ return either;
+ }
+
+ @Override
+ public <T extends GraphNode> Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> getChild(String key, String uniqueId, GraphEdgeLabels edgeType, NodeTypeEnum nodeTypeEnum, Class<T> clazz) {
+ Either<ImmutablePair<T, GraphEdge>, TitanOperationStatus> eitherChild = super.getChild(key, uniqueId, edgeType, nodeTypeEnum, clazz);
+ if (eitherChild.isRight()) {
+ return eitherChild;
+ }
+ ImmutablePair<T, GraphEdge> pair = eitherChild.left().value();
+ GraphNode graphNode = pair.left;
+ GraphEdge graphEdge = pair.right;
+ healingPipelineDao.performGraphReadHealing(graphNode, graphEdge);
+ healingPipelineDao.setHealingVersion(graphNode);
+ return eitherChild;
+ }
+
+ private <T extends GraphNode> void transformPair(ImmutablePair<T, GraphEdge> either) {
+ GraphEdge edgeType = either.right;
+ GraphNode childVertex = either.left;
+ Integer healingVersioInt = childVertex.getHealingVersion();
+ HealVersionBuilder.build(healingVersioInt);
+ healingPipelineDao.performGraphReadHealing(childVertex, edgeType);
+ healingPipelineDao.setHealingVersion(childVertex);
+ }
+
+ @Override
+ public Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> getChildrenVertecies(String key, String uniqueId, GraphEdgeLabels edgeType) {
+ Either<List<ImmutablePair<TitanVertex, Edge>>, TitanOperationStatus> either = super.getChildrenVertecies(key, uniqueId, edgeType);
+ if (either.isRight()) {
+ return either;
+ }
+ List<ImmutablePair<TitanVertex, Edge>> list = either.left().value();
+ list.forEach(this::transformVertexPair);
+ return either;
+ }
+
+ private void transformVertexPair(ImmutablePair<TitanVertex, Edge> either) {
+ String edgeType = either.right.label();
+ TitanVertex childVertex = either.left;
+ VertexProperty<Integer> healingVersionProperty = childVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty());
+ Integer healingVersioInt = healingVersionProperty.orElse(HealConstants.DEFAULT_HEAL_VERSION);
+ HealVersionBuilder.build(healingVersioInt);
+ healingPipelineDao.performGraphReadHealing(childVertex, edgeType);
+ healingPipelineDao.setHealingVersion(childVertex);
+ }
+
+ @Override
+ public <T extends GraphNode> Either<T, TitanOperationStatus> updateNode(GraphNode node, Class<T> clazz) {
+ healingPipelineDao.setHealingVersion(node);
+ return super.updateNode(node, clazz);
+ }
+
+ @Override
+ public TitanOperationStatus updateVertex(GraphNode node, Vertex vertex) {
+ healingPipelineDao.setHealingVersion(node);
+ return super.updateVertex(node, vertex);
+ }
+
+
+ public void setHealingPipelineDao(HealingPipelineDao healingPipelineDao) {
+ this.healingPipelineDao = healingPipelineDao;
+ }
+}
diff --git a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
index 3c502ff..2123910 100644
--- a/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
+++ b/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanGenericDao.java
@@ -20,28 +20,44 @@
package org.openecomp.sdc.be.dao.titan;
-import com.thinkaurelius.titan.core.*;
+import com.thinkaurelius.titan.core.PropertyKey;
+import com.thinkaurelius.titan.core.TitanEdge;
+import com.thinkaurelius.titan.core.TitanGraph;
+import com.thinkaurelius.titan.core.TitanGraphQuery;
+import com.thinkaurelius.titan.core.TitanVertex;
+import com.thinkaurelius.titan.core.TitanVertexQuery;
import com.thinkaurelius.titan.graphdb.query.TitanPredicate;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.ImmutableTriple;
-import org.apache.tinkerpop.gremlin.structure.*;
+import org.apache.tinkerpop.gremlin.structure.Direction;
+import org.apache.tinkerpop.gremlin.structure.Edge;
+import org.apache.tinkerpop.gremlin.structure.Element;
+import org.apache.tinkerpop.gremlin.structure.Property;
+import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper;
import org.openecomp.sdc.be.config.ConfigurationManager;
import org.openecomp.sdc.be.dao.graph.GraphElementFactory;
-import org.openecomp.sdc.be.dao.graph.datatype.*;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphElementTypeEnum;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
+import org.openecomp.sdc.be.dao.graph.datatype.RelationEndPoint;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.resources.data.GraphNodeLock;
import org.openecomp.sdc.common.log.wrappers.Logger;
-import org.springframework.stereotype.Component;
+import org.springframework.beans.factory.annotation.Qualifier;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-import java.util.stream.StreamSupport;
-@Component("titan-generic-dao")
public class TitanGenericDao {
private static final String FAILED_TO_RETRIEVE_GRAPH_STATUS_IS = "Failed to retrieve graph. status is {}";
@@ -51,7 +67,7 @@
private static Logger log = Logger.getLogger(TitanGenericDao.class.getName());
private static final String LOCK_NODE_PREFIX = "lock_";
- public TitanGenericDao(TitanGraphClient titanClient) {
+ public TitanGenericDao(@Qualifier("titan-client") TitanGraphClient titanClient) {
this.titanClient = titanClient;
log.info("** TitanGenericDao created");
}
diff --git a/catalog-dao/src/main/resources/dao.properties b/catalog-dao/src/main/resources/dao.properties
new file mode 100644
index 0000000..5306906
--- /dev/null
+++ b/catalog-dao/src/main/resources/dao.properties
@@ -0,0 +1,16 @@
+#
+# Copyright ? 2016-2018 European Support Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+current.heal.version = 0
\ No newline at end of file
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java
new file mode 100644
index 0000000..83b6892
--- /dev/null
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/dao/cassandra/HealingPipelineDaoTest.java
@@ -0,0 +1,315 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.dao.cassandra;
+
+import com.google.common.collect.ImmutableListMultimap;
+import com.thinkaurelius.titan.core.TitanVertex;
+import com.thinkaurelius.titan.graphdb.relations.StandardVertexProperty;
+import com.thinkaurelius.titan.graphdb.types.system.EmptyVertex;
+import com.thinkaurelius.titan.graphdb.types.system.ImplicitKey;
+import java.util.HashMap;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
+import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.heal.*;
+import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
+import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
+import org.openecomp.sdc.be.datatypes.enums.GraphPropertyEnum;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+
+import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.Assert.*;
+
+public class HealingPipelineDaoTest {
+
+
+ @Test
+ public void shouldUpgrade() {
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(3);
+ healingPipelineDao.initHealVersion();
+ healingPipelineDao.initGraphHealers();
+ final HealVersion<Integer> version3 = HealVersionBuilder.build(3);
+ assertFalse(healingPipelineDao.shouldHeal(HealVersionBuilder.build(2), version3));
+ assertFalse(healingPipelineDao.shouldHeal(version3, version3));
+ assertTrue(healingPipelineDao.shouldHeal(HealVersionBuilder.build(2), HealVersionBuilder.build(1)));
+ }
+
+
+ @Test
+ public void testPipelineFilter3Attributes() {
+ // init data
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(7);
+ healingPipelineDao.initHealVersion();
+ healingPipelineDao.initGraphHealers();
+ healingPipelineDao.setHealingPipeline(createPipelineMap());
+
+ assertEquals(2,
+ healingPipelineDao.getHealersForVertex(EdgeLabelEnum.ATTRIBUTES.name(), HealVersionBuilder.build(5)).size());
+
+ GraphVertex graphVertex = new GraphVertex();
+ final int version = 5;
+ graphVertex.addMetadataProperty(GraphPropertyEnum.HEALING_VERSION, Integer.valueOf(version));
+
+ // perform test
+
+ Optional optional = healingPipelineDao.performGraphReadHealing(graphVertex, EdgeLabelEnum.ATTRIBUTES);
+ assertTrue(optional.isPresent());
+ final GraphVertex changedVertex = (GraphVertex) optional.get();
+
+ //validate result
+ final Object healVersion = changedVertex.getMetadataProperties().get(GraphPropertyEnum.HEALING_VERSION);
+ assertNotNull(healVersion);
+ assertTrue(healVersion instanceof Integer);
+ assertEquals(healingPipelineDao.getCurrentHealVersion().getVersion().intValue(), ((Integer) healVersion).intValue());
+ }
+
+ @Test
+ public void testPipelineFilter3AttributesTitanVertex() {
+ // init data
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(7);
+ healingPipelineDao.initHealVersion();
+ healingPipelineDao.initGraphHealers();
+ healingPipelineDao.setHealingPipeline(createPipelineMap());
+
+ assertEquals(2,
+ healingPipelineDao.getHealersForVertex(GraphEdgeLabels.CAPABILITY.getProperty(), HealVersionBuilder.build(5)).size());
+ TitanVertex titanVertex = Mockito.mock(TitanVertex.class);
+ final int version = 5;
+ StandardVertexProperty vertexProperty = new StandardVertexProperty(1, ImplicitKey.ID, new EmptyVertex(), version, (byte) 1);
+ Mockito.when(titanVertex.property(GraphPropertyEnum.HEALING_VERSION.getProperty())).thenReturn(vertexProperty);
+
+ // perform test
+
+ Optional optional = healingPipelineDao.performGraphReadHealing(titanVertex, GraphEdgeLabels.CAPABILITY);
+ assertTrue(optional.isPresent());
+ final TitanVertex changedVertex = (TitanVertex) optional.get();
+
+ //validate result
+ assertNotNull(changedVertex);
+
+ }
+
+ @Test
+ public void testPipelineFilterGenericTitanDao() {
+ // init data
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(7);
+ healingPipelineDao.initHealVersion();
+ healingPipelineDao.initGraphHealers();
+ healingPipelineDao.setHealingPipeline(createPipelineMap());
+ assertEquals(1,
+
+ healingPipelineDao.getHealersForVertex(GraphEdgeLabels.ATTRIBUTE.getProperty(), HealVersionBuilder.build(6)).size());
+
+ GraphNode mockGraphNode = new MockGraphNode(NodeTypeEnum.Attribute);
+ final int version = 5;
+ mockGraphNode.setHealingVersion(Integer.valueOf(version));
+
+ // perform test
+
+ Optional optional = healingPipelineDao.performGraphReadHealing(mockGraphNode,createGraphEdge(GraphEdgeLabels.ATTRIBUTE));
+ assertTrue(optional.isPresent());
+ final GraphNode changedVertex = (GraphNode) optional.get();
+
+ //validate result
+ final Integer healVersion = changedVertex.getHealingVersion();
+ assertNotNull(healVersion);
+ assertEquals(healingPipelineDao.getCurrentHealVersion().getVersion(), healVersion);
+ }
+
+ @Test
+ public void testPipelineFilterTitanGraph1Attributes() {
+ // init data
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(7);
+ healingPipelineDao.initHealVersion();
+ healingPipelineDao.initGraphHealers();
+ healingPipelineDao.setHealingPipeline(createPipelineMap());
+
+ assertEquals(2,
+ healingPipelineDao.getHealersForVertex(GraphEdgeLabels.ATTRIBUTE.getProperty(), HealVersionBuilder.build(5)).size());
+
+ }
+
+ @Test
+ public void healTest() {
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(3);
+ healingPipelineDao.initHealVersion();
+ healingPipelineDao.initGraphHealers();
+ final HealVersion<Integer> version3 = HealVersionBuilder.build(3);
+ assertFalse(healingPipelineDao.shouldHeal(HealVersionBuilder.build(2), version3));
+ assertFalse(healingPipelineDao.shouldHeal(version3, version3));
+ assertTrue(healingPipelineDao.shouldHeal(HealVersionBuilder.build(2), HealVersionBuilder.build(1)));
+ }
+
+
+ @Test
+ public void setCurrentVersion() {
+ //init data
+ GraphVertex graphVertex = new GraphVertex();
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ final int healVersion = 7;
+ healingPipelineDao.setHealVersion(healVersion);
+ healingPipelineDao.initHealVersion();
+ healingPipelineDao.initGraphHealers();
+
+ //execute code
+ healingPipelineDao.setHealingVersion(graphVertex);
+
+ //validate result
+ final Object currentVersion = graphVertex.getMetadataProperties().get(GraphPropertyEnum.HEALING_VERSION);
+ assertNotNull(currentVersion);
+ assertTrue(currentVersion instanceof Integer);
+ assertEquals(healingPipelineDao.getCurrentHealVersion().getVersion().intValue(), ((Integer) currentVersion).intValue());
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testMultilistValidation() {
+ // init data
+ HealingPipelineDao healingPipelineDao = new HealingPipelineDao();
+ healingPipelineDao.setHealVersion(7);
+ healingPipelineDao.initHealVersion();
+ healingPipelineDao.initGraphHealers();
+
+ ImmutableListMultimap<String, Heal> shouldFail = ImmutableListMultimap.<String, Heal>builder().put(EdgeLabelEnum.ATTRIBUTES.name(), new GraphVertexHealTestMock(3))
+ .put(EdgeLabelEnum.ATTRIBUTES.name(), new GraphVertexHealTestMock(4))
+ .put(EdgeLabelEnum.ATTRIBUTES.name(), new GraphVertexHealTestMock(5))
+ .put(EdgeLabelEnum.ATTRIBUTES.name(), new GraphVertexHealTestMock(6))
+ .put(EdgeLabelEnum.CAPABILITIES.name(), new GraphVertexHealTestMock(3))
+ .put(EdgeLabelEnum.CAPABILITIES.name(), new GraphVertexHealTestMock(3)) // this should cause exception
+ .put(EdgeLabelEnum.CAPABILITIES.name(), new GraphVertexHealTestMock(69)).build();
+
+ //performTest
+ healingPipelineDao.setHealingPipeline(shouldFail);
+ }
+
+ private ImmutableListMultimap<String, Heal> createPipelineMap() {
+ return ImmutableListMultimap.<String, Heal>builder().put(EdgeLabelEnum.ATTRIBUTES.name(), new GraphVertexHealTestMock(3))
+ .put(EdgeLabelEnum.ATTRIBUTES.name(), new GraphVertexHealTestMock(4))
+ .put(EdgeLabelEnum.ATTRIBUTES.name(), new GraphVertexHealTestMock(5))
+ .put(EdgeLabelEnum.ATTRIBUTES.name(), new GraphVertexHealTestMock(6))
+ .put(EdgeLabelEnum.CAPABILITIES.name(), new GraphVertexHealTestMock(3))
+ .put(EdgeLabelEnum.CAPABILITIES.name(), new GraphVertexHealTestMock(6))
+ .put(EdgeLabelEnum.CAPABILITIES.name(), new GraphVertexHealTestMock(69))
+ .put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(4))
+ .put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(5))
+ .put(GraphEdgeLabels.ATTRIBUTE.getProperty(), new GraphNodeHealTestMock(6))
+ .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(4))
+ .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(5))
+ .put(GraphEdgeLabels.CAPABILITY.getProperty(), new TitanVertexHealTestMock(6)).build();
+ }
+
+ public GraphEdge createGraphEdge(GraphEdgeLabels graphEdgeLabels){
+ return new GraphEdge(graphEdgeLabels, new HashMap<>());
+ }
+
+
+ private class GraphVertexHealTestMock extends AbstractGraphVertexHeal {
+
+ private HealVersion healVersion;
+
+ public GraphVertexHealTestMock(int i) {
+ healVersion = HealVersionBuilder.build(i);
+ }
+
+ @Override
+ public HealVersion fromVersion() {
+ return healVersion;
+ }
+
+ @Override
+ public void healData(GraphVertex parentVertex) {
+
+ }
+
+ }
+
+ private class GraphNodeHealTestMock extends AbstractTitanVertexHeal {
+ private HealVersion healVersion;
+
+ public GraphNodeHealTestMock(int i) {
+ healVersion = HealVersionBuilder.build(i);
+ }
+
+ @Override
+ public HealVersion fromVersion() {
+ return healVersion;
+ }
+
+ @Override
+ public void healData(GraphNode parentV) {
+
+ }
+ }
+
+
+ private class TitanVertexHealTestMock implements Heal<TitanVertex> {
+ private HealVersion healVersion;
+
+ public TitanVertexHealTestMock(int i) {
+ healVersion = HealVersionBuilder.build(i);
+ }
+
+ @Override
+ public HealVersion fromVersion() {
+ return healVersion;
+ }
+
+ @Override
+ public void healData(TitanVertex parentV) {
+
+ }
+ }
+
+ private class MockGraphNode extends GraphNode {
+ private int healVersion;
+
+ public MockGraphNode(NodeTypeEnum label) {
+ super(label);
+ }
+
+ @Override
+ public String getUniqueId() {
+ return null;
+ }
+
+ @Override
+ public Map<String, Object> toGraphMap() {
+ return null;
+ }
+
+ @Override
+ public Integer getHealingVersion() {
+ return healVersion;
+ }
+
+ @Override
+ public void setHealingVersion(Integer version) {
+ this.healVersion = version;
+ }
+ }
+
+}
diff --git a/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/HealVersionTest.java b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/HealVersionTest.java
new file mode 100644
index 0000000..01ac5c3
--- /dev/null
+++ b/catalog-dao/src/test/java/org/openecomp/sdc/be/resources/HealVersionTest.java
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2016-2018 European Support Limited
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.openecomp.sdc.be.resources;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersion;
+import org.openecomp.sdc.be.dao.jsongraph.heal.HealVersionBuilder;
+
+public class HealVersionTest {
+
+ @Test
+ public void buildVersions() {
+ final HealVersion<Integer> version1 = HealVersionBuilder.build(1);
+ final HealVersion<Integer> version2 = HealVersionBuilder.build(2);
+ Assert.assertTrue(version1.compareTo(version2) < 0);
+ }
+
+}
diff --git a/catalog-dao/src/test/resources/application-context-test.xml b/catalog-dao/src/test/resources/application-context-test.xml
index 468dab3..24980df 100644
--- a/catalog-dao/src/test/resources/application-context-test.xml
+++ b/catalog-dao/src/test/resources/application-context-test.xml
@@ -18,5 +18,5 @@
">
</context:component-scan>
-
+ <context:property-placeholder location="classpath:dao.properties" />
</beans>
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
index b18fb96..6dfd1fc 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/BaseOperation.java
@@ -59,6 +59,7 @@
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.openecomp.sdc.common.util.ValidationUtils;
import org.springframework.beans.factory.annotation.Autowired;
+import org.openecomp.sdc.be.dao.impl.HealingPipelineDao;
import java.util.*;
import java.util.EnumMap;
@@ -85,6 +86,9 @@
@Autowired
protected TopologyTemplateOperation topologyTemplateOperation;
+// @Autowired
+ protected HealingPipelineDao healingPipelineDao;
+
public void setTitanDao(TitanDao titanDao) {
this.titanDao = titanDao;
}
@@ -284,6 +288,7 @@
}
protected Either<GraphVertex, TitanOperationStatus> updateOrCopyOnUpdate(GraphVertex dataVertex, GraphVertex toscaElementVertex, EdgeLabelEnum label) {
+// healingPipelineDao.setHealingVersion(dataVertex);
Iterator<Edge> edges = dataVertex.getVertex().edges(Direction.IN, label.name());
int edgeCount = 0;
Edge edgeToRemove = null;
@@ -1483,4 +1488,8 @@
private GraphVertex throwStorageException(TitanOperationStatus status) {
throw new StorageException(status);
}
+
+ public void setHealingPipelineDao(HealingPipelineDao healingPipelineDao) {
+ this.healingPipelineDao = healingPipelineDao;
+ }
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
index 9e1e001..0ee7c9e 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacade.java
@@ -28,7 +28,7 @@
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
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;
@@ -84,7 +84,7 @@
@Autowired
private GroupsOperation groupsOperation;
@Autowired
- private TitanDao titanDao;
+ private HealingTitanDao titanDao;
private static final Logger log = Logger.getLogger(ToscaOperationFacade.class.getName());
// endregion
@@ -1921,7 +1921,7 @@
return result;
}
- public TitanDao getTitanDao() {
+ public HealingTitanDao getTitanDao() {
return titanDao;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
index b42581a..3e987ed 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/AbstractOperation.java
@@ -26,6 +26,11 @@
import com.google.gson.reflect.TypeToken;
import com.thinkaurelius.titan.core.TitanVertex;
import fj.data.Either;
+import java.lang.reflect.Type;
+import java.util.List;
+import java.util.Map;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.config.BeEcompErrorManager;
import org.openecomp.sdc.be.config.BeEcompErrorManager.ErrorSeverity;
@@ -33,7 +38,7 @@
import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
@@ -53,18 +58,12 @@
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-import java.util.function.Supplier;
-import java.util.stream.Collectors;
-
public abstract class AbstractOperation {
private static final Logger log = Logger.getLogger(AbstractOperation.class.getName());
@Autowired
- protected TitanGenericDao titanGenericDao;
+ protected HealingTitanGenericDao titanGenericDao;
public static final String EMPTY_VALUE = null;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityOperation.java
index 7a17183..382a2e0 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityOperation.java
@@ -20,16 +20,26 @@
package org.openecomp.sdc.be.model.operations.impl;
+import static org.springframework.util.CollectionUtils.isEmpty;
+
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgePropertiesDictionary;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.CapabilityDefinition;
@@ -44,12 +54,6 @@
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
-import java.util.*;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-
-import static org.springframework.util.CollectionUtils.isEmpty;
-
@Component("capability-operation")
public class CapabilityOperation extends AbstractOperation {
@@ -67,7 +71,7 @@
@VisibleForTesting
- public void setTitanGenericDao(TitanGenericDao titanGenericDao) {
+ public void setTitanGenericDao(HealingTitanGenericDao titanGenericDao) {
this.titanGenericDao = titanGenericDao;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperation.java
index 3a4a272..1cc1380 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperation.java
@@ -21,13 +21,17 @@
package org.openecomp.sdc.be.model.operations.impl;
import fj.data.Either;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
import org.openecomp.sdc.be.model.CapabilityTypeDefinition;
@@ -42,11 +46,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.stream.Collectors;
-
@Component("capability-type-operation")
public class CapabilityTypeOperation extends AbstractOperation implements ICapabilityTypeOperation {
@Autowired
@@ -69,7 +68,7 @@
*
* @param titanGenericDao
*/
- public void setTitanGenericDao(TitanGenericDao titanGenericDao) {
+ public void setTitanGenericDao(HealingTitanGenericDao titanGenericDao) {
this.titanGenericDao = titanGenericDao;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CommonTypeOperations.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CommonTypeOperations.java
index 0189b61..96b0832 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CommonTypeOperations.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/CommonTypeOperations.java
@@ -1,12 +1,6 @@
package org.openecomp.sdc.be.model.operations.impl;
-import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
-import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
-import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.PropertyDefinition;
-import org.springframework.stereotype.Component;
+import static java.util.Collections.emptyList;
import java.util.HashMap;
import java.util.List;
@@ -15,17 +9,23 @@
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
-
-import static java.util.Collections.emptyList;
+import org.openecomp.sdc.be.dao.graph.datatype.GraphNode;
+import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
+import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
+import org.openecomp.sdc.be.model.PropertyDefinition;
+import org.springframework.stereotype.Component;
@Component
public class CommonTypeOperations {
- private final TitanGenericDao titanGenericDao;
+ private final HealingTitanGenericDao titanGenericDao;
private final PropertyOperation propertyOperation;
private final OperationUtils operationUtils;
- public CommonTypeOperations(TitanGenericDao titanGenericDao, PropertyOperation propertyOperation, OperationUtils operationUtils) {
+ public CommonTypeOperations(HealingTitanGenericDao titanGenericDao, PropertyOperation propertyOperation,
+ OperationUtils operationUtils) {
this.titanGenericDao = titanGenericDao;
this.propertyOperation = propertyOperation;
this.operationUtils = operationUtils;
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
index fb0674c..34dce75 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperation.java
@@ -23,6 +23,10 @@
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanVertex;
import fj.data.Either;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.UUID;
+import java.util.function.Supplier;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.apache.tinkerpop.gremlin.structure.VertexProperty;
@@ -34,27 +38,30 @@
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgePropertiesDictionary;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
-import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ComponentInstance;
+import org.openecomp.sdc.be.model.ComponentInstanceInput;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.IComponentInstanceConnectedElement;
import org.openecomp.sdc.be.model.cache.ApplicationDataTypeCache;
import org.openecomp.sdc.be.model.operations.api.IComponentInstanceOperation;
import org.openecomp.sdc.be.model.operations.api.IInputsOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
-import org.openecomp.sdc.be.resources.data.*;
+import org.openecomp.sdc.be.resources.data.AttributeData;
+import org.openecomp.sdc.be.resources.data.AttributeValueData;
+import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
+import org.openecomp.sdc.be.resources.data.InputValueData;
+import org.openecomp.sdc.be.resources.data.InputsData;
import org.openecomp.sdc.common.datastructure.Wrapper;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.beans.factory.annotation.Autowired;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.UUID;
-import java.util.function.Supplier;
-
@org.springframework.stereotype.Component("component-instance-operation")
public class ComponentInstanceOperation extends AbstractOperation implements IComponentInstanceOperation {
@@ -78,7 +85,7 @@
*
* @param titanGenericDao
*/
- public void setTitanGenericDao(TitanGenericDao titanGenericDao) {
+ public void setTitanGenericDao(HealingTitanGenericDao titanGenericDao) {
this.titanGenericDao = titanGenericDao;
}
diff --git a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
index 5e900e4..fb023c7 100644
--- a/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
+++ b/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperation.java
@@ -24,11 +24,34 @@
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.collect.Maps;
-import com.google.gson.*;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonSerializationContext;
+import com.google.gson.JsonSerializer;
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanVertex;
import com.thinkaurelius.titan.core.TitanVertexProperty;
import fj.data.Either;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.StringJoiner;
+import java.util.function.Consumer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.StringUtils;
@@ -45,32 +68,40 @@
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
import org.openecomp.sdc.be.datatypes.elements.PropertyRule;
import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.ComponentInstanceProperty;
+import org.openecomp.sdc.be.model.DataTypeDefinition;
+import org.openecomp.sdc.be.model.IComplexDefaultValue;
+import org.openecomp.sdc.be.model.PropertyConstraint;
+import org.openecomp.sdc.be.model.PropertyDefinition;
import org.openecomp.sdc.be.model.operations.api.DerivedFromOperation;
import org.openecomp.sdc.be.model.operations.api.IPropertyOperation;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.openecomp.sdc.be.model.tosca.ToscaPropertyType;
-import org.openecomp.sdc.be.model.tosca.constraints.*;
+import org.openecomp.sdc.be.model.tosca.constraints.ConstraintType;
+import org.openecomp.sdc.be.model.tosca.constraints.GreaterOrEqualConstraint;
+import org.openecomp.sdc.be.model.tosca.constraints.GreaterThanConstraint;
+import org.openecomp.sdc.be.model.tosca.constraints.InRangeConstraint;
+import org.openecomp.sdc.be.model.tosca.constraints.LessOrEqualConstraint;
+import org.openecomp.sdc.be.model.tosca.constraints.LessThanConstraint;
+import org.openecomp.sdc.be.model.tosca.constraints.MinLengthConstraint;
+import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint;
import org.openecomp.sdc.be.model.tosca.converters.PropertyValueConverter;
-import org.openecomp.sdc.be.resources.data.*;
+import org.openecomp.sdc.be.resources.data.ComponentInstanceData;
+import org.openecomp.sdc.be.resources.data.DataTypeData;
+import org.openecomp.sdc.be.resources.data.PropertyData;
+import org.openecomp.sdc.be.resources.data.PropertyValueData;
+import org.openecomp.sdc.be.resources.data.ResourceMetadataData;
+import org.openecomp.sdc.be.resources.data.UniqueIdData;
import org.openecomp.sdc.common.log.wrappers.Logger;
import org.springframework.stereotype.Component;
-import java.io.IOException;
-import java.lang.reflect.Type;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.function.Consumer;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
@Component("property-operation")
public class PropertyOperation extends AbstractOperation implements IPropertyOperation {
@@ -101,7 +132,7 @@
}
- public PropertyOperation(TitanGenericDao titanGenericDao, DerivedFromOperation derivedFromOperation) {
+ public PropertyOperation(HealingTitanGenericDao titanGenericDao, DerivedFromOperation derivedFromOperation) {
this.titanGenericDao = titanGenericDao;
this.derivedFromOperation = derivedFromOperation;
}
@@ -495,7 +526,7 @@
*
* @param titanGenericDao
*/
- public void setTitanGenericDao(TitanGenericDao titanGenericDao) {
+ public void setTitanGenericDao(HealingTitanGenericDao titanGenericDao) {
this.titanGenericDao = titanGenericDao;
}
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/config/ModelOperationsSpringConfig.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/config/ModelOperationsSpringConfig.java
index e7210d4..d6b2dd6 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/config/ModelOperationsSpringConfig.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/config/ModelOperationsSpringConfig.java
@@ -2,8 +2,11 @@
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.PropertySource;
@Configuration
-@ComponentScan({"org.openecomp.sdc.be.dao.cassandra","org.openecomp.sdc.be.model.cache","org.openecomp.sdc.be.model.jsontitan.operations","org.openecomp.sdc.be.model.jsontitan.utils", "org.openecomp.sdc.be.model.operations.impl"})
-public class ModelOperationsSpringConfig {
-}
+@ComponentScan({"org.openecomp.sdc.be.dao.cassandra", "org.openecomp.sdc.be.model.cache",
+ "org.openecomp.sdc.be.model.jsontitan.operations", "org.openecomp.sdc.be.model.jsontitan.utils",
+ "org.openecomp.sdc.be.model.operations.impl"})
+@PropertySource("classpath:dao.properties")
+public class ModelOperationsSpringConfig { }
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ArchiveOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ArchiveOperationTest.java
index 1b9da4d..b906604 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ArchiveOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ArchiveOperationTest.java
@@ -34,7 +34,7 @@
* Created by yavivi on 21/03/2018.
*/
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration("classpath:application-context-test.xml")
+@ContextConfiguration(value = {"classpath:application-context-test.xml", "classpath:healing-context-test.xml"})
public class ArchiveOperationTest extends ModelTestBase {
private static final String CI_UID_RES1_CP = "cp_uid";
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/GroupsOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/GroupsOperationTest.java
index 191546d..575fbbc 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/GroupsOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/GroupsOperationTest.java
@@ -1,6 +1,10 @@
package org.openecomp.sdc.be.model.jsontitan.operations;
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+
import fj.data.Either;
+import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -8,20 +12,19 @@
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.config.TitanSpringConfig;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
-import org.openecomp.sdc.be.model.*;
+import org.openecomp.sdc.be.model.Component;
+import org.openecomp.sdc.be.model.ComponentParametersView;
+import org.openecomp.sdc.be.model.GroupDefinition;
+import org.openecomp.sdc.be.model.ModelTestBase;
+import org.openecomp.sdc.be.model.Resource;
import org.openecomp.sdc.be.model.config.ModelOperationsSpringConfig;
import org.openecomp.sdc.be.model.operations.api.StorageOperationStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.util.List;
-
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TitanSpringConfig.class, ModelOperationsSpringConfig.class})
@@ -31,7 +34,7 @@
private GroupsOperation groupsOperation;
@Autowired
- TitanDao titanDao;
+ HealingTitanDao titanDao;
@Autowired
private ToscaOperationFacade toscaOperationFacade;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationGraphTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationGraphTest.java
index ac8d8e7..1887891 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationGraphTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/NodeTemplateOperationGraphTest.java
@@ -1,8 +1,23 @@
package org.openecomp.sdc.be.model.jsontitan.operations;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanVertex;
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 javax.annotation.Resource;
import org.apache.tinkerpop.gremlin.structure.Direction;
import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
@@ -14,7 +29,7 @@
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.config.TitanSpringConfig;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
-import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgePropertyEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -27,21 +42,11 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import javax.annotation.Resource;
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStream;
-import java.util.*;
-
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.*;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {TitanSpringConfig.class, ModelOperationsSpringConfig.class})
public class NodeTemplateOperationGraphTest extends ModelTestBase{
@Resource
- private TitanDao titanDao;
+ private HealingTitanDao titanDao;
@Resource
private NodeTemplateOperation nodeTemplateOperation;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/PolicyOperationIntegrationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/PolicyOperationIntegrationTest.java
index ee88e9a..ca8713f 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/PolicyOperationIntegrationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/PolicyOperationIntegrationTest.java
@@ -8,6 +8,7 @@
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.config.TitanSpringConfig;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -44,7 +45,7 @@
@Resource
private TopologyTemplateOperation topologyTemplateOperation;
@Resource
- private TitanDao titanDao;
+ private HealingTitanDao titanDao;
@Resource
private PolicyOperation policyOperation;
private PropertyDataDefinition prop1, prop2;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperationCapabilityIntegrationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperationCapabilityIntegrationTest.java
index 1f30d27..9936d45 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperationCapabilityIntegrationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/TopologyTemplateOperationCapabilityIntegrationTest.java
@@ -7,6 +7,7 @@
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.config.TitanSpringConfig;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.VertexTypeEnum;
@@ -43,7 +44,7 @@
private TopologyTemplateOperation topologyTemplateOperation;
@Resource
- private TitanDao titanDao;
+ private HealingTitanDao titanDao;
private CapabilityPropertyDataObject capabilityProperty1;
private CapabilityPropertyDataObject capabilityProperty2;
private CapabilityPropertyDataObject capabilityProperty3;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadePoliciesTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadePoliciesTest.java
index 0568830..95dca7f 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadePoliciesTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadePoliciesTest.java
@@ -8,6 +8,7 @@
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.config.TitanSpringConfig;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.PolicyTargetType;
@@ -39,7 +40,7 @@
@Autowired
private ToscaOperationFacade toscaOperationFacade;
@Autowired
- private TitanDao titanDao;
+ private HealingTitanDao titanDao;
private PolicyDefinition policy1, policy2;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
index 7086110..63856e6 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/jsontitan/operations/ToscaOperationFacadeTest.java
@@ -40,6 +40,7 @@
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.dao.jsongraph.GraphVertex;
+import org.openecomp.sdc.be.dao.jsongraph.HealingTitanDao;
import org.openecomp.sdc.be.dao.jsongraph.TitanDao;
import org.openecomp.sdc.be.dao.jsongraph.types.EdgeLabelEnum;
import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
@@ -89,7 +90,7 @@
private ToscaOperationFacade testInstance;
@Mock
- private TitanDao titanDaoMock;
+ private HealingTitanDao titanDaoMock;
@Mock
private TopologyTemplateOperation topologyTemplateOperationMock;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
index 79c2d9b..f853553 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/CapabilityTypeOperationTest.java
@@ -20,9 +20,24 @@
package org.openecomp.sdc.be.model.operations.impl;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanVertex;
import fj.data.Either;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.annotation.Resource;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -30,6 +45,7 @@
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -62,7 +78,7 @@
public class CapabilityTypeOperationTest extends ModelTestBase {
@Resource(name = "titan-generic-dao")
- private TitanGenericDao titanDao;
+ private HealingTitanGenericDao titanDao;
@Resource(name = "capability-type-operation")
private CapabilityTypeOperation capabilityTypeOperation;
@@ -74,7 +90,7 @@
@Before
public void cleanUp() {
- TitanGenericDao titanGenericDao = capabilityTypeOperation.titanGenericDao;
+ HealingTitanGenericDao titanGenericDao = capabilityTypeOperation.titanGenericDao;
Either<TitanGraph, TitanOperationStatus> graphResult = titanGenericDao.getGraph();
TitanGraph graph = graphResult.left().value();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java
index a19f188..849a442 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/ComponentInstanceOperationTest.java
@@ -38,6 +38,7 @@
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.enums.NodeTypeEnum;
@@ -63,7 +64,7 @@
private ComponentInstanceOperation componentInstanceOperation;
@Mock
- protected TitanGenericDao titanGenericDao;
+ protected HealingTitanGenericDao titanGenericDao;
@Test
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java
index 94e22e6..0f8e294 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/GroupTypeOperationTest.java
@@ -12,6 +12,7 @@
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
import org.openecomp.sdc.be.dao.neo4j.GraphPropertiesDictionary;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.GroupTypeDataDefinition;
@@ -44,7 +45,7 @@
private static final String NULL_STRING = null;
@Resource(name = "titan-generic-dao")
- private TitanGenericDao titanDao;
+ private HealingTitanGenericDao titanDao;
@Resource(name = "capability-type-operation")
private CapabilityTypeOperation capabilityTypeOperation;
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
index 64856c8..ef1025f 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PolicyTypeOperationTest.java
@@ -20,9 +20,18 @@
package org.openecomp.sdc.be.model.operations.impl;
+import static com.google.common.collect.Sets.newHashSet;
+import static java.util.Arrays.asList;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import com.thinkaurelius.titan.core.TitanGraph;
import com.thinkaurelius.titan.core.TitanVertex;
import fj.data.Either;
+import java.util.Iterator;
+import java.util.List;
+import java.util.stream.Stream;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.junit.Before;
@@ -31,6 +40,7 @@
import org.junit.runner.RunWith;
import org.openecomp.sdc.be.dao.graph.datatype.GraphEdge;
import org.openecomp.sdc.be.dao.neo4j.GraphEdgeLabels;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.PolicyTypeDataDefinition;
@@ -45,16 +55,6 @@
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import java.util.Iterator;
-import java.util.List;
-import java.util.stream.Stream;
-
-import static com.google.common.collect.Sets.newHashSet;
-import static java.util.Arrays.asList;
-import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:application-context-test.xml")
public class PolicyTypeOperationTest extends ModelTestBase {
@@ -64,7 +64,7 @@
private PolicyTypeOperation policyTypeOperation;
@Autowired
- private TitanGenericDao titanGenericDao;
+ private HealingTitanGenericDao titanGenericDao;
@BeforeClass
public static void setupBeforeClass() {
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
index 17d0586..ae428bd 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/PropertyOperationTest.java
@@ -27,6 +27,7 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGraphClient;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
@@ -50,7 +51,7 @@
public class PropertyOperationTest extends ModelTestBase {
- TitanGenericDao titanGenericDao = Mockito.mock(TitanGenericDao.class);
+ HealingTitanGenericDao titanGenericDao = Mockito.mock(HealingTitanGenericDao.class);
PropertyOperation propertyOperation = new PropertyOperation(titanGenericDao, null);
@@ -511,7 +512,7 @@
}
private PropertyOperation createTestSubject() {
- return new PropertyOperation(new TitanGenericDao(new TitanGraphClient()), null);
+ return new PropertyOperation(new HealingTitanGenericDao(new TitanGraphClient()), null);
}
@@ -642,11 +643,12 @@
result = testSubject.updatePropertyFromGraph(propertyId, propertyDefinition);
}
-
+
@Test
- public void testSetTitanGenericDao() throws Exception {
+ public void testSetTitanGenericDao() {
+
PropertyOperation testSubject;
- TitanGenericDao titanGenericDao = null;
+ HealingTitanGenericDao titanGenericDao = null;
// default test
testSubject = createTestSubject();
@@ -655,7 +657,7 @@
@Test
- public void testAddPropertyToNodeType() throws Exception {
+ public void testAddPropertyToNodeType() {
PropertyOperation testSubject;
String propertyName = "";
PropertyDefinition propertyDefinition = new PropertyDefinition();
diff --git a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
index 6f8c7ea..3d60a65 100644
--- a/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
+++ b/catalog-model/src/test/java/org/openecomp/sdc/be/model/operations/impl/RelationshipTypeOperationTest.java
@@ -44,6 +44,7 @@
import org.mockito.MockitoAnnotations;
import org.mockito.Spy;
import org.openecomp.sdc.be.dao.graph.datatype.GraphRelation;
+import org.openecomp.sdc.be.dao.titan.HealingTitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanGenericDao;
import org.openecomp.sdc.be.dao.titan.TitanOperationStatus;
import org.openecomp.sdc.be.datatypes.elements.RelationshipInstDataDefinition;
@@ -69,7 +70,7 @@
private static final String PROP = "prop";
@Mock
- TitanGenericDao titanGenericDao;
+ HealingTitanGenericDao titanGenericDao;
@Mock
PropertyOperation propertyOperation;
diff --git a/catalog-model/src/test/resources/application-context-test.xml b/catalog-model/src/test/resources/application-context-test.xml
index 2447774..a39a1ee 100644
--- a/catalog-model/src/test/resources/application-context-test.xml
+++ b/catalog-model/src/test/resources/application-context-test.xml
@@ -12,8 +12,11 @@
org.openecomp.sdc.be.model.cache,
org.openecomp.sdc.be.dao.titan,
org.openecomp.sdc.be.dao.cassandra,
- org.openecomp.sdc.be.model.jsontitan.utils">
+ org.openecomp.sdc.be.model.jsontitan.utils
+ ">
+
</context:component-scan>
-
+ <bean name="healingPipelineDao" class="org.openecomp.sdc.be.dao.impl.HealingPipelineDao"/>
+ <import resource="healing-context-test.xml"/>
</beans>
diff --git a/catalog-model/src/test/resources/dao.properties b/catalog-model/src/test/resources/dao.properties
new file mode 100644
index 0000000..5306906
--- /dev/null
+++ b/catalog-model/src/test/resources/dao.properties
@@ -0,0 +1,16 @@
+#
+# Copyright ? 2016-2018 European Support Limited
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+current.heal.version = 0
\ No newline at end of file
diff --git a/catalog-model/src/test/resources/healing-context-test.xml b/catalog-model/src/test/resources/healing-context-test.xml
new file mode 100644
index 0000000..16c96df
--- /dev/null
+++ b/catalog-model/src/test/resources/healing-context-test.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+
+ <context:property-placeholder location="classpath:dao.properties" />
+</beans>
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
index a2f7bbb..4613a59 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
@@ -55,7 +55,10 @@
//Archive/Restore
IS_ARCHIVED ("isArchived", Boolean.class, false, true),
IS_VSP_ARCHIVED ("isVspArchived", Boolean.class, false, true),
- ARCHIVE_TIME ("archiveTime", Long.class, false, true);
+ ARCHIVE_TIME ("archiveTime", Long.class, false, true),
+
+ //Healing
+ HEALING_VERSION ("healVersion", Integer.class, false, true);
private String property;
private Class clazz;