


-- Inserted at 2010-01-18T15:53:48.929Z

alter table `REGISTRATION` add column `OID_REGISTRATION_PROTOCOL` bigint(20), add index (`OID_REGISTRATION_PROTOCOL`);


create table `REGISTRATION_PROTOCOL_PERSON` (OID_REGISTRATION_PROTOCOL bigint unsigned not null, OID_PERSON bigint unsigned not null,  primary key (OID_REGISTRATION_PROTOCOL, OID_PERSON), key(OID_REGISTRATION_PROTOCOL), key(OID_PERSON)) type=InnoDB;
create table `REGISTRATION_PROTOCOL` (
  `ID_INTERNAL` int(11) NOT NULL auto_increment,
  `OID` bigint(20),
  `OID_ROOT_DOMAIN_OBJECT` bigint(20),
  `REGISTRATION_AGREEMENT` text,
  primary key (ID_INTERNAL),
  index (OID),
  index (OID_ROOT_DOMAIN_OBJECT)
) type=InnoDB, character set latin1 ;

set @xpto = (select max(DOMAIN_CLASS_ID)+1 from FF$DOMAIN_CLASS_INFO);
insert into FF$DOMAIN_CLASS_INFO values ('net.sourceforge.fenixedu.domain.student.RegistrationProtocol',@xpto);

insert into REGISTRATION_PROTOCOL (REGISTRATION_AGREEMENT, OID_ROOT_DOMAIN_OBJECT) select distinct REGISTRATION_AGREEMENT, OID_ROOT_DOMAIN_OBJECT from REGISTRATION;
update REGISTRATION_PROTOCOL, FF$DOMAIN_CLASS_INFO set OID = (DOMAIN_CLASS_ID << 32) + ID_INTERNAL where DOMAIN_CLASS_NAME = 'net.sourceforge.fenixedu.domain.student.RegistrationProtocol'; 
	
update REGISTRATION, REGISTRATION_PROTOCOL set REGISTRATION.OID_REGISTRATION_PROTOCOL = REGISTRATION_PROTOCOL.OID
	where REGISTRATION.REGISTRATION_AGREEMENT = REGISTRATION_PROTOCOL.REGISTRATION_AGREEMENT;
	
insert into ROLE (ROLE_TYPE, OID_ROOT_DOMAIN_OBJECT) values('EXTERNAL_SUPERVISOR', 1035087118337);
update ROLE, FF$DOMAIN_CLASS_INFO set ROLE.OID = (DOMAIN_CLASS_ID << 32) + ROLE.ID_INTERNAL where DOMAIN_CLASS_NAME = 'net.sourceforge.fenixedu.domain.Role' and ROLE.ROLE_TYPE = 'EXTERNAL_SUPERVISOR'; 
update ROLE set PORTAL_SUB_APPLICATION = '/externalSupervisor' where ROLE_TYPE = 'EXTERNAL_SUPERVISOR';
update ROLE set PAGE = '/welcome.do' where ROLE_TYPE = 'EXTERNAL_SUPERVISOR';
update ROLE set PAGE_NAME_PROPERTY = 'portal.externalSupervisor' where ROLE_TYPE = 'EXTERNAL_SUPERVISOR';
update ROLE set KEY_ROOT_DOMAIN_OBJECT = 1 where ROLE_TYPE = 'EXTERNAL_SUPERVISOR';
update ROLE set OJB_CONCRETE_CLASS = 'net.sourceforge.fenixedu.domain.Role' where ROLE_TYPE = 'EXTERNAL_SUPERVISOR';