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"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="foam.mongoose"
android:versionCode="10"
android:versionCode="11"
android:versionName="1.0">
<application android:label="@string/app_name"
android:icon="@drawable/logo"
......
......@@ -213,6 +213,23 @@
(list "unique_id" "varchar" unique-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)
(let ((s (db-select
db (string-append
......@@ -230,6 +247,7 @@
(vector-ref i 0))
(cdr s)))))
(define (all-entities-where-ignore-delete db table type ktv)
(let ((s (db-select
db (string-append
......@@ -259,7 +277,7 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int "
"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)")
(ktv-key ktv) (ktv-value ktv)
"name" "deleted" type)))
......@@ -283,7 +301,7 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int "
"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)")
(ktv-key ktv) (ktv-value ktv)
(ktv-key ktv2) (ktv-value ktv2)
......@@ -308,7 +326,7 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int "
"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)")
(ktv-key ktv) (ktv-value ktv)
(ktv-key ktv2) (ktv-value ktv2) or-value
......@@ -324,7 +342,7 @@
(define (all-entities-where-newer db table type ktv ktv2)
(let ((s (db-select
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) " "
"as a on a.entity_id = e.entity_id and a.attribute_id = ? and a.value = ?"
"join " table "_value_" (ktv-type ktv2) " "
......@@ -333,11 +351,14 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int "
"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) "
"order by substr(n.value,3)")
"where e.entity_type = ? and (d.value='NULL' or d.value is NULL or d.value = 0) "
"order by substr(n.value,3)"
)
(ktv-key ktv) (ktv-value ktv)
(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))
(if (null? s)
'()
......@@ -358,7 +379,7 @@
"as n on n.entity_id = e.entity_id and n.attribute_id = ? "
"left join " table "_value_int "
"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)")
(ktv-key ktv) (ktv-value ktv)
(ktv-key ktv2) (ktv-value ktv2) "Unknown"
......@@ -413,6 +434,15 @@
(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)
(prof-start "db-all")
(let ((r (map
......
......@@ -86,7 +86,7 @@
db "local" "app-settings" "null" 1
(list
(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
......@@ -470,7 +470,7 @@
type 3 30 (layout 100 60 1 'left 0)
(map
(lambda (ii)
(dbg (list (car ii) (caddr ii))))
(list (car ii) (caddr ii)))
id->items)
(lambda (v state)
(cond
......@@ -996,7 +996,7 @@
(list
(populate-grid-selector
"gp-int-pack" "single"
(db-all db "sync" "pack") #f
(db-all-sort-normal db "sync" "pack") #f
(lambda (pack)
(entity-add-value! "id-other-pack" "varchar" (ktv-get pack "unique_id"))
(list)))
......@@ -1523,7 +1523,7 @@
(list
(populate-grid-selector
"choose-obs-pack-selector" "single"
(db-all db "sync" "pack") #f
(db-all-sort-normal db "sync" "pack") #f
(lambda (pack)
(msg "in selector" pack)
(set-current! 'pack pack)
......@@ -1702,7 +1702,7 @@
(lambda (activity arg)
(list
(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)
(set-current! 'pack pack)
(list (start-activity "manage-individual" 2 ""))))
......
......@@ -957,6 +957,9 @@ public class StarwispBuilder
///////////////////////////////////////////////////////////
// problem associating the id number
if (id==0) return;
// now try and find the widget
View vv=ctx.findViewById(id);
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