OSDN Git Service

Added "stack:" to supported search terms.
authorRandy Baumgarte <randy@fbn.cx>
Wed, 5 Jan 2011 23:41:19 +0000 (18:41 -0500)
committerRandy Baumgarte <randy@fbn.cx>
Mon, 10 Jan 2011 01:14:53 +0000 (20:14 -0500)
src/cx/fbn/nevernote/sql/REnSearch.java

index b2b4e44..7668f25 100644 (file)
@@ -55,6 +55,7 @@ public class REnSearch {
        private final List<String>      sourceApplication;\r
        private final List<String>      recoType;\r
        private final List<String>      todo;\r
        private final List<String>      sourceApplication;\r
        private final List<String>      recoType;\r
        private final List<String>      todo;\r
+       private final List<String>  stack;\r
        private final List<Tag>         tagIndex;\r
        private final ApplicationLogger logger;\r
 //     private final DatabaseConnection db;\r
        private final List<Tag>         tagIndex;\r
        private final ApplicationLogger logger;\r
 //     private final DatabaseConnection db;\r
@@ -85,6 +86,7 @@ public class REnSearch {
                recoType = new ArrayList<String>();\r
                todo = new ArrayList<String>();\r
                any = false;\r
                recoType = new ArrayList<String>();\r
                todo = new ArrayList<String>();\r
                any = false;\r
+               stack = new ArrayList<String>();\r
                \r
                if (s == null) \r
                        return;\r
                \r
                if (s == null) \r
                        return;\r
@@ -110,7 +112,7 @@ public class REnSearch {
        public List<String> getCreated() { return created; }\r
        public List<String> getUpdated() { return updated; }\r
        public List<String> getSubjectDate() { return subjectDate; }\r
        public List<String> getCreated() { return created; }\r
        public List<String> getUpdated() { return updated; }\r
        public List<String> getSubjectDate() { return subjectDate; }\r
-       \r
+       public List<String> getStack() { return stack; }\r
 \r
        // match tag names\r
        private boolean matchTagsAll(List<String> tagNames) {\r
 \r
        // match tag names\r
        private boolean matchTagsAll(List<String> tagNames) {\r
@@ -196,6 +198,28 @@ public class REnSearch {
                        return matchListAll(getNotebooks(), name);\r
        }\r
        // Match notebooks in search terms against notes\r
                        return matchListAll(getNotebooks(), name);\r
        }\r
        // Match notebooks in search terms against notes\r
+       private boolean matchNotebookStack(String guid) {\r
+               if (getStack().size() == 0)\r
+                       return true;\r
+               NotebookTable bookTable = new NotebookTable(logger, conn);\r
+               List<Notebook> books = bookTable.getAll();\r
+\r
+               String name = new String("");\r
+               for (int i=0; i<books.size(); i++) {\r
+                       if (guid.equalsIgnoreCase(books.get(i).getGuid())) {\r
+                               name = books.get(i).getStack();\r
+                               i=books.size();\r
+                       }\r
+               }\r
+               if (name == null)\r
+                       name = "";\r
+               if (any)\r
+                       return matchListAny(getStack(), name);\r
+               else\r
+                       return matchListAll(getStack(), name);\r
+       }\r
+\r
+       // Match notebooks in search terms against notes\r
        private boolean matchListAny(List<String> list, String title) {\r
                if (list.size() == 0)\r
                        return true;\r
        private boolean matchListAny(List<String> list, String title) {\r
                if (list.size() == 0)\r
                        return true;\r
@@ -411,6 +435,10 @@ public class REnSearch {
                                todo.add(word);\r
                        if (word.startsWith("-todo:")) \r
                                todo.add(word);\r
                                todo.add(word);\r
                        if (word.startsWith("-todo:")) \r
                                todo.add(word);\r
+                       if (word.startsWith("stack:"))\r
+                               stack.add(word);\r
+                       if (word.startsWith("-stack:"))\r
+                               stack.add(word);\r
 \r
                        if (word.startsWith("latitude:")) \r
                                latitude.add(word);\r
 \r
                        if (word.startsWith("latitude:")) \r
                                latitude.add(word);\r
@@ -731,6 +759,8 @@ public class REnSearch {
                                        good = false;\r
                                if (good && !matchNotebook(n.getNotebookGuid()))\r
                                        good = false;\r
                                        good = false;\r
                                if (good && !matchNotebook(n.getNotebookGuid()))\r
                                        good = false;\r
+                               if (good && !matchNotebookStack(n.getNotebookGuid()))\r
+                                       good = false;\r
                                if (good && !matchListAny(getIntitle(), n.getTitle()))\r
                                        good = false;\r
                                if (good && !matchListAny(getAuthor(), n.getAttributes().getAuthor()))\r
                                if (good && !matchListAny(getIntitle(), n.getTitle()))\r
                                        good = false;\r
                                if (good && !matchListAny(getAuthor(), n.getAttributes().getAuthor()))\r
@@ -752,6 +782,8 @@ public class REnSearch {
                                        good = false;\r
                                if (good && !matchNotebook(n.getNotebookGuid()))\r
                                        good = false;\r
                                        good = false;\r
                                if (good && !matchNotebook(n.getNotebookGuid()))\r
                                        good = false;\r
+                               if (good && !matchNotebookStack(n.getNotebookGuid()))\r
+                                       good = false;\r
                                if (good && !matchListAll(getIntitle(), n.getTitle()))\r
                                        good = false;\r
                                if (good && !matchListAll(getAuthor(), n.getAttributes().getAuthor()))\r
                                if (good && !matchListAll(getIntitle(), n.getTitle()))\r
                                        good = false;\r
                                if (good && !matchListAll(getAuthor(), n.getAttributes().getAuthor()))\r