m5db

package module
v0.0.0-...-84aae2b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2024 License: MIT Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ColumnNamesCsv_CNT = "IDX_inbatch, RelFP, AbsFP, Descr, T_Cre, T_Imp, T_Edt, " +
	"RawMT, Mimtp, MType, Contt"

ColumnNamesCsv_CNT TODO: this can be left unset and then (easily!) auto-generated from ColumnSpecsCNT.

View Source
var ColumnNamesCsv_INB = "FilCt, Descr, T_Cre, T_Imp, T_Edt, RelFP, AbsFP"

ColumnNamesCsv_INB is TODO: It should be auto-generated!

View Source
var ColumnNamesCsv_TRF = "idx_cnt_map, idx_cnt_tpc"

ColumnNamesCsv_TRF is TODO: It should be auto-generated!

View Source
var ColumnSpecsCNT = []D.ColumnSpec{
	D.ColumnSpec{D.SFT_FRKEY.DT(), "idx_inbatch", "inbatch",
		"Input batch of imported content"},
	D.DD_RelFP,
	D.DD_AbsFP,
	D.ColumnSpec{D.SFT_FTEXT.DT(), "descr", "Description",
		"Content entity description"},
	D.DD_T_Cre,
	D.DD_T_Imp,
	D.DD_T_Edt,
	D.ColumnSpec{D.SFT_TOKEN.DT(), "rawmt", "Markup type", "Raw markup type"},
	D.ColumnSpec{D.SFT_STRNG.DT(), "mimtp", "MIME type", "MIME type"},
	D.ColumnSpec{D.SFT_STRNG.DT(), "mtype", "MType", "MType"},
	D.ColumnSpec{D.SFT_FTEXT.DT(), "contt", "Content", "Entity raw content"},
}

ColumnSpecsCNT field order MUST be kept in sync with ColumnNamesCsvCNT and [ColumnPtrsCNT] and it specifies:

  • a primary key (actually, it does NOT - a primary key is assumed, and handled elsewhere)
  • a foreign key "inbatch"
  • two path fields (rel & abs)
  • three time fields (creation, import, last-edit)
  • a description
  • three content-type fields (raw markup type, MIME-type, MType); NOTE: these are persisted in the DB because
  • - they are useful in searching thru content
  • - they can be expensive to calculate at import time
  • - they can be overridden by choices made by users
  • the content itself
  • (not for now!) XML content type and XML DOCTYPE
  • (not for now!) two LwDITA fields (flavor [xdita,hdita!,mdita]), LwDITA content type)

.

View Source
var ColumnSpecsINB = []D.ColumnSpec{
	D.ColumnSpec{D.SFT_COUNT.DT(), "filct",
		"Nr. of files", "Number of files"},
	D.ColumnSpec{D.SFT_FTEXT.DT(), "descr",
		"Batch descr.", "Inbatch description"},
	D.DD_T_Cre,
	D.DD_T_Imp,
	D.DD_T_Edt,
	D.DD_RelFP,
	D.DD_AbsFP,
}

ColumnSpecsINB field order MUST be kept in sync with ColumnNamesCsvINB and [ColumnPtrsINB]. It specifies:

  • file count
  • two path fields (rel & abs) (placed at the end because they tend to be looong)
  • three time fields (creation, import, last-edit) (the meaning of creation is TBD)
  • description
  • NOT the primary key, which is handled automatically

.

View Source
var ColumnSpecsTRF = []D.ColumnSpec{
	D.ColumnSpec{D.SFT_FRKEY.DT(), "idx_cnt_map", "contentity",
		"Referencing map"},
	D.ColumnSpec{D.SFT_FRKEY.DT(), "idx_cnt_tpc", "contentity",
		"Referenced topic"},
}

ColumnSpecsTRF field order MUST be kept in sync with ColumnNamesCsvTRF and [ColumnPtrsTRF] and it specifies:

  • the primary index into table "contentity" of the map that makes the reference
  • the primary index into table "contentity" of the topic that is referred to
  • NOT the primary key, which is handled automatically

Note that it is unclear ATM so far whether this table also includes maps referring to submaps, or topics referring to other topics. .

M5_TableDetails configures the three key tables.

View Source
var PKSpecCNT = D.ColumnSpec{D.SFT_PRKEY.DT(),
	"idx_contentity", "Pri.key", "Primary key"}

PKSpecCNT should be auto.generated!

View Source
var PKSpecINB = D.ColumnSpec{D.SFT_PRKEY.DT(),
	"idx_inbatch", "Pri.key", "Primary key"}

PKSpecINB specifies the table's primary key. TODO: It should be auto.generated!

