apm_package_instance_new (public)

 apm_package_instance_new -package_key package_key \
    [ -instance_name instance_name ] [ -package_id package_id ] \
    [ -context_id context_id ]

Defined in packages/acs-tcl/tcl/apm-procs.tcl

Creates a new instance of a package and calls the post instantiation proc, if any. If the package is a singleton and already exists then this procedure will silently do nothing.

Switches:
-package_key
(required)
The package_key of the package to instantiate.
-instance_name
(optional)
The name of the package instance, defaults to the pretty name of the package type.
-package_id
(optional)
The id of the new package. Optional.
-context_id
(optional)
The context_id of the new package. Optional.
Returns:
The id of the instantiated package

Partial Call Graph (max 5 caller/called nodes):
%3 test_test_apm_package_instance__new test_apm_package_instance__new (test acs-tcl) apm_package_instance_new apm_package_instance_new test_test_apm_package_instance__new->apm_package_instance_new apm::package_version::attributes::get_instance_name apm::package_version::attributes::get_instance_name (private) apm_package_instance_new->apm::package_version::attributes::get_instance_name apm_invoke_callback_proc apm_invoke_callback_proc (public) apm_package_instance_new->apm_invoke_callback_proc apm_parameter_sync apm_parameter_sync (public) apm_package_instance_new->apm_parameter_sync db_0or1row db_0or1row (public) apm_package_instance_new->db_0or1row db_exec_plsql db_exec_plsql (public) apm_package_instance_new->db_exec_plsql apm_package_install apm_package_install (public) apm_package_install->apm_package_instance_new install::xml::action::create-package install::xml::action::create-package (public) install::xml::action::create-package->apm_package_instance_new packages/acs-admin/www/apm/package-instance-create.tcl packages/acs-admin/ www/apm/package-instance-create.tcl packages/acs-admin/www/apm/package-instance-create.tcl->apm_package_instance_new site_node::instantiate_and_mount site_node::instantiate_and_mount (public) site_node::instantiate_and_mount->apm_package_instance_new

Testcases:
test_apm_package_instance__new
Source code:
    if { $instance_name eq "" } {
        set p_name [apm::package_version::attributes::get_instance_name $package_key]

        if {$p_name eq ""} {
            set instance_name [db_string pretty_name_from_key {select pretty_name
                from apm_enabled_package_versions
                where package_key = :package_key}]
        } else {
            set instance_name  "$p_name"
        }
    }
    #
    # Do not do anything for already instantiated singleton packages
    #
    if {![db_0or1row instantiated_singleton_p {
        select package_id
          from apm_package_types t,
               apm_packages p
         where t.singleton_p = 't'
           and t.package_key = p.package_key
           and t.package_key = :package_key}]
    } {
        #
        # Instantiate package
        #
        set package_id [db_exec_plsql invoke_new {}]

        apm_parameter_sync $package_key $package_id

        foreach inherited_package_key [nsv_get apm_package_inherit_order $package_key] {
            apm_invoke_callback_proc  -package_key $inherited_package_key  -type after-instantiate  -arg_list [list package_id $package_id]
        }
    }

    return $package_id
Generic XQL file:
packages/acs-tcl/tcl/apm-procs.xql

PostgreSQL XQL file:
<fullquery name="apm_package_instance_new.invoke_new">
    <querytext>

      select apm_package__new(
        :package_id,
        :instance_name,
        :package_key,
        'apm_package',
        now(),
        null,
        null,
        :context_id
      );

      </querytext>
</fullquery>
packages/acs-tcl/tcl/apm-procs-postgresql.xql

Oracle XQL file:
<fullquery name="apm_package_instance_new.invoke_new">
    <querytext>

	begin
      :1 := apm_package.new(
        package_id => :package_id,
        instance_name => :instance_name,
        package_key => :package_key,
        context_id => :context_id
      );
	end;

      </querytext>
</fullquery>
packages/acs-tcl/tcl/apm-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: