cmd

package
v1.0.0-beta13 Latest Latest
Warning

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

Go to latest
Published: May 9, 2022 License: Apache-2.0 Imports: 28 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFileLoader = func(s string) (io.ReadCloser, error) {
	obj, err := cmdutil.ReadURL(s)
	if err != nil {
		return nil, err
	}
	return ioutil.NopCloser(bytes.NewReader(obj)), nil
}
View Source
var ExportTarget = io.Writer(os.Stdout)

Functions

func Execute

func Execute() error

Execute executes the root command.

func LoadBundle

func LoadBundle(ctx *ls.Context, file []string) (ls.SchemaLoader, error)

func LoadSchemaFromFileOrRepo

func LoadSchemaFromFileOrRepo(ctx *ls.Context, compiledSchema, repoDir, schemaName, typeName string, bundleNames []string) (*ls.Layer, error)

func LoadValuesetFiles

func LoadValuesetFiles(vs *Valuesets, files []string) error

func OutputIngestedGraph

func OutputIngestedGraph(cmd *cobra.Command, outFormat string, target graph.Graph, wr io.Writer, includeSchema bool) error

func ReadLayers

func ReadLayers(input []byte, interner ls.Interner) ([]*ls.Layer, error)

ReadLayers reads layer(s) from jsongraph, jsonld

Types

type Attribute

type Attribute struct {
	ID            string `json:"@id"`
	AttributeName string `json:"attributeName"`
	Types         string `json:"@type"`
}

Following structs are used to define a Layered Schema

type BaseIngestParams

type BaseIngestParams struct {
	Repo                 string   `json:"repo" yaml:"repo"`
	Schema               string   `json:"schema" yaml:"schema"`
	Type                 string   `json:"type" yaml:"type"`
	Bundle               []string `json:"bundle" yaml:"bundle"`
	CompiledSchema       string   `json:"compiledSchema" yaml:"compiledSchema"`
	EmbedSchemaNodes     bool     `json:"embedSchemaNodes" yaml:"embedSchemaNodes"`
	OnlySchemaAttributes bool     `json:"onlySchemaAttributes" yaml:"onlySchemaAttributes"`
}

func (BaseIngestParams) IsEmptySchema

func (b BaseIngestParams) IsEmptySchema() bool

IsEmptySchema returns true if none of the schema properties are set

type Bundle

type Bundle struct {
	Base               string                    `json:"base" yaml:"base"`
	SchemaSpreadsheets []SpreadsheetReference    `json:"schemaSpreadsheets" yaml:"schemaSpreadsheets"`
	TypeNames          map[string]*BundleVariant `json:"typeNames" yaml:"typeNames"`
}

Bundle defines type names for variants so references can be resolved

func ParseBundle

func ParseBundle(text string, contentType string) (*Bundle, error)

ParseBundle parses a bundle from JSON

func (*Bundle) GetLayers

func (bundle *Bundle) GetLayers(ctx *ls.Context, layers map[string]*ls.Layer, loader func(s string) (*ls.Layer, error), fileLoader func(string) (io.ReadCloser, error)) (map[string]*ls.Layer, error)

GetLayers returns the layers of the bundle keyed by variant type

func (Bundle) LoadSpreadsheets

func (b Bundle) LoadSpreadsheets(ctx *ls.Context) (map[string]*ls.Layer, error)

func (*Bundle) Merge

func (b *Bundle) Merge(bundle Bundle)

Merge bundle into b

func (*Bundle) ResolveFilenames

func (b *Bundle) ResolveFilenames(dir string)

type BundleSchemaRef

type BundleSchemaRef struct {
	Schema     string               `json:"schema,omitempty" yaml:"schema,omitempty"`
	LayerID    string               `json:"layerId,omitempty" yaml:"layerId,omitempty"`
	JSONSchema *JSONSchemaReference `json:"jsonSchema" yaml:"jsonSchema"`
	// contains filtered or unexported fields
}

func (BundleSchemaRef) GetLayerID

func (ref BundleSchemaRef) GetLayerID() string

GetLayerID returns the layer id for the schema reference

func (*BundleSchemaRef) Merge

func (b *BundleSchemaRef) Merge(ref BundleSchemaRef)

