SELECT @UNIT_ID := ID_INTERNAL FROM PARTY WHERE ACRONYM LIKE '%ACD%';
select @SITE_ID := KEY_SITE FROM PARTY WHERE ID_INTERNAL=@UNIT_ID;

update CONTENT set OJB_CONCRETE_CLASS='net.sourceforge.fenixedu.domain.StudentsSite' WHERE ID_INTERNAL=@SITE_ID;

insert into META_DOMAIN_OBJECT (KEY_ROOT_DOMAIN_OBJECT,TYPE) values (1,'net.sourceforge.fenixedu.domain.StudentsSite');

SELECT @MDO_ID := ID_INTERNAL FROM META_DOMAIN_OBJECT WHERE TYPE='net.sourceforge.fenixedu.domain.StudentsSite';

insert into CONTENT (OJB_CONCRETE_CLASS, KEY_ROOT_DOMAIN_OBJECT,CONTENT_ID,NAME,PERSONALIZED_LOGO,
SHOW_BANNER,SHOW_INTRODUCTION,SHOW_ANNOUNCEMENTS,SHOW_EVENTS,LAYOUT,SHOW_FLAGS,SHOW_INSTITUTION_LOGO,KEY_META_DOMAIN_OBJECT)
values('net.sourceforge.fenixedu.domain.contents.MetaDomainObjectPortal',1,'e36ffab4-3a6a-102b-903e-0016ec912b39', 'pt9:Alunos CD',0,1,1,1,1,'BANNER_INTRO',1,1,@MDO_ID);

select @RootPortal := KEY_ROOT_PORTAL FROM ROOT_DOMAIN_OBJECT;
select @PortalUUID := CONTENT_ID FROM CONTENT WHERE ID_INTERNAL=@RootPortal;
select @NODE_ORDER := MAX(NODE_ORDER) FROM NODE WHERE KEY_PARENT=@RootPortal;
SELECT @MDO_PORTAL := ID_INTERNAL FROM CONTENT WHERE CONTENT_ID='e36ffab4-3a6a-102b-903e-0016ec912b39';

insert into NODE(OJB_CONCRETE_CLASS,KEY_ROOT_DOMAIN_OBJECT,KEY_PARENT,KEY_CHILD,
NODE_ORDER,VISIBLE,ASCENDING,CONTENT_ID) 
select 'net.sourceforge.fenixedu.domain.contents.ExplicitOrderNode', '1', @RootPortal, C.ID_INTERNAL, @NODE_ORDER+1,'1','1',concat(@PortalUUID,C.CONTENT_ID) FROM CONTENT C WHERE ID_INTERNAL=@MDO_PORTAL;
