Changeset 23116
- Timestamp:
- 2010-10-12T13:55:07+13:00 (13 years ago)
- Location:
- main/trunk/greenstone2/perllib/classify
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/classify/AZCompactList.pm
r22038 r23116 184 184 { 185 185 my $self = shift (@_); 186 my ($doc_obj ,$edit_mode) = @_;186 my ($doc_obj) = @_; 187 187 188 188 my $doc_OID = $doc_obj->get_OID(); … … 215 215 my $full_doc_OID 216 216 = ($thissection ne "") ? "$doc_OID.$thissection" : $doc_OID; 217 218 if (($edit_mode eq "delete") || ($edit_mode eq "update")) {219 print $outhandle " Deleting $full_doc_OID for AZCompactList\n";220 delete $self->{'list'}->{$full_doc_OID};221 delete $self->{'listmetavalue'}->{$full_doc_OID};222 delete $self->{'list_mvpair'}->{$full_doc_OID};223 delete $self->{'reclassify'}->{$full_doc_OID};224 225 next if ($edit_mode eq "delete");226 }227 228 217 229 218 if (defined $self->{'list_mvpair'}->{$full_doc_OID}) -
main/trunk/greenstone2/perllib/classify/AZList.pm
r20428 r23116 121 121 sub classify { 122 122 my $self = shift (@_); 123 my ($doc_obj ,$edit_mode) = @_;123 my ($doc_obj) = @_; 124 124 125 125 my $doc_OID = $doc_obj->get_OID(); 126 126 my $outhandle = $self->{'outhandle'}; 127 128 if (($edit_mode eq "delete") || ($edit_mode eq "update")) {129 $self->oid_hash_delete($doc_OID,'list');130 return if ($edit_mode eq "delete");131 }132 127 133 128 my $metavalue; -
main/trunk/greenstone2/perllib/classify/AZSectionList.pm
r18455 r23116 71 71 sub classify { 72 72 my $self = shift (@_); 73 my ($doc_obj ,$edit_mode) = @_;73 my ($doc_obj) = @_; 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 , $edit_mode);79 $self->classify_section ($thissection, $doc_obj); 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 , $edit_mode) = @_;86 my ($section, $doc_obj) = @_; 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 }94 89 95 90 my $metavalue; -
main/trunk/greenstone2/perllib/classify/AllList.pm
r22220 r23116 72 72 sub classify { 73 73 my $self = shift (@_); 74 my ($doc_obj , $edit_mode) = @_;74 my ($doc_obj) = @_; 75 75 76 76 my $doc_OID = $doc_obj->get_OID(); 77 77 78 if ($edit_mode eq "delete") { 79 $self->oid_array_delete($doc_OID,'list'); 80 81 } 82 elsif ($edit_mode eq "update") { 83 # do nothing. Doc is already in the list. Is the order important?? 84 } 85 else { 86 push (@{$self->{'list'}}, $doc_OID); 87 } 88 78 push (@{$self->{'list'}}, $doc_OID); 79 89 80 return; 90 81 } -
main/trunk/greenstone2/perllib/classify/BaseClassifier.pm
r20453 r23116 330 330 sub classify { 331 331 my $self = shift (@_); 332 my ($doc_obj , $edit_mode) = @_;332 my ($doc_obj) = @_; 333 333 334 334 my $outhandle = $self->{'outhandle'}; -
main/trunk/greenstone2/perllib/classify/Collage.pm
r18455 r23116 139 139 140 140 my $self = shift (@_); 141 my ($doc_obj ,$edit_mode) = @_;141 my ($doc_obj) = @_; 142 142 143 143 my $has_image_type = 0; … … 162 162 my $doc_OID = $doc_obj->get_OID(); 163 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 } 164 push (@{$self->{'list'}}, $doc_OID); 165 170 166 } 171 167 -
main/trunk/greenstone2/perllib/classify/DateList.pm
r20828 r23116 133 133 sub classify { 134 134 my $self = shift (@_); 135 my ($doc_obj , $edit_mode) = @_;135 my ($doc_obj) = @_; 136 136 137 137 my $doc_OID = $doc_obj->get_OID(); … … 151 151 } 152 152 153 if (($edit_mode eq "delete") || ($edit_mode eq "update")) {154 $self->oid_hash_delete($doc_OID,'list');155 return if ($edit_mode eq "delete");156 }157 158 153 my $sort_other = ""; 159 154 if (defined $self->{'sort'} && $self->{'sort'} ne "") { -
main/trunk/greenstone2/perllib/classify/HFileHierarchy.pm
r23081 r23116 181 181 { 182 182 my $self = shift (@_); 183 my ($doc_obj,$ edit_mode,$sortmeta,$metavalues) = @_;183 my ($doc_obj,$sortmeta,$metavalues) = @_; 184 184 185 185 my $outhandle = $self->{'outhandle'}; … … 191 191 (defined $self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}})) { 192 192 193 if ($edit_mode eq "delete") { 194 # find it, and remove it 195 my $existing_list = $self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}}->{'contents'}; 196 197 my $filtered_list = []; 198 foreach my $existing_oid_pair (@$existing_list) { 199 if ($existing_oid_pair->[0] eq $doc_OID) { 200 print $outhandle " Deleting $doc_OID for $metaelement in hierarchy\n"; 201 } 202 else { 203 push(@$filtered_list,$existing_oid_pair); 204 } 205 } 206 $self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}}->{'contents'} = $filtered_list; 207 } 208 else { 209 push (@{$self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}}->{'contents'}}, 210 [$doc_OID, $sortmeta]); 211 my $localid = $self->{'descriptorlist'}->{$metaelement}; 212 my $classid = $self->get_number(); 213 214 $doc_obj->add_metadata($doc_obj->get_top_section(), "memberof", "CL$classid.$localid"); 215 } 193 push (@{$self->{'locatorlist'}->{$self->{'descriptorlist'}->{$metaelement}}->{'contents'}}, 194 [$doc_OID, $sortmeta]); 195 my $localid = $self->{'descriptorlist'}->{$metaelement}; 196 my $classid = $self->get_number(); 197 198 $doc_obj->add_metadata($doc_obj->get_top_section(), "memberof", "CL$classid.$localid"); 199 216 200 } 217 201 } -
main/trunk/greenstone2/perllib/classify/HTML.pm
r18455 r23116 86 86 sub classify { 87 87 my $self = shift (@_); 88 my ($doc_obj ,$edit_mode) = @_;88 my ($doc_obj) = @_; 89 89 90 90 # we don't do anything for individual documents -
main/trunk/greenstone2/perllib/classify/Hierarchy.pm
r18522 r23116 86 86 sub auto_classify { 87 87 my $self = shift (@_); 88 my ($doc_obj,$ edit_mode,$nosort,$sortmeta,$metavalues) = @_;88 my ($doc_obj,$nosort,$sortmeta,$metavalues) = @_; 89 89 90 90 my $doc_OID = $doc_obj->get_OID(); 91 92 if (($edit_mode eq "delete") || ($edit_mode eq "update")) {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 if ($edit_mode eq "delete");100 }101 91 102 92 #Add all the metadata values to the hash … … 143 133 sub classify { 144 134 my $self = shift (@_); 145 my ($doc_obj ,$edit_mode) = @_;135 my ($doc_obj) = @_; 146 136 147 137 my $doc_OID = $doc_obj->get_OID(); … … 185 175 186 176 if (defined $self->{'subjectfile'}) { 187 $self->hfile_classify($doc_obj,$ edit_mode,$sortmeta,$metavalues);177 $self->hfile_classify($doc_obj,$sortmeta,$metavalues); 188 178 } 189 179 else { 190 $self->auto_classify($doc_obj,$ edit_mode,$nosort,$sortmeta,$metavalues);180 $self->auto_classify($doc_obj,$nosort,$sortmeta,$metavalues); 191 181 } 192 182 } -
main/trunk/greenstone2/perllib/classify/List.pm
r22667 r23116 290 290 { 291 291 my $self = shift(@_); 292 my ($doc_obj ,$edit_mode) = @_;292 my ($doc_obj) = @_; 293 293 294 294 # If "-classify_sections" is set, classify every section of the document … … 296 296 my $section = $doc_obj->get_next_section($doc_obj->get_top_section()); 297 297 while (defined $section) { 298 $self->classify_section($doc_obj, $doc_obj->get_OID() . ".$section", $section , $edit_mode);298 $self->classify_section($doc_obj, $doc_obj->get_OID() . ".$section", $section); 299 299 $section = $doc_obj->get_next_section($section); 300 300 } … … 302 302 # Otherwise just classify the top document section 303 303 else { 304 $self->classify_section($doc_obj, $doc_obj->get_OID(), $doc_obj->get_top_section() , $edit_mode);304 $self->classify_section($doc_obj, $doc_obj->get_OID(), $doc_obj->get_top_section()); 305 305 } 306 306 } … … 310 310 { 311 311 my $self = shift(@_); 312 my ($doc_obj,$section_OID,$section ,$edit_mode) = @_;312 my ($doc_obj,$section_OID,$section) = @_; 313 313 314 314 my @metadata_groups = @{$self->{'metadata_groups'}}; … … 342 342 # We're not classifying this section because it doesn't have the required metadata 343 343 return if (!$classify_section); 344 345 if (($edit_mode eq "delete") || ($edit_mode eq "update")) {346 $self->oid_array_delete($section_OID,'OIDs');347 if ($edit_mode eq "delete") {348 return;349 }350 }351 344 352 345 # Otherwise, include this section in the classifier … … 358 351 # Take care not to do a metadata group more than once 359 352 unless ($metadata_groups_done{$metadata_group}) { 360 if ($edit_mode eq "update") {361 # if we are updating, we delete all the old values before362 # adding the new ones, otherwise, the section will end up in363 # the classifier twice.364 delete $self->{$metadata_group . ".list"}->{$section_OID};365 }366 367 353 my $remove_prefix_expr = $self->{$metadata_group . ".remove_prefix_expr"}; 368 354 my $remove_suffix_expr = $self->{$metadata_group . ".remove_suffix_expr"}; -
main/trunk/greenstone2/perllib/classify/Phind.pm
r22382 r23116 249 249 sub classify { 250 250 my $self = shift (@_); 251 my ($doc_obj ,$edit_mode) = @_;251 my ($doc_obj) = @_; 252 252 253 253 my $verbosity = $self->{'verbosity'}; … … 267 267 my $phrlanguage = $self->{'language'}; 268 268 return if ($doclanguage && ($doclanguage !~ /$phrlanguage/i)); 269 270 if ($edit_mode eq "delete") {271 # This classifier works quite differently to the others272 # Probably doesn't support incremental building anyway273 return;274 }275 269 276 270 # record this file -
main/trunk/greenstone2/perllib/classify/RecentDocumentsList.pm
r20454 r23116 126 126 sub classify { 127 127 my $self = shift (@_); 128 my ($doc_obj ,$edit_mode) = @_;128 my ($doc_obj) = @_; 129 129 130 130 my $doc_OID = $doc_obj->get_OID(); … … 132 132 if (!defined $lastmodified || $lastmodified eq "") { 133 133 print $self->{'outhandle'}, "RecentDocumentsList: $doc_OID has no lastmodified metadata, not classifying\n"; 134 return;135 }136 137 if ($edit_mode eq "delete") {138 $self->oid_hash_delete($doc_OID,'list');139 134 return; 140 135 } -
main/trunk/greenstone2/perllib/classify/SectionList.pm
r18566 r23116 63 63 sub classify { 64 64 my $self = shift (@_); 65 my ($doc_obj, $edit_mode,@options) = @_;65 my ($doc_obj, @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, $ edit_mode, $sortmeta, $nosort);99 $self->classify_section($thissection, $doc_obj, $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, $ edit_mode, $sortmeta, $nosort);104 $self->classify_section($thissection, $doc_obj, $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, $ edit_mode, $sortmeta, $nosort) = @_;112 my ($section, $doc_obj, $sortmeta, $nosort) = @_; 113 113 114 114 my $doc_OID = $doc_obj->get_OID(); -
main/trunk/greenstone2/perllib/classify/SimpleList.pm
r20654 r23116 128 128 sub classify { 129 129 my $self = shift (@_); 130 my ($doc_obj , $edit_mode) = @_;130 my ($doc_obj) = @_; 131 131 132 132 my $doc_OID = $doc_obj->get_OID(); … … 139 139 } 140 140 141 if ($edit_mode eq "delete") {142 if ($nosort) {143 $self->oid_array_delete($doc_OID,'list');144 }145 else {146 $self->oid_hash_delete($doc_OID,'list');147 }148 return;149 }150 151 141 my $metavalue; 152 142 my $metaname;
Note:
See TracChangeset
for help on using the changeset viewer.