diff --git a/README.md b/README.md
index 473f43762..35f72ef3d 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
[![GitHub contributors](https://img.shields.io/github/contributors/tmobile/pacbot.svg)](https://github.com/tmobile/pacbot/graphs/contributors)
[![Gitter](https://github.com/tmobile/pacbot/blob/master/wiki/images/chat.svg)](https://gitter.im/TMO-OSS/PacBot)
-
+
# Introduction
diff --git a/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/TargetTypesRepository.java b/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/TargetTypesRepository.java
index 75f4d9cab..5d76d2163 100644
--- a/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/TargetTypesRepository.java
+++ b/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/TargetTypesRepository.java
@@ -64,5 +64,8 @@ public interface TargetTypesRepository extends JpaRepository getAllTargetTypes();
+
+ @Query("SELECT dataSourceName FROM TargetTypes WHERE targetName = (:targetType) ")
+ public String findDataSourceByTargetType(@Param("targetType") String targetType);
}
diff --git a/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/service/AssetGroupServiceImpl.java b/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/service/AssetGroupServiceImpl.java
index deec808b7..3c081a18b 100644
--- a/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/service/AssetGroupServiceImpl.java
+++ b/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/service/AssetGroupServiceImpl.java
@@ -304,7 +304,7 @@ private UpdateAssetGroupDetails buildAssetGroupDetails(final AssetGroupDetails e
targetTypesIndex.put(targetTypeDetails.getTargetType(), idx[0]);
targetTypes.setAdded(true);
targetTypes.setTargetName(targetTypeDetails.getTargetType());
- targetTypes.setAllAttributesName(commonService.getFieldNames(existingAssetGroupDetails.getDataSource() + "_" + targetTypeDetails.getTargetType(), targetTypeDetails.getTargetType()));
+ targetTypes.setAllAttributesName(commonService.getFieldNames(targetTypesRepository.findDataSourceByTargetType(targetTypeDetails.getTargetType()) + "_" + targetTypeDetails.getTargetType(), targetTypeDetails.getTargetType()));
if(targetTypeDetails.getAttributeName().equalsIgnoreCase("all") && targetTypeDetails.getAttributeValue().equalsIgnoreCase("all")) {
targetTypes.setIncludeAll(true);
targetTypes.setAttributes(Lists.newArrayList());
@@ -335,7 +335,7 @@ private UpdateAssetGroupDetails buildAssetGroupDetails(final AssetGroupDetails e
TargetTypesDetails targetTypeAttribute = new TargetTypesDetails();
targetTypeAttribute.setAttributes(Lists.newArrayList());
targetTypeAttribute.setTargetName(targetName.trim());
- targetTypeAttribute.setAllAttributesName(commonService.getFieldNames(existingAssetGroupDetails.getDataSource() + "_" + targetName, targetName));
+ targetTypeAttribute.setAllAttributesName(commonService.getFieldNames(targetTypesRepository.findDataSourceByTargetType(targetName) + "_" + targetName, targetName));
targetTypeAttribute.setIncludeAll(false);
attributes.add(targetTypeAttribute);
}
@@ -353,8 +353,9 @@ private boolean deleteAssetGroupAlias(final AssetGroupDetails assetGroupDetails)
if(!targetTypes.isEmpty()) {
targetTypes.forEach(targetType -> {
+ String targetName = targetType.getTargetType().toLowerCase().trim().replaceAll(" ", "-");
Map addObj = Maps.newHashMap();
- addObj.put("index", assetGroupDetails.getDataSource().toLowerCase().trim().replaceAll(" ", "-")+"_"+targetType.getTargetType().toLowerCase().trim().replaceAll(" ", "-"));
+ addObj.put("index", targetTypesRepository.findDataSourceByTargetType(targetName).toLowerCase().trim().replaceAll(" ", "-")+"_"+targetName);
addObj.put("alias", aliasName);
Map add = Maps.newHashMap();
add.put("remove", addObj);
@@ -384,7 +385,8 @@ private Map createAliasForAssetGroup(final CreateUpdateAssetGrou
final String aliasName = assetGroupDetailsJson.getGroupName().toLowerCase().trim().replaceAll(" ", "-");
for (int targetIndex = 0; targetIndex < targetTypes.size(); targetIndex++) {
Map addObj = Maps.newHashMap();
- addObj.put("index", assetGroupDetailsJson.getDataSourceName().toLowerCase().trim().replaceAll(" ", "-") + "_" + targetTypes.get(targetIndex).getTargetName().toLowerCase().trim().replaceAll(" ", "-"));
+ String targetType = targetTypes.get(targetIndex).getTargetName().toLowerCase().trim().replaceAll(" ", "-");
+ addObj.put("index", targetTypesRepository.findDataSourceByTargetType(targetType).toLowerCase().trim().replaceAll(" ", "-") + "_" + targetType);
addObj.put("alias", aliasName);
List attributes = Lists.newArrayList();
if (!targetTypes.get(targetIndex).isIncludeAll()) {
diff --git a/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/service/DatasourceService.java b/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/service/DatasourceService.java
index 4bec3f28e..b2a8411d2 100644
--- a/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/service/DatasourceService.java
+++ b/api/pacman-api-admin/src/main/java/com/tmobile/pacman/api/admin/repository/service/DatasourceService.java
@@ -15,7 +15,9 @@
******************************************************************************/
package com.tmobile.pacman.api.admin.repository.service;
-import java.util.Collection;
+import java.util.List;
+
+import com.tmobile.pacman.api.admin.repository.model.Datasource;
/**
* DataSource Service Functionalities
@@ -28,5 +30,5 @@ public interface DatasourceService {
* @author Nidhish
* @return All dataSource details list
*/
- public Collection