View Source
var PKSpecTRF = D.ColumnSpec{D.SFT_PRKEY.DT(),
	"idx_topicref", "Pri.key", "Primary key"}

PKSpecTRF specifies the table's primary key. TODO: It should be auto.generated!

View Source
var TableDetailsCNT = DRM.TableDetails{
	TableSummaryCNT,
	"idx_contentity",
	"IDX_inbatch, RelFP, AbsFP, Descr, T_Cre, T_Imp, T_Edt, " +
		"RawMT, Mimtp, MType, Contt",

	ColumnSpecsCNT,
	ColumnPtrsFuncCNT,

	&ContentityRow{},
}

TableDetailsCNT specifies 11 DB columns, incl primary key (assumed) and one foreign key, "inbatch".

TableDetailsINB TBS has no foreign keys.

TableDetailsTRF specifies only two foreign keys.

View Source
var TableSummaryCNT = D.TableSummary{
	D.SCT_TABLE.DT(), "contentity", "cnt", "Content entity"}

TableSummaryCNT summarizes the table.

View Source
var TableSummaryINB = D.TableSummary{
	D.SCT_TABLE.DT(), "inbatch", "inb",
	"Input batch of imported files"}
View Source
var TableSummaryTRF = D.TableSummary{
	D.SCT_TABLE.DT(), "topicref", "trf",
	"Reference from map to topic"}

Functions

func ColumnNamesCsvCNT

func ColumnNamesCsvCNT(inclPK bool) string

func ColumnNamesCsvINB

func ColumnNamesCsvINB(inclPK bool) string

ColumnNamesCsvINB is TODO: this can be left unset and then (easily!) auto-generated from ColumnSpecsINB.

func ColumnNamesCsvTRF

func ColumnNamesCsvTRF(inclPK bool) string

ColumnNamesCsvTRF is TODO: this can be left unset and then (easily!) auto-generated from ColumnSpecsTRF.

func ColumnPtrsFuncCNT

func ColumnPtrsFuncCNT(acro DRM.RowModel, inclPK bool) []any

ColumnPtrsFuncCNT goes into a field in struct TableDetails and MUST be kept in sync:

