[ 
https://issues.apache.org/jira/browse/OFBIZ-12526?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17482560#comment-17482560
 ] 

Ioan Eugen Stan commented on OFBIZ-12526:
-----------------------------------------

Hello [~pierresmits] , 

I uploaded a CSV file [^ofbiz-demo-data-count-by-tables.csv] with the count for 
all the entities in the database and also the select query that I used to get 
that count (used Derby). 

To get the data I did the follwoing:

Loaded the demo data with 
{code:java}
./gradle cleanAll loadAll{code}
Ran the following Clojure code to export data from the embedded derby populated 
from demo data:
{code:java}
(ns dev.ofbiz-play
  "OFBiz related code - exploratory."
  (:require [next.jdbc :as jdbc]
            [next.jdbc.result-set :as rs]
            [clojure.data.csv :as csv]
            [clojure.java.io :as io])){code}
{code:java}
(comment  ;; open jdbc connection to OFBiz derby embedded database loaded with 
./gradle cleanAll loadAll
  (let [db {:jdbcUrl 
"jdbc:derby:/home/ieugen/proiecte/ofbiz/ofbiz-framework/runtime/data/derby/ofbiz"}
        ds (jdbc/get-datasource db)]
    (with-open [connection (jdbc/get-connection ds)]
      ;; read jdbc metadata for all tables
      (let [metadata (.getMetaData connection)
            rs (.getTables metadata nil nil nil (into-array ["TABLE" "VIEW"]))
            ;; get the table names from the metadata response 
            table-names (map :SYSTABLES/TABLE_NAME
                             (filter #(= "OFBIZ" (:SYSSCHEMAS/TABLE_SCHEM %))
                                     (rs/datafiable-result-set rs ds)))
            ;; build the data we need by counting all fields from each tables
            results (map (fn [t]
                           (let [query (str "select count(*) as COUNT from 
OFBIZ." t)
                                 data (:COUNT (first (jdbc/execute! ds 
[query])))]
                             {:table-name t
                              :sql-query query
                              :data data})) table-names)
            ;; get only values from map as a vector
            report-data (map (juxt :table-name :data :sql-query) results)
            report-header ["table_name" "data" "sql-query"]]
        (with-open [writer (io/writer "ofbiz-demo-data-count-by-tables.csv")]
          (csv/write-csv writer
                         (concat [report-header] report-data))))))
  0) {code}
with the dependencies listed bellow: 
deps.edn
{code:java}
{:aliases  {:dev {:extra-paths ["development/src" "development/resources"]
                  :extra-deps {org.apache.derby/derby {:mvn/version "10.15.2.0"}
                               org.clojure/clojure {:mvn/version "1.10.3"}
                               org.clojure/data.csv {:mvn/version "1.0.0"}} }} 
}{code}





 

> Maintenance (demo) dataset(s)
> -----------------------------
>
>                 Key: OFBIZ-12526
>                 URL: https://issues.apache.org/jira/browse/OFBIZ-12526
>             Project: OFBiz
>          Issue Type: Improvement
>          Components: ALL APPLICATIONS
>    Affects Versions: Upcoming Branch
>            Reporter: Pierre Smits
>            Assignee: Pierre Smits
>            Priority: Major
>              Labels: consistency, usability, ux
>         Attachments: ofbiz-demo-data-count-by-tables.csv
>
>
> Good (demo) data increases the appeal of OFBiz, making it easier for both 
> user and contributor to understand how particular functions like screens, 
> services, etc. (should) work.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to