INSERT INTO `ACCESSIBLE_ITEM` (`UUID`, `OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `KEY_PARENT`, `KEY_MODULE`, `KEY_AVAILABILITY_POLICY`, `NAME`, `TITLE`, `DESCRIPTION`, `PATH`, `PREFIX`, `RELATIVE`, `ENABLED`, `PARAMETERS`, `ORDER_IN_MODULE`, `VISIBLE`, `MAXIMIZED`, `PRINCIPAL`, `KEY_SUPERIOR_SECTION`, `SECTION_ORDER`, `KEY_SITE`, `LAST_MODIFIED_DATE_YEAR_MONTH_DAY`, `KEY_SECTION`, `ITEM_ORDER`, `INFORMATION`, `KEY_FUNCTIONALITY`, `SHOW_NAME`, `KEY_INTRODUCTION_UNIT_SITE`) 
SELECT '72551ac3-ed0a-4e5a-8d1e-6d49dd60eb28', 'net.sourceforge.fenixedu.domain.functionalities.ConcreteFunctionality', 1, NULL, `ID_INTERNAL`, NULL, 'pt12:Dissertaçõesen13:Dissertations', NULL, NULL, '/showDegreeTheses.do?method=showTheses', NULL, 1, 1, 'degreeID', 8, 1, 0, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL FROM `ACCESSIBLE_ITEM` WHERE `UUID` = 'ab4c28f5-1803-4f98-a900-87ee6705b79e';

UPDATE `ACCESSIBLE_ITEM` AS own SET own.`KEY_AVAILABILITY_POLICY` = NULL WHERE own.`UUID` = '72551ac3-ed0a-4e5a-8d1e-6d49dd60eb28';
INSERT INTO `AVAILABILITY_POLICY` (`OJB_CONCRETE_CLASS`, `KEY_ROOT_DOMAIN_OBJECT`, `KEY_ACCESSIBLE_ITEM`, `EXPRESSION`, `TARGET_GROUP`) SELECT 'net.sourceforge.fenixedu.domain.functionalities.ExpressionGroupAvailability', 1, `ID_INTERNAL`, 'ifTrue($I(degreeID, Degree).anyThesisAvailable)', 'ifTrue($I(degreeID, Degree).anyThesisAvailable)' FROM `ACCESSIBLE_ITEM` WHERE `UUID` = '72551ac3-ed0a-4e5a-8d1e-6d49dd60eb28';
UPDATE `ACCESSIBLE_ITEM` AS f, `AVAILABILITY_POLICY` AS ap SET f.`KEY_AVAILABILITY_POLICY` = ap.`ID_INTERNAL` WHERE f.`UUID` = '72551ac3-ed0a-4e5a-8d1e-6d49dd60eb28' AND ap.`KEY_ACCESSIBLE_ITEM` = f.`ID_INTERNAL`;

INSERT INTO ACCESSIBLE_ITEM (OJB_CONCRETE_CLASS, KEY_ROOT_DOMAIN_OBJECT, KEY_SITE, KEY_FUNCTIONALITY, SECTION_ORDER)
SELECT "net.sourceforge.fenixedu.domain.FunctionalitySection",
	   1,
	   S.ID_INTERNAL,
	   F.ID_INTERNAL,
	   O.MAX_ORDER
FROM SITE S, ACCESSIBLE_ITEM F, 
	 (SELECT MAX(SECTION_ORDER) + 1 AS MAX_ORDER
	 FROM ACCESSIBLE_ITEM AI, SITE S
	 WHERE AI.KEY_SITE = S.ID_INTERNAL
	   AND AI.KEY_SUPERIOR_SECTION IS NULL
	   AND S.SITE_TYPE = 'net.sourceforge.fenixedu.domain.DegreeSite') AS O
WHERE S.SITE_TYPE = 'net.sourceforge.fenixedu.domain.DegreeSite'
  AND F.UUID = '72551ac3-ed0a-4e5a-8d1e-6d49dd60eb28';
--  SQL file representing changes to the functionalities model
--  Generated at Wed Jul 11 11:39:34 WEST 2007
--  DO NOT EDIT THIS FILE, run the generating script instead

