Changeset 2090 for trunk/LATMOS-Accounts/lib
- Timestamp:
- 09/19/17 16:15:20 (7 years ago)
- Location:
- trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Nethost.pm
r2054 r2090 19 19 20 20 sub _object_table { 'nethost' } 21 22 sub _object_table_attributes_read { 'nethost_attributes_read' } 21 23 22 24 sub _key_field { 'name' } … … 126 128 multiple => 1, ro => 1, managed => 1, 127 129 reference => 'netzone', 128 get => sub {129 my ($self) = @_;130 my $find = $self->base->db->prepare_cached(q{131 select name from netzone where ikey in132 (133 select netzone_attributes.okey from netzone_attributes join134 nethost_attributes_ips on netzone_attributes.attr='net'135 and136 nethost_attributes_ips.value::inet <<=137 netzone_attributes.value::inet138 where nethost_attributes_ips.okey = $1139 except140 select netzone_attributes.okey from netzone_attributes join141 nethost_attributes_ips on netzone_attributes.attr='netExclude'142 and nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet143 where nethost_attributes_ips.okey = $1144 )145 order by name146 });147 $find->execute($self->object->get_attributes('ikey'));148 my @zones;149 while (my $res = $find->fetchrow_hashref) {150 push(@zones, $res->{name});151 }152 return @zones ? [ @zones ] : undef;153 },154 130 label => l('NetZones'), 155 131 }, -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Onlyaddress.pm
r1023 r2090 35 35 ($base->{wexported} ? '' : 'and "user".exported = true'), 36 36 $base->db->quote_identifier($class->_object_table), 37 $base->db->quote_identifier($class->_object_table . '_attributes'), # attr37 $base->db->quote_identifier($class->_object_table_attributes_read), # attr 38 38 ($base->{wexported} ? '' : 'and ' . 39 39 $base->db->quote_identifier($class->_object_table) . '.exported = true'), … … 59 59 $base->db->quote_identifier($class->_key_field), 60 60 $base->db->quote_identifier($class->_object_table), 61 $base->db->quote_identifier($class->_object_table . '_attributes'), # attr61 $base->db->quote_identifier($class->_object_table_attributes_read), # attr 62 62 ($base->{wexported} ? '' : 'and exported = true'), 63 63 $base->db->quote_identifier($class->_key_field), … … 79 79 $base->db->quote_identifier($class->_key_field), 80 80 ($base->{wexported} ? '' : 'and exported = true'), 81 $base->db->quote_identifier($class->_object_table . '_attributes'),81 $base->db->quote_identifier($class->_object_table_attributes_read), 82 82 ), 83 83 ); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
r2088 r2090 21 21 22 22 sub _attributes_table { $_[0]->_object_table . '_attributes_list' } 23 24 # Write extend attribute table 25 sub _object_table_attributes { $_[0]->_object_table . '_attributes' } 26 # Read search table (with compute attribute) 27 sub _object_table_attributes_read { $_[0]->_object_table . '_attributes' } 23 28 24 29 sub listReal { … … 516 521 where %s = ? 517 522 }, 518 $self->db->quote_identifier($self->_object_table . '_attributes'),523 $self->db->quote_identifier($self->_object_table_attributes_read), 519 524 $self->db->quote_identifier($self->_object_table), 520 525 $self->db->quote_identifier($self->_key_field), … … 620 625 sprintf( 621 626 q{delete from %s where okey = ? and attr = ?}, 622 $self->db->quote_identifier($self->_object_table . '_attributes'),627 $self->db->quote_identifier($self->_object_table_attributes), 623 628 ), 624 629 ); … … 626 631 sprintf( 627 632 q{delete from %s where okey = ? and attr = ? and value = ?}, 628 $self->db->quote_identifier($self->_object_table . '_attributes'),633 $self->db->quote_identifier($self->_object_table_attributes), 629 634 ), 630 635 ); … … 632 637 sprintf( 633 638 q{insert into %s (okey, attr, value) values (?,?,?)}, 634 $self->db->quote_identifier($self->_object_table . '_attributes'),639 $self->db->quote_identifier($self->_object_table_attributes), 635 640 ) 636 641 ); … … 638 643 sprintf( 639 644 q{update %s set value = ? where okey = ? and attr = ?}, 640 $self->db->quote_identifier($self->_object_table . '_attributes'),645 $self->db->quote_identifier($self->_object_table_attributes), 641 646 ) 642 647 ); … … 839 844 ($base->{wexported} ? '' : ' and "exported" = true'), 840 845 $base->db->quote_identifier($class->_object_table), 841 $base->db->quote_identifier($class->_object_table . 842 '_attributes'), 846 $base->db->quote_identifier($class->_object_table_attributes_read), 843 847 $base->db->quote_identifier($class->_object_table), 844 $base->db->quote_identifier($class->_object_table . 845 '_attributes'), 848 $base->db->quote_identifier($class->_object_table_attributes_read), 846 849 ) 847 850 ); … … 906 909 q{select name, value from %s left join %s on %s.ikey = %s.okey and attr = ?} . ($base->{wexported} ? '' : ' and "exported" = true'), 907 910 $base->db->quote_identifier($class->_object_table), 908 $base->db->quote_identifier($class->_object_table . 909 '_attributes'), 911 $base->db->quote_identifier($class->_object_table_attributes_read), 910 912 $base->db->quote_identifier($class->_object_table), 911 $base->db->quote_identifier($class->_object_table . 912 '_attributes'), 913 $base->db->quote_identifier($class->_object_table_attributes_read), 913 914 ) 914 915 ); … … 1065 1066 my $sql = sprintf( 1066 1067 q{select okey from %s where attr = ? and "value" = ANY (?) }, 1067 $base->db->quote_identifier($class->_object_table . '_attributes'),1068 $base->db->quote_identifier($class->_object_table_attributes_read), 1068 1069 ); 1069 1070 push(@attrbind, $attribute->iname); … … 1123 1124 $base->db->quote_identifier($class->_object_table), 1124 1125 $base->db->quote_identifier( 1125 $class->_object_table . '_attributes'1126 $class->_object_table_attributes_read 1126 1127 ), 1127 1128 ); … … 1137 1138 q{select okey from %s where attr = ? %s}, 1138 1139 $base->db->quote_identifier( 1139 $class->_object_table . '_attributes'1140 $class->_object_table_attributes_read 1140 1141 ), 1141 1142 $val eq '*' -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/upgrade.pm
r2083 r2090 1112 1112 }, 1113 1113 { 1114 ver => 26,1114 ver => '26', 1115 1115 sql => [ ], 1116 1116 }, 1117 { 1118 ver => 27, 1119 sql => [ 1120 q{ 1121 CREATE OR REPLACE VIEW nethost_attributes_netzone AS 1122 SELECT netzone.name AS value, 'netZone' AS attr, nethost_attributes_ips.attr_key, nethost_attributes_ips.okey 1123 FROM nethost_attributes_ips, netzone_attributes, netzone 1124 WHERE netzone.ikey = netzone_attributes.okey AND netzone_attributes.attr = 'net'::text AND nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet 1125 EXCEPT 1126 SELECT netzone.name AS value, 'netZone' AS attr, nethost_attributes_ips.attr_key, nethost_attributes_ips.okey 1127 FROM nethost_attributes_ips, netzone_attributes, netzone 1128 WHERE netzone.ikey = netzone_attributes.okey AND netzone_attributes.attr = 'netExclude'::text AND nethost_attributes_ips.value::inet <<= netzone_attributes.value::inet; 1129 }, 1130 q{ 1131 CREATE OR REPLACE VIEW nethost_attributes_read AS 1132 SELECT nethost_attributes.value, nethost_attributes.attr, nethost_attributes.attr_key, nethost_attributes.okey 1133 FROM nethost_attributes 1134 UNION 1135 SELECT nethost_attributes_netzone.value, nethost_attributes_netzone.attr, nethost_attributes_netzone.attr_key, nethost_attributes_netzone.okey 1136 FROM nethost_attributes_netzone; 1137 } 1138 ], 1139 } 1117 1140 ); 1118 1141 … … 1215 1238 return; 1216 1239 } 1217 1240 1218 1241 if ($self->_CreateInternalObjects) { 1219 1242 $self->log(LA_DEBUG, "upgrade::_CreateInternalObjects done");
Note: See TracChangeset
for help on using the changeset viewer.