github.com/Kindred87/Obsidian@v0.0.0-20210809203756-86936424b848/api/datasource_request.go (about)

     1  package api
     2  
     3  import (
     4  	"github.com/Kindred87/Obsidian/datasource"
     5  )
     6  
     7  type DatasourceAdd struct {
     8  	OverwriteExisting bool
     9  	Alias             string
    10  }
    11  
    12  // OverwriteExisting returns the value of OverwriteExistingConfig.
    13  func (req *DatasourceAddRequest) OverwriteExisting() bool {
    14  	return req.OverwriteExistingConfig
    15  }
    16  
    17  // Alias returns the value of DatasourceName.
    18  func (req *DatasourceAddRequest) Alias() string {
    19  	return req.DatasourceName
    20  }
    21  
    22  // IncludeProgramDirectory returns the value of SearchInProgramDirectory.
    23  func (req *DatasourceAddRequest) IncludeProgramDirectory() bool {
    24  	return req.SearchInProgramDirectory
    25  }
    26  
    27  // Paths returns the value of DirectoriesToSearch.
    28  func (req *DatasourceAddRequest) Paths() []string {
    29  	return req.DirectoriesToSearch
    30  }
    31  
    32  // FilenameSpecs returns the FilenameSpec equivalent of FilenameSpecifications.
    33  func (req *DatasourceAddRequest) FilenameSpecs() (fileSpecs []datasource.FilenameSpec) {
    34  	for _, spec := range req.FilenameSpecifications {
    35  		toAppend := datasource.FilenameSpec{
    36  			Filename:        spec.Filename,
    37  			NameIsSubstring: spec.FilenameIsSubstring,
    38  		}
    39  		fileSpecs = append(fileSpecs, toAppend)
    40  	}
    41  	return fileSpecs
    42  }
    43  
    44  // FileType returns the string value of FileExtension.
    45  func (req *DatasourceAddRequest) FileType() string {
    46  	return req.FileExtension.String()
    47  }
    48  
    49  // RequireAllValueSpecs returns the value of RequireAllValueSpecifications.
    50  func (req *DatasourceAddRequest) RequireAllValueSpecs() bool {
    51  	return req.RequireAllValueSpecifications
    52  }
    53  
    54  // ValueSpecs returns the ValueSpec equivalent of ValueSpecifications.
    55  func (req *DatasourceAddRequest) ValueSpecs() (valueSpecs []datasource.ValueSpec) {
    56  	for _, spec := range req.ValueSpecifications {
    57  		toAppend := datasource.ValueSpec{
    58  			Value:       spec.Value,
    59  			IsSubstring: spec.IsSubstring,
    60  			InRow:       int(spec.InRow),
    61  			InColumn:    int(spec.InColumn),
    62  		}
    63  		valueSpecs = append(valueSpecs, toAppend)
    64  	}
    65  	return valueSpecs
    66  }