update the object stored for one workflow with user input

This commit is contained in:
pb
2024-03-29 17:00:53 +01:00
parent 49d3ba9763
commit b51c0f1b74
3 changed files with 79 additions and 24 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"encoding/xml"
"errors"
"fmt"
"net/url"
"os"
"sort"
@@ -73,7 +74,7 @@ type ResourceObject interface {
addLink(direction LinkingState, rObjID string)
}
// This type allows to process computing and storage componant
// This type allows to process computing and storage component
// which can get input from the user
type EditableResourceObject interface{
ResourceObject
@@ -600,10 +601,10 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
// For each cell of the xml graph,
// in the case cell has a rID retrieve its rType from the value of rID of the componant in the worfklow
// retrieve the componant's type
// in the case cell has a rID retrieve its rType from the value of rID of the component in the worfklow
// retrieve the component's type
// create an object from the rType
// update the existing workflow with the new componant
// update the existing workflow with the new component
// or by defautlt : the cell represents an arrow
// if the source or the target of the arrow is a datacenter
// define which end of the arrow is the DC
@@ -614,18 +615,26 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
for _, object := range *xmlmodel.Root.MxObject{
resObj, err, mxissues := returned_wf.mxCellToComponant(object.MxCell,ws)
resObj, err, mxissues := returned_wf.mxCellToComponent(object.MxCell,ws)
if err != nil {
issues = append(issues, mxissues...)
}
returned_wf.UpdateObj(resObj,object.ID)
// // retrieve the rType in the mxCell
// rType := w.getRtype(*object.MxCell.RID)
// // create a composant and add it to the appropriate list
// resObj := returned_wf.CreateResourceObject(rType)
// // use the addUserInput method with a map[string]string made of the
// resObj
// add the component to the worflow's attribute that stores
// all components in a map[string]Component where the key
// is the component's ID in the mxGraph and the value the Component object
returned_wf.UpdateObj(resObj,object.ID)
xmlmodel.removeMxCell(object.ID)
// Construct the object corresponding to the componant's type and use its addUserInput method
if(resObj.getRtype() == rtype.COMPUTING){
comp_obj := returned_wf.GetResource(&object.ID).(*ComputingObject)
comp_obj.AddUserInput(object.Settings)
returned_wf.UpdateObj(comp_obj,object.ID)
}
// if(resObj.getRtype() == rtype.DATA){
fmt.Printf("Test")
// }
}
@@ -633,7 +642,7 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
switch {
case cell.RID != nil:
resObj, err, mxissues := returned_wf.mxCellToComponant(cell,ws)
resObj, err, mxissues := returned_wf.mxCellToComponent(cell,ws)
if err != nil {
issues = append(issues, mxissues...)
}
@@ -705,7 +714,7 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
// datalist := make(map[string]bool)
// Test wether the computing componants are linked with a DC
// Test wether the computing components are linked with a DC
for _, comp := range returned_wf.Computing {
if comp.DataCenterID == "" {
issues = append(issues, errors.New("Computing "+*comp.getName()+" without a Datacenter"))
@@ -1041,7 +1050,7 @@ func CheckAndBookWorkflowSchedule(username, workflowName string, book bool) (myR
}
// Not sure if this method handles error propagation well
func (wf Workflow) mxCellToComponant(cell MxCell, ws Workspace) (resObj ResourceObject,err error, issues []error){
func (wf Workflow) mxCellToComponent(cell MxCell, ws Workspace) (resObj ResourceObject,err error, issues []error){
rType := ws.getRtype(*cell.RID)
if rType == rtype.INVALID {