equal
deleted
inserted
replaced
46 "WHERE " + Data.session_name.equal(session_name) + |
46 "WHERE " + Data.session_name.equal(session_name) + |
47 (if (theory_name == "") "" else " AND " + Data.theory_name.equal(theory_name)) + |
47 (if (theory_name == "") "" else " AND " + Data.theory_name.equal(theory_name)) + |
48 (if (name == "") "" else " AND " + Data.name.equal(name)) |
48 (if (name == "") "" else " AND " + Data.name.equal(name)) |
49 } |
49 } |
50 |
50 |
51 sealed case class Entry_Name(session: String, theory: String, name: String) { |
51 sealed case class Entry_Name(session: String = "", theory: String = "", name: String = "") { |
52 def readable(db: SQL.Database): Boolean = { |
52 def readable(db: SQL.Database): Boolean = { |
53 val select = Data.table.select(List(Data.name), Data.where_equal(session, theory, name)) |
53 val select = Data.table.select(List(Data.name), Data.where_equal(session, theory, name)) |
54 db.using_statement(select)(stmt => stmt.execute_query().next()) |
54 db.using_statement(select)(stmt => stmt.execute_query().next()) |
55 } |
55 } |
56 |
56 |
110 |
110 |
111 def compound_name(a: String, b: String): String = |
111 def compound_name(a: String, b: String): String = |
112 if (a.isEmpty) b else a + ":" + b |
112 if (a.isEmpty) b else a + ":" + b |
113 |
113 |
114 def empty_entry(theory_name: String, name: String): Entry = |
114 def empty_entry(theory_name: String, name: String): Entry = |
115 Entry(Entry_Name("", theory_name, name), false, Future.value(false, Bytes.empty), XML.Cache.none) |
115 Entry(Entry_Name(theory = theory_name, name = name), |
|
116 false, Future.value(false, Bytes.empty), XML.Cache.none) |
116 |
117 |
117 sealed case class Entry( |
118 sealed case class Entry( |
118 entry_name: Entry_Name, |
119 entry_name: Entry_Name, |
119 executable: Boolean, |
120 executable: Boolean, |
120 body: Future[(Boolean, Bytes)], |
121 body: Future[(Boolean, Bytes)], |
190 cache: XML.Cache |
191 cache: XML.Cache |
191 ): Entry = { |
192 ): Entry = { |
192 val body = |
193 val body = |
193 if (args.compress) Future.fork(bytes.maybe_compress(cache = cache.xz)) |
194 if (args.compress) Future.fork(bytes.maybe_compress(cache = cache.xz)) |
194 else Future.value((false, bytes)) |
195 else Future.value((false, bytes)) |
195 val entry_name = Entry_Name(session_name, args.theory_name, args.name) |
196 val entry_name = Entry_Name(session = session_name, theory = args.theory_name, name = args.name) |
196 Entry(entry_name, args.executable, body, cache) |
197 Entry(entry_name, args.executable, body, cache) |
197 } |
198 } |
198 |
199 |
199 |
200 |
200 /* database consumer thread */ |
201 /* database consumer thread */ |
275 session_name: String, |
276 session_name: String, |
276 theory_name: String |
277 theory_name: String |
277 ) : Provider = { |
278 ) : Provider = { |
278 new Provider { |
279 new Provider { |
279 def apply(export_name: String): Option[Entry] = |
280 def apply(export_name: String): Option[Entry] = |
280 Entry_Name(session_name, theory_name, export_name).read(db, cache) |
281 Entry_Name(session = session_name, theory = theory_name, name = export_name) |
|
282 .read(db, cache) |
281 |
283 |
282 def focus(other_theory: String): Provider = |
284 def focus(other_theory: String): Provider = |
283 if (other_theory == theory_name) this |
285 if (other_theory == theory_name) this |
284 else Provider.database(db, cache, session_name, other_theory) |
286 else Provider.database(db, cache, session_name, other_theory) |
285 |
287 |
310 session_name: String, |
312 session_name: String, |
311 theory_name: String |
313 theory_name: String |
312 ) : Provider = { |
314 ) : Provider = { |
313 new Provider { |
315 new Provider { |
314 def apply(export_name: String): Option[Entry] = |
316 def apply(export_name: String): Option[Entry] = |
315 Entry_Name(session_name, theory_name, export_name).read(dir, cache) |
317 Entry_Name(session = session_name, theory = theory_name, name = export_name) |
|
318 .read(dir, cache) |
316 |
319 |
317 def focus(other_theory: String): Provider = |
320 def focus(other_theory: String): Provider = |
318 if (other_theory == theory_name) this |
321 if (other_theory == theory_name) this |
319 else Provider.directory(dir, cache, session_name, other_theory) |
322 else Provider.directory(dir, cache, session_name, other_theory) |
320 |
323 |
361 // export |
364 // export |
362 if (export_patterns.nonEmpty) { |
365 if (export_patterns.nonEmpty) { |
363 val matcher = make_matcher(export_patterns) |
366 val matcher = make_matcher(export_patterns) |
364 for { |
367 for { |
365 (theory_name, name) <- export_names if matcher(theory_name, name) |
368 (theory_name, name) <- export_names if matcher(theory_name, name) |
366 entry <- Entry_Name(session_name, theory_name, name).read(db, store.cache) |
369 entry <- Entry_Name(session = session_name, theory = theory_name, name = name) |
|
370 .read(db, store.cache) |
367 } { |
371 } { |
368 val elems = theory_name :: space_explode('/', name) |
372 val elems = theory_name :: space_explode('/', name) |
369 val path = |
373 val path = |
370 if (elems.length < export_prune + 1) { |
374 if (elems.length < export_prune + 1) { |
371 error("Cannot prune path by " + export_prune + " element(s): " + Path.make(elems)) |
375 error("Cannot prune path by " + export_prune + " element(s): " + Path.make(elems)) |