airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scnakand...@apache.org
Subject airavata git commit: removing duplicates
Date Fri, 24 Feb 2017 20:25:19 GMT
Repository: airavata
Updated Branches:
  refs/heads/develop 1378dbdb0 -> 6c367b92d


removing duplicates


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/6c367b92
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/6c367b92
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/6c367b92

Branch: refs/heads/develop
Commit: 6c367b92d589dd79926d47f534c232b6161d85b0
Parents: 1378dbd
Author: scnakandala <supun.nakandala@gmail.com>
Authored: Fri Feb 24 15:25:15 2017 -0500
Committer: scnakandala <supun.nakandala@gmail.com>
Committed: Fri Feb 24 15:25:15 2017 -0500

----------------------------------------------------------------------
 .../registry/db/repositories/EntityRepository.java   | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/6c367b92/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
----------------------------------------------------------------------
diff --git a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
index 2d16d34..d713124 100644
--- a/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
+++ b/modules/sharing-registry/sharing-registry-server/src/main/java/org/apache/airavata/sharing/registry/db/repositories/EntityRepository.java
@@ -30,10 +30,7 @@ import org.apache.airavata.sharing.registry.models.*;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 public class EntityRepository extends AbstractRepository<Entity, EntityEntity, EntityPK>
{
     private final static Logger logger = LoggerFactory.getLogger(EntityRepository.class);
@@ -57,7 +54,7 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity,
E
             groupIdString += groupId + "','";
         groupIdString = groupIdString.substring(0, groupIdString.length()-2);
 
-        String query = "SELECT DISTINCT E.* FROM ENTITY AS E INNER JOIN SHARING AS S ON (E.ENTITY_ID=S.ENTITY_ID
AND E.DOMAIN_ID=S.DOMAIN_ID) WHERE " +
+        String query = "SELECT E.* FROM ENTITY AS E INNER JOIN SHARING AS S ON (E.ENTITY_ID=S.ENTITY_ID
AND E.DOMAIN_ID=S.DOMAIN_ID) WHERE " +
                 "E.DOMAIN_ID = '" + domainId + "' AND " + "S.GROUP_ID IN(" + groupIdString
+ ") AND ";
 
         for(SearchCriteria searchCriteria : filters){
@@ -135,6 +132,8 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity,
E
                 .setMaxResults(newLimit).getResultList());
         List<Entity> resultSet = new ArrayList<>();
 
+        HashMap<String, Object> keys = new HashMap<>();
+
         temp.stream().forEach(rs->{
             Entity entity = new Entity();
             entity.setEntityId((String)(rs[0]));
@@ -150,7 +149,11 @@ public class EntityRepository extends AbstractRepository<Entity, EntityEntity,
E
             entity.setCreatedTime((long)(rs[10]));
             entity.setUpdatedTime((long)(rs[11]));
 
-            resultSet.add(entity);
+            //Removing duplicates. Another option is to change the query to remove duplicates.
+            if (!keys.containsKey(entity + domainId + "," + entity.entityId)) {
+                resultSet.add(entity);
+                keys.put(entity + domainId + "," + entity.entityId, null);
+            }
         });
 
         return resultSet;


Mime
View raw message