src/main/java/de/unirostock/sems/bives/cellml/algorithm/CellMLGraphProducer.java
protected void processHnA ()
	{
		LOGGER.info ("processHnA");
		
		// 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 = cellmlDocA.getModel ().getComponents ();
		
		// create nodes in graph
		for (CellMLComponent component : components.values ())
		{
			//LOGGER.info ("create node A: " + component.getName ());
			HierarchyNetworkComponent nc = new HierarchyNetworkComponent (hn, component.getName (), null, component.getDocumentNode (), null);
			
			HashMap<String, CellMLVariable> vars = component.getVariables ();
			for (CellMLVariable var : vars.values ())
			{
				//LOGGER.info ("create var A: " + var.getName ());
				HierarchyNetworkVariable hnVar = new HierarchyNetworkVariable (hn, var.getName (), null, var.getDocumentNode (), null, nc, null);
				nc.addVariable (hnVar);
				hn.setVariable (var.getDocumentNode (), hnVar);
				variableMapper.put (var, hnVar);
			}
			hn.setComponent (component.getDocumentNode (), nc);
			componentMapper.put (component, nc);
			
		}
		
		CellMLHierarchyNetwork enc = cellmlDocA.getModel ().getHierarchy ().getHierarchyNetwork ("encapsulation", "");
		//LOGGER.info ("found " + enc.getNodes ().size () + " enc nodes");
		
		// connect nodes
		for (CellMLComponent component : components.values ())
		{
			//LOGGER.info ("check " + component.getName ());
			CellMLHierarchyNode compNode = enc.getNode (component);
			//LOGGER.info ("hierarchy node: " + compNode);
			if (compNode != null)
			{
				CellMLHierarchyNode parent = compNode.getParent ();
				if (parent != null)
				{
					//LOGGER.info ("create comp connection A: " + component.getName () + " -> " + parent.getComponent ().getName ());
					componentMapper.get (component).setParentA (componentMapper.get (parent.getComponent ()));
				}
			}
			

			HashMap<String, CellMLVariable> vars = component.getVariables ();
			//LOGGER.info ("has " + vars.size () + " vars");
			for (CellMLVariable var : vars.values ())
			{
				HierarchyNetworkVariable hnv = variableMapper.get (var);
				//System.out.println ("con var A: " + var.getName () + " = " + var.getPublicInterfaceConnections () + " / " + var.getPrivateInterfaceConnections ());
				if (var.getPublicInterface () == CellMLVariable.INTERFACE_IN)
				{
					List<CellMLVariable> cons = var.getPublicInterfaceConnections ();
					for (CellMLVariable con : cons)
					{
						//LOGGER.info ("create var connection A (pub): " + var.getName () + " -> " + con.getName () + " --- " + var.getComponent ().getName () + " -> " + con.getComponent ().getName ());
						hnv.addConnectionA (variableMapper.get (con));
					}
				}
				if (var.getPrivateInterface () == CellMLVariable.INTERFACE_IN)
				{
					List<CellMLVariable> cons = var.getPrivateInterfaceConnections ();
					for (CellMLVariable con : cons)
					{
						//LOGGER.info ("create var connection A (priv): " + var.getName () + " -> " + con.getName () + " --- " + var.getComponent ().getName () + " -> " + con.getComponent ().getName ());
						hnv.addConnectionA (variableMapper.get (con));
					}
				}
			}
		}
	}
/**
	 * Process Hierarchy Network of the original document.
	 */
Process Hierarchy Network of the original document.
Process Hierarchy Network of the original document .
protected void processHnA ()
	{
		LOGGER.info ("processHnA");
		HashMap<CellMLComponent, HierarchyNetworkComponent> componentMapper = new HashMap<CellMLComponent, HierarchyNetworkComponent> ();
		HashMap<CellMLVariable, HierarchyNetworkVariable> variableMapper = new HashMap<CellMLVariable, HierarchyNetworkVariable> ();
		HashMap<String,CellMLComponent> components = cellmlDocA.getModel ().getComponents ();
		for (CellMLComponent component : components.values ())
		{
			HierarchyNetworkComponent nc = new HierarchyNetworkComponent (hn, component.getName (), null, component.getDocumentNode (), null);
			HashMap<String, CellMLVariable> vars = component.getVariables ();
			for (CellMLVariable var : vars.values ())
			{
				HierarchyNetworkVariable hnVar = new HierarchyNetworkVariable (hn, var.getName (), null, var.getDocumentNode (), null, nc, null);
				nc.addVariable (hnVar);
				hn.setVariable (var.getDocumentNode (), hnVar);
				variableMapper.put (var, hnVar);
			}
			hn.setComponent (component.getDocumentNode (), nc);
			componentMapper.put (component, nc);
		}
		CellMLHierarchyNetwork enc = cellmlDocA.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).setParentA (componentMapper.get (parent.getComponent ()));
				}
			}
			HashMap<String, CellMLVariable> vars = component.getVariables ();
			for (CellMLVariable var : vars.values ())
			{
				HierarchyNetworkVariable hnv = variableMapper.get (var);
				if (var.getPublicInterface () == CellMLVariable.INTERFACE_IN)
				{
					List<CellMLVariable> cons = var.getPublicInterfaceConnections ();
					for (CellMLVariable con : cons)
					{
						hnv.addConnectionA (variableMapper.get (con));
					}
				}
				if (var.getPrivateInterface () == CellMLVariable.INTERFACE_IN)
				{
					List<CellMLVariable> cons = var.getPrivateInterfaceConnections ();
					for (CellMLVariable con : cons)
					{
						hnv.addConnectionA (variableMapper.get (con));
					}
				}
			}
		}
	}
protected void processHnA ( ) { LOGGER . info ( "processHnA" ) ; HashMap < CellMLComponent , HierarchyNetworkComponent > componentMapper = new HashMap < CellMLComponent , HierarchyNetworkComponent > ( ) ; HashMap < CellMLVariable , HierarchyNetworkVariable > variableMapper = new HashMap < CellMLVariable , HierarchyNetworkVariable > ( ) ; HashMap < String , CellMLComponent > components = cellmlDocA . getModel ( ) . getComponents ( ) ; for ( CellMLComponent component : components . values ( ) ) { HierarchyNetworkComponent nc = new HierarchyNetworkComponent ( hn , component . getName ( ) , null , component . getDocumentNode ( ) , null ) ; HashMap < String , CellMLVariable > vars = component . getVariables ( ) ; for ( CellMLVariable var : vars . values ( ) ) { HierarchyNetworkVariable hnVar = new HierarchyNetworkVariable ( hn , var . getName ( ) , null , var . getDocumentNode ( ) , null , nc , null ) ; nc . addVariable ( hnVar ) ; hn . setVariable ( var . getDocumentNode ( ) , hnVar ) ; variableMapper . put ( var , hnVar ) ; } hn . setComponent ( component . getDocumentNode ( ) , nc ) ; componentMapper . put ( component , nc ) ; } CellMLHierarchyNetwork enc = cellmlDocA . 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 ) . setParentA ( componentMapper . get ( parent . getComponent ( ) ) ) ; } } HashMap < String , CellMLVariable > vars = component . getVariables ( ) ; for ( CellMLVariable var : vars . values ( ) ) { HierarchyNetworkVariable hnv = variableMapper . get ( var ) ; if ( var . getPublicInterface ( ) == CellMLVariable . INTERFACE_IN ) { List < CellMLVariable > cons = var . getPublicInterfaceConnections ( ) ; for ( CellMLVariable con : cons ) { hnv . addConnectionA ( variableMapper . get ( con ) ) ; } } if ( var . getPrivateInterface ( ) == CellMLVariable . INTERFACE_IN ) { List < CellMLVariable > cons = var . getPrivateInterfaceConnections ( ) ; for ( CellMLVariable con : cons ) { hnv . addConnectionA ( variableMapper . get ( con ) ) ; } } } } }
Process Hierarchy Network of the original document.
Process Hierarchy Network of the original document .
// looks like wee need two traversals... // create nodes in graph //LOGGER.info ("create node A: " + component.getName ()); //LOGGER.info ("create var A: " + var.getName ()); //LOGGER.info ("found " + enc.getNodes ().size () + " enc nodes"); // connect nodes //LOGGER.info ("check " + component.getName ()); //LOGGER.info ("hierarchy node: " + compNode); //LOGGER.info ("create comp connection A: " + component.getName () + " -> " + parent.getComponent ().getName ()); //LOGGER.info ("has " + vars.size () + " vars"); //System.out.println ("con var A: " + var.getName () + " = " + var.getPublicInterfaceConnections () + " / " + var.getPrivateInterfaceConnections ()); //LOGGER.info ("create var connection A (pub): " + var.getName () + " -> " + con.getName () + " --- " + var.getComponent ().getName () + " -> " + con.getComponent ().getName ()); //LOGGER.info ("create var connection A (priv): " + var.getName () + " -> " + con.getName () + " --- " + var.getComponent ().getName () + " -> " + con.getComponent ().getName ());