Browse Source

[GinR] Vendoring updated

cgars 7 years ago
parent
commit
6ebb1ad890
2 changed files with 66 additions and 1 deletions
  1. 65 0
      vendor/github.com/G-Node/godML/odml/odml.go
  2. 1 1
      vendor/vendor.json

+ 65 - 0
vendor/github.com/G-Node/godML/odml/odml.go

@@ -0,0 +1,65 @@
+package odml
+
+import (
+	"fmt"
+	"encoding/json"
+)
+
+type Section struct {
+	Name       string        `json:"-" xml:"name"`
+	Type       string        `json:"-" xml:"type"`
+	Properties [] Property   `json:"-" xml:"property"`
+	Text       string        `json:"text"`
+	Sections   [] Section    `json:"-" xml:"section"`
+	Children   [] OdMLObject `json:"children,omitempty"`
+}
+
+type Property struct {
+	Name       string   `json:"-" xml:"name"`
+	Value      []string `json:"-" xml:"value"`
+	Text       string   `json:"text"`
+	Icon       string
+	Definition string   `xml:"definition"`
+}
+
+type OdMLObject struct {
+	Prop    Property
+	Section Section
+	Type    string
+}
+
+type Odml struct {
+	OdmnlSections []Section `json:"children" xml:"section"`
+}
+
+func (u *Property) MarshalJSON() ([]byte, error) {
+	type Alias Property
+	if u.Text == "" {
+		u.Text = fmt.Sprintf("%s: %s (%s)", u.Name, u.Value, u.Definition)
+	}
+	return json.Marshal(Alias(*u))
+}
+
+func (u *Section) MarshalJSON() ([]byte, error) {
+	type Alias Section
+	if u.Text == "" {
+		u.Text = fmt.Sprintf("%s", u.Name)
+	}
+	for _, x := range u.Properties {
+		u.Children = append(u.Children, OdMLObject{Prop: x, Type: "property"})
+	}
+	for _, x := range u.Sections {
+		u.Children = append(u.Children, OdMLObject{Section: x, Type: "section"})
+	}
+	return json.Marshal(Alias(*u))
+}
+
+func (u *OdMLObject) MarshalJSON() ([]byte, error) {
+	if u.Type == "property" {
+		return u.Prop.MarshalJSON()
+	}
+	if u.Type == "section" {
+		return u.Section.MarshalJSON()
+	}
+	return nil, fmt.Errorf("Could not unmarshal odml object")
+}

+ 1 - 1
vendor/vendor.json

@@ -34,7 +34,7 @@
 		},
 		},
 		{
 		{
 			"checksumSHA1": "dpa+gHrdw4GXFknbMysx2/32kUM=",
 			"checksumSHA1": "dpa+gHrdw4GXFknbMysx2/32kUM=",
-			"path": "github.com/G-Node/odML/odml",
+			"path": "github.com/G-Node/godML/odml",
 			"revision": ""
 			"revision": ""
 		},
 		},
 		{
 		{