src/main/java/de/unirostock/sems/bives/cellml/algorithm/CellMLGraphProducer.java
protected void processHnB ()
	{
		LOGGER.info ("processHnB");

		
		// looks like wee need two traversals...
		HashMap<CellMLComponent, HierarchyNetworkComponent> componentMapper = new HashMap<CellMLComponent, HierarchyNetworkComponent> ();
		HashMap<CellMLVariable, HierarchyNetworkVariable> variableMapper = new HashMap<CellMLVariable, HierarchyNetworkVariable> ();
		
		HashMap<String,CellMLComponent> components = cellmlDocB.getModel ().getComponents ();
		
		// create nodes in graph
		for (CellMLComponent component : components.values ())
		{
			

			Connection con = conMgmt.getConnectionForNode (component.getDocumentNode ());
			HierarchyNetworkComponent nc = null;
			if (con == null)
			{
				// no equivalent in doc a
				//LOGGER.info ("create node: " + component.getName ());
				nc = new HierarchyNetworkComponent (hn, null, component.getName (), null, component.getDocumentNode ());
			}
			else
			{
				//LOGGER.info ("add b to node: " + component.getName ());
				nc = hn.getComponent (con.getPartnerOf (component.getDocumentNode ()));
				nc.setDocB (component.getDocumentNode ());
				nc.setLabelB (component.getName ());
			}
			hn.setComponent (component.getDocumentNode (), nc);
			componentMapper.put (component, nc);
			
			
			
			
			HashMap<String, CellMLVariable> vars = component.getVariables ();
			for (CellMLVariable var : vars.values ())
			{
				DocumentNode varNode = var.getDocumentNode ();
				HierarchyNetworkVariable hnVar = null;
				// var already defined?
				Connection c = conMgmt.getConnectionForNode (varNode);
				if (c == null || hn.getVariable (c.getPartnerOf (varNode)) == null)
				{
					// no equivalent in doc a
					//LOGGER.info ("create var: " + var.getName ());
					hnVar = new HierarchyNetworkVariable (hn, null, var.getName (), null, varNode, null, nc);
				}
				else
				{
					//LOGGER.info ("add b to var: " + var.getName ());
					hnVar = hn.getVariable (c.getPartnerOf (varNode));
					hnVar.setDocB (varNode);
					hnVar.setLabelB (var.getName ());
					hnVar.setComponentB (nc);
				}
				
				nc.addVariable (hnVar);
				hn.setVariable (varNode, hnVar);
				variableMapper.put (var, hnVar);
			}
			hn.setComponent (component.getDocumentNode (), nc);
			componentMapper.put (component, nc);
			
		}
		
		CellMLHierarchyNetwork enc = cellmlDocB.getModel ().getHierarchy ().getHierarchyNetwork ("encapsulation", "");
		//LOGGER.info ("found " + enc.getNodes ().size () + " enc nodes");
		
		// connect nodes
		for (CellMLComponent component : components.values ())
		{
			CellMLHierarchyNode compNode = enc.getNode (component);
			if (compNode != null)
			{
				CellMLHierarchyNode parent = compNode.getParent ();
				if (parent != null)
				{
					//LOGGER.info ("create comp connection B: " + component.getName () + " -> " + parent.getComponent ().getName ());
					componentMapper.get (component).setParentB (componentMapper.get (parent.getComponent ()));
				}
			}
			

			HashMap<String, CellMLVariable> vars = component.getVariables ();
			for (CellMLVariable var : vars.values ())
			{
				HierarchyNetworkVariable hnv = variableMapper.get (var);
				/*List<CellMLVariable> cons = var.getPrivateInterfaceConnections ();
				for (CellMLVariable con : cons)
				{
					LOGGER.info ("create var connection B: " + var.getName () + " -> " + con.getName ());
					hnv.addConnectionB (variableMapper.get (con));
				}*/
				if (var.getPublicInterface () == CellMLVariable.INTERFACE_IN)
				{
					List<CellMLVariable> cons = var.getPublicInterfaceConnections ();
					for (CellMLVariable con : cons)
					{
						//LOGGER.info ("create var connection B (pub): " + var.getName () + " -> " + con.getName () + " --- " + var.getComponent ().getName () + " -> " + con.getComponent ().getName ());
						hnv.addConnectionB (variableMapper.get (con));
					}
				}
				if (var.getPrivateInterface () == CellMLVariable.INTERFACE_IN)
				{
					List<CellMLVariable> cons = var.getPrivateInterfaceConnections ();
					for (CellMLVariable con : cons)
					{
						//LOGGER.info ("create var connection B (prib): " + var.getName () + " -> " + con.getName () + " --- " + var.getComponent ().getName () + " -> " + con.getComponent ().getName ());
						hnv.addConnectionB (variableMapper.get (con));
					}
				}
			}
		}
	}
