airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata] branch group-based-auth updated: AIRAVATA-2800 Using FieldConstants in ProjectRepository API
Date Mon, 04 Jun 2018 23:06:47 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch group-based-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/group-based-auth by this push:
     new e55f3cf  AIRAVATA-2800 Using FieldConstants in ProjectRepository API
e55f3cf is described below

commit e55f3cff0553ffe77a093bf192282a243d353c5c
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Mon Jun 4 19:05:53 2018 -0400

    AIRAVATA-2800 Using FieldConstants in ProjectRepository API
---
 .../core/repositories/expcatalog/ProjectRepository.java  | 15 ++++++++-------
 .../repositories/expcatalog/ProjectRepositoryTest.java   | 16 +++++++---------
 2 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepository.java
b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepository.java
index c3a231e..1535fe1 100644
--- a/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepository.java
+++ b/modules/registry-refactoring/src/main/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepository.java
@@ -28,6 +28,7 @@ import org.apache.airavata.registry.core.utils.ObjectMapperSingleton;
 import org.apache.airavata.registry.core.utils.QueryConstants;
 import org.apache.airavata.registry.cpi.RegistryException;
 import org.apache.airavata.registry.cpi.ResultOrderType;
+import org.apache.airavata.registry.cpi.utils.Constants;
 import org.dozer.Mapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -92,7 +93,7 @@ public class ProjectRepository extends ExpCatAbstractRepository<Project,
Project
                                          Object orderByIdentifier, ResultOrderType resultOrderType)
throws RegistryException{
         Map<String, Object> queryParameters = new HashMap<>();
 
-        if (fieldName.equals(DBConstants.Project.OWNER)) {
+        if (fieldName.equals(Constants.FieldConstants.ProjectConstants.OWNER)) {
             logger.debug("Checking if the field name is owner");
             queryParameters.put(DBConstants.Project.OWNER, value);
             List<Project> projectList = select(QueryConstants.GET_ALL_PROJECTS_FOR_OWNER,
limit, offset, queryParameters);
@@ -136,32 +137,32 @@ public class ProjectRepository extends ExpCatAbstractRepository<Project,
Project
         String query = "SELECT P FROM " + ProjectEntity.class.getSimpleName() + " P WHERE
";
         Map<String, Object> queryParameters = new HashMap<>();
 
-        if (filters == null || !filters.containsKey(DBConstants.Project.GATEWAY_ID)) {
+        if (filters == null || !filters.containsKey(Constants.FieldConstants.ProjectConstants.GATEWAY_ID))
{
             logger.error("GatewayId is required");
             throw new RegistryException("GatewayId is required");
         }
 
         for (String field : filters.keySet()) {
 
-            if (field.equals(DBConstants.Project.GATEWAY_ID)) {
+            if (field.equals(Constants.FieldConstants.ProjectConstants.GATEWAY_ID)) {
                 logger.debug("Filter Projects by Gateway ID");
                 queryParameters.put(DBConstants.Project.GATEWAY_ID, filters.get(field));
                 query += "P.gatewayId LIKE :" + DBConstants.Project.GATEWAY_ID + " AND ";
             }
 
-            else if (field.equals(DBConstants.Project.OWNER)) {
+            else if (field.equals(Constants.FieldConstants.ProjectConstants.OWNER)) {
                 logger.debug("Filter Projects by Owner");
                 queryParameters.put(DBConstants.Project.OWNER, filters.get(field));
                 query += "P.owner LIKE :" + DBConstants.Project.OWNER + " AND ";
             }
 
-            else if (field.equals(DBConstants.Project.PROJECT_NAME)) {
+            else if (field.equals(Constants.FieldConstants.ProjectConstants.PROJECT_NAME))
{
                 logger.debug("Filter Projects by Project Name");
                 queryParameters.put(DBConstants.Project.PROJECT_NAME, filters.get(field));
                 query += "P.name LIKE :" + DBConstants.Project.PROJECT_NAME + " AND ";
             }
 
-            else if (field.equals(DBConstants.Project.DESCRIPTION)) {
+            else if (field.equals(Constants.FieldConstants.ProjectConstants.DESCRIPTION))
{
                 logger.debug("Filter Projects by Description");
                 queryParameters.put(DBConstants.Project.DESCRIPTION, filters.get(field));
                 query += "P.description LIKE :" + DBConstants.Project.DESCRIPTION + " AND
";
@@ -185,7 +186,7 @@ public class ProjectRepository extends ExpCatAbstractRepository<Project,
Project
             query = query.substring(0, query.length() - 5);
         }
 
-        if (orderByIdentifier != null && resultOrderType != null && orderByIdentifier.equals(DBConstants.Project.CREATION_TIME))
{
+        if (orderByIdentifier != null && resultOrderType != null && orderByIdentifier.equals(Constants.FieldConstants.ProjectConstants.CREATION_TIME))
{
             String order = (resultOrderType == ResultOrderType.ASC) ? "ASC" : "DESC";
             query += " ORDER BY P." + DBConstants.Project.CREATION_TIME + " " + order;
         }
diff --git a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepositoryTest.java
b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepositoryTest.java
index 44f4800..6e09b0d 100644
--- a/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepositoryTest.java
+++ b/modules/registry-refactoring/src/test/java/org/apache/airavata/registry/core/repositories/expcatalog/ProjectRepositoryTest.java
@@ -23,8 +23,8 @@ package org.apache.airavata.registry.core.repositories.expcatalog;
 import org.apache.airavata.model.workspace.Gateway;
 import org.apache.airavata.model.workspace.Project;
 import org.apache.airavata.registry.core.repositories.expcatalog.util.Initialize;
-import org.apache.airavata.registry.core.utils.DBConstants;
 import org.apache.airavata.registry.cpi.RegistryException;
+import org.apache.airavata.registry.cpi.utils.Constants;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -36,9 +36,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.*;
 
 public class ProjectRepositoryTest {
 
@@ -88,16 +86,16 @@ public class ProjectRepositoryTest {
         Project retrievedProject = projectRepository.getProject(projectId);
         assertEquals(gatewayId, retrievedProject.getGatewayId());
 
-        assertTrue(projectRepository.getProjectIDs(DBConstants.Project.OWNER, "user").contains(projectId));
+        assertTrue(projectRepository.getProjectIDs(Constants.FieldConstants.ProjectConstants.OWNER,
"user").contains(projectId));
 
         List<String> accessibleProjectIds = new ArrayList<>();
         accessibleProjectIds.add(projectId);
 
         Map<String, String> filters = new HashMap<>();
-        filters.put(DBConstants.Project.GATEWAY_ID, retrievedProject.getGatewayId());
-        filters.put(DBConstants.Project.OWNER, retrievedProject.getOwner());
-        filters.put(DBConstants.Project.PROJECT_NAME, retrievedProject.getName());
-        filters.put(DBConstants.Project.DESCRIPTION, retrievedProject.getDescription());
+        filters.put(Constants.FieldConstants.ProjectConstants.GATEWAY_ID, retrievedProject.getGatewayId());
+        filters.put(Constants.FieldConstants.ProjectConstants.OWNER, retrievedProject.getOwner());
+        filters.put(Constants.FieldConstants.ProjectConstants.PROJECT_NAME, retrievedProject.getName());
+        filters.put(Constants.FieldConstants.ProjectConstants.DESCRIPTION, retrievedProject.getDescription());
 
         assertTrue(projectRepository.searchAllAccessibleProjects(accessibleProjectIds, filters,
                 -1, 0, null, null).size() == 1);

-- 
To stop receiving notification emails like this one, please contact
machristie@apache.org.

Mime
View raw message