Merge branch 'feature/sort_links'
This commit is contained in:
		@@ -678,9 +678,59 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	issues = returned_wf.CreateLinks(xmlmodel.Root.MxLink, issues)
 | 
						issues = returned_wf.createLinks(xmlmodel.Root.MxLink, issues)
 | 
				
			||||||
	issues = returned_wf.CheckLinks(issues)
 | 
						issues = returned_wf.checkLinks(issues)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// dcslist := make(map[string]bool)
 | 
				
			||||||
 | 
						// dataslist := make(map[string]bool)
 | 
				
			||||||
 | 
						// // datalist := make(map[string]bool)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// // 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"))
 | 
				
			||||||
 | 
						// 	} else {
 | 
				
			||||||
 | 
						// 		// If doesn't exist in the list, means is new element to register as used
 | 
				
			||||||
 | 
						// 		dcslist[comp.DataCenterID] = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 	for _, dcin := range comp.Inputs {
 | 
				
			||||||
 | 
						// 		switch returned_wf.GetResource(&dcin).getRtype() {
 | 
				
			||||||
 | 
						// 		case rtype.DATA:
 | 
				
			||||||
 | 
						// 			dataslist[dcin] = true
 | 
				
			||||||
 | 
						// 		}
 | 
				
			||||||
 | 
						// 	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// 	for _, dcout := range comp.Outputs {
 | 
				
			||||||
 | 
						// 		switch returned_wf.GetResource(&dcout).getRtype() {
 | 
				
			||||||
 | 
						// 		case rtype.DATA:
 | 
				
			||||||
 | 
						// 			dataslist[dcout] = true
 | 
				
			||||||
 | 
						// 		}
 | 
				
			||||||
 | 
						// 	}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// for _, storage_component := range returned_wf.Storage {
 | 
				
			||||||
 | 
						// 	if storage_component.Inputs == nil && storage_component.Outputs == nil {
 | 
				
			||||||
 | 
						// 		issues = append(issues, errors.New("Storage "+*storage_component.getName()+" without compatible inputs and outputs"))
 | 
				
			||||||
 | 
						// 	}
 | 
				
			||||||
 | 
						// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// for dcID, dc_component := range returned_wf.Datacenter {
 | 
				
			||||||
 | 
						// 	// if rID doesn't exist in the list, it means that it's not used
 | 
				
			||||||
 | 
						// 	if _, ok := dcslist[dcID]; !ok {
 | 
				
			||||||
 | 
						// 		issues = append(issues, errors.New("DC "+*dc_component.getName()+" not attached to any Computing"))
 | 
				
			||||||
 | 
						// 	}
 | 
				
			||||||
 | 
						// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// for dcID, data_component := range returned_wf.Data {
 | 
				
			||||||
 | 
						// 	// if rID doesn't exist in the list, it means that it's not used
 | 
				
			||||||
 | 
						// 	if _, ok := dataslist[dcID]; !ok {
 | 
				
			||||||
 | 
						// 		issues = append(issues, errors.New("Data "+*data_component.getName()+" not attached to any Computing"))
 | 
				
			||||||
 | 
						// 	}
 | 
				
			||||||
 | 
						// }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	//////////////////////////////////////////////////////////
 | 
						//////////////////////////////////////////////////////////
 | 
				
			||||||
	//														//
 | 
						//														//
 | 
				
			||||||
