-- sql/objects-create.sql
--
-- PL/SQL that makes various portal tables into acs objects.
-- It's stored here to keep the data model clear.
--
-- Ian Baker <ibaker@arsdigita.com>
-- $Id: objects-create.sql,v 1.1 2002/07/09 17:35:10 rmello Exp $
--


create function inline_0 ()
returns integer as '
declare 
 attr_id acs_attributes.attribute_id%TYPE; 
begin

-- First, the portal type.

  PERFORM acs_object_type__create_type ( 
    ''portal'', 
    ''Portal'', 
    ''Portals'', 
    ''acs_object'', 
    ''PORTALS'', 
    ''PORTAL_ID'',
    ''portal'',
    ''f'',
    null,
    null
  ); 

-- and its attributes, ''name'', and ''cache_time''

  attr_id := acs_attribute__create_attribute ( 
    ''portal'', 
    ''NAME'', 
    ''string'',
    ''Name'', 
    ''Names'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f''
  );

-- portal_templates, now.

  PERFORM acs_object_type__create_type (
    ''portal_template'',
    ''Portal Template'',
    ''Portal Templates'',
    ''acs_object'',
    ''PORTAL_TEMPLATES'',
    ''TEMPLATE_ID'',
    ''portal_template'',
    ''f'',
    null,
    null
  );

-- and its attributes

  attr_id := acs_attribute__create_attribute ( 
    ''portal_template'', 
    ''NAME'', 
    ''string'',
    ''Name'', 
    ''Names'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f''
  ); 

  attr_id := acs_attribute__create_attribute ( 
    ''portal_template'', 
    ''DESCRIPTION'', 
    ''string'',
    ''Description'', 
    ''Descriptions'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f'' 
  ); 

  attr_id := acs_attribute__create_attribute ( 
    ''portal_template'', 
    ''TYPE'', 
    ''string'',
    ''Type'', 
    ''Types'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f''
  ); 

  attr_id := acs_attribute__create_attribute (
    ''portal_template'',
    ''FILENAME'',
    ''string'',
    ''Filename'',
    ''Filenames'',
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f''
  ); 

  attr_id := acs_attribute__create_attribute (
    ''portal_template'',
    ''SUPPORTED_REGIONS'',
    ''string'',
    ''Supported Regions'',
    ''Supported Regions'',
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f''
  ); 

  attr_id := acs_attribute__create_attribute ( 
    ''portal_template'', 
    ''EXAMPLE'',
    ''string'',
    ''Example'',
    ''Examples'',
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f'' 
  );

-- element configurations,
-- which have no attributes of their own.

  PERFORM acs_object_type__create_type (
    ''portal_element_config'',
    ''Portal Element Configuration'',
    ''Portal Element Configurations'',
    ''acs_object'',
    ''PORTAL_ELEMENT_CONFIGS'',
    ''CONFIG_ID'',
    ''portal_config'',
    ''f'',
    null,
    null
  );

-- datasources

  PERFORM acs_object_type__create_type ( 
    ''portal_datasource'',
    ''Portal Data Source'',
    ''Portal Data Sources'',
    ''acs_object'',
    ''PORTAL_DATASOURCES'',
    ''DATASOURCE_ID'',
    ''portal_datasource'',
    ''f'',
    null,
    null
  ); 

-- datasource attributes

  attr_id := acs_attribute__create_attribute ( 
    ''portal_datasource'', 
    ''NAME'', 
    ''string'',
    ''Name'', 
    ''Names'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f'' 
  ); 

  attr_id := acs_attribute__create_attribute ( 
    ''portal_datasource'', 
    ''DESCRIPTION'', 
    ''string'',
    ''Description'', 
    ''Descriptions'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f'' 
  ); 

  attr_id := acs_attribute__create_attribute ( 
    ''portal_datasource'', 
    ''CONTENT'', 
    ''string'',
    ''Content'', 
    ''Contents'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f'' 
  ); 

-- Finally, elements.

  PERFORM acs_object_type__create_type ( 
    ''portal_element'',
    ''Portal Element'',
    ''Portal Elements'',
    ''acs_object'', 
    ''PORTAL_ELEMENTS'', 
    ''ELEMENT_ID'',
    ''portal_element'',
    ''f'',
    null,
    null
  ); 

-- and attributes for the element object...

  attr_id := acs_attribute__create_attribute ( 
    ''portal_element'', 
    ''NAME'', 
    ''string'',
    ''Name'', 
    ''Names'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f'' 
  ); 

  attr_id := acs_attribute__create_attribute ( 
    ''portal_element'',
    ''DESCRIPTION'', 
    ''string'',
    ''Description'', 
    ''Descriptions'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f'' 
  );

  attr_id := acs_attribute__create_attribute ( 
    ''portal_element'',
    ''EXPORTABLE_P'', 
    ''string'',
    ''Exportable'', 
    ''Exportable'', 
     null,
     null,
     null,
     0,
     1,
     null,
     ''type_specific'',
     ''f'' 
  );

  return 0;
end; 
' language 'plpgsql';

select inline_0 ();

drop function inline_0 ();