func ColumnPtrsFuncCNT(cro *ContentityRow, inclPK bool) []any {

func ColumnPtrsFuncINB

func ColumnPtrsFuncINB(ainbro DRM.RowModel, inclPK bool) []any

ColumnPtrsFuncINB supplies a field in TableDetails. NOTE: It MUST be kept in sync:

func ColumnPtrsFuncINB(inbro *InbatchRow, inclPK bool) []any {

func ColumnPtrsFuncTRF

func ColumnPtrsFuncTRF(atro DRM.RowModel, inclPK bool) []any

ColumnPtrsFuncTRF MUST be kept in sync:

func ColumnPtrsFuncTRF(tro *TopicrefRow, inclPK bool) []any {

Types

type ContentityRow

type ContentityRow struct {
	Idx_Contentity int
	Idx_Inbatch    int // NOTE: Rename to FILESET? Could be multiple?
	Descr          string
	// Times is T_Cre, T_Imp, T_Edt string
	DRU.Times
	// FSItem has Raw [the byte content) AND path and
	// name information AND whether it is a directory
	// (indicated by SU.MarkupType == MU_type_DIRLIKE).
	// NOTE that directory-like and byte-content are
	// mutually exclusive !!
	// CT.TypedRaw { Raw, SU.MarkupType string };
	// RelFP, ShortFP string;
	// FileMeta { os.FileInfo, exists bool, MU.Errer }
	FU.FSItem
	// PathAnalysis is a ptr, so that we get a
	// NPE if it is not initialized properly;
	// or if analysis failed, if (for example)
	// the content is too short.
	// FU.PathAnalysis is
	// XU.ContypingInfo { FileExt, MimeType, =>
	//   MimeTypeAsSnift, MType string }
	// ContentityBasics { XmlRoot, Text, Meta CT.Span; // => TopLevel !!
	//     MetaFormat string; MetaProps SU.PropSet }
	// XmlContype string
	// *XU.ParsedPreamble
	// *XU.ParsedDoctype
	// DitaFlavor  string
	// DitaContype string
	*CA.PathAnalysis // NEED DETAIL

}

ContentityRow describes (in the DB) the entity's content plus its "dead properties" - basically, properties that are set by the user, rather than calculated as needed. Raw content is in [FSItem.TypedRaw.Raw] and directory typing is in [FSItem.TypedRaw.MarkupType] and they are MUTUALLY EXCLUSIVE.

func NewContentityRow

func NewContentityRow(pFSI *FU.FSItem, pPA *CA.PathAnalysis) (*ContentityRow, error)

NewContentityRow does content fetching & analysis, while "promoting" an [FSItem]; it work for "Dirlike" (directories and symlinks) too. If the second argument is nil, the first argument is verified to be Dirlike. In such case (Dirlike), the return value *ContentityRow is basically a shell. .

func (*ContentityRow) ColumnNamesCsv

func (cro *ContentityRow) ColumnNamesCsv(inclPK bool) string

func (*ContentityRow) ColumnPtrsMethod

func (cro *ContentityRow) ColumnPtrsMethod(inclPK bool) []any

func (*ContentityRow) Debug

func (p *ContentityRow) Debug() string

Debug implements Stringser FIXME

func (*ContentityRow) Echo

func (p *ContentityRow) Echo() string

Echo implements Stringser FIXME

func (*ContentityRow) Info

func (p *ContentityRow) Info() string

Info implements Stringser FIXME

func (*ContentityRow) String

func (p *ContentityRow) String() string

String implements Stringer FIXME

func (*ContentityRow) TableDetails

func (cro *ContentityRow) TableDetails() DRM.TableDetails

TableDetails returns the table detail info, given any instance.

type InbatchRow

type InbatchRow struct {
	Idx_Inbatch int
	FilCt       int
	Descr       string
	RelFP       string
	AbsFP       FU.AbsFilePath
	T_Cre       string
	T_Imp       string
	T_Edt       string
}

InbatchRow describes (in the DB) a single import batch (probably at the CLI field names); field names MUST be kept in sync with [ColumnPtrsINB].

  • NOTE: Maybe rename Inbatch* to FileSet* (and INB to FLS) ?
  • TODO: Maybe represent this (or, each file) with a dsmnd.NSPath: Batch.nr+Path

func (*InbatchRow) ColumnNamesCsv

func (cro *InbatchRow) ColumnNamesCsv(inclPK bool) string

func (*InbatchRow) ColumnPtrsMethod

func (inbro *InbatchRow) ColumnPtrsMethod(inclPK bool) []any

ColumnPtrsMethod is NOTE: Maybe do the "switch (Rowmodeler).RowmodelImplName" trick here.

func (*InbatchRow) Debug

func (p *InbatchRow) Debug() string

Debug implements Stringser FIXME

func (*InbatchRow) Echo

func (p *InbatchRow) Echo() string

Echo implements Stringser FIXME

func (*InbatchRow) Info

func (p *InbatchRow) Info() string

Info implements Stringser FIXME

func (*InbatchRow) String

func (p *InbatchRow) String() string

String implements Stringer FIXME

func (*InbatchRow) TableDetails

func (inb *InbatchRow) TableDetails() DRM.TableDetails

TableDetails returns the table detail info, given any instance.

type TopicrefRow

type TopicrefRow struct {
	Idx_Topicref       int
	Idx_Map_Contentity int
	Idx_Tpc_Contentity int
}

TopicrefRow describes (in the DB) a reference from a Map (i.e. TOC) to a Topic; field names MUST be kept in sync with [ColumnPtrsTRF].

Note that "Topic" does NOT necessarily refer to a DITA `topictref`element!

The relationship is N-to-N btwn Maps and Topics, so a TopicrefRow might not be unique because a map might explicitly reference a particular topic more than once. So for simplicity, let's create only one TopicrefRow per map/topic pair, and see if it creates problems elsewhere later on. Maybe a record also needs a "count" field.

Note also that if we decide to use multi-trees, then perhaps these links can count not just as kids for maps, but also as parents for topics. .

func (*TopicrefRow) ColumnNamesCsv

func (tro *TopicrefRow) ColumnNamesCsv(inclPK bool) string

func (*TopicrefRow) ColumnPtrsMethod

func (tro *TopicrefRow) ColumnPtrsMethod(inclPK bool) []any

ColumnPtrsMethod is NOTE: Maybe do the "switch (Rowmodeler).RowmodelImplName" trick here.

func (*TopicrefRow) Debug

func (p *TopicrefRow) Debug() string

Debug implements Stringser FIXME

func (*TopicrefRow) Echo

func (p *TopicrefRow) Echo() string

Echo implements Stringser FIXME

func (*TopicrefRow) Info

func (p *TopicrefRow) Info() string

Info implements Stringser FIXME

func (*TopicrefRow) String

func (p *TopicrefRow) String() string

String implements Stringer FIXME

func (*TopicrefRow) TableDetails

func (tro *TopicrefRow) TableDetails() DRM.TableDetails

TableDetails returns the table detail info, given any instance.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL