Changeset 10040 for trunk/gsdl/bin/script/gti.pl
- Timestamp:
- 2005-06-10T10:17:22+12:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/gti.pl
r10027 r10040 89 89 # Process the command 90 90 if ($gti_command =~ /^get-first-n-chunks-requiring-work$/i) { 91 &get_first_n_chunks_requiring_work(@gti_command_arguments);91 print &get_first_n_chunks_requiring_work(@gti_command_arguments); 92 92 } 93 93 if ($gti_command =~ /^get-language-status$/i) { 94 &get_language_status(@gti_command_arguments);94 print &get_language_status(@gti_command_arguments); 95 95 } 96 96 if ($gti_command =~ /^search-chunks$/i) { 97 &search_chunks(@gti_command_arguments);97 print &search_chunks(@gti_command_arguments); 98 98 } 99 99 if ($gti_command =~ /^submit-translation$/i) { 100 # This command cannot produce any output since it reads input 100 101 &submit_translation(@gti_command_arguments); 101 102 } … … 179 180 &log_message("Number of target chunks requiring updating: " . scalar(@target_file_keys_requiring_updating)); 180 181 181 # Writean XML response to the command182 print"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";183 print"<GTIResponse>\n";184 print" <TranslationFile"182 # Form an XML response to the command 183 my $xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 184 $xml_response .= "<GTIResponse>\n"; 185 $xml_response .= " <TranslationFile" 185 186 . " key=\"" . $translation_file_key . "\"" 186 187 . " target_file_path=\"" . $target_file . "\"" … … 191 192 # Do chunks requiring translation first 192 193 if ($num_chunks_to_return > scalar(@target_file_keys_requiring_translation)) { 193 print" <ChunksRequiringTranslation size=\"" . scalar(@target_file_keys_requiring_translation) . "\">\n";194 $xml_response .= " <ChunksRequiringTranslation size=\"" . scalar(@target_file_keys_requiring_translation) . "\">\n"; 194 195 } 195 196 else { 196 print" <ChunksRequiringTranslation size=\"" . $num_chunks_to_return . "\">\n";197 $xml_response .= " <ChunksRequiringTranslation size=\"" . $num_chunks_to_return . "\">\n"; 197 198 } 198 199 … … 203 204 my $source_file_chunk_text = &make_text_xml_safe($source_file_key_to_text_mapping{$chunk_key}); 204 205 205 print" <Chunk key=\"$chunk_key\">\n";206 print" <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n";207 print" <TargetFileText></TargetFileText>\n";208 print" </Chunk>\n";206 $xml_response .= " <Chunk key=\"$chunk_key\">\n"; 207 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 208 $xml_response .= " <TargetFileText></TargetFileText>\n"; 209 $xml_response .= " </Chunk>\n"; 209 210 210 211 $num_chunks_to_return--; 211 212 } 212 213 213 print" </ChunksRequiringTranslation>\n";214 $xml_response .= " </ChunksRequiringTranslation>\n"; 214 215 215 216 # Then do chunks requiring updating 216 217 if ($num_chunks_to_return > scalar(@target_file_keys_requiring_updating)) { 217 print" <ChunksRequiringUpdating size=\"" . scalar(@target_file_keys_requiring_updating) . "\">\n";218 $xml_response .= " <ChunksRequiringUpdating size=\"" . scalar(@target_file_keys_requiring_updating) . "\">\n"; 218 219 } 219 220 else { 220 print" <ChunksRequiringUpdating size=\"" . $num_chunks_to_return . "\">\n";221 $xml_response .= " <ChunksRequiringUpdating size=\"" . $num_chunks_to_return . "\">\n"; 221 222 } 222 223 … … 229 230 my $target_file_chunk_text = &make_text_xml_safe($target_file_key_to_text_mapping{$chunk_key}); 230 231 231 print" <Chunk key=\"$chunk_key\">\n";232 print" <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n";233 print" <TargetFileText date=\"$target_file_chunk_date\">$target_file_chunk_text</TargetFileText>\n";234 print" </Chunk>\n";232 $xml_response .= " <Chunk key=\"$chunk_key\">\n"; 233 $xml_response .= " <SourceFileText date=\"$source_file_chunk_date\">$source_file_chunk_text</SourceFileText>\n"; 234 $xml_response .= " <TargetFileText date=\"$target_file_chunk_date\">$target_file_chunk_text</TargetFileText>\n"; 235 $xml_response .= " </Chunk>\n"; 235 236 236 237 $num_chunks_to_return--; 237 238 } 238 239 239 print " </ChunksRequiringUpdating>\n"; 240 241 print "</GTIResponse>\n"; 240 $xml_response .= " </ChunksRequiringUpdating>\n"; 241 242 $xml_response .= "</GTIResponse>\n"; 243 return $xml_response; 242 244 } 243 245 … … 253 255 } 254 256 255 # Writean XML response to the command256 print"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";257 print"<GTIResponse>\n";258 print" <LanguageStatus code=\"$target_language_code\">\n";257 # Form an XML response to the command 258 my $xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 259 $xml_response .= "<GTIResponse>\n"; 260 $xml_response .= " <LanguageStatus code=\"$target_language_code\">\n"; 259 261 260 262 foreach my $translation_file (@$gti_translation_files) { … … 298 300 } 299 301 300 print" <TranslationFile"302 $xml_response .= " <TranslationFile" 301 303 . " key=\"" . $translation_file->{'key'} . "\"" 302 304 . " target_file_path=\"" . $target_file . "\"" … … 306 308 } 307 309 308 print " </LanguageStatus>\n"; 309 print "</GTIResponse>\n"; 310 $xml_response .= " </LanguageStatus>\n"; 311 312 $xml_response .= "</GTIResponse>\n"; 313 return $xml_response; 310 314 } 311 315 … … 362 366 } 363 367 364 # Writean XML response to the command365 print"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";366 print"<GTIResponse>\n";367 368 print" <ChunksMatchingQuery size=\"" . scalar(@target_file_keys_matching_query) . "\">\n";368 # Form an XML response to the command 369 my $xml_response = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 370 $xml_response .= "<GTIResponse>\n"; 371 372 $xml_response .= " <ChunksMatchingQuery size=\"" . scalar(@target_file_keys_matching_query) . "\">\n"; 369 373 foreach my $chunk_key (@target_file_keys_matching_query) { 370 374 my $target_file_chunk_text = &make_text_xml_safe($target_file_key_to_text_mapping{$chunk_key}); 371 375 372 print " <Chunk key=\"$chunk_key\">\n"; 373 print " <TargetFileText>$target_file_chunk_text</TargetFileText>\n"; 374 print " </Chunk>\n"; 375 } 376 print " </ChunksMatchingQuery>\n"; 377 378 print "</GTIResponse>\n"; 376 $xml_response .= " <Chunk key=\"$chunk_key\">\n"; 377 $xml_response .= " <TargetFileText>$target_file_chunk_text</TargetFileText>\n"; 378 $xml_response .= " </Chunk>\n"; 379 } 380 $xml_response .= " </ChunksMatchingQuery>\n"; 381 382 $xml_response .= "</GTIResponse>\n"; 383 return $xml_response; 379 384 } 380 385 … … 391 396 # Check that the necessary arguments were supplied 392 397 if (!$target_language_code || !$translation_file_key) { 393 &throw_fatal_error("Missing command argument."); # !! This cannot be here !! 398 &log_message("Fatal error (but cannot be thrown): Missing command argument."); 399 die "\n"; 394 400 } 395 401
Note:
See TracChangeset
for help on using the changeset viewer.