newntui/discovermdi/src/disgraphnode.cpp
//------------------------------------------------------------------------------------
// This function will evaluate accessCmd command to receve the list of
// the related objects, will search the graph to locate if and where
// this existing objects located in the graph and will add edges of the
// type "relationID" connecting this node with all located elements 
// (nodes or node fields) in the graph.
//------------------------------------------------------------------------------------
This function will evaluate accessCmd command to receve the list of
the related objects, will search the graph to locate if and where
this existing objects located in the graph and will add edges of the
type "relationID" connecting this node with all located elements
(nodes or node fields) in the graph.
This function will evaluate accessCmd command to receve the list of the related objects will search the graph to locate if and where this existing objects located in the graph and will add edges of the type " relationID " connecting this node with all located elements ( nodes or node fields ) in the graph .
void CDisGraphNode::CreateRelations(CString& acccessCmd, 
				                    int relationID, 
				                    CEdgeProperties* unselected,
								    CEdgeProperties* selected,
									CEdgeProperties* focused) {
CString command;
CString result;
int i;
int* sourceNodeIDs;
int* sourceFieldIDs;
int* targetNodeIDs;
int* targetFieldIDs;
   command.Format("%s",acccessCmd);
   result = m_ParentGraph->Evaluate(command);
   int amount = m_ParentGraph->ParseRelationResults(result,&sourceNodeIDs,&sourceFieldIDs,&targetNodeIDs,&targetFieldIDs);
   for(i=0;i<amount;i++) {
	   CDisGraphNode* sourceNode;
	   CDisGraphNode* targetNode;
	   int sourceFieldNumber=-1;
	   int targetFieldNumber=-1;
       sourceNode = m_ParentGraph->NodeFromID(sourceNodeIDs[i]);
       targetNode = m_ParentGraph->NodeFromID(targetNodeIDs[i]);
	   if(sourceFieldIDs[i]!=-1)
	       sourceFieldNumber = sourceNode->FindFieldNumber(sourceFieldIDs[i]);
	   if(targetFieldIDs[i]!=-1)
	       targetFieldNumber = targetNode->FindFieldNumber(targetFieldIDs[i]);
       if((sourceNodeIDs[i]!=targetNodeIDs[i]) && (sourceFieldIDs[i]!=-1 || targetFieldIDs[i])) {
	       CDisGraphEdge* pEdge;
	       pEdge = (CDisGraphEdge *) m_ParentGraph->addEdge(sourceNode,targetNode);
	       pEdge->SetEdge(relationID,
		                  unselected!=NULL ? unselected : m_EdgeUnselected,
					      selected!=NULL   ? selected   : m_EdgeSelected,
					      focused!=NULL    ? focused    : m_EdgeFocused);
	       pEdge->PortRelation(sourceFieldNumber,targetFieldNumber);
	   }
   }
   if(amount>0) {
      delete sourceNodeIDs;
      delete sourceFieldIDs;
      delete targetNodeIDs;
      delete targetFieldIDs;
   }
}
void CDisGraphNode :: CreateRelations ( CString & acccessCmd , int relationID , CEdgeProperties * unselected , CEdgeProperties * selected , CEdgeProperties * focused ) { CString command ; CString result ; int i ; int * sourceNodeIDs ; int * sourceFieldIDs ; int * targetNodeIDs ; int * targetFieldIDs ; command . Format ( " " , acccessCmd ) ; result = m_ParentGraph -> Evaluate ( command ) ; int amount = m_ParentGraph -> ParseRelationResults ( result , & sourceNodeIDs , & sourceFieldIDs , & targetNodeIDs , & targetFieldIDs ) ; for ( i = 0 ; i < amount ; i ++ ) { CDisGraphNode * sourceNode ; CDisGraphNode * targetNode ; int sourceFieldNumber = -1 ; int targetFieldNumber = -1 ; sourceNode = m_ParentGraph -> NodeFromID ( sourceNodeIDs [ i ] ) ; targetNode = m_ParentGraph -> NodeFromID ( targetNodeIDs [ i ] ) ; if ( sourceFieldIDs [ i ] != -1 ) sourceFieldNumber = sourceNode -> FindFieldNumber ( sourceFieldIDs [ i ] ) ; if ( targetFieldIDs [ i ] != -1 ) targetFieldNumber = targetNode -> FindFieldNumber ( targetFieldIDs [ i ] ) ; if ( ( sourceNodeIDs [ i ] != targetNodeIDs [ i ] ) && ( sourceFieldIDs [ i ] != -1 || targetFieldIDs [ i ] ) ) { CDisGraphEdge * pEdge ; pEdge = ( CDisGraphEdge * ) m_ParentGraph -> addEdge ( sourceNode , targetNode ) ; pEdge -> SetEdge ( relationID , unselected != NULL ? unselected : m_EdgeUnselected , selected != NULL ? selected : m_EdgeSelected , focused != NULL ? focused : m_EdgeFocused ) ; pEdge -> PortRelation ( sourceFieldNumber , targetFieldNumber ) ; } } if ( amount > 0 ) { delete sourceNodeIDs ; delete sourceFieldIDs ; delete targetNodeIDs ; delete targetFieldIDs ; } }
This function will evaluate accessCmd command to receve the list of
the related objects, will search the graph to locate if and where
this existing objects located in the graph and will add edges of the
type "relationID" connecting this node with all located elements
(nodes or node fields) in the graph.
This function will evaluate accessCmd command to receve the list of the related objects will search the graph to locate if and where this existing objects located in the graph and will add edges of the type " relationID " connecting this node with all located elements ( nodes or node fields ) in the graph .
// the relations script procedure will receve this node Id as a parameter and // will return a list containing as many 4-group elements as the quantity of // the relations it located. Each 4-digit entry contains the source node id //(it always be this node ID), source node field ID if any or 0 if node itself, // target node id and target node field id. // line this: // { SourceNode Sourcefield TargetNode TargetField } // { SourceNode Sourcefield TargetNode TargetField } // ...... // { SourceNode Sourcefield TargetNode TargetField } // We need to locate source and target node to connect // We will use ports on this nodes to connect fields properly. // We will find port indexes using the returned fields IDs // TS API manipulations to connect new edge using ports  // (will be implemented later) // removing id arrays created by ParseRelationsResults