private void insertNode(Node<OrganizationalUnit> node,
Node<OrganizationalUnit> parent,
OrganizationalUnitHierarchy hierarchy) {
logger.debug("IN: node = " + node + ", parent = " + parent + ", hierarchy = " + hierarchy);
OrganizationalUnitNode aNode = new OrganizationalUnitNode();
aNode.setHierarchy(hierarchy);
OrganizationalUnit content = node.getNodeContent();
content = DAOFactory.getOrganizationalUnitDAO().getOrganizationalUnitByLabelAndName(content.getLabel(), content.getName());
if(content == null){
//then insert it!!there could be a misalignment
DAOFactory.getOrganizationalUnitDAO().insertOrganizationalUnit(node.getNodeContent());
content = DAOFactory.getOrganizationalUnitDAO().getOrganizationalUnitByLabelAndName(node.getNodeContent().getLabel(), node.getNodeContent().getName());
}
aNode.setOu(content);
aNode.setPath(node.getPath());
if (parent != null) {
OrganizationalUnitNode parentNode = DAOFactory.getOrganizationalUnitDAO().getOrganizationalUnitNode(parent.getPath(), hierarchy.getId());
Integer parentNodeId = parentNode.getNodeId();
aNode.setParentNodeId(parentNodeId);
}
DAOFactory.getOrganizationalUnitDAO().insertOrganizationalUnitNode(aNode);
logger.debug("OUT");
}