This is an automated email from the ASF dual-hosted git repository.
isjarana pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/airavata-custos.git
The following commit(s) were added to refs/heads/develop by this push:
new ec860f2 Fix for issue 142
new be77618 Merge pull request #165 from isururanawaka/refactor_develop
ec860f2 is described below
commit ec860f2f4fce5717778c1c83b4c901db1794fabc
Author: Isuru Ranawaka <[email protected]>
AuthorDate: Wed May 19 12:26:02 2021 -0400
Fix for issue 142
---
.../respository/SearchTenantRepositoryImpl.java | 16 +++++++++++++++-
.../profile/service/TenantProfileService.java | 16 +---------------
.../src/main/proto/TenantProfileService.proto | 13 +++++++------
.../main/resources/tenant-management-service.pb | Bin 151021 -> 151075 bytes
4 files changed, 23 insertions(+), 22 deletions(-)
diff --git
a/custos-core-services/tenant-profile-core-service/src/main/java/org/apache/custos/tenant/profile/persistance/respository/SearchTenantRepositoryImpl.java
b/custos-core-services/tenant-profile-core-service/src/main/java/org/apache/custos/tenant/profile/persistance/respository/SearchTenantRepositoryImpl.java
index 54707a0..470f720 100644
---
a/custos-core-services/tenant-profile-core-service/src/main/java/org/apache/custos/tenant/profile/persistance/respository/SearchTenantRepositoryImpl.java
+++
b/custos-core-services/tenant-profile-core-service/src/main/java/org/apache/custos/tenant/profile/persistance/respository/SearchTenantRepositoryImpl.java
@@ -60,22 +60,36 @@ public class SearchTenantRepositoryImpl implements
SearchTenantRepository {
if (requestEmail != null && !requestEmail.isEmpty()) {
query = query + "E.requester_email = :" + "requester_email" + "
AND ";
valueMap.put("requester_email", requestEmail);
+
}
if (status != null && !status.isEmpty()) {
query = query + "E.status LIKE :" + "status" + " AND ";
valueMap.put("status", status);
+
}
if (parentId > 0) {
query = query + "E.parent_id = :" + "parent_id" + " AND ";
valueMap.put("parent_id", parentId);
+
+ }
+
+ if ((requestEmail == null || requestEmail.isEmpty()) && (status ==
null || status.isEmpty()) && parentId == 0) {
+ String directQuery = "SELECT * FROM tenant E ORDER BY E.created_at
DESC";
+ if (limit > 0) {
+ directQuery = directQuery + " LIMIT " + ":limit" + " OFFSET "
+ ":offset";
+ valueMap.put("limit", limit);
+ valueMap.put("offset", offset);
+ }
+ return directQuery;
}
query = query.substring(0, query.length() - 5);
query = query + " ORDER BY E.created_at DESC";
- if (offset > 0 & limit > 0) {
+
+ if (limit > 0) {
query = query + " LIMIT " + ":limit" + " OFFSET " + ":offset";
valueMap.put("limit", limit);
valueMap.put("offset", offset);
diff --git
a/custos-core-services/tenant-profile-core-service/src/main/java/org/apache/custos/tenant/profile/service/TenantProfileService.java
b/custos-core-services/tenant-profile-core-service/src/main/java/org/apache/custos/tenant/profile/service/TenantProfileService.java
index f3081ed..223182f 100644
---
a/custos-core-services/tenant-profile-core-service/src/main/java/org/apache/custos/tenant/profile/service/TenantProfileService.java
+++
b/custos-core-services/tenant-profile-core-service/src/main/java/org/apache/custos/tenant/profile/service/TenantProfileService.java
@@ -164,7 +164,7 @@ public class TenantProfileService extends
TenantProfileServiceImplBase {
String status = null;
- if (request.getStatus() != null &&
!request.getStatus().name().equals("")) {
+ if (!request.getStatus().equals(TenantStatus.UNKNOWN)) {
status = request.getStatus().name();
}
@@ -177,20 +177,6 @@ public class TenantProfileService extends
TenantProfileServiceImplBase {
List<Tenant> tenants = null;
List<Tenant> total_tenants = null;
-// if (status == null && requesterEmail != null &&
!requesterEmail.equals("")) {
-// tenants =
tenantRepository.findByRequesterEmail(requesterEmail);
-// } else if(status != null && requesterEmail != null &&
!requesterEmail.equals("")) {
-// tenants =
tenantRepository.findByRequesterEmailAndStatus(requesterEmail, status);
-// } else if (status == null && parentId == 0) {
-// tenants = tenantRepository.getAllWithPaginate(limit,offset);
-// } else if (status != null && parentId == 0){
-// tenants =
tenantRepository.findByStatusWithPaginate(status,limit,offset);
-// } else if (status == null && parentId > 0) {
-// tenants =
tenantRepository.getAllChildTenantsWithPaginate(parentId,limit,offset);
-// } else if (status != null && parentId >0 ) {
-// tenants =
tenantRepository.findChildTenantsByStatusWithPaginate(status,parentId,limit,offset);
-// }
-
tenants = tenantRepository.searchTenants(requesterEmail, status,
parentId, limit, offset);
total_tenants = tenantRepository.searchTenants(requesterEmail,
status, parentId, -1, -1);
diff --git
a/custos-core-services/tenant-profile-core-service/src/main/proto/TenantProfileService.proto
b/custos-core-services/tenant-profile-core-service/src/main/proto/TenantProfileService.proto
index 6073bfc..f094023 100644
---
a/custos-core-services/tenant-profile-core-service/src/main/proto/TenantProfileService.proto
+++
b/custos-core-services/tenant-profile-core-service/src/main/proto/TenantProfileService.proto
@@ -55,12 +55,13 @@ message Tenant {
}
enum TenantStatus {
- REQUESTED = 0;
- APPROVED = 1;
- DENIED = 2;
- CANCELLED = 3;
- ACTIVE = 4;
- DEACTIVATED = 5;
+ UNKNOWN = 0;
+ REQUESTED = 1;
+ APPROVED = 2;
+ DENIED = 3;
+ CANCELLED = 4;
+ ACTIVE = 5;
+ DEACTIVATED = 6;
}
message TenantAttributeUpdateMetadata {
diff --git
a/custos-integration-services/tenant-management-service-parent/tenant-management-service-sidecar/src/main/resources/tenant-management-service.pb
b/custos-integration-services/tenant-management-service-parent/tenant-management-service-sidecar/src/main/resources/tenant-management-service.pb
index ac3ffff..bf65d59 100644
Binary files
a/custos-integration-services/tenant-management-service-parent/tenant-management-service-sidecar/src/main/resources/tenant-management-service.pb
and
b/custos-integration-services/tenant-management-service-parent/tenant-management-service-sidecar/src/main/resources/tenant-management-service.pb
differ