Replacing queries with AbstractRepository methods
MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepository.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationDeploymentRepository.java
@@ -111,16 +111,7 @@ public class ApplicationDeploymentRepository extends AppCatAbstractRepository<Ap
@Override
public ApplicationDeploymentDescription getApplicationDeployement(String deploymentId) throws AppCatalogException {
- Map<String, Object> queryParameters = new HashMap<>();
- queryParameters.put(DBConstants.ApplicationDeployment.APPLICATION_DEPLOYMENT_ID, deploymentId);
- List<ApplicationDeploymentDescription> applicationDeploymentDescriptionList = select(QueryConstants.FIND_APPLICATION_DEPLOYMENT, -1, 0, queryParameters);
-
- if(!applicationDeploymentDescriptionList.isEmpty() && applicationDeploymentDescriptionList != null) {
- logger.debug("Return the record (there is only one record)");
- return applicationDeploymentDescriptionList.get(0);
- }
-
- return null;
+ return get(deploymentId);
}
@Override

MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepository.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/appcatalog/ApplicationInterfaceRepository.java
@@ -155,30 +155,12 @@ public class ApplicationInterfaceRepository extends AppCatAbstractRepository<App
@Override
public ApplicationModule getApplicationModule(String moduleId) throws AppCatalogException {
ApplicationModuleRepository applicationModuleRepository = new ApplicationModuleRepository();
- Map<String, Object> queryParameters = new HashMap<>();
- queryParameters.put(DBConstants.ApplicationModule.APPLICATION_MODULE_ID, moduleId);
- List<ApplicationModule> applicationModuleList = applicationModuleRepository.select(QueryConstants.FIND_APPLICATION_MODULE, -1, 0, queryParameters);
-
- if(!applicationModuleList.isEmpty() && applicationModuleList != null) {
- logger.debug("Return the record (there is only one record)");
- return applicationModuleList.get(0);
- }
-
- return null;
+ return applicationModuleRepository.get(moduleId);
}
@Override
public ApplicationInterfaceDescription getApplicationInterface(String interfaceId) throws AppCatalogException {
- Map<String, Object> queryParameters = new HashMap<>();
- queryParameters.put(DBConstants.ApplicationInterface.APPLICATION_INTERFACE_ID, interfaceId);
- List<ApplicationInterfaceDescription> applicationInterfaceDescriptionList = select(QueryConstants.FIND_APPLICATION_INTERFACE, -1, 0, queryParameters);
-
- if(!applicationInterfaceDescriptionList.isEmpty() && applicationInterfaceDescriptionList != null) {
- logger.debug("Return the record (there is only one record)");
- return applicationInterfaceDescriptionList.get(0);
- }
-
- return null;
+ return get(interfaceId);
}
@Override

MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/DBConstants.java
@@ -24,7 +24,6 @@ public class DBConstants {
public static int SELECT_MAX_ROWS = 1000;
public static class ApplicationDeployment {
- public static final String APPLICATION_DEPLOYMENT_ID = "appDeploymentId";
public static final String APPLICATION_MODULE_ID = "appModuleId";
public static final String COMPUTE_HOST_ID = "computeHostId";
public static final String GATEWAY_ID = "gatewayId";
@@ -33,13 +32,11 @@ public class DBConstants {
}
public static class ApplicationModule {
- public static final String APPLICATION_MODULE_ID = "appModuleId";
public static final String APPLICATION_MODULE_NAME = "appModuleName";
public static final String GATEWAY_ID = "gatewayId";
}
public static class ApplicationInterface {
- public static final String APPLICATION_INTERFACE_ID = "applicationInterfaceId";
public static final String APPLICATION_NAME = "applicationName";
public static final String GATEWAY_ID = "gatewayId";
}

MODIFY
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/utils/QueryConstants.java
@@ -38,8 +38,6 @@ public interface QueryConstants {
"WHERE AD.appModuleId LIKE : " + DBConstants.ApplicationDeployment.APPLICATION_MODULE_ID;
String FIND_APPLICATION_DEPLOYMENTS_FOR_COMPUTE_HOST_ID = "SELECT AD FROM " + ApplicationDeploymentEntity.class.getSimpleName() + " AD " +
"WHERE AD.computeHostId LIKE : " + DBConstants.ApplicationDeployment.COMPUTE_HOST_ID;
- String FIND_APPLICATION_DEPLOYMENT = "SELECT AD FROM " + ApplicationDeploymentEntity.class.getSimpleName() + " AD " +
- "WHERE AD.appDeploymentId LIKE : " + DBConstants.ApplicationDeployment.APPLICATION_DEPLOYMENT_ID;
String GET_ALL_APPLICATION_DEPLOYMENTS = "SELECT AD FROM " + ApplicationDeploymentEntity.class.getSimpleName() + " AD";
String FIND_ACCESSIBLE_APPLICATION_DEPLOYMENTS = "SELECT AD FROM " + ApplicationDeploymentEntity.class.getSimpleName() + " AD " +
"WHERE AD.gatewayId LIKE : " + DBConstants.ApplicationDeployment.GATEWAY_ID + " AND AD.appDeploymentId IN :" +
@@ -51,8 +49,6 @@ public interface QueryConstants {
"WHERE AM.gatewayId LIKE : " + DBConstants.ApplicationModule.GATEWAY_ID;
String FIND_APPLICATION_MODULES_FOR_APPLICATION_MODULE_NAME = "SELECT AM FROM " + ApplicationModuleEntity.class.getSimpleName() + " AM " +
"WHERE AM.appModuleName LIKE : " + DBConstants.ApplicationModule.APPLICATION_MODULE_NAME;
- String FIND_APPLICATION_MODULE = "SELECT AM FROM " + ApplicationModuleEntity.class.getSimpleName() + " AM " +
- "WHERE AM.appModuleId LIKE : " + DBConstants.ApplicationModule.APPLICATION_MODULE_ID;
String FIND_ACCESSIBLE_APPLICATION_MODULES = "SELECT AM FROM " + ApplicationModuleEntity.class.getSimpleName() + " AM " +
", " + ApplicationDeploymentEntity.class.getSimpleName() + " AD WHERE AM.appModuleId = AD.appModuleId AND AM.gatewayId LIKE : " +
DBConstants.ApplicationModule.GATEWAY_ID + " AND AD.appDeploymentId IN :" + DBConstants.ApplicationDeployment.ACCESSIBLE_APPLICATION_DEPLOYMENT_IDS +
@@ -63,8 +59,6 @@ public interface QueryConstants {
"WHERE AI.gatewayId LIKE : " + DBConstants.ApplicationInterface.GATEWAY_ID;
String FIND_APPLICATION_INTERFACES_FOR_APPLICATION_NAME = "SELECT AI FROM " + ApplicationInterfaceEntity.class.getSimpleName() + " AI " +
"WHERE AI.applicationName LIKE : " + DBConstants.ApplicationInterface.APPLICATION_NAME;
- String FIND_APPLICATION_INTERFACE = "SELECT AI FROM " + ApplicationInterfaceEntity.class.getSimpleName() + " AI " +
- "WHERE AI.applicationInterfaceId LIKE : " + DBConstants.ApplicationInterface.APPLICATION_INTERFACE_ID;
String GET_ALL_APPLICATION_INTERFACES = "SELECT AI FROM " + ApplicationInterfaceEntity.class.getSimpleName() + " AI";
// Application Inputs Queries

Replacing queries with AbstractRepository methods