Changeset 18455
- Timestamp:
- 2009-02-03T09:46:33+13:00 (15 years ago)
- Location:
- gsdl/trunk/perllib
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/classify.pm
r17288 r18455 280 280 # classify_doc lets each of the classifiers classify a document 281 281 sub classify_doc { 282 my ($classifiers, $doc_obj ) = @_;282 my ($classifiers, $doc_obj, $edit_mode) = @_; 283 283 284 284 foreach my $classobj (@$classifiers) { 285 285 my $title = $classobj->{'title'}; 286 $classobj->classify($doc_obj );286 $classobj->classify($doc_obj,$edit_mode); 287 287 } 288 288 } -
gsdl/trunk/perllib/classify/AZCompactList.pm
r17209 r18455 180 180 { 181 181 my $self = shift (@_); 182 my ($doc_obj ) = @_;182 my ($doc_obj,$edit_mode) = @_; 183 183 184 184 my $doc_OID = $doc_obj->get_OID(); … … 211 211 my $full_doc_OID 212 212 = ($thissection ne "") ? "$doc_OID.$thissection" : $doc_OID; 213 214 if ($edit_mode eq "delete") { 215 print $outhandle " Deleting $full_doc_OID\n"; 216 delete $self->{'list'}->{$full_doc_OID}; 217 delete $self->{'listmetavalue'}->{$full_doc_OID}; 218 delete $self->{'list_mvpair'}->{$full_doc_OID}; 219 delete $self->{'reclassify'}->{$full_doc_OID}; 220 221 next; 222 } 223 224 213 225 if (defined $self->{'list_mvpair'}->{$full_doc_OID}) 214 226 { … … 486 498 if ($self->{'doclevel'} =~ m/^top/i) { # toplevel 487 499 $self->{'classifiers'}->{$node_name}->{'classifyobj'} 488 ->classify($doc_obj, "Section=$section");500 ->classify($doc_obj,"add", "Section=$section"); 489 501 } else { # section level 490 502 # Thanks to Don Gourley for this... 491 503 # classify can't handle multi-level section 492 504 $self->{'classifiers'}->{$node_name}->{'classifyobj'} 493 ->classify_section($section, $doc_obj, $sortmeta);505 ->classify_section($section, $doc_obj, "add", $sortmeta); 494 506 } 495 507 } … … 497 509 { 498 510 $self->{'classifiers'}->{$node_name}->{'classifyobj'} 499 ->classify($doc_obj );511 ->classify($doc_obj,"add"); 500 512 } 501 513 } else { # this key is not in the hash -
gsdl/trunk/perllib/classify/AZList.pm
r17209 r18455 119 119 sub classify { 120 120 my $self = shift (@_); 121 my ($doc_obj ) = @_;121 my ($doc_obj,$edit_mode) = @_; 122 122 123 123 my $doc_OID = $doc_obj->get_OID(); 124 124 my $outhandle = $self->{'outhandle'}; 125 126 if ($edit_mode eq "delete") { 127 $self->oid_hash_delete($doc_OID,'list'); 128 return; 129 } 125 130 126 131 my $metavalue; -
gsdl/trunk/perllib/classify/AZSectionList.pm
r17209 r18455 71 71 sub classify { 72 72 my $self = shift (@_); 73 my ($doc_obj ) = @_;73 my ($doc_obj,$edit_mode) = @_; 74 74 75 75 my $doc_OID = $doc_obj->get_OID(); … … 77 77 78 78 while (defined $thissection) { 79 $self->classify_section ($thissection, $doc_obj );79 $self->classify_section ($thissection, $doc_obj, $edit_mode); 80 80 $thissection = $doc_obj->get_next_section ($thissection); 81 81 } … … 84 84 sub classify_section { 85 85 my $self = shift (@_); 86 my ($section, $doc_obj ) = @_;86 my ($section, $doc_obj, $edit_mode) = @_; 87 87 88 88 my $doc_OID = $doc_obj->get_OID(); 89 90 if ($edit_mode eq "delete") { 91 $self->oid_hash_delete("$doc_OID$section",'list'); 92 return; 93 } 89 94 90 95 my $metavalue; -
gsdl/trunk/perllib/classify/AllList.pm
r17209 r18455 72 72 sub classify { 73 73 my $self = shift (@_); 74 my ($doc_obj ) = @_;74 my ($doc_obj, $edit_mode) = @_; 75 75 76 76 my $doc_OID = $doc_obj->get_OID(); 77 77 78 push (@{$self->{'list'}}, $doc_OID); 78 if ($edit_mode eq "delete") { 79 $self->oid_array_delete($doc_OID,'list'); 80 } 81 else { 82 push (@{$self->{'list'}}, $doc_OID); 83 } 79 84 80 85 return; -
gsdl/trunk/perllib/classify/BaseClassifier.pm
r17209 r18455 298 298 } 299 299 300 sub oid_array_delete 301 { 302 my $self = shift (@_); 303 my ($delete_oid,$field) = @_; 304 305 my $outhandle = $self->{'outhandle'}; 306 307 my @filtered_list = (); 308 foreach my $existing_oid (@{$self->{$field}}) { 309 if ($existing_oid eq $delete_oid) { 310 print $outhandle " Deleting $delete_oid\n"; 311 } 312 else { 313 push(@filtered_list,$existing_oid); 314 } 315 } 316 $self->{$field} = \@filtered_list; 317 } 318 319 sub oid_hash_delete 320 { 321 my $self = shift (@_); 322 my ($delete_oid,$field) = @_; 323 324 my $outhandle = $self->{'outhandle'}; 325 326 print $outhandle " Deleting $delete_oid\n"; 327 delete $self->{$field}->{$delete_oid}; 328 } 329 300 330 sub classify { 301 331 my $self = shift (@_); 302 my ($doc_obj ) = @_;332 my ($doc_obj, $edit_mode) = @_; 303 333 304 334 my $outhandle = $self->{'outhandle'}; -
gsdl/trunk/perllib/classify/Collage.pm
r17209 r18455 139 139 140 140 my $self = shift (@_); 141 my ($doc_obj ) = @_;141 my ($doc_obj,$edit_mode) = @_; 142 142 143 143 my $has_image_type = 0; … … 159 159 160 160 if ($has_image_type) { 161 161 162 my $doc_OID = $doc_obj->get_OID(); 162 push (@{$self->{'list'}}, $doc_OID); 163 164 if ($edit_mode eq "delete") { 165 $self->oid_array_delete($doc_OID,'list'); 166 } 167 else { 168 push (@{$self->{'list'}}, $doc_OID); 169 } 163 170 } 164 171 -
gsdl/trunk/perllib/classify/DateList.pm
r17209 r18455 129 129 sub classify { 130 130 my $self = shift (@_); 131 my ($doc_obj ) = @_;131 my ($doc_obj, $edit_mode) = @_; 132 132 133 133 my $doc_OID = $doc_obj->get_OID(); … … 147 147 } 148 148 149 if ($edit_mode eq "delete") { 150 $self->oid_hash_delete($doc_OID,'list'); 151 return; 152 } 153 149 154 my $sort_other = ""; 150 155 if (defined $self->{'sort'} && $self->{'sort'} ne "") { -
gsdl/trunk/perllib/classify/GenericList.pm
r17209 r18455 194 194 { 195 195 my $self = shift(@_); 196 my $doc_obj = shift(@_);196 my ($doc_obj,$edit_mode) = @_; 197 197 198 198 # If "-classify_sections" is set, classify every section of the document … … 200 200 my $section = $doc_obj->get_next_section($doc_obj->get_top_section()); 201 201 while (defined $section) { 202 $self->classify_section($doc_obj, $doc_obj->get_OID() . ".$section", $section );202 $self->classify_section($doc_obj, $doc_obj->get_OID() . ".$section", $section, $edit_mode); 203 203 $section = $doc_obj->get_next_section($section); 204 204 } … … 206 206 # Otherwise just classify the top document section 207 207 else { 208 $self->classify_section($doc_obj, $doc_obj->get_OID(), $doc_obj->get_top_section() );208 $self->classify_section($doc_obj, $doc_obj->get_OID(), $doc_obj->get_top_section(), $edit_mode); 209 209 } 210 210 } … … 214 214 { 215 215 my $self = shift(@_); 216 my $doc_obj = shift(@_); 217 my $section_OID = shift(@_); 218 my $section = shift(@_); 216 my ($doc_obj,$section_OID,$section,$edit_mode) = @_; 219 217 220 218 my @metadata_groups = @{$self->{'metadata_groups'}}; … … 235 233 return if (!$classify_section); 236 234 235 if ($edit_mode eq "delete") { 236 $self->oid_array_delete($section_OID,'OIDs'); 237 return; 238 } 239 237 240 # Otherwise, include this section in the classifier 238 241 push(@{$self->{'OIDs'}}, $section_OID); -
gsdl/trunk/perllib/classify/HFileHierarchy.pm
r17209 r18455 197 197 { 198 198 my $self = shift (@_); 199 my ($doc_obj,$sortmeta,$metavalues) = @_; 199 my ($doc_obj,$edit_mode,$sortmeta,$metavalues) = @_; 200 201 my $outhandle = $self->{'outhandle'}; 200 202 201 203 my $doc_OID = $doc_obj->get_OID(); … … 204 206 if ((defined $self->{'descriptorlist'}->{$metaelement}) && 205 207 (defined $self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}})) { 206 push (@{$self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}}->{'contents'}}, 207 [$doc_OID, $sortmeta]); 208 my $localid = $self->{'descriptorlist'}->{$metaelement}; 209 my $classid = $self->get_number(); 210 211 $doc_obj->add_metadata($doc_obj->get_top_section(), "memberof", "CL$classid.$localid"); 208 209 if ($edit_mode eq "delete") { 210 # find it, and remove it 211 my $existing_list = $self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}}->{'contents'}; 212 213 my $filtered_list = []; 214 foreach my $existing_oid_pair (@$existing_list) { 215 if ($existing_oid_pair->[0] eq $doc_OID) { 216 print $outhandle " Deleting $doc_OID for $metaelement in hierarchy\n"; 217 } 218 else { 219 push(@$filtered_list,$existing_oid_pair); 220 } 221 } 222 $self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}}->{'contents'} = $filtered_list; 223 } 224 else { 225 push (@{$self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}}->{'contents'}}, 226 [$doc_OID, $sortmeta]); 227 my $localid = $self->{'descriptorlist'}->{$metaelement}; 228 my $classid = $self->get_number(); 229 230 $doc_obj->add_metadata($doc_obj->get_top_section(), "memberof", "CL$classid.$localid"); 231 } 212 232 } 213 233 } -
gsdl/trunk/perllib/classify/HTML.pm
r17209 r18455 86 86 sub classify { 87 87 my $self = shift (@_); 88 my ($doc_obj ) = @_;88 my ($doc_obj,$edit_mode) = @_; 89 89 90 90 # we don't do anything for individual documents -
gsdl/trunk/perllib/classify/Hierarchy.pm
r17209 r18455 86 86 sub auto_classify { 87 87 my $self = shift (@_); 88 my ($doc_obj,$ nosort,$sortmeta,$metavalues) = @_;88 my ($doc_obj,$edit_mode,$nosort,$sortmeta,$metavalues) = @_; 89 89 90 90 my $doc_OID = $doc_obj->get_OID(); 91 91 92 if ($edit_mode eq "delete") { 93 if ($nosort) { 94 $self->oid_array_delete($doc_OID,'docs'); 95 } 96 else { 97 $self->oid_hash_delete($doc_OID,'docs'); 98 } 99 return; 100 } 101 92 102 #Add all the metadata values to the hash 93 103 my $path_hash; … … 133 143 sub classify { 134 144 my $self = shift (@_); 135 my ($doc_obj ) = @_;145 my ($doc_obj,$edit_mode) = @_; 136 146 137 147 my $doc_OID = $doc_obj->get_OID(); … … 175 185 176 186 if (defined $self->{'subjectfile'}) { 177 $self->hfile_classify($doc_obj,$ sortmeta,$metavalues);187 $self->hfile_classify($doc_obj,$edit_mode,$sortmeta,$metavalues); 178 188 } 179 189 else { 180 $self->auto_classify($doc_obj,$ nosort,$sortmeta,$metavalues);190 $self->auto_classify($doc_obj,$edit_mode,$nosort,$sortmeta,$metavalues); 181 191 } 182 192 } -
gsdl/trunk/perllib/classify/List.pm
r17209 r18455 123 123 sub classify { 124 124 my $self = shift (@_); 125 my ($doc_obj ) = @_;125 my ($doc_obj, $edit_mode) = @_; 126 126 127 127 my $doc_OID = $doc_obj->get_OID(); 128 128 129 129 130 # are we sorting the list?? … … 133 134 } 134 135 136 if ($edit_mode eq "delete") { 137 if ($nosort) { 138 $self->oid_array_delete($doc_OID,'list'); 139 } 140 else { 141 $self->oid_hash_delete($doc_OID,'list'); 142 } 143 return; 144 } 145 135 146 my $metavalue; 136 147 my $metaname; -
gsdl/trunk/perllib/classify/Phind.pm
r17209 r18455 242 242 sub classify { 243 243 my $self = shift (@_); 244 my $doc_obj = shift@_;244 my ($doc_obj,$edit_mode) = @_; 245 245 246 246 my $verbosity = $self->{'verbosity'}; … … 260 260 my $phrlanguage = $self->{'language'}; 261 261 return if ($doclanguage && ($doclanguage !~ /$phrlanguage/i)); 262 262 263 if ($edit_mode eq "delete") { 264 # This classifier works quite differently to the others 265 # Probably doesn't support incremental building anyway 266 return; 267 } 268 263 269 # record this file 264 270 $self->{'total'} ++; -
gsdl/trunk/perllib/classify/RecentDocumentsList.pm
r17209 r18455 124 124 sub classify { 125 125 my $self = shift (@_); 126 my ($doc_obj ) = @_;126 my ($doc_obj,$edit_mode) = @_; 127 127 128 128 my $doc_OID = $doc_obj->get_OID(); … … 130 130 if (!defined $lastmodified || $lastmodified eq "") { 131 131 print $self->{'outhandle'}, "RecentDocumentsList: $doc_OID has no lastmodified metadata, not classifying\n"; 132 return; 133 } 134 135 if ($edit_mode eq "delete") { 136 $self->oid_hash_delete($doc_OID,'list'); 132 137 return; 133 138 } -
gsdl/trunk/perllib/classify/SectionList.pm
r17209 r18455 63 63 sub classify { 64 64 my $self = shift (@_); 65 my ($doc_obj, @options) = @_;65 my ($doc_obj, $edit_mode, @options) = @_; 66 66 67 67 # @options used by AZCompactList when is uses SectionList internally … … 97 97 if (defined $thissection) { 98 98 # just classify the one section 99 $self->classify_section($thissection, $doc_obj, $ sortmeta, $nosort);99 $self->classify_section($thissection, $doc_obj, $edit_mode, $sortmeta, $nosort); 100 100 } else 101 101 { 102 102 $thissection = $doc_obj->get_next_section ($doc_obj->get_top_section()); 103 103 while (defined $thissection) { 104 $self->classify_section($thissection, $doc_obj, $ sortmeta, $nosort);104 $self->classify_section($thissection, $doc_obj, $edit_mode, $sortmeta, $nosort); 105 105 $thissection = $doc_obj->get_next_section ($thissection); 106 106 } … … 110 110 sub classify_section { 111 111 my $self = shift (@_); 112 my ($section, $doc_obj, $ sortmeta, $nosort) = @_;112 my ($section, $doc_obj, $edit_mode, $sortmeta, $nosort) = @_; 113 113 114 114 my $doc_OID = $doc_obj->get_OID();
Note:
See TracChangeset
for help on using the changeset viewer.