2017-08-28 20:56:18 -05:00
|
|
|
// Copyright 2017 Baliance. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by the terms of the Affero GNU General
|
|
|
|
// Public License version 3.0 as published by the Free Software Foundation and
|
|
|
|
// appearing in the file LICENSE included in the packaging of this file. A
|
|
|
|
// commercial license can be purchased by contacting sales@baliance.com.
|
|
|
|
|
|
|
|
package diagram
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type AG_ConstraintRefAttributes struct {
|
|
|
|
RefTypeAttr ST_ConstraintType
|
|
|
|
RefForAttr ST_ConstraintRelationship
|
|
|
|
RefForNameAttr *string
|
|
|
|
RefPtTypeAttr ST_ElementType
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewAG_ConstraintRefAttributes() *AG_ConstraintRefAttributes {
|
|
|
|
ret := &AG_ConstraintRefAttributes{}
|
2017-09-04 16:55:00 -05:00
|
|
|
ret.RefTypeAttr = ST_ConstraintTypeNone
|
|
|
|
ret.RefForAttr = ST_ConstraintRelationshipSelf
|
|
|
|
ret.RefPtTypeAttr = ST_ElementTypeAll
|
2017-08-28 20:56:18 -05:00
|
|
|
return ret
|
|
|
|
}
|
2017-09-01 15:19:23 -05:00
|
|
|
|
2017-08-28 20:56:18 -05:00
|
|
|
func (m *AG_ConstraintRefAttributes) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
|
|
|
|
if m.RefTypeAttr != ST_ConstraintTypeUnset {
|
|
|
|
attr, err := m.RefTypeAttr.MarshalXMLAttr(xml.Name{Local: "refType"})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
start.Attr = append(start.Attr, attr)
|
|
|
|
}
|
|
|
|
if m.RefForAttr != ST_ConstraintRelationshipUnset {
|
|
|
|
attr, err := m.RefForAttr.MarshalXMLAttr(xml.Name{Local: "refFor"})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
start.Attr = append(start.Attr, attr)
|
|
|
|
}
|
|
|
|
if m.RefForNameAttr != nil {
|
|
|
|
start.Attr = append(start.Attr, xml.Attr{Name: xml.Name{Local: "refForName"},
|
|
|
|
Value: fmt.Sprintf("%v", *m.RefForNameAttr)})
|
|
|
|
}
|
|
|
|
if m.RefPtTypeAttr != ST_ElementTypeUnset {
|
|
|
|
attr, err := m.RefPtTypeAttr.MarshalXMLAttr(xml.Name{Local: "refPtType"})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
start.Attr = append(start.Attr, attr)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-09-01 15:19:23 -05:00
|
|
|
|
2017-08-28 20:56:18 -05:00
|
|
|
func (m *AG_ConstraintRefAttributes) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
|
|
|
|
// initialize to default
|
2017-09-04 16:55:00 -05:00
|
|
|
m.RefTypeAttr = ST_ConstraintTypeNone
|
|
|
|
m.RefForAttr = ST_ConstraintRelationshipSelf
|
|
|
|
m.RefPtTypeAttr = ST_ElementTypeAll
|
2017-08-28 20:56:18 -05:00
|
|
|
for _, attr := range start.Attr {
|
|
|
|
if attr.Name.Local == "refType" {
|
|
|
|
m.RefTypeAttr.UnmarshalXMLAttr(attr)
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "refFor" {
|
|
|
|
m.RefForAttr.UnmarshalXMLAttr(attr)
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "refForName" {
|
|
|
|
parsed, err := attr.Value, error(nil)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
m.RefForNameAttr = &parsed
|
|
|
|
}
|
|
|
|
if attr.Name.Local == "refPtType" {
|
|
|
|
m.RefPtTypeAttr.UnmarshalXMLAttr(attr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// skip any extensions we may find, but don't support
|
|
|
|
for {
|
|
|
|
tok, err := d.Token()
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("parsing AG_ConstraintRefAttributes: %s", err)
|
|
|
|
}
|
|
|
|
if el, ok := tok.(xml.EndElement); ok && el.Name == start.Name {
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
2017-09-01 15:19:23 -05:00
|
|
|
|
|
|
|
// Validate validates the AG_ConstraintRefAttributes and its children
|
2017-08-28 20:56:18 -05:00
|
|
|
func (m *AG_ConstraintRefAttributes) Validate() error {
|
|
|
|
return m.ValidateWithPath("AG_ConstraintRefAttributes")
|
|
|
|
}
|
2017-09-01 15:19:23 -05:00
|
|
|
|
|
|
|
// ValidateWithPath validates the AG_ConstraintRefAttributes and its children, prefixing error messages with path
|
2017-08-28 20:56:18 -05:00
|
|
|
func (m *AG_ConstraintRefAttributes) ValidateWithPath(path string) error {
|
|
|
|
if err := m.RefTypeAttr.ValidateWithPath(path + "/RefTypeAttr"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := m.RefForAttr.ValidateWithPath(path + "/RefForAttr"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if err := m.RefPtTypeAttr.ValidateWithPath(path + "/RefPtTypeAttr"); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|