@@ -783,10 +833,10 @@ func (ws Workspace) ConsumeMxGraphModel(xmlmodel MxGraphModel) (returned_wf *Wor
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w *Workflow) CreateLinks(links []MxLink, issues []error) []error {
 | 
					func (w *Workflow) createLinks(links []MxLink, issues []error) []error {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	for _, link := range links {	
 | 
						for _, link := range links {	
 | 
				
			||||||
		if len(link.Source) > 0 && len(link.Target) > 0 {
 | 
							if (len(link.Source) > 0 && len(link.Target) > 0){
 | 
				
			||||||
			sourceObj := w.GetResource(&link.Source)
 | 
								sourceObj := w.GetResource(&link.Source)
 | 
				
			||||||
			targetObj := w.GetResource(&link.Target)
 | 
								targetObj := w.GetResource(&link.Target)
 | 
				
			||||||
			link_object := NewLink(sourceObj, link.Source, targetObj, link.Target)
 | 
								link_object := NewLink(sourceObj, link.Source, targetObj, link.Target)
 | 
				
			||||||
@@ -812,33 +862,33 @@ func (w *Workflow) processLinkErrors(link MxLink) (issue error) {
 | 
				
			|||||||
	return issue
 | 
						return issue
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w *Workflow) CheckLinks(issues []error) []error {
 | 
					func (w *Workflow) checkLinks(issues []error) []error {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// Check that storage components have a valid link
 | 
						// Check that storage components have a valid link
 | 
				
			||||||
	for id, storage := range w.Storage {
 | 
						for id, storage := range w.Storage {
 | 
				
			||||||
		if !w.IsComponentSrc(id) && !w.IsComponentDst(id) {
 | 
							if(!w.isComponentSrc(id) && !w.isComponentDst(id)){
 | 
				
			||||||
			issues = append(issues, errors.New("Storage "+*storage.getName()+" without compatible inputs and outputs"))
 | 
								issues = append(issues, errors.New("Storage "+*storage.getName()+" without compatible inputs and outputs"))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Check that data components are linked to a computing component
 | 
						// Check that data components are linked to a computing component
 | 
				
			||||||
	for id, data := range w.Data {
 | 
						for id, data := range w.Data {
 | 
				
			||||||
		if !w.HasLinkageToComputing(id) {
 | 
							if(!w.isLinkedToComputing(id)){
 | 
				
			||||||
			issues = append(issues, errors.New("Data "+*data.getName()+" not attached to any Computing"))
 | 
								issues = append(issues, errors.New("Data "+*data.getName()+" not attached to any Computing"))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Check that DC is linked to a computing component
 | 
						// Check that DC is linked to a computing component
 | 
				
			||||||
	for id, dc := range w.Datacenter {
 | 
						for id, dc:= range w.Datacenter {
 | 
				
			||||||
		if !w.HasLinkageToComputing(id) {
 | 
							if(!w.isLinkedToComputing(id)){
 | 
				
			||||||
			issues = append(issues, errors.New("Datacenter "+*dc.getName()+" not attached to any Computing"))
 | 
								issues = append(issues, errors.New("Datacenter "+*dc.getName()+" not attached to any Computing"))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Check that all data computing components are linked to a DC
 | 
						// Check that all data computing components are linked to a DC
 | 
				
			||||||
	for id, comp := range w.Computing {
 | 
						for id,comp:= range w.Computing {
 | 
				
			||||||
		if !w.HasLinkageToDC(id) {
 | 
							if(!w.isLinkedToDC(id)){
 | 
				
			||||||
			issues = append(issues, errors.New("Computing "+*comp.getName()+" not attached to any datacenter"))
 | 
								issues = append(issues, errors.New("Computing "+*comp.getName()+" not attached to any datacenter"))
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -847,10 +897,10 @@ func (w *Workflow) CheckLinks(issues []error) []error {
 | 
				
			|||||||
	return issues
 | 
						return issues
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w *Workflow) IsComponentSrc(id string) bool {
 | 
					func (w *Workflow) isComponentSrc(id string) bool {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	for _, link := range w.Links {
 | 
						for _, link := range w.Links{
 | 
				
			||||||
		if link.Source == id && link.Source != "" {
 | 
							if(link.Source == id && link.Source != ""){
 | 
				
			||||||
			return true
 | 
								return true
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -858,10 +908,10 @@ func (w *Workflow) IsComponentSrc(id string) bool {
 | 
				
			|||||||
	return false
 | 
						return false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w *Workflow) IsComponentDst(id string) bool {
 | 
					func (w *Workflow) isComponentDst(id string) bool {
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	for _, link := range w.Links {
 | 
						for _, link := range w.Links{
 | 
				
			||||||
		if link.Destination == id && link.Source != "" {
 | 
							if(link.Destination == id && link.Source != ""){
 | 
				
			||||||
			return true
 | 
								return true
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -869,10 +919,10 @@ func (w *Workflow) IsComponentDst(id string) bool {
 | 
				
			|||||||
	return false
 | 
						return false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w *Workflow) HasLinkageToComputing(id string) bool {
 | 
					func (w *Workflow) isLinkedToComputing(id string) bool {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for idComputing, _ := range w.Computing {
 | 
						for idComputing, _ := range w.Computing {
 | 
				
			||||||
		if (w.IsComponentSrc(id) && w.IsComponentDst(idComputing)) || (w.IsComponentSrc(idComputing) && w.IsComponentDst(id)) {
 | 
							if( (w.isComponentSrc(id) && w.isComponentDst(idComputing)) || (w.isComponentSrc(idComputing) && w.isComponentDst(id))){
 | 
				
			||||||
			return true
 | 
								return true
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -881,7 +931,7 @@ func (w *Workflow) HasLinkageToComputing(id string) bool {
 | 
				
			|||||||
	return false
 | 
						return false
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (w *Workflow) HasLinkageToDC(id string) bool {
 | 
					func (w *Workflow) isLinkedToDC(id string) bool {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for _, link := range w.Links {
 | 
						for _, link := range w.Links {
 | 
				
			||||||
		if link.Source == id && link.DCLink {
 | 
							if link.Source == id && link.DCLink {
 | 
				
			||||||
@@ -1104,18 +1154,3 @@ func (wf Workflow) mxCellToComponent(cell MxCell, ws Workspace) (resObj Resource
 | 
				
			|||||||
	return
 | 
						return
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// func (ws Workspace) extractMxCell(xmlModel MxGraphModel){
 | 
					 | 
				
			||||||
// 	// Iterate through all objects of the MxGraph
 | 
					 | 
				
			||||||
// 	graphObjects := xmlModel.Root.MxObject
 | 
					 | 
				
			||||||
// 	for _, object := range(*graphObjects){
 | 
					 | 
				
			||||||
// 		current_obj_id, _ := strconv.Atoi(object.ID)
 | 
					 | 
				
			||||||
// 		inside_cell_id := strconv.Itoa(current_obj_id + 1)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
// 		cell := ws.GetResource(&inside_cell_id)
 | 
					 | 
				
			||||||
// 		// component := w.GetResource(cell.RID)
 | 
					 | 
				
			||||||
// 		fmt.Print(cell)
 | 
					 | 
				
			||||||
// 	}
 | 
					 | 
				
			||||||
// 		// Extract the mxCell object
 | 
					 | 
				
			||||||
// 		// Invoke the addParameter method from the component
 | 
					 | 
				
			||||||
// 		// Edit the ID to get the object's one
 | 
					 | 
				
			||||||
// }
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user