Index: openacs-4/packages/postal-address/postal-address.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/postal-address/postal-address.info,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/postal-address/postal-address.info	13 Mar 2003 21:49:44 -0000	1.1
@@ -0,0 +1,78 @@
+<?xml version="1.0"?>
+<!-- Generated by the OpenACS Package Manager -->
+
+<package key="postal-address" url="http://openacs.org/repository/apm/packages/postal-address" type="apm_service">
+    <package-name>Postal Address</package-name>
+    <pretty-plural>Postal Addresses</pretty-plural>
+    <initial-install-p>f</initial-install-p>
+    <singleton-p>f</singleton-p>
+
+    <version name="0.1d" url="http://openacs.org/repository/download/apm/postal-address-0.1d.apm">
+    <database-support>
+        <database>oracle</database>
+        <database>postgresql</database>
+    </database-support>
+        <owner url="mailto:jon@mayuli.com">Jon Griffin</owner>
+        <summary>This is an implementation of HR-XML's address standard.</summary>
+        <vendor url="http://www.mayuli.com">Mayuli Enterprises LLC</vendor>
+        <description format="text/html">This is an implementation of HR-XML's address standard.&lt;p&gt;
+Originally part of Contacts-Lite, it is now a service.</description>
+
+        <requires url="acs-kernel" version="4.6"/>
+        <requires url="acs-reference" version="0.2d"/>
+        <requires url="ref-countries" version="0.1d"/>
+
+        <files>
+            <file type="package_spec" path="postal-address.info"/>
+            <file path="sql/oracle/oracle.notes"/>
+            <file type="data_model_create" db_type="postgresql" path="sql/postgresql/postal-address-create.sql"/>
+            <file type="data_model" db_type="postgresql" path="sql/postgresql/postal-address-plsql.sql"/>
+            <file type="query_file" db_type="oracle" path="www/add-edit-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/add-edit-postgresql.xql"/>
+            <file type="content_page" path="www/add-edit.adp"/>
+            <file type="content_page" path="www/add-edit.tcl"/>
+            <file type="query_file" path="www/add-edit.xql"/>
+            <file type="query_file" db_type="oracle" path="www/address-delete-2-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/address-delete-2-postgresql.xql"/>
+            <file type="content_page" path="www/address-delete-2.tcl"/>
+            <file type="query_file" path="www/address-delete-2.xql"/>
+            <file type="content_page" path="www/address-delete.adp"/>
+            <file type="content_page" path="www/address-delete.tcl"/>
+            <file type="query_file" path="www/address-delete.xql"/>
+            <file type="content_page" path="www/admin/address-type/add-edit.adp"/>
+            <file type="content_page" path="www/admin/address-type/add-edit.tcl"/>
+            <file type="query_file" path="www/admin/address-type/add-edit.xql"/>
+            <file type="content_page" path="www/admin/address-type/delete-2.tcl"/>
+            <file type="content_page" path="www/admin/address-type/delete.adp"/>
+            <file type="content_page" path="www/admin/address-type/delete.tcl"/>
+            <file type="query_file" path="www/admin/address-type/delete.xql"/>
+            <file type="content_page" path="www/admin/address-type/index.adp"/>
+            <file type="content_page" path="www/admin/address-type/index.tcl"/>
+            <file type="query_file" path="www/admin/address-type/index.xql"/>
+            <file type="content_page" path="www/admin/index.adp"/>
+            <file type="content_page" path="www/admin/index.tcl"/>
+            <file type="query_file" db_type="oracle" path="www/delete-2-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/delete-2-postgresql.xql"/>
+            <file type="content_page" path="www/delete-2.tcl"/>
+            <file type="query_file" path="www/delete-2.xql"/>
+            <file type="content_page" path="www/delete.adp"/>
+            <file type="content_page" path="www/delete.tcl"/>
+            <file type="query_file" path="www/delete.xql"/>
+            <file type="query_file" db_type="oracle" path="www/index-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/index-postgresql.xql"/>
+            <file type="content_page" path="www/index.adp"/>
+            <file type="content_page" path="www/index.tcl"/>
+            <file type="query_file" path="www/index.xql"/>
+            <file type="content_page" path="www/notes.txt"/>
+            <file type="query_file" db_type="oracle" path="www/one-oracle.xql"/>
+            <file type="query_file" db_type="postgresql" path="www/one-postgresql.xql"/>
+            <file type="content_page" path="www/one.adp"/>
+            <file type="content_page" path="www/one.tcl"/>
+            <file type="query_file" path="www/one.xql"/>
+        </files>
+        <parameters>
+        <!-- No version parameters -->
+        </parameters>
+
+    </version>
+</package>
Index: openacs-4/packages/postal-address/sql/postgresql/postal-address-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/postal-address/sql/postgresql/postal-address-create.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/postal-address/sql/postgresql/postal-address-create.sql	13 Mar 2003 21:52:22 -0000	1.1
@@ -0,0 +1,82 @@
+-- @cvs-id: $Id: postal-address-create.sql,v 1.1 2003/03/13 21:52:22 jong Exp $
+
+-- lookup table 
+
+-- This is for hr-xml defined type
+create table postal_types
+(
+    type_id         integer
+                    constraint postal_types_id_pk
+                        primary key,
+    description     varchar (40)
+                    constraint postal_types_desc_nn
+                        not null
+);
+
+insert into postal_types values (1,'Post Office Box');
+insert into postal_types values (2,'Street Address');
+insert into postal_types values (3,'Military Address');
+insert into postal_types values (4,'Undefined (default)');
+
+-- main table
+-- will get organization_name from other organizations table
+-- I am not storing the parsed elements here.
+-- That is better left to a validation proc
+
+create table postal_addresses
+(
+    address_id          integer 
+                        constraint postal__address_id_pk
+                            primary key
+                        constraint postal_address_id_fk
+                            references acs_objects (object_id),
+    -- this could be a contact,person,organization etc.
+    party_id            integer
+                        constraint postal_owner_id_fk
+                            references parties (party_id),
+    delivery_address    varchar (1000)
+                        constraint postal_address_delivery_nn
+                        not null,
+    postal_code         varchar (30),
+    municipality        varchar (100),
+    region              varchar (100),
+    country_code        char    (2)
+                        constraint postal_addresses_country_fk
+                            references countries (iso)
+                        constraint postal_addresses_country_nn
+                            not null,
+    additional_text     varchar(100),
+    postal_type         integer
+                        constraint postal_addresses_type_fk
+                            references postal_types (type_id)
+);
+
+create index postal_addresses_country_ix on postal_addresses(country_code);
+create index postal_addresses_party_ix on postal_addresses(party_id);
+
+comment on table postal_addresses is '
+This is the master address table.
+';
+
+comment on column postal_addresses.delivery_address is '
+This is the main delivery address. In the US of A it would be equivalent to line1, line2 and etc.
+';
+
+comment on column postal_addresses.postal_code is '
+This is equivalent to zip in the good ol'' US of A.
+';
+
+comment on column postal_addresses.municipality is '
+This is equivalent to City in the good ol'' US of A.
+';
+
+comment on column postal_addresses.region is '
+This is equivalent to state in the good ol'' US of A.
+';
+
+comment on column postal_addresses.country_code is '
+Required. This is the country of reference for validations and etc.
+';
+
+-- plsql
+\i postal-address-plsql.sql
Index: openacs-4/packages/postal-address/sql/postgresql/postal-address-plsql.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/postal-address/sql/postgresql/postal-address-plsql.sql,v
diff -u
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/postal-address/sql/postgresql/postal-address-plsql.sql	13 Mar 2003 21:52:22 -0000	1.1
@@ -0,0 +1,118 @@
+-- packages/postal_address/sql/postgresql/postal_address-plsql.sql
+--
+-- @author Jon Griffin
+-- @creation-date 26 February 2003
+-- @cvs-id $Id: postal-address-plsql.sql,v 1.1 2003/03/13 21:52:22 jong Exp $
+
+-- What no comments?
+
+create function inline_0 () 
+returns integer as '  
+begin 
+    PERFORM acs_object_type__create_type (  
+      ''postal_address'', -- object_type  
+      ''Postal Address'', -- pretty_name 
+      ''Postal Address'',  -- pretty_plural 
+      ''acs_object'',   -- supertype 
+      ''postal_addresses'',  -- table_name 
+      ''address_id'', -- id_column 
+      ''postal_address'', -- package_name 
+      ''f'', -- abstract_p 
+      null, -- type_extension_table 
+      null -- name_method 
+  ); 
+ 
+  return 0;  
+end;' language 'plpgsql'; 
+
+select inline_0 (); 
+
+drop function inline_0 ();
+
+------ start of oacs new proc
+create or replace function postal_address__new ( varchar,integer,char,varchar,varchar,
+integer,varchar,integer,varchar,integer,varchar,integer )
+returns integer as ' 
+declare 
+    p_additional_text     alias for $1; -- comment
+    p_address_id          alias for $2; -- comment
+    p_country_code        alias for $3; -- comment
+    p_delivery_address    alias for $4; -- comment
+    p_municipality        alias for $5; -- comment
+    p_party_id            alias for $6; -- comment
+    p_postal_code         alias for $7; -- comment
+    p_postal_type         alias for $8; -- comment
+    p_region              alias for $9; -- comment
+    p_creation_user       alias for $10; -- comment
+    p_creation_ip         alias for $11; -- comment
+    p_context_id          alias for $12; -- comment
+
+    -- local vars
+    v_address_id postal_addresses.address_id%TYPE; 
+begin 
+  v_address_id := acs_object__new (  
+    null,  
+    ''postal_address'',
+    now(), 
+    p_creation_user, 
+    p_creation_ip, 
+    p_context_id 
+  );   
+   
+
+  insert into postal_addresses (
+    additional_text,
+    address_id,
+    country_code,
+    delivery_address,
+    municipality,
+    party_id,
+    postal_code,
+    postal_type,
+    region 
+  )  
+  values ( 
+    p_additional_text,
+    v_address_id,
+    p_country_code,
+    p_delivery_address,
+    p_municipality,
+    p_party_id,
+    p_postal_code,
+    p_postal_type,
+    p_region 
+  ); 
+
+  PERFORM acs_permission__grant_permission (
+     v_address_id,
+     p_creation_user,
+     ''admin''
+  );
+
+   raise NOTICE ''Adding postal_address - %'',v_address_id;
+  return v_address_id;
+
+end;' language 'plpgsql';
+
+------ end new proc
+
+create or replace function postal_address__del (integer) 
+returns integer as ' 
+declare 
+ p_address_id    alias for $1; 
+ v_return integer := 0;  
+begin 
+
+   delete from acs_permissions 
+     where object_id = p_address_id; 
+
+   delete from postal_addresses 
+     where address_id = p_address_id;
+
+   raise NOTICE ''Deleting postal_address - %'',p_address_id;
+
+   PERFORM acs_object__delete(p_address_id);
+
+   return v_return;
+
+end;' language 'plpgsql';
\ No newline at end of file