insert into CONTENT (OJB_CONCRETE_CLASS,NAME,TITLE,ENABLED,VISIBLE,KEY_SITE,MODIFICATION_DATE,OLD_ID_INTERNAL) 
select 'net.sourceforge.fenixedu.domain.Section', AI.NAME, AI.TITLE, AI.ENABLED, AI.VISIBLE, AI.KEY_SITE, 
AI.LAST_MODIFIED_DATE_YEAR_MONTH_DAY, AI.ID_INTERNAL FROM ACCESSIBLE_ITEM AI WHERE OJB_CONCRETE_CLASS=
'net.sourceforge.fenixedu.domain.Section';

insert into CONTENT(OJB_CONCRETE_CLASS, NAME,TITLE,ENABLED,VISIBLE,BODY,SHOW_NAME,OLD_ID_INTERNAL) 
select 'net.sourceforge.fenixedu.domain.Item', AI.NAME,AI.TITLE,AI.ENABLED,AI.VISIBLE,AI.INFORMATION,AI.SHOW_NAME,AI.ID_INTERNAL 
FROM ACCESSIBLE_ITEM AI WHERE OJB_CONCRETE_CLASS='net.sourceforge.fenixedu.domain.Item';

 insert NODE(KEY_PARENT,KEY_CHILD,NODE_ORDER,VISIBLE,OJB_CONCRETE_CLASS,ASCENDING) 
select C2.ID_INTERNAL, C1.ID_INTERNAL,AI.SECTION_ORDER,AI.VISIBLE,'net.sourceforge.fenixedu.domain.contents.ExplicitOrderNode','1' 
from ACCESSIBLE_ITEM AI, CONTENT C1, CONTENT C2 WHERE AI.OJB_CONCRETE_CLASS='net.sourceforge.fenixedu.domain.Section' 
AND AI.KEY_SUPERIOR_SECTION IS NOT NULL and C1.OLD_ID_INTERNAL=AI.ID_INTERNAL 
AND C1.OJB_CONCRETE_CLASS='net.sourceforge.fenixedu.domain.Section' AND C2.OJB_CONCRETE_CLASS='net.sourceforge.fenixedu.domain.Section' 
AND C2.OLD_ID_INTERNAL=AI.KEY_SUPERIOR_SECTION;

 insert into NODE(KEY_PARENT,KEY_CHILD,NODE_ORDER,VISIBLE,OJB_CONCRETE_CLASS,ASCENDING) 
select C1.ID_INTERNAL, C2.ID_INTERNAL,AI.ITEM_ORDER,AI.VISIBLE,'net.sourceforge.fenixedu.domain.contents.ExplicitOrderNode','1' 
from ACCESSIBLE_ITEM AI, CONTENT C1, CONTENT C2 WHERE AI.OJB_CONCRETE_CLASS='net.sourceforge.fenixedu.domain.Item' 
AND AI.KEY_SECTION IS NOT NULL and C1.OLD_ID_INTERNAL=AI.KEY_SECTION AND C1.OJB_CONCRETE_CLASS='net.sourceforge.fenixedu.domain.Section' 
AND C2.OJB_CONCRETE_CLASS='net.sourceforge.fenixedu.domain.Item' AND C2.OLD_ID_INTERNAL=AI.ID_INTERNAL;


