initial commit lets start
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
"schema"
|
||||
)
|
||||
|
||||
type Data struct {
|
||||
XMLName xml.Name `xml:"data"`
|
||||
Name string `xml:"name,attr"`
|
||||
HandleUnknown string `xml:"handleUnknown,attr"`
|
||||
ProjectInformation *ProjectInformation `xml:"ProjectInformation,omitempty"`
|
||||
Resource *Resourse `xml:"resource,omitempty"`
|
||||
TaskSettings *TaskSettings `xml:"TaskSettings,omitempty"`
|
||||
Attributes *Attributes `xml:"Attributes,omitempty"`
|
||||
InterfaceAsPlainText *InterfaceAsPlainText `xml:"InterfaceAsPlainText,omitempty"`
|
||||
ObjectId *ObjectId `xml:"ObjectId,omitempty"`
|
||||
}
|
||||
|
||||
func NewData(name, handleUnknown string) *Data {
|
||||
return &Data{
|
||||
Name: name,
|
||||
HandleUnknown: handleUnknown,
|
||||
}
|
||||
}
|
||||
|
||||
func (d *Data) AddResources(proj *schema.Project) error {
|
||||
for _, device := range proj.Devices {
|
||||
res := d.AddResource(device.Name)
|
||||
err := res.AddTasks(device)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (d *Data) AddResource(name string) *Resourse {
|
||||
d.Resource = &Resourse{
|
||||
Name: name,
|
||||
}
|
||||
return d.Resource
|
||||
}
|
||||
Reference in New Issue
Block a user