summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaulina Jankowska <paulinkaj1@gmail.com>2013-08-27 20:16:25 (GMT)
committer Paulina Jankowska <paulinkaj1@gmail.com>2013-08-27 20:16:25 (GMT)
commit56a72c92b813f2fd231fc30bd63b36bce88474fd (patch)
tree42bea37aa181cba5b3723b73e314aa0a553886c6
parent4dd989f2fb9599a901b8ce538b8bc41544721362 (diff)
downloadQCG-Data-56a72c92b813f2fd231fc30bd63b36bce88474fd.zip
QCG-Data-56a72c92b813f2fd231fc30bd63b36bce88474fd.tar.gz
QCG-Data-56a72c92b813f2fd231fc30bd63b36bce88474fd.tar.bz2
MetadataSearch engine for idrop-web - lots of condition nodes
-rw-r--r--idrop-web/grails-app/controllers/org/irods/mydrop/controller/MetadataSearchController.groovy40
1 files changed, 31 insertions, 9 deletions
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/MetadataSearchController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/MetadataSearchController.groovy
index 4fe3012..8feb5b3 100644
--- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/MetadataSearchController.groovy
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/MetadataSearchController.groovy
@@ -58,22 +58,30 @@ class MetadataSearchController {
List<MetaDataAndDomainData> queryResults = new ArrayList<MetaDataAndDomainData>()
List<MetaDataAndDomainData> finalResults = new ArrayList<MetaDataAndDomainData>()
- int counter = 0
+ int counter = -1
for(AVUNode avuNode in metadataSearchCommand.AVUNodes) { //for every condition node do:
if(avuNode.andOr == "Every") { //if every condition has to be fulfilled
queryResults = connectedByAnd(avuNode, dataObjAO, collectionAO)
} else { //if at least one condition has to be fulfilled
queryResults = connectedByOr(avuNode, dataObjAO, collectionAO)
- log.info(queryResults.toString())
}
- log.info("OPERATOR:" + metadataSearchCommand.AVUOps[counter])
+ if(counter >= 0) { //if there's more than one node, check operator between nodes
+ log.info("OPERATOR:" + metadataSearchCommand.AVUOps[counter])
+ if (metadataSearchCommand.AVUOps[counter] == "AND") {
+ finalResults = intersectLists(finalResults, queryResults)
+ } else {
+ finalResults = sumOfLists(finalResults, queryResults)
+ }
+ } else {
+ finalResults = sumOfLists(finalResults, queryResults)
+ }
counter++
}
- for (MetaDataAndDomainData data : queryResults){
+ for (MetaDataAndDomainData data : finalResults){
results.add(collectionAndDataObjectListAndSearchAO.getCollectionAndDataObjectListingEntryAtGivenAbsolutePath(data.domainObjectUniqueName))
}
@@ -135,12 +143,29 @@ class MetadataSearchController {
if(elem1.getDomainObjectUniqueName() == elem2.getDomainObjectUniqueName())
alreadyEx = true
}
- log.info("ATR:" + elem1.getAvuAttribute())
if(!alreadyEx) list2.add(elem1)
}
list2
}
+ private def intersectLists(List<MetaDataAndDomainData> list1, List<MetaDataAndDomainData> list2) {
+
+ List<MetaDataAndDomainData> finalList = new ArrayList<MetaDataAndDomainData>()
+ boolean ex = false
+
+ for(MetaDataAndDomainData elem1 in list1) {
+ ex = false
+ for(MetaDataAndDomainData elem2 in list2) {
+ if(elem1.getDomainObjectUniqueName() == elem2.getDomainObjectUniqueName())
+ ex = true
+ }
+ if(ex) finalList.add(elem1)
+ }
+ finalList
+ }
+
+
+
def chooseOperator(String op) {
switch(op){
case "=":
@@ -165,10 +190,7 @@ class MetadataSearchController {
AVUQueryOperatorEnum.LIKE;
break
case "not like":
-
- log.info("OP: notlike " + op)
- AVUQueryOperatorEnum.NOT_LIKE;
-
+ AVUQueryOperatorEnum.NOT_LIKE;
}
}