Merge resets b with ref if ref is nonempty

func (*BundleSchemaRef) ResolveFilenames

func (ref *BundleSchemaRef) ResolveFilenames(dir string)

type BundleVariant

type BundleVariant struct {
	BundleSchemaRef
	Overlays []BundleSchemaRef `json:"overlays" yaml:"overlays"`
}

BundleVariant combines a schema and overlays

func (*BundleVariant) Merge

func (b *BundleVariant) Merge(variant BundleVariant)

Merge variant into b

func (*BundleVariant) ResolveFilenames

func (b *BundleVariant) ResolveFilenames(dir string)

type CSVExport

type CSVExport struct {
	SpecFile string `json:"specFile" yaml:"specFile"`
	lscsv.Writer
	// contains filtered or unexported fields
}

func (CSVExport) Help

func (CSVExport) Help()

func (*CSVExport) Run

func (ecsv *CSVExport) Run(pipeline *PipelineContext) error

type CSVImportSpec

type CSVImportSpec struct {
	AttributeID  string         `json:"attributeId"`
	LayerType    string         `json:"layerType"`
	LayerID      string         `json:"layerId"`
	RootID       string         `json:"rootId"`
	ValueType    string         `json:"valueType"`
	EntityIDRows []int          `json:"entityIdRows"`
	EntityID     string         `json:"entityId"`
	Required     string         `json:"required"`
	StartRow     int            `json:"startRow"`
	NRows        int            `json:"nrows"`
	Terms        []dec.TermSpec `json:"terms"`
}

func (CSVImportSpec) Import

func (spec CSVImportSpec) Import(records [][]string) (*ls.Layer, error)

type CSVIngester

type CSVIngester struct {
	BaseIngestParams
	StartRow     int    `json:"startRow" yaml:"startRow"`
	EndRow       int    `json:"endRow" yaml:"endRow"`
	HeaderRow    int    `json:"headerRow" yaml:"headerRow"`
	ID           string `json:"id" yaml:"id"`
	IngestByRows bool   `json:"ingestByRows" yaml:"ingestByRows"`
	// contains filtered or unexported fields
}

func (CSVIngester) Help

func (CSVIngester) Help()

func (*CSVIngester) Run

func (ci *CSVIngester) Run(pipeline *PipelineContext) error

type ImportJSONSchemaRequest

type ImportJSONSchemaRequest struct {
	Entities []jsonsch.Entity   `json:"entities"`
	SchemaID string             `json:"schemaId"`
	Schema   string             `json:"schemaVariant"`
	Layers   []SliceByTermsSpec `json:"layers"`
}

func (*ImportJSONSchemaRequest) CompileAndImport

func (req *ImportJSONSchemaRequest) CompileAndImport() (graph.Graph, []jsonsch.EntityLayer, error)

func (*ImportJSONSchemaRequest) Slice

func (req *ImportJSONSchemaRequest) Slice(index int, item jsonsch.EntityLayer) ([]*ls.Layer, error)

type JSONExport

type JSONExport struct{}

func (JSONExport) Help

func (JSONExport) Help()

func (*JSONExport) Run

func (*JSONExport) Run(pipeline *PipelineContext) error

type JSONIngester

type JSONIngester struct {
	BaseIngestParams
	ID string
	// contains filtered or unexported fields
}

func (JSONIngester) Help

func (JSONIngester) Help()

func (*JSONIngester) Run

func (ji *JSONIngester) Run(pipeline *PipelineContext) error

type JSONSchemaReference

type JSONSchemaReference struct {
	// Refer to a layer by ID. Layer can be imported as a spreadsheet
	LayerID string `json:"layerId" yaml:"layerId" bson:"layerId"`
	// This is the filename
	Ref       string `json:"ref" yaml:"ref" bson:"ref"`
	Namespace string `json:"namespace" yaml:"namespace" bson:"namespace"`
}

type LS

type LS struct {
	Context string `json:"@context"`
	ID      string `json:"@id"`
	Type    string `json:"@type"`
	Layer   Layer  `json:"layer"`
}

type Layer

type Layer struct {
	AttributeList []Attribute `json:"attributeList"`
}

type OCStep

type OCStep struct {
	Expr string
}

func (OCStep) Help

func (OCStep) Help()

func (*OCStep) Run

func (oc *OCStep) Run(pipeline *PipelineContext) error

type PipelineContext

type PipelineContext struct {
	*ls.Context
	Graph      graph.Graph
	Roots      []graph.Node
	InputFiles []string

	Properties map[string]interface{}
	// contains filtered or unexported fields
}

func (*PipelineContext) Next

func (ctx *PipelineContext) Next() error

type ReadGraphStep

type ReadGraphStep struct {
	Format string
}

func NewReadGraphStep

func NewReadGraphStep(cmd *cobra.Command) ReadGraphStep

func (ReadGraphStep) Run

func (rd ReadGraphStep) Run(pipeline *PipelineContext) error

type ReshapeStep

type ReshapeStep struct {
	BaseIngestParams
	// contains filtered or unexported fields
}

func (ReshapeStep) Help

func (ReshapeStep) Help()

func (*ReshapeStep) Run

func (rs *ReshapeStep) Run(pipeline *PipelineContext) error

type SliceByTermsSpec

type SliceByTermsSpec struct {
	Type  string   `json:"type"`
	Terms []string `json:"terms"`
	ID    string   `json:"@id"`
	File  string   `json:"file"`
}

func (SliceByTermsSpec) Slice

func (spec SliceByTermsSpec) Slice(sourceLayer *ls.Layer, targetType string, templateData interface{}) (*ls.Layer, error)

type SpreadsheetReference

type SpreadsheetReference struct {
	File    string         `json:"file" yaml:"file"`
	Spec    *CSVImportSpec `json:"spec" yaml:"spec"`
	Context []interface{}  `json:"context" yaml:"context"`
}

func (SpreadsheetReference) Import

func (s SpreadsheetReference) Import(ctx *ls.Context) (map[string]*ls.Layer, error)

type Step

type Step interface {
	Run(*PipelineContext) error
}

type StepFunc

type StepFunc func(*PipelineContext) error

func (StepFunc) Run

func (f StepFunc) Run(ctx *PipelineContext) error

type Valueset

type Valueset struct {
	ID     string          `json:"id" yaml:"id"`
	Values []ValuesetValue `json:"values" yaml:"values"`
}

func (Valueset) Lookup

type ValuesetStep

type ValuesetStep struct {
	BaseIngestParams
	ValuesetFiles []string `json:"valuesetFiles" yaml:"valuesetFiles"`
	// contains filtered or unexported fields
}

func (ValuesetStep) Help

func (ValuesetStep) Help()

func (*ValuesetStep) Run

func (vs *ValuesetStep) Run(pipeline *PipelineContext) error

type ValuesetValue

type ValuesetValue struct {
	// Possible input values
	Values []string `json:"values" yaml:"values"`
	// Possible input value as key-value pairs
	KeyValues     map[string]string `json:"keyValues" yaml:"keyValues"`
	CaseSensitive bool              `json:"caseSensitive" yaml:"caseSensitive"`
	// Result output value
	Result string `json:"result" yaml:"result"`
	// Result output values as key-value pairs
	ResultValues map[string]string `json:"results" yaml:"results"`
}

func (ValuesetValue) IsDefault

func (v ValuesetValue) IsDefault() bool

func (ValuesetValue) Match

type Valuesets

type Valuesets struct {
	Sets map[string]Valueset `json:"valuesets" yaml:"valuesets"`
}

func (Valuesets) Lookup

Lookup can be used as the external lookup func of LookupProcessor

type WriteGraphStep

type WriteGraphStep struct {
	Format        string
	IncludeSchema bool
	Cmd           *cobra.Command
}

func NewWriteGraphStep

func NewWriteGraphStep(cmd *cobra.Command) WriteGraphStep

func (WriteGraphStep) Help

func (WriteGraphStep) Help()

func (WriteGraphStep) Run

func (wr WriteGraphStep) Run(pipeline *PipelineContext) error

type XMLIngester

type XMLIngester struct {
	BaseIngestParams
	ID string
	// contains filtered or unexported fields
}

func (XMLIngester) Help

func (XMLIngester) Help()

func (*XMLIngester) Run

func (xml *XMLIngester) Run(pipeline *PipelineContext) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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