Commit 45dc469f authored by Dave Griffiths's avatar Dave Griffiths
Browse files

delete fix, pack ordering and possible crash fix with id numbers

parent f0d91e62
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foam.mongoose" package="foam.mongoose"
android:versionCode="10" android:versionCode="11"
android:versionName="1.0"> android:versionName="1.0">
<application android:label="@string/app_name" <application android:label="@string/app_name"
android:icon="@drawable/logo" android:icon="@drawable/logo"
......
...@@ -213,6 +213,23 @@ ...@@ -213,6 +213,23 @@
(list "unique_id" "varchar" unique-id) (list "unique_id" "varchar" unique-id)
(get-entity-plain db table entity-id)))) (get-entity-plain db table entity-id))))
(define (all-entities-sort-normal db table type)
(let ((s (db-select
db (string-append
"select e.entity_id from " table "_entity as e "
"join " table "_value_varchar "
"as n on n.entity_id = e.entity_id "
"where entity_type = ? and n.attribute_id = ? "
"order by n.value")
type "name")))
(msg (db-status db))
(if (null? s)
'()
(map
(lambda (i)
(vector-ref i 0))
(cdr s)))))
(define (all-entities db table type) (define (all-entities db table type)
(let ((s (db-select (let ((s (db-select
db (string-append db (string-append
...@@ -230,6 +247,7 @@ ...@@ -230,6 +247,7 @@
(vector-ref i 0)) (vector-ref i 0))
(cdr s))))) (cdr s)))))
(define (all-entities-where-ignore-delete db table type ktv) (define (all-entities-where-ignore-delete db table type ktv)
(let ((s (db-select (let ((s (db-select
db (string-append db (string-append
...@@ -259,7 +277,7 @@ ...@@ -259,7 +277,7 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? " "as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int " "left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = ? " "as d on d.entity_id = e.entity_id and d.attribute_id = ? "
"where e.entity_type = ? and (d.value is NULL or d.value = 0) " "where e.entity_type = ? and (d.value='NULL' or d.value is NULL or d.value = 0) "
"order by substr(n.value,3)") "order by substr(n.value,3)")
(ktv-key ktv) (ktv-value ktv) (ktv-key ktv) (ktv-value ktv)
"name" "deleted" type))) "name" "deleted" type)))
...@@ -283,7 +301,7 @@ ...@@ -283,7 +301,7 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? " "as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int " "left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = ? " "as d on d.entity_id = e.entity_id and d.attribute_id = ? "
"where e.entity_type = ? and (d.value is NULL or d.value = 0) " "where e.entity_type = ? and (d.value='NULL' or d.value is NULL or d.value = 0) "
"order by substr(n.value,3)") "order by substr(n.value,3)")
(ktv-key ktv) (ktv-value ktv) (ktv-key ktv) (ktv-value ktv)
(ktv-key ktv2) (ktv-value ktv2) (ktv-key ktv2) (ktv-value ktv2)
...@@ -308,7 +326,7 @@ ...@@ -308,7 +326,7 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? " "as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int " "left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = ? " "as d on d.entity_id = e.entity_id and d.attribute_id = ? "
"where e.entity_type = ? and (d.value is NULL or d.value = 0) " "where e.entity_type = ? and (d.value='NULL' or d.value is NULL or d.value = 0) "
"order by substr(n.value,3)") "order by substr(n.value,3)")
(ktv-key ktv) (ktv-value ktv) (ktv-key ktv) (ktv-value ktv)
(ktv-key ktv2) (ktv-value ktv2) or-value (ktv-key ktv2) (ktv-value ktv2) or-value
...@@ -324,7 +342,7 @@ ...@@ -324,7 +342,7 @@
(define (all-entities-where-newer db table type ktv ktv2) (define (all-entities-where-newer db table type ktv ktv2)
(let ((s (db-select (let ((s (db-select
db (string-append db (string-append
"select e.entity_id from " table "_entity as e " "select e.entity_id,d.value,b.value from " table "_entity as e "
"join " table "_value_" (ktv-type ktv) " " "join " table "_value_" (ktv-type ktv) " "
"as a on a.entity_id = e.entity_id and a.attribute_id = ? and a.value = ?" "as a on a.entity_id = e.entity_id and a.attribute_id = ? and a.value = ?"
"join " table "_value_" (ktv-type ktv2) " " "join " table "_value_" (ktv-type ktv2) " "
...@@ -333,11 +351,14 @@ ...@@ -333,11 +351,14 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? " "as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int " "left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = ? " "as d on d.entity_id = e.entity_id and d.attribute_id = ? "
"where e.entity_type = ? and (d.value is NULL or d.value = 0) " "where e.entity_type = ? and (d.value='NULL' or d.value is NULL or d.value = 0) "
"order by substr(n.value,3)") "order by substr(n.value,3)"
)
(ktv-key ktv) (ktv-value ktv) (ktv-key ktv) (ktv-value ktv)
(ktv-key ktv2) (ktv-value ktv2) "Unknown" (ktv-key ktv2) (ktv-value ktv2) "Unknown"
"name" "deleted" type))) "name" "deleted"
type)))
(msg "where newer" (ktv-value ktv2) s)
(msg "date select" (db-status db)) (msg "date select" (db-status db))
(if (null? s) (if (null? s)
'() '()
...@@ -358,7 +379,7 @@ ...@@ -358,7 +379,7 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? " "as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int " "left join " table "_value_int "
"as d on d.entity_id = e.entity_id and d.attribute_id = ? " "as d on d.entity_id = e.entity_id and d.attribute_id = ? "
"where e.entity_type = ? and (d.value is NULL or d.value = 0) " "where e.entity_type = ? and (d.value='NULL' or d.value is NULL or d.value = 0) "
"order by substr(n.value,3)") "order by substr(n.value,3)")
(ktv-key ktv) (ktv-value ktv) (ktv-key ktv) (ktv-value ktv)
(ktv-key ktv2) (ktv-value ktv2) "Unknown" (ktv-key ktv2) (ktv-value ktv2) "Unknown"
...@@ -413,6 +434,15 @@ ...@@ -413,6 +434,15 @@
(else (cons (car ktv-list) (ktv-set (cdr ktv-list) ktv))))) (else (cons (car ktv-list) (ktv-set (cdr ktv-list) ktv)))))
(define (db-all-sort-normal db table type)
(prof-start "db-all")
(let ((r (map
(lambda (i)
(get-entity db table i))
(all-entities-sort-normal db table type))))
(prof-end "db-all")
r))
(define (db-all db table type) (define (db-all db table type)
(prof-start "db-all") (prof-start "db-all")
(let ((r (map (let ((r (map
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
db "local" "app-settings" "null" 1 db "local" "app-settings" "null" 1
(list (list
(ktv "user-id" "varchar" "No name yet..."))) (ktv "user-id" "varchar" "No name yet...")))
(msg (db-all db "local" "app-settings"))) (msg (db-all-sort-normal db "local" "app-settings")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; stuff in memory ;; stuff in memory
...@@ -470,7 +470,7 @@ ...@@ -470,7 +470,7 @@
type 3 30 (layout 100 60 1 'left 0) type 3 30 (layout 100 60 1 'left 0)
(map (map
(lambda (ii) (lambda (ii)
(dbg (list (car ii) (caddr ii)))) (list (car ii) (caddr ii)))
id->items) id->items)
(lambda (v state) (lambda (v state)
(cond (cond
...@@ -996,7 +996,7 @@ ...@@ -996,7 +996,7 @@
(list (list
(populate-grid-selector (populate-grid-selector
"gp-int-pack" "single" "gp-int-pack" "single"
(db-all db "sync" "pack") #f (db-all-sort-normal db "sync" "pack") #f
(lambda (pack) (lambda (pack)
(entity-add-value! "id-other-pack" "varchar" (ktv-get pack "unique_id")) (entity-add-value! "id-other-pack" "varchar" (ktv-get pack "unique_id"))
(list))) (list)))
...@@ -1523,7 +1523,7 @@ ...@@ -1523,7 +1523,7 @@
(list (list
(populate-grid-selector (populate-grid-selector
"choose-obs-pack-selector" "single" "choose-obs-pack-selector" "single"
(db-all db "sync" "pack") #f (db-all-sort-normal db "sync" "pack") #f
(lambda (pack) (lambda (pack)
(msg "in selector" pack) (msg "in selector" pack)
(set-current! 'pack pack) (set-current! 'pack pack)
...@@ -1702,7 +1702,7 @@ ...@@ -1702,7 +1702,7 @@
(lambda (activity arg) (lambda (activity arg)
(list (list
(populate-grid-selector (populate-grid-selector
"manage-packs-list" "button" (db-all db "sync" "pack") #f "manage-packs-list" "button" (db-all-sort-normal db "sync" "pack") #f
(lambda (pack) (lambda (pack)
(set-current! 'pack pack) (set-current! 'pack pack)
(list (start-activity "manage-individual" 2 "")))) (list (start-activity "manage-individual" 2 ""))))
......
...@@ -957,6 +957,9 @@ public class StarwispBuilder ...@@ -957,6 +957,9 @@ public class StarwispBuilder
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
// problem associating the id number
if (id==0) return;
// now try and find the widget // now try and find the widget
View vv=ctx.findViewById(id); View vv=ctx.findViewById(id);
if (vv==null) if (vv==null)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment