diff --git a/lib/NGCP/Panel/Controller/API/AutoAttendants.pm b/lib/NGCP/Panel/Controller/API/AutoAttendants.pm index 2c33956734..d004fe907a 100644 --- a/lib/NGCP/Panel/Controller/API/AutoAttendants.pm +++ b/lib/NGCP/Panel/Controller/API/AutoAttendants.pm @@ -52,6 +52,7 @@ sub GET :Allow { my $subscribers = $self->item_rs($c); (my $total_count, $subscribers, my $subscribers_rows) = $self->paginate_order_collection($c, $subscribers); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $subscriber (@$subscribers_rows) { push @embedded, $self->hal_from_item($c, $subscriber); push @links, Data::HAL::Link->new( @@ -59,6 +60,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $subscriber->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/BalanceIntervals.pm b/lib/NGCP/Panel/Controller/API/BalanceIntervals.pm index aade2846c7..8d4cc4a520 100644 --- a/lib/NGCP/Panel/Controller/API/BalanceIntervals.pm +++ b/lib/NGCP/Panel/Controller/API/BalanceIntervals.pm @@ -99,6 +99,7 @@ sub GET :Allow { contract_id_field => 'id'); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $contract (@$contracts) { my $balance = NGCP::Panel::Utils::ProfilePackages::get_contract_balance(c => $c, contract => $contract, @@ -112,6 +113,7 @@ sub GET :Allow { push @links, $link; #push @links, Data::HAL::Link->new(relation => 'collection', href => sprintf("/api/%s/%d/", $self->resource_name, $contract->id)); } + $self->expand_collection_fields($c, \@embedded); $self->delay_commit($c,$guard); push @links, Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Controller/API/BillingFees.pm b/lib/NGCP/Panel/Controller/API/BillingFees.pm index 603ecbf6b2..dd2d58040a 100644 --- a/lib/NGCP/Panel/Controller/API/BillingFees.pm +++ b/lib/NGCP/Panel/Controller/API/BillingFees.pm @@ -82,6 +82,7 @@ sub GET :Allow { (my $total_count, $fees, my $fees_rows) = $self->paginate_order_collection($c, $fees); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $fee (@$fees_rows) { push @embedded, $self->hal_from_fee($c, $fee, $form); push @links, Data::HAL::Link->new( @@ -89,6 +90,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $fee->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/BillingNetworks.pm b/lib/NGCP/Panel/Controller/API/BillingNetworks.pm index 27638da6ca..bc9f7bc273 100644 --- a/lib/NGCP/Panel/Controller/API/BillingNetworks.pm +++ b/lib/NGCP/Panel/Controller/API/BillingNetworks.pm @@ -81,6 +81,7 @@ sub GET :Allow { (my $total_count, $bns, my $bns_rows) = $self->paginate_order_collection($c, $bns); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $bn (@$bns_rows) { push @embedded, $self->hal_from_item($c, $bn, "billingnetworks"); push @links, Data::HAL::Link->new( @@ -88,6 +89,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $bn->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/BillingProfiles.pm b/lib/NGCP/Panel/Controller/API/BillingProfiles.pm index c29650c89f..8bd2d9130a 100644 --- a/lib/NGCP/Panel/Controller/API/BillingProfiles.pm +++ b/lib/NGCP/Panel/Controller/API/BillingProfiles.pm @@ -73,6 +73,7 @@ sub GET :Allow { (my $total_count, $profiles, my $profiles_rows) = $self->paginate_order_collection($c, $profiles); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $profile (@$profiles_rows) { push @embedded, $self->hal_from_item($c, $profile, $self->resource_from_item($c, $profile, $form), $form); push @links, Data::HAL::Link->new( @@ -80,6 +81,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $profile->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/BillingZones.pm b/lib/NGCP/Panel/Controller/API/BillingZones.pm index 651a7904c6..80d2e38f48 100644 --- a/lib/NGCP/Panel/Controller/API/BillingZones.pm +++ b/lib/NGCP/Panel/Controller/API/BillingZones.pm @@ -66,6 +66,7 @@ sub GET :Allow { (my $total_count, $zones, my $zones_rows) = $self->paginate_order_collection($c, $zones); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $zone (@$zones_rows) { push @embedded, $self->hal_from_zone($c, $zone, $form); push @links, Data::HAL::Link->new( @@ -73,6 +74,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $zone->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/CCMapEntries.pm b/lib/NGCP/Panel/Controller/API/CCMapEntries.pm index d5db3bc652..0c5beeb45b 100644 --- a/lib/NGCP/Panel/Controller/API/CCMapEntries.pm +++ b/lib/NGCP/Panel/Controller/API/CCMapEntries.pm @@ -50,6 +50,7 @@ sub GET :Allow { my $cfs = $self->item_rs($c); (my $total_count, $cfs, my $cfs_rows) = $self->paginate_order_collection($c, $cfs); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $cf (@$cfs_rows) { try { push @embedded, $self->hal_from_item($c, $cf, "ccmapentries"); @@ -59,6 +60,7 @@ sub GET :Allow { ); } } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/CFMappings.pm b/lib/NGCP/Panel/Controller/API/CFMappings.pm index 93b788fc02..348dd3f987 100644 --- a/lib/NGCP/Panel/Controller/API/CFMappings.pm +++ b/lib/NGCP/Panel/Controller/API/CFMappings.pm @@ -70,6 +70,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $subs (@$items_rows) { push @embedded, $self->hal_from_item($c, $subs, "cfmappings"); push @links, Data::HAL::Link->new( @@ -77,6 +78,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $subs->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/CFSourceSets.pm b/lib/NGCP/Panel/Controller/API/CFSourceSets.pm index eb527e5a15..3fefba1da2 100644 --- a/lib/NGCP/Panel/Controller/API/CFSourceSets.pm +++ b/lib/NGCP/Panel/Controller/API/CFSourceSets.pm @@ -77,6 +77,7 @@ sub GET :Allow { (my $total_count, $ssets, my $ssets_rows) = $self->paginate_order_collection($c, $ssets); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $sset (@$ssets_rows) { push @embedded, $self->hal_from_item($c, $sset, "cfsourcesets"); push @links, Data::HAL::Link->new( @@ -84,6 +85,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $sset->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/CallLists.pm b/lib/NGCP/Panel/Controller/API/CallLists.pm index 703c5d1371..e42938f423 100644 --- a/lib/NGCP/Panel/Controller/API/CallLists.pm +++ b/lib/NGCP/Panel/Controller/API/CallLists.pm @@ -321,6 +321,7 @@ sub GET :Allow { my $href_data = $owner->{subscriber} ? "subscriber_id=".$owner->{subscriber}->id : "customer_id=".$owner->{customer}->id; + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form, { 'owner' => $owner }); push @links, Data::HAL::Link->new( @@ -328,6 +329,7 @@ sub GET :Allow { href => sprintf('/%s%d?%s', $c->request->path, $item->id, $href_data), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/CallRecordingStreams.pm b/lib/NGCP/Panel/Controller/API/CallRecordingStreams.pm index ee6cc143f3..5e4414159d 100644 --- a/lib/NGCP/Panel/Controller/API/CallRecordingStreams.pm +++ b/lib/NGCP/Panel/Controller/API/CallRecordingStreams.pm @@ -82,6 +82,7 @@ sub GET :Allow { (my $total_count, $callrecordingstreams, my $callrecordingstreams_rows) = $self->paginate_order_collection($c, $callrecordingstreams); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $domain (@$callrecordingstreams_rows) { push @embedded, $self->hal_from_item($c, $domain, $form); push @links, Data::HAL::Link->new( @@ -89,6 +90,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $domain->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Calls.pm b/lib/NGCP/Panel/Controller/API/Calls.pm index 384a2e5618..b999f44c39 100644 --- a/lib/NGCP/Panel/Controller/API/Calls.pm +++ b/lib/NGCP/Panel/Controller/API/Calls.pm @@ -86,6 +86,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -93,6 +94,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Capabilities.pm b/lib/NGCP/Panel/Controller/API/Capabilities.pm index efb32ada88..c3c489b629 100644 --- a/lib/NGCP/Panel/Controller/API/Capabilities.pm +++ b/lib/NGCP/Panel/Controller/API/Capabilities.pm @@ -57,6 +57,7 @@ sub GET :Allow { (my $total_count, $capabilities, my $capabilities_rows) = $self->paginate_order_collection($c, $capabilities); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $cap (@{ $capabilities_rows }) { push @embedded, $self->hal_from_item($c, $cap, $form); push @links, Data::HAL::Link->new( @@ -64,6 +65,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $cap->{id}), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Contracts.pm b/lib/NGCP/Panel/Controller/API/Contracts.pm index da47990e4e..0b443077e6 100644 --- a/lib/NGCP/Panel/Controller/API/Contracts.pm +++ b/lib/NGCP/Panel/Controller/API/Contracts.pm @@ -99,6 +99,7 @@ sub GET :Allow { contract_id_field => 'id'); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $contract (@$contracts) { #NGCP::Panel::Utils::ProfilePackages::get_contract_balance push @embedded, $self->hal_from_contract($c, $contract, $form, $now); @@ -107,6 +108,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $contract->id), ); } + $self->expand_collection_fields($c, \@embedded); $self->delay_commit($c,$guard); #potential db write ops in hal_from push @links, Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Controller/API/CustomerBalances.pm b/lib/NGCP/Panel/Controller/API/CustomerBalances.pm index 30eb861d06..d76bbb695b 100644 --- a/lib/NGCP/Panel/Controller/API/CustomerBalances.pm +++ b/lib/NGCP/Panel/Controller/API/CustomerBalances.pm @@ -129,6 +129,7 @@ sub GET :Allow { contract_id_field => 'id'); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items) { my $balance = $self->item_by_id($c, $item->id,$now); push @embedded, $self->hal_from_item($c, $balance, $form); @@ -137,6 +138,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); $self->delay_commit($c,$guard); push @links, Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Controller/API/CustomerContacts.pm b/lib/NGCP/Panel/Controller/API/CustomerContacts.pm index aadf069d46..4c9e8b1a16 100644 --- a/lib/NGCP/Panel/Controller/API/CustomerContacts.pm +++ b/lib/NGCP/Panel/Controller/API/CustomerContacts.pm @@ -69,6 +69,7 @@ sub GET :Allow { (my $total_count, $contacts, my $contacts_rows) = $self->paginate_order_collection($c, $contacts); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $contact (@$contacts_rows) { push @embedded, $self->hal_from_contact($c, $contact, $form); push @links, Data::HAL::Link->new( @@ -76,6 +77,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $contact->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/CustomerFraudPreferences.pm b/lib/NGCP/Panel/Controller/API/CustomerFraudPreferences.pm index 4545c02bbc..46609f0a51 100644 --- a/lib/NGCP/Panel/Controller/API/CustomerFraudPreferences.pm +++ b/lib/NGCP/Panel/Controller/API/CustomerFraudPreferences.pm @@ -88,6 +88,7 @@ sub GET :Allow { (my $total_count, $customer_rs, my $customer_rows) = $self->paginate_order_collection($c, $customer_rs); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $customer (@$customer_rows) { push @embedded, $self->hal_from_item($c, $customer, $form); push @links, Data::HAL::Link->new( @@ -95,6 +96,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $customer->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/CustomerLocations.pm b/lib/NGCP/Panel/Controller/API/CustomerLocations.pm index 7df8780e89..bcdb9560f7 100644 --- a/lib/NGCP/Panel/Controller/API/CustomerLocations.pm +++ b/lib/NGCP/Panel/Controller/API/CustomerLocations.pm @@ -69,6 +69,7 @@ sub GET :Allow { (my $total_count, $cls, my $cls_rows) = $self->paginate_order_collection($c, $cls); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $cl (@$cls_rows) { push @embedded, $self->hal_from_item($c, $cl, $self->resource_name); push @links, Data::HAL::Link->new( @@ -76,6 +77,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $cl->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/CustomerZoneCosts.pm b/lib/NGCP/Panel/Controller/API/CustomerZoneCosts.pm index 7558ddbcc2..d0a30ae7da 100644 --- a/lib/NGCP/Panel/Controller/API/CustomerZoneCosts.pm +++ b/lib/NGCP/Panel/Controller/API/CustomerZoneCosts.pm @@ -75,6 +75,7 @@ sub GET :Allow { return unless $query_string; my (@embedded, @links); my $error_flag = 0; + $self->expand_prepare_collection($c); for my $dev (@$field_devs_rows) { my $hal = $self->hal_from_item($c, $dev); $error_flag = 1 unless $hal; @@ -85,6 +86,7 @@ sub GET :Allow { ); } last if $error_flag; + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Customers.pm b/lib/NGCP/Panel/Controller/API/Customers.pm index e73293252b..1636cc6668 100644 --- a/lib/NGCP/Panel/Controller/API/Customers.pm +++ b/lib/NGCP/Panel/Controller/API/Customers.pm @@ -158,6 +158,7 @@ sub GET :Allow { contract_id_field => 'id'); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $customer (@$customers) { push @embedded, $self->hal_from_customer($c, $customer, $form, $now); push @links, Data::HAL::Link->new( @@ -165,6 +166,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $customer->id), ); } + $self->expand_collection_fields($c, \@embedded); $self->delay_commit($c,$guard); #potential db write ops in hal_from push @links, Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Controller/API/Domains.pm b/lib/NGCP/Panel/Controller/API/Domains.pm index db51ef6b75..e3a3a6c8a4 100644 --- a/lib/NGCP/Panel/Controller/API/Domains.pm +++ b/lib/NGCP/Panel/Controller/API/Domains.pm @@ -61,6 +61,7 @@ sub GET :Allow { (my $total_count, $domains, my $domains_rows) = $self->paginate_order_collection($c, $domains); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $domain (@$domains_rows) { push @embedded, $self->hal_from_item($c, $domain, $form); push @links, Data::HAL::Link->new( @@ -68,6 +69,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $domain->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/EmailTemplates.pm b/lib/NGCP/Panel/Controller/API/EmailTemplates.pm index 8c5391ac26..d50591400b 100644 --- a/lib/NGCP/Panel/Controller/API/EmailTemplates.pm +++ b/lib/NGCP/Panel/Controller/API/EmailTemplates.pm @@ -66,6 +66,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -73,6 +74,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/EmergencyMappingContainers.pm b/lib/NGCP/Panel/Controller/API/EmergencyMappingContainers.pm index f1137a1e61..1509bf9853 100644 --- a/lib/NGCP/Panel/Controller/API/EmergencyMappingContainers.pm +++ b/lib/NGCP/Panel/Controller/API/EmergencyMappingContainers.pm @@ -67,6 +67,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -74,6 +75,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/EmergencyMappings.pm b/lib/NGCP/Panel/Controller/API/EmergencyMappings.pm index 82a437df27..78dc624823 100644 --- a/lib/NGCP/Panel/Controller/API/EmergencyMappings.pm +++ b/lib/NGCP/Panel/Controller/API/EmergencyMappings.pm @@ -107,6 +107,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -114,6 +115,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Events.pm b/lib/NGCP/Panel/Controller/API/Events.pm index 72916035d4..8fbd0038e5 100644 --- a/lib/NGCP/Panel/Controller/API/Events.pm +++ b/lib/NGCP/Panel/Controller/API/Events.pm @@ -102,6 +102,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { my $hal = $self->hal_from_item($c, $item, $form); $hal->_forcearray(1); @@ -113,6 +114,7 @@ sub GET :Allow { $link->_forcearray(1); push @links, $link; } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Interceptions.pm b/lib/NGCP/Panel/Controller/API/Interceptions.pm index 558160dc1a..43946fba80 100644 --- a/lib/NGCP/Panel/Controller/API/Interceptions.pm +++ b/lib/NGCP/Panel/Controller/API/Interceptions.pm @@ -85,6 +85,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -92,6 +93,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/InvoiceTemplates.pm b/lib/NGCP/Panel/Controller/API/InvoiceTemplates.pm index 1057585aaa..18f2d376ec 100644 --- a/lib/NGCP/Panel/Controller/API/InvoiceTemplates.pm +++ b/lib/NGCP/Panel/Controller/API/InvoiceTemplates.pm @@ -68,6 +68,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -75,6 +76,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/LnpCarriers.pm b/lib/NGCP/Panel/Controller/API/LnpCarriers.pm index 832b97dfd3..fbae74c234 100644 --- a/lib/NGCP/Panel/Controller/API/LnpCarriers.pm +++ b/lib/NGCP/Panel/Controller/API/LnpCarriers.pm @@ -61,6 +61,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -68,6 +69,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/LnpNumbers.pm b/lib/NGCP/Panel/Controller/API/LnpNumbers.pm index cfdfa132e5..8595e928f0 100644 --- a/lib/NGCP/Panel/Controller/API/LnpNumbers.pm +++ b/lib/NGCP/Panel/Controller/API/LnpNumbers.pm @@ -98,6 +98,7 @@ sub GET :Allow { #$t2 = time; print("page: " . ($t2 - $t1) . "secs\n"); $t1 = time; my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -105,6 +106,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/MailToFaxSettings.pm b/lib/NGCP/Panel/Controller/API/MailToFaxSettings.pm index e73cf03f67..f4c80c736f 100644 --- a/lib/NGCP/Panel/Controller/API/MailToFaxSettings.pm +++ b/lib/NGCP/Panel/Controller/API/MailToFaxSettings.pm @@ -82,6 +82,7 @@ sub GET :Allow { my $cfs = $self->item_rs($c); (my $total_count, $cfs, my $cfs_rows) = $self->paginate_order_collection($c, $cfs); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $cf (@$cfs_rows) { try { push @embedded, $self->hal_from_item($c, $cf); @@ -91,6 +92,7 @@ sub GET :Allow { ); } } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/MaliciousCalls.pm b/lib/NGCP/Panel/Controller/API/MaliciousCalls.pm index 365bd3fd18..25307002eb 100644 --- a/lib/NGCP/Panel/Controller/API/MaliciousCalls.pm +++ b/lib/NGCP/Panel/Controller/API/MaliciousCalls.pm @@ -130,6 +130,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -137,6 +138,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/ManagerSecretary.pm b/lib/NGCP/Panel/Controller/API/ManagerSecretary.pm index 12ef2d2e61..1a859573ae 100644 --- a/lib/NGCP/Panel/Controller/API/ManagerSecretary.pm +++ b/lib/NGCP/Panel/Controller/API/ManagerSecretary.pm @@ -70,6 +70,7 @@ sub GET :Allow { my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $cf (@$cfs_rows) { try { push @embedded, $self->hal_from_item($c, $cf, $form); @@ -79,6 +80,7 @@ sub GET :Allow { ); } } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/NcosLevels.pm b/lib/NGCP/Panel/Controller/API/NcosLevels.pm index 74bdee2a74..caa1d44442 100644 --- a/lib/NGCP/Panel/Controller/API/NcosLevels.pm +++ b/lib/NGCP/Panel/Controller/API/NcosLevels.pm @@ -68,6 +68,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -75,6 +76,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/NcosLnpCarriers.pm b/lib/NGCP/Panel/Controller/API/NcosLnpCarriers.pm index 00ae2ceb0b..820a21df6c 100644 --- a/lib/NGCP/Panel/Controller/API/NcosLnpCarriers.pm +++ b/lib/NGCP/Panel/Controller/API/NcosLnpCarriers.pm @@ -72,6 +72,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -79,6 +80,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/NcosLnpPatterns.pm b/lib/NGCP/Panel/Controller/API/NcosLnpPatterns.pm index 5f727a8b3e..5e9d3aeff6 100644 --- a/lib/NGCP/Panel/Controller/API/NcosLnpPatterns.pm +++ b/lib/NGCP/Panel/Controller/API/NcosLnpPatterns.pm @@ -61,6 +61,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -68,6 +69,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/NcosPatterns.pm b/lib/NGCP/Panel/Controller/API/NcosPatterns.pm index 8870ebfc39..d04f6c8b95 100644 --- a/lib/NGCP/Panel/Controller/API/NcosPatterns.pm +++ b/lib/NGCP/Panel/Controller/API/NcosPatterns.pm @@ -61,6 +61,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -68,6 +69,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/PbxDeviceConfigs.pm b/lib/NGCP/Panel/Controller/API/PbxDeviceConfigs.pm index f9c5f095c4..16839e6fd1 100644 --- a/lib/NGCP/Panel/Controller/API/PbxDeviceConfigs.pm +++ b/lib/NGCP/Panel/Controller/API/PbxDeviceConfigs.pm @@ -83,6 +83,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -90,6 +91,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/PbxDeviceFirmwares.pm b/lib/NGCP/Panel/Controller/API/PbxDeviceFirmwares.pm index 3e812f8f4e..df1b620be8 100644 --- a/lib/NGCP/Panel/Controller/API/PbxDeviceFirmwares.pm +++ b/lib/NGCP/Panel/Controller/API/PbxDeviceFirmwares.pm @@ -84,6 +84,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -91,6 +92,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/PbxDeviceProfiles.pm b/lib/NGCP/Panel/Controller/API/PbxDeviceProfiles.pm index baaf0a21bc..c864e79ec1 100644 --- a/lib/NGCP/Panel/Controller/API/PbxDeviceProfiles.pm +++ b/lib/NGCP/Panel/Controller/API/PbxDeviceProfiles.pm @@ -61,6 +61,7 @@ sub GET :Allow { (my $total_count, $field_devs, my $field_devs_rows) = $self->paginate_order_collection($c, $field_devs); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $dev (@$field_devs_rows) { push @embedded, $self->hal_from_item($c, $dev); push @links, Data::HAL::Link->new( @@ -68,6 +69,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $dev->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/PbxDevices.pm b/lib/NGCP/Panel/Controller/API/PbxDevices.pm index 31f36d1603..510ea37acc 100644 --- a/lib/NGCP/Panel/Controller/API/PbxDevices.pm +++ b/lib/NGCP/Panel/Controller/API/PbxDevices.pm @@ -115,6 +115,7 @@ sub GET :Allow { (my $total_count, $field_devs, my $field_devs_rows) = $self->paginate_order_collection($c, $field_devs); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $dev (@$field_devs_rows) { push @embedded, $self->hal_from_item($c, $dev); push @links, Data::HAL::Link->new( @@ -122,6 +123,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $dev->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/PeeringGroups.pm b/lib/NGCP/Panel/Controller/API/PeeringGroups.pm index f83d2ab2be..993721cb64 100644 --- a/lib/NGCP/Panel/Controller/API/PeeringGroups.pm +++ b/lib/NGCP/Panel/Controller/API/PeeringGroups.pm @@ -48,6 +48,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -55,6 +56,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/PeeringInboundRules.pm b/lib/NGCP/Panel/Controller/API/PeeringInboundRules.pm index 7c0cdc1ef3..1bc2382d27 100644 --- a/lib/NGCP/Panel/Controller/API/PeeringInboundRules.pm +++ b/lib/NGCP/Panel/Controller/API/PeeringInboundRules.pm @@ -78,6 +78,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -85,6 +86,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/PeeringRules.pm b/lib/NGCP/Panel/Controller/API/PeeringRules.pm index 7b1bb1df84..aeb3cc5a89 100644 --- a/lib/NGCP/Panel/Controller/API/PeeringRules.pm +++ b/lib/NGCP/Panel/Controller/API/PeeringRules.pm @@ -82,6 +82,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -89,6 +90,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/PeeringServers.pm b/lib/NGCP/Panel/Controller/API/PeeringServers.pm index 5f1c98adfa..15b7998899 100644 --- a/lib/NGCP/Panel/Controller/API/PeeringServers.pm +++ b/lib/NGCP/Panel/Controller/API/PeeringServers.pm @@ -87,6 +87,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -94,6 +95,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/ProfilePackages.pm b/lib/NGCP/Panel/Controller/API/ProfilePackages.pm index df24a1b570..e3ceb409d7 100644 --- a/lib/NGCP/Panel/Controller/API/ProfilePackages.pm +++ b/lib/NGCP/Panel/Controller/API/ProfilePackages.pm @@ -95,6 +95,7 @@ sub GET :Allow { (my $total_count, $packages, my $packages_rows) = $self->paginate_order_collection($c, $packages); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $package (@$packages_rows) { push @embedded, $self->hal_from_item($c, $package, "profilepackages", $form); push @links, Data::HAL::Link->new( @@ -102,6 +103,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $package->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Reminders.pm b/lib/NGCP/Panel/Controller/API/Reminders.pm index de25d11bab..47b8bd4a11 100644 --- a/lib/NGCP/Panel/Controller/API/Reminders.pm +++ b/lib/NGCP/Panel/Controller/API/Reminders.pm @@ -78,6 +78,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -85,6 +86,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Resellers.pm b/lib/NGCP/Panel/Controller/API/Resellers.pm index 2082dfa783..04470da980 100644 --- a/lib/NGCP/Panel/Controller/API/Resellers.pm +++ b/lib/NGCP/Panel/Controller/API/Resellers.pm @@ -68,6 +68,7 @@ sub GET :Allow { (my $total_count, $resellers, my $resellers_rows) = $self->paginate_order_collection($c, $resellers); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $reseller (@$resellers_rows) { push @embedded, $self->hal_from_reseller($c, $reseller, $form); push @links, Data::HAL::Link->new( @@ -75,6 +76,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $reseller->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/SoundFiles.pm b/lib/NGCP/Panel/Controller/API/SoundFiles.pm index 6cf476ca92..1ff574b614 100644 --- a/lib/NGCP/Panel/Controller/API/SoundFiles.pm +++ b/lib/NGCP/Panel/Controller/API/SoundFiles.pm @@ -72,6 +72,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -79,6 +80,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/SpeedDials.pm b/lib/NGCP/Panel/Controller/API/SpeedDials.pm index 70272532e2..1d1f1e98df 100644 --- a/lib/NGCP/Panel/Controller/API/SpeedDials.pm +++ b/lib/NGCP/Panel/Controller/API/SpeedDials.pm @@ -66,6 +66,7 @@ sub GET :Allow { my $subscribers = $self->item_rs($c); (my $total_count, $subscribers, my $subscribers_rows) = $self->paginate_order_collection($c, $subscribers); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $subscriber (@$subscribers_rows) { push @embedded, $self->hal_from_item($c, $subscriber); push @links, Data::HAL::Link->new( @@ -73,6 +74,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $subscriber->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/SubscriberLocationMappings.pm b/lib/NGCP/Panel/Controller/API/SubscriberLocationMappings.pm index 54637e7bf6..358ba9d4ac 100644 --- a/lib/NGCP/Panel/Controller/API/SubscriberLocationMappings.pm +++ b/lib/NGCP/Panel/Controller/API/SubscriberLocationMappings.pm @@ -67,6 +67,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -74,6 +75,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/SubscriberPreferences.pm b/lib/NGCP/Panel/Controller/API/SubscriberPreferences.pm index 9ad9fa039b..8fcfd5b86e 100644 --- a/lib/NGCP/Panel/Controller/API/SubscriberPreferences.pm +++ b/lib/NGCP/Panel/Controller/API/SubscriberPreferences.pm @@ -97,6 +97,7 @@ sub GET :Allow { contract_id_field => 'contract_id'); my $now = NGCP::Panel::Utils::DateTime::current_local; my (@embedded, @links, %contract_map); + $self->expand_prepare_collection($c); for my $subscriber (@$subscribers) { next unless($subscriber->provisioning_voip_subscriber); my $contract = $subscriber->contract; @@ -110,6 +111,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $subscriber->id), ); } + $self->expand_collection_fields($c, \@embedded); $self->delay_commit($c,$guard); push @links, Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Controller/API/SubscriberProfileSets.pm b/lib/NGCP/Panel/Controller/API/SubscriberProfileSets.pm index 899614d58e..8daff9fac5 100644 --- a/lib/NGCP/Panel/Controller/API/SubscriberProfileSets.pm +++ b/lib/NGCP/Panel/Controller/API/SubscriberProfileSets.pm @@ -68,6 +68,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -75,6 +76,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/SubscriberProfiles.pm b/lib/NGCP/Panel/Controller/API/SubscriberProfiles.pm index 81d0440eeb..37725b37de 100644 --- a/lib/NGCP/Panel/Controller/API/SubscriberProfiles.pm +++ b/lib/NGCP/Panel/Controller/API/SubscriberProfiles.pm @@ -69,6 +69,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -76,6 +77,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/SubscriberRegistrations.pm b/lib/NGCP/Panel/Controller/API/SubscriberRegistrations.pm index 0cde29d021..eda7bf74d5 100644 --- a/lib/NGCP/Panel/Controller/API/SubscriberRegistrations.pm +++ b/lib/NGCP/Panel/Controller/API/SubscriberRegistrations.pm @@ -94,6 +94,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { my $halitem = $self->hal_from_item($c, $item, $form); next unless($halitem); @@ -103,6 +104,7 @@ sub GET :Allow { href => sprintf('/%s%s', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Subscribers.pm b/lib/NGCP/Panel/Controller/API/Subscribers.pm index a8e58e7df7..ecb5ff1d14 100644 --- a/lib/NGCP/Panel/Controller/API/Subscribers.pm +++ b/lib/NGCP/Panel/Controller/API/Subscribers.pm @@ -322,6 +322,7 @@ sub GET :Allow { my $now = NGCP::Panel::Utils::DateTime::current_local; my (@embedded, @links, %contract_map); my ($form) = $self->get_form($c); + $self->expand_prepare_collection($c); for my $subscriber (@$subscribers) { my $contract = $subscriber->contract; NGCP::Panel::Utils::ProfilePackages::get_contract_balance(c => $c, @@ -335,6 +336,7 @@ sub GET :Allow { href => sprintf('%s%d', $self->dispatch_path, $subscriber->id), ); } + $self->expand_collection_fields($c, \@embedded); $self->delay_commit($c,$guard); push @links, Data::HAL::Link->new( diff --git a/lib/NGCP/Panel/Controller/API/SystemContacts.pm b/lib/NGCP/Panel/Controller/API/SystemContacts.pm index fb4af9ca56..1c6ddc654d 100644 --- a/lib/NGCP/Panel/Controller/API/SystemContacts.pm +++ b/lib/NGCP/Panel/Controller/API/SystemContacts.pm @@ -58,6 +58,7 @@ sub GET :Allow { (my $total_count, $contacts, my $contacts_rows) = $self->paginate_order_collection($c, $contacts); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $contact (@$contacts_rows) { push @embedded, $self->hal_from_contact($c, $contact, $form); push @links, Data::HAL::Link->new( @@ -65,6 +66,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $contact->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/TopupLogs.pm b/lib/NGCP/Panel/Controller/API/TopupLogs.pm index 7900bad717..44c7c95d40 100644 --- a/lib/NGCP/Panel/Controller/API/TopupLogs.pm +++ b/lib/NGCP/Panel/Controller/API/TopupLogs.pm @@ -167,6 +167,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { my $hal = $self->hal_from_item($c, $item, $form); $hal->_forcearray(1); @@ -178,6 +179,7 @@ sub GET :Allow { $link->_forcearray(1); push @links, $link; } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/TrustedSources.pm b/lib/NGCP/Panel/Controller/API/TrustedSources.pm index 81a1cd10e1..611146d20d 100644 --- a/lib/NGCP/Panel/Controller/API/TrustedSources.pm +++ b/lib/NGCP/Panel/Controller/API/TrustedSources.pm @@ -66,6 +66,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -73,6 +74,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/UpnRewriteSets.pm b/lib/NGCP/Panel/Controller/API/UpnRewriteSets.pm index 4448847cd1..812d019754 100644 --- a/lib/NGCP/Panel/Controller/API/UpnRewriteSets.pm +++ b/lib/NGCP/Panel/Controller/API/UpnRewriteSets.pm @@ -65,6 +65,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -72,6 +73,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/VoicemailSettings.pm b/lib/NGCP/Panel/Controller/API/VoicemailSettings.pm index 2fd3f18f60..52814a8fcf 100644 --- a/lib/NGCP/Panel/Controller/API/VoicemailSettings.pm +++ b/lib/NGCP/Panel/Controller/API/VoicemailSettings.pm @@ -65,6 +65,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -72,6 +73,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->provisioning_voip_subscriber->voip_subscriber->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Voicemails.pm b/lib/NGCP/Panel/Controller/API/Voicemails.pm index edf6c33ab9..d7137df0a5 100644 --- a/lib/NGCP/Panel/Controller/API/Voicemails.pm +++ b/lib/NGCP/Panel/Controller/API/Voicemails.pm @@ -82,6 +82,7 @@ sub GET :Allow { my $items = $self->get_list($c); (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item); push @links, Data::HAL::Link->new( @@ -89,6 +90,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Controller/API/Vouchers.pm b/lib/NGCP/Panel/Controller/API/Vouchers.pm index 6e3e49ed00..0695753e4d 100644 --- a/lib/NGCP/Panel/Controller/API/Vouchers.pm +++ b/lib/NGCP/Panel/Controller/API/Vouchers.pm @@ -74,6 +74,7 @@ sub GET :Allow { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my $form = $self->get_form($c); + $self->expand_prepare_collection($c); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form); push @links, Data::HAL::Link->new( @@ -81,6 +82,7 @@ sub GET :Allow { href => sprintf('/%s%d', $c->request->path, $item->id), ); } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies', diff --git a/lib/NGCP/Panel/Role/API.pm b/lib/NGCP/Panel/Role/API.pm index 2f3c904d6e..28cabc3499 100644 --- a/lib/NGCP/Panel/Role/API.pm +++ b/lib/NGCP/Panel/Role/API.pm @@ -1318,6 +1318,48 @@ sub hal_from_item { return $hal; } +sub expand_prepare_collection { + my ($self, $c) = @_; + + $c->stash->{expand_is_collection} = 1; +} + +sub expand_collection_fields { + my ($self, $c, $embedded) = @_; + + my $expand_cache = $c->stash->{expand_cache} // return; + + my ($key_fields, $new_key_fields) = (0,0); + my $failsafe = 0; + my $max_failsafe = 100; # support max of 100 expand_field iterations + + do { + $failsafe++; + $key_fields = keys %{$expand_cache}; + $self->expand_check_prepared_cache($c); + for my $hal (@{$embedded}) { + $self->expand_fields($c, $hal->{resource}); + } + $new_key_fields = keys %{$expand_cache}; + } until ($key_fields == $new_key_fields || $failsafe == $max_failsafe); + + #require Data::Dumper; + #print Data::Dumper->new([$expand_cache])->Terse(1)->Maxdepth(3)->Dump; +} + +sub expand_check_prepared_cache { + my ($self, $c) = @_; + + my $expand_cache = $c->stash->{expand_cache} // return; + + for my $key_field (keys %{$expand_cache}) { + my $cache = $expand_cache->{$key_field}; + next if $cache->{invalid}; + $cache->{expanded} = 1 if $cache->{prepared}; + $cache->{prepared} //= 1; + } +} + sub expand_fields { my ($self, $c, $resource) = @_; @@ -1346,55 +1388,103 @@ sub expand_fields { } sub expand_field { - my ($self, $c, $resource, $resource_form, $field) = @_; + my ($self, $c, $resource, $resource_form, $field, $depth) = @_; - my ($subfield, $found); - if ($field =~ /^([^\.]+)\.(.+)/) { - $field = $1; - $subfield = $2; + $depth //= 0; + my ($pri_field, $key_field, $found); + my @fields = split(/\./, $field); + if (exists $fields[$depth]) { + $pri_field = $fields[$depth]; } + my @parents = @fields; + my @sub_fields = splice(@parents, $depth); + shift @sub_fields; # remove current field + my $parent = join('.', @parents); + $key_field = $depth == 0 ? $pri_field : $parent . '.' . $pri_field; - return unless exists $resource->{$field}; + return unless exists $resource->{$pri_field}; $found = 1; - my $expand_form = NGCP::Panel::Form::get("NGCP::Panel::Form::Expand", $c); + my $cache = $c->stash->{expand_cache}{$key_field} //= {}; - my ($attr, $expand); - my $f_field = $resource_form->field($field); + return if $cache->{invalid}; + + my $expand_form = $cache->{expand_form} //= + NGCP::Panel::Form::get("NGCP::Panel::Form::Expand", $c); + + my ($attr, $expand) = @{$cache}{qw(attr expand)}; + if (!$attr || !$expand) { + if (my $f_field = $resource_form->field($pri_field)) { + $attr = $f_field->element_attr; + $expand = $attr->{expand}; + } + + if (!$expand) { # use default field expand if specified + if (my $f_field = $expand_form->field($pri_field)) { + $attr = $f_field->element_attr; + $expand = $attr->{expand}; + } + } - if ($f_field) { - $attr = $f_field->element_attr; - $expand = $attr->{expand}; + if ($attr && $expand) { + $cache->{attr} = $attr; + $cache->{expand} = $expand; + } else { + $cache->{invalid} = 1; + return; + } } - unless ($expand) { # use default field expand if specified - $f_field = $expand_form->field($field) // return; - $attr = $f_field->element_attr // return; - $expand = $attr->{expand} // return; + my ($to, $class, $form) = @{$cache}{qw(to class form)}; + if (!$to || !$class || !$form) { + try { + die unless $expand->{allowed_roles}; + die unless any { $c->user->roles eq $_ } @{$expand->{allowed_roles}}; + + $to = $expand->{to} // $pri_field . '_expand'; + $class = $expand->{class} // die; + $form = $class->get_form($c) // die; + + $cache->{to} = $to; + $cache->{class} = $class; + $cache->{form} = $form; + } catch ($e) { + $cache->{invalid} = 1; + return; + } } - return unless $expand->{allowed_roles}; - return unless any { $c->user->roles eq $_ } @{$expand->{allowed_roles}}; + $cache->{parent} = $parent; - my $id = $resource->{$field} // return $found; # null value but the field exists - my $to = $expand->{to} // $field . '_expand'; - my $class = $expand->{class} // return; - my $form = $class->get_form($c) // return; + my $id; + if (exists $resource->{$pri_field}) { + $id = $resource->{$pri_field} // return $found; + } else { + return; + } if (ref $id eq 'ARRAY') { for (my $i=0; $i<=$#$id; $i++) { my $a_id = $id->[$i]; - $resource->{$to}[$i] = - $self->get_expanded_field_data($c, $expand, $resource, $field, $class, $form, $a_id); - if ($subfield) { - $found = $self->expand_field($c, $resource->{$to}[$i], $form, $subfield); + if ($c->stash->{expand_is_collection} && !$cache->{prepared}) { + $cache->{ids}{$a_id} = 1; + } else { + $resource->{$to}[$i] = + $self->get_expanded_field_data($c, $expand, $resource, $key_field, $a_id); + } + if (@sub_fields) { + $found = $self->expand_field($c, $resource->{$to}[$i], $form, $field, $depth+1); } } } else { - $resource->{$to} ||= - $self->get_expanded_field_data($c, $expand, $resource, $field, $class, $form, $id); - if ($subfield) { - $found = $self->expand_field($c, $resource->{$to}, $form, $subfield); + if ($c->stash->{expand_is_collection} && !$cache->{prepared}) { + $cache->{ids}{$id} = 1; + } else { + $resource->{$to} ||= + $self->get_expanded_field_data($c, $expand, $resource, $key_field, $id); + } + if (@sub_fields) { + $found = $self->expand_field($c, $resource->{$to}, $form, $field, $depth+1); } } @@ -1402,9 +1492,30 @@ sub expand_field { } sub get_expanded_field_data { - my ($self, $c, $expand, $resource, $field, $class, $form, $id) = @_; + my ($self, $c, $expand, $resource, $key_field, $id) = @_; + + my $cache = $c->stash->{expand_cache}{$key_field} // return; + + my ($class, $form) = @{$cache}{qw(class form)}; - my $item = $class->item_by_id($c, $id) // return; + my $item; + if ($c->stash->{expand_is_collection}) { + return if !$cache->{prepared} && $cache->{expanded}; + + if (!$cache->{items_by_id} && $cache->{ids}) { + my %items_by_id = map { $_->id => $_ } + $class->item_rs($c)->search({ + 'me.id' => { '-in' => [keys %{$cache->{ids}}] }, + },{ + 'order_by' => { '-asc' => 'id' }, + })->all(); + $cache->{items_by_id} = \%items_by_id; + } + + $item = $cache->{items_by_id}{$id} // return; + } else { + $item = $class->item_by_id($c, $id) // return; + } my $item_res = $class->resource_from_item($c, $item, $form); my $data = $class->post_process_hal_resource($c, $item, $item_res, $form); diff --git a/lib/NGCP/Panel/Role/Entities.pm b/lib/NGCP/Panel/Role/Entities.pm index f18ff34db6..92902e6889 100644 --- a/lib/NGCP/Panel/Role/Entities.pm +++ b/lib/NGCP/Panel/Role/Entities.pm @@ -211,10 +211,12 @@ sub get { (my $total_count, $items, my $items_rows) = $self->paginate_order_collection($c, $items); my (@embedded, @links); my ($form) = $self->get_form($c); + $self->expand_collection_fields($c, \@embedded); for my $item (@$items_rows) { push @embedded, $self->hal_from_item($c, $item, $form, {}); push @links, grep { $_->relation->_original eq 'ngcp:'.$self->resource_name } @{$embedded[-1]->links}; } + $self->expand_collection_fields($c, \@embedded); push @links, Data::HAL::Link->new( relation => 'curies',