-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
291 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
# Changelog | ||
|
||
## 1.2.0 (2023-02-28) | ||
|
||
### Features | ||
|
||
- Managed Metadata support | ||
|
||
## 1.1.0 (2023-02-26) | ||
|
||
### Features | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ db/ | |
*.log | ||
.cq/ | ||
db.sql | ||
.env | ||
.env | ||
db.sql-journal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,3 +69,6 @@ spec: | |
- OrderDate | ||
- Total | ||
alias: "order" | ||
mmd: | ||
8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f: | ||
alias: "department" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package mmd | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/cloudquery/plugin-sdk/schema" | ||
"github.com/koltyakov/cq-source-sharepoint/internal/util" | ||
"github.com/koltyakov/gosip/api" | ||
"github.com/rs/zerolog" | ||
) | ||
|
||
type MMD struct { | ||
sp *api.SP | ||
logger zerolog.Logger | ||
|
||
TablesMap map[string]Model // normalized table name to table metadata (map[CQ Table Name]Model) | ||
} | ||
|
||
type Model struct { | ||
ID string | ||
Spec Spec | ||
FieldsMap map[string]string // cq column name to column metadata | ||
} | ||
|
||
func NewMMD(sp *api.SP, logger zerolog.Logger) *MMD { | ||
return &MMD{ | ||
sp: sp, | ||
logger: logger, | ||
TablesMap: map[string]Model{}, | ||
} | ||
} | ||
|
||
func (m *MMD) GetDestTable(terSetID string, spec Spec) (*schema.Table, error) { | ||
tableName := util.NormalizeEntityName(strings.ReplaceAll(terSetID, "-", "")) // ToDo: ${TertGoup}_${TermSetName} | ||
if spec.Alias != "" { | ||
tableName = util.NormalizeEntityName(spec.Alias) | ||
} | ||
|
||
table := &schema.Table{ | ||
Name: "sharepoint_mmd_" + tableName, | ||
Description: "", // TermSetName | ||
Columns: []schema.Column{ | ||
{Name: "id", Type: schema.TypeUUID, CreationOptions: schema.ColumnCreationOptions{PrimaryKey: true}}, | ||
{Name: "name", Type: schema.TypeString}, | ||
{Name: "description", Type: schema.TypeString}, | ||
{Name: "tagging", Type: schema.TypeBool}, | ||
{Name: "deprecated", Type: schema.TypeBool}, | ||
{Name: "pinned", Type: schema.TypeBool}, | ||
{Name: "reused", Type: schema.TypeBool}, | ||
{Name: "root", Type: schema.TypeBool}, | ||
{Name: "source", Type: schema.TypeBool}, | ||
{Name: "path", Type: schema.TypeStringArray}, | ||
{Name: "children", Type: schema.TypeInt}, | ||
{Name: "merged", Type: schema.TypeUUIDArray}, | ||
{Name: "shared_props", Type: schema.TypeJSON}, | ||
{Name: "local_props", Type: schema.TypeJSON}, | ||
{Name: "custom_sort", Type: schema.TypeUUIDArray}, | ||
{Name: "owner", Type: schema.TypeString}, | ||
{Name: "created", Type: schema.TypeTimestamp}, | ||
{Name: "modified", Type: schema.TypeTimestamp}, | ||
}, | ||
} | ||
|
||
// ToDo: Remove this reverce mapping | ||
m.TablesMap[table.Name] = Model{ | ||
ID: terSetID, | ||
Spec: spec, | ||
FieldsMap: map[string]string{ | ||
"id": "Id", | ||
"name": "Name", | ||
"description": "Description", | ||
"tagging": "IsAvailableForTagging", | ||
"deprecated": "IsDeprecated", | ||
"pinned": "IsPinned", | ||
"reused": "IsReused", | ||
"root": "IsRoot", | ||
"source": "IsSourceTerm", | ||
"path": "PathOfTerm", | ||
"children": "TermsCount", | ||
"merged": "MergedTermIds", | ||
"shared_props": "CustomProperties", | ||
"local_props": "LocalCustomProperties", | ||
"custom_sort": "CustomSortOrder", | ||
"owner": "Owner", | ||
"created": "CreatedDate", | ||
"modified": "LastModifiedDate", | ||
}, | ||
} | ||
|
||
return table, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package mmd | ||
|
||
// Spec is the configuration for MMD term set source | ||
type Spec struct { | ||
// Optional, an alias for the table name | ||
// Don't map different lists to the same table - such scenariou is not supported | ||
Alias string `json:"alias"` | ||
} | ||
|
||
// SetDefault sets default values for list spec | ||
// func (s *Spec) SetDefault() {} |
Oops, something went wrong.