/**
	 * Process Hierarchy Network of the modified document.
	 */
Process Hierarchy Network of the modified document.
Process Hierarchy Network of the modified document .
protected void processHnB ()
	{
		LOGGER.info ("processHnB");
		HashMap<CellMLComponent, HierarchyNetworkComponent> componentMapper = new HashMap<CellMLComponent, HierarchyNetworkComponent> ();
		HashMap<CellMLVariable, HierarchyNetworkVariable> variableMapper = new HashMap<CellMLVariable, HierarchyNetworkVariable> ();
		HashMap<String,CellMLComponent> components = cellmlDocB.getModel ().getComponents ();
		for (CellMLComponent component : components.values ())
		{
			Connection con = conMgmt.getConnectionForNode (component.getDocumentNode ());
			HierarchyNetworkComponent nc = null;
			if (con == null)
			{
				nc = new HierarchyNetworkComponent (hn, null, component.getName (), null, component.getDocumentNode ());
			}
			else
			{
				nc = hn.getComponent (con.getPartnerOf (component.getDocumentNode ()));
				nc.setDocB (component.getDocumentNode ());
				nc.setLabelB (component.getName ());
			}
			hn.setComponent (component.getDocumentNode (), nc);
			componentMapper.put (component, nc);
			HashMap<String, CellMLVariable> vars = component.getVariables ();
			for (CellMLVariable var : vars.values ())
			{
				DocumentNode varNode = var.getDocumentNode ();
				HierarchyNetworkVariable hnVar = null;
				Connection c = conMgmt.getConnectionForNode (varNode);
				if (c == null || hn.getVariable (c.getPartnerOf (varNode)) == null)
				{
					hnVar = new HierarchyNetworkVariable (hn, null, var.getName (), null, varNode, null, nc);
				}
				else
				{
					hnVar = hn.getVariable (c.getPartnerOf (varNode));
					hnVar.setDocB (varNode);
					hnVar.setLabelB (var.getName ());
					hnVar.setComponentB (nc);
				}
				nc.addVariable (hnVar);
				hn.setVariable (varNode, hnVar);
				variableMapper.put (var, hnVar);
			}
			hn.setComponent (component.getDocumentNode (), nc);
			componentMapper.put (component, nc);
		}
		CellMLHierarchyNetwork enc = cellmlDocB.getModel ().getHierarchy ().getHierarchyNetwork ("encapsulation", "");
		for (CellMLComponent component : components.values ())
		{
			CellMLHierarchyNode compNode = enc.getNode (component);
			if (compNode != null)
			{
				CellMLHierarchyNode parent = compNode.getParent ();
				if (parent != null)
				{
					componentMapper.get (component).setParentB (componentMapper.get (parent.getComponent ()));
				}
			}
			HashMap<String, CellMLVariable> vars = component.getVariables ();
			for (CellMLVariable var : vars.values ())
			{
				HierarchyNetworkVariable hnv = variableMapper.get (var);
				/*List<CellMLVariable> cons = var.getPrivateInterfaceConnections ();
				for (CellMLVariable con : cons)
				{
					LOGGER.info ("create var connection B: " + var.getName () + " -> " + con.getName ());
					hnv.addConnectionB (variableMapper.get (con));
				}*/
				if (var.getPublicInterface () == CellMLVariable.INTERFACE_IN)
				{
					List<CellMLVariable> cons = var.getPublicInterfaceConnections ();
					for (CellMLVariable con : cons)
					{
						hnv.addConnectionB (variableMapper.get (con));
					}
				}
				if (var.getPrivateInterface () == CellMLVariable.INTERFACE_IN)
				{
					List<CellMLVariable> cons = var.getPrivateInterfaceConnections ();
					for (CellMLVariable con : cons)
					{
						hnv.addConnectionB (variableMapper.get (con));
					}
				}
			}
		}
	}
protected void processHnB ( ) { LOGGER . info ( "processHnB" ) ; HashMap < CellMLComponent , HierarchyNetworkComponent > componentMapper = new HashMap < CellMLComponent , HierarchyNetworkComponent > ( ) ; HashMap < CellMLVariable , HierarchyNetworkVariable > variableMapper = new HashMap < CellMLVariable , HierarchyNetworkVariable > ( ) ; HashMap < String , CellMLComponent > components = cellmlDocB . getModel ( ) . getComponents ( ) ; for ( CellMLComponent component : components . values ( ) ) { Connection con = conMgmt . getConnectionForNode ( component . getDocumentNode ( ) ) ; HierarchyNetworkComponent nc = null ; if ( con == null ) { nc = new HierarchyNetworkComponent ( hn , null , component . getName ( ) , null , component . getDocumentNode ( ) ) ; } else { nc = hn . getComponent ( con . getPartnerOf ( component . getDocumentNode ( ) ) ) ; nc . setDocB ( component . getDocumentNode ( ) ) ; nc . setLabelB ( component . getName ( ) ) ; } hn . setComponent ( component . getDocumentNode ( ) , nc ) ; componentMapper . put ( component , nc ) ; HashMap < String , CellMLVariable > vars = component . getVariables ( ) ; for ( CellMLVariable var : vars . values ( ) ) { DocumentNode varNode = var . getDocumentNode ( ) ; HierarchyNetworkVariable hnVar = null ; Connection c = conMgmt . getConnectionForNode ( varNode ) ; if ( c == null || hn . getVariable ( c . getPartnerOf ( varNode ) ) == null ) { hnVar = new HierarchyNetworkVariable ( hn , null , var . getName ( ) , null , varNode , null , nc ) ; } else { hnVar = hn . getVariable ( c . getPartnerOf ( varNode ) ) ; hnVar . setDocB ( varNode ) ; hnVar . setLabelB ( var . getName ( ) ) ; hnVar . setComponentB ( nc ) ; } nc . addVariable ( hnVar ) ; hn . setVariable ( varNode , hnVar ) ; variableMapper . put ( var , hnVar ) ; } hn . setComponent ( component . getDocumentNode ( ) , nc ) ; componentMapper . put ( component , nc ) ; } CellMLHierarchyNetwork enc = cellmlDocB . getModel ( ) . getHierarchy ( ) . getHierarchyNetwork ( "encapsulation" , "" ) ; for ( CellMLComponent component : components . values ( ) ) { CellMLHierarchyNode compNode = enc . getNode ( component ) ; if ( compNode != null ) { CellMLHierarchyNode parent = compNode . getParent ( ) ; if ( parent != null ) { componentMapper . get ( component ) . setParentB ( componentMapper . get ( parent . getComponent ( ) ) ) ; } } HashMap < String , CellMLVariable > vars = component . getVariables ( ) ; for ( CellMLVariable var : vars . values ( ) ) { HierarchyNetworkVariable hnv = variableMapper . get ( var ) ; /*List<CellMLVariable> cons = var.getPrivateInterfaceConnections ();
				for (CellMLVariable con : cons)
				{
					LOGGER.info ("create var connection B: " + var.getName () + " -> " + con.getName ());
					hnv.addConnectionB (variableMapper.get (con));
				}*/ if ( var . getPublicInterface ( ) == CellMLVariable . INTERFACE_IN ) { List < CellMLVariable > cons = var . getPublicInterfaceConnections ( ) ; for ( CellMLVariable con : cons ) { hnv . addConnectionB ( variableMapper . get ( con ) ) ; } } if ( var . getPrivateInterface ( ) == CellMLVariable . INTERFACE_IN ) { List < CellMLVariable > cons = var . getPrivateInterfaceConnections ( ) ; for ( CellMLVariable con : cons ) { hnv . addConnectionB ( variableMapper . get ( con ) ) ; } } } } }
Process Hierarchy Network of the modified document.
Process Hierarchy Network of the modified document .
// looks like wee need two traversals... // create nodes in graph // no equivalent in doc a //LOGGER.info ("create node: " + component.getName ()); //LOGGER.info ("add b to node: " + component.getName ()); // var already defined? // no equivalent in doc a //LOGGER.info ("create var: " + var.getName ()); //LOGGER.info ("add b to var: " + var.getName ()); //LOGGER.info ("found " + enc.getNodes ().size () + " enc nodes"); // connect nodes //LOGGER.info ("create comp connection B: " + component.getName () + " -> " + parent.getComponent ().getName ()); //LOGGER.info ("create var connection B (pub): " + var.getName () + " -> " + con.getName () + " --- " + var.getComponent ().getName () + " -> " + con.getComponent ().getName ()); //LOGGER.info ("create var connection B (prib): " + var.getName () + " -> " + con.getName () + " --- " + var.getComponent ().getName () + " -> " + con.getComponent ().getName ());