--- TMS now stores these fields for every document ----
Author Name:
Author Email:
Business Unit:
Business Division:
Campaign ID:
Campaign Rating:
Channel:
Client:
Contact Name:
Contact Email:
Content Description:
Content Type:
Domain:
Ext. Application ID:
Ext. Document ID:
Ext. Style ID:
Purchase Order:
Reference URL:
Region:

We should send these up with each document and these fields should be configured per translation profile.

CommentFileSizeAuthor
#59 2903254-intelligence-metadata-59.patch142.64 KBpenyaskito
#59 2903254-intelligence-metadata.interdiff.57-59.txt7.72 KBpenyaskito
#57 2903254-intelligence-metadata-57.patch140.65 KBpenyaskito
#57 2903254-intelligence-metadata.interdiff.55-57.txt1.54 KBpenyaskito
#55 2903254-intelligence-metadata-55.patch140.74 KBpenyaskito
#55 2903254-intelligence-metadata.interdiff.54-55.txt6.67 KBpenyaskito
#54 2903254-intelligence-metadata-54.patch136.57 KBpenyaskito
#54 2903254-intelligence-metadata.interdiff.52-54.txt4.89 KBpenyaskito
#52 2903254-intelligence-metadata-52.patch136.25 KBpenyaskito
#52 2903254-intelligence-metadata.interdiff.50-52.txt2.16 KBpenyaskito
#50 2903254-intelligence-metadata-50.patch136.23 KBpenyaskito
#50 2903254-intelligence-metadata.interdiff.49-50.txt9.83 KBpenyaskito
#49 2903254-intelligence-metadata-49.patch136.96 KBt.murphy
#49 2903254-intelligence-metadata.interdiff.47-49.txt7.87 KBt.murphy
#47 2903254-intelligence-metadata-47.patch131.43 KBt.murphy
#47 2903254-intelligence-metadata.interdiff.44-47.txt30.29 KBt.murphy
#44 2903254-intelligence-metadata-43.patch130.18 KBt.murphy
#44 2903254-intelligence-metadata.interdiff.42-43.txt1.34 KBt.murphy
#41 2903254-intelligence-metadata-41.patch126.65 KBpenyaskito
#41 2903254-intelligence-metadata.interdiff.40-41.txt45.07 KBpenyaskito
#40 2903254-intelligence-metadata-40.patch93.58 KBpenyaskito
#40 2903254-intelligence-metadata.interdiff.38-40.txt1.86 KBpenyaskito
#38 2903254-intelligence-metadata-38.patch93.49 KBpenyaskito
#38 2903254-intelligence-metadata.interdiff.36-38.txt1.08 KBpenyaskito
#36 2903254-intelligence-metadata-36.patch93.46 KBpenyaskito
#36 2903254-intelligence-metadata.interdiff.35-36.txt46.73 KBpenyaskito
#35 2903254-intelligence-metadata-35.patch91.51 KBpenyaskito
#35 2903254-intelligence-metadata.interdiff.34-35.txt914 bytespenyaskito
#34 2903254-intelligence-metadata-34.patch91.51 KBt.murphy
#34 2903254-intelligence-metadata.interdiff.33-34.txt851 bytest.murphy
#33 2903254-intelligence-metadata-33.patch91.51 KBt.murphy
#33 2903254-intelligence-metadata.interdiff.31-33.txt5.51 KBt.murphy
#31 2903254-intelligence-metadata-31.patch91.56 KBpenyaskito
#31 2903254-intelligence-metadata.interdiff.30-31.txt41.14 KBpenyaskito
#30 2903254-intelligence-metadata-30.patch50.61 KBt.murphy
#30 2903254-intelligence-metadata.interdiff.29-30.txt15.71 KBt.murphy
#29 2903254-intelligence-metadata-29.patch48 KBpenyaskito
#29 2903254-intelligence-metadata.interdiff.27-29.txt3 KBpenyaskito
#27 2903254-intelligence-metadata-27.patch47.97 KBpenyaskito
#27 2903254-intelligence-metadata.interdiff.26-27.txt22.79 KBpenyaskito
#26 2903254-intelligence-metadata-26.patch47.01 KBpenyaskito
#26 2903254-intelligence-metadata.interdiff.24-26.txt3.31 KBpenyaskito
#24 upload_lingotek_content-2903254-24.patch50.31 KBt.murphy
#21 upload_lingotek_content-2903254-21.patch50.09 KBt.murphy
#21 interdiff-upload_lingotek_content-2903254-20-upload_lingotek_content-2903254-21.txt5.74 KBt.murphy
#20 upload_lingotek_content-2903254-20.patch50.99 KBt.murphy
#20 interdiff-upload_lingotek_content-2903254-19-upload_lingotek_content-2903254-20.txt980 bytest.murphy
#19 upload_lingotek_content-2903254-19.patch51 KBt.murphy
#19 interdiff-upload_lingotek_content-2903254-18-upload_lingotek_content-2903254-19.txt533 bytest.murphy
#18 upload_lingotek_content-2903254-18.patch50.97 KBt.murphy
#18 interdiff-upload_lingotek_content-2903254-17-upload_lingotek_content-2903254-18.txt542 bytest.murphy
#17 upload_lingotek_content-2903254-17.patch50.96 KBt.murphy
#17 interdiff-upload_lingotek_content-2903254-16-upload_lingotek_content-2903254-17.txt589 bytest.murphy
#16 upload_lingotek_content-2903254-16.patch50.87 KBt.murphy
#16 interdiff-upload_lingotek_content-2903254-15-upload_lingotek_content-2903254-16.txt687 bytest.murphy
#15 upload_lingotek_content-2903254-15.patch50.32 KBt.murphy
#15 interdiff-upload_lingotek_content-2903254-14-upload_lingotek_content-2903254-15.txt4.91 KBt.murphy
#14 upload_lingotek_content-2903254-14.patch45.32 KBt.murphy
#14 interdiff-upload_lingotek_content-2903254-13-upload_lingotek_content-2903254-14.txt1.13 KBt.murphy
#13 upload_lingotek_content-2903254-13.patch45.13 KBt.murphy
#13 interdiff-upload_lingotek_content-2903254-12-upload_lingotek_content-2903254-13.txt705 bytest.murphy
#12 interdiff-upload_lingotek_content-2903254-11-upload_lingotek_content-2903254-12.txt5.18 KBt.murphy
#12 upload_lingotek_content-2903254-12.patch45.13 KBt.murphy
#11 upload_lingotek_content-2903254-11.patch45.05 KBt.murphy
#10 upload_lingotek_content-2903254-10.patch41.82 KBt.murphy
#9 upload_lingotek_content-2903254-9.patch41.82 KBt.murphy
#8 upload_lingotek_content-2903254-8.patch41.82 KBt.murphy
#7 upload_lingotek_content-2903254-7.patch41.82 KBt.murphy
#5 interdiff-1-2.txt405 bytesmdahl328151
#5 2903254-upload-lingotek-metadata-2.patch11.17 KBmdahl328151
#2 2903254-upload-lingotek-metadata.patch11.19 KBmdahl328151

Comments

mdahl328151 created an issue. See original summary.

mdahl328151’s picture

Status: Active » Needs work
StatusFileSize
new11.19 KB
mdahl328151’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 2: 2903254-upload-lingotek-metadata.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

mdahl328151’s picture

Status: Needs work » Needs review
StatusFileSize
new11.17 KB
new405 bytes

Status: Needs review » Needs work

The last submitted patch, 5: 2903254-upload-lingotek-metadata-2.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

t.murphy’s picture

StatusFileSize
new41.82 KB

Updated the API call and added content metadata options in the translation profile form.

t.murphy’s picture

StatusFileSize
new41.82 KB

Test failed because campaign_rating was set as a string in the schema, but should be an integer

t.murphy’s picture

StatusFileSize
new41.82 KB

Updated the automatic, disabled, and manual profiles in the config

t.murphy’s picture

StatusFileSize
new41.82 KB

Changed the value of the default campaign rating for the default profiles.

t.murphy’s picture

StatusFileSize
new45.05 KB

Patch did not include changes.

t.murphy’s picture

t.murphy’s picture

Fixed the handling of Lingotek Metadata in Lingotek.php on line 192 and 227.

t.murphy’s picture

Updated the metadata in the API call to check and see if it is even set.

t.murphy’s picture

Fixed two unit tests to account for the changes

t.murphy’s picture

t.murphy’s picture

Some objects going through the metadata don't have profiles and so I put a try catch around it.

t.murphy’s picture

Another attempt at fixing the getEntityProfile call.

t.murphy’s picture

Removed Client parameter from the API call

t.murphy’s picture

Status: Needs work » Needs review

Added the ability to send metadata in the document upload and update calls. These metadata can be controlled by the profile the content is using. There is a permission checkbox and text field for each on the profile so that they can be configured. The concept is finished for now and ready to be reviewed.

penyaskito’s picture

Status: Needs review » Needs work

This patch doesn't apply with latest HEAD.

t.murphy’s picture

StatusFileSize
new50.31 KB

Interdiff not available because patch 21 won't apply. Just had to update the patch since another patch committed before this one had a conflict with this one.

t.murphy’s picture

Status: Needs work » Needs review
penyaskito’s picture

StatusFileSize
new3.31 KB
new47.01 KB

The configuration files changes are invalid, or at least the installation aborts when using config strict checking (which happens in simpletests). Also, as there won't be any option to edit default provided profiles, I don't think it makes sense to duplicate the defaults.
I'm not sure yet, but I think config schema won't complain about not having them.

penyaskito’s picture

StatusFileSize
new22.79 KB
new47.97 KB

Added LingotekIntelligenceMetadataInterface for separating those methods from LingotekProfileInterface.
We will reuse that one for a global intelligence metadata settings that can be overridden by profiles.

Status: Needs review » Needs work

The last submitted patch, 27: 2903254-intelligence-metadata-27.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new3 KB
new48 KB

Fixed typo in method name and coding standards.

t.murphy’s picture

penyaskito’s picture

Added configuration form and services for checking the global intelligence settings.
Added tests for this form.

Status: Needs review » Needs work

The last submitted patch, 31: 2903254-intelligence-metadata-31.patch, failed testing. View results

t.murphy’s picture

t.murphy’s picture

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new914 bytes
new91.51 KB

Fixed test.

penyaskito’s picture

StatusFileSize
new46.73 KB
new93.46 KB

Reuse form for the profiles overrides. Add tests for the profile form.

Status: Needs review » Needs work

The last submitted patch, 36: 2903254-intelligence-metadata-36.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new1.08 KB
new93.49 KB

A simple addition to a test discovered a bug. Congrats.

Status: Needs review » Needs work

The last submitted patch, 38: 2903254-intelligence-metadata-38.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new1.86 KB
new93.58 KB

Coding standards.

penyaskito’s picture

StatusFileSize
new45.07 KB
new126.65 KB

Added logic for using the general settings or overriding with the profile settings as needed.

Added some basic test coverage.

penyaskito’s picture

StatusFileSize
new4.79 KB
new130.27 KB

A test for using the contact email as author setting.

penyaskito’s picture

Status: Needs review » Needs work
  1. +++ b/css/lingotek.settings.css
    @@ -4,3 +4,7 @@ input.field-property-checkbox {
    +.indent-form-item {
    +  margin-left: 25px;
    +}
    

    There's already a ".indented" class in Drupal classy theme. Let's reuse that one.

  2. +++ b/src/Form/LingotekIntelligenceMetadataForm.php
    @@ -0,0 +1,367 @@
    +    $form['intelligence_metadata']['region'] = [
    +      '#attributes' => ['class' => ['indent-form-item']],
    +      '#type' => 'select',
    +      '#title' => $this->t('Region'),
    +      '#options' => ['region1' => 'Region 1', 'region2' => 'Region 2', 'region3' => 'Region 3'],
    +      '#default_value' => $metadata->getRegion() ?: 'region1',
    +      '#states' => [
    +        'visible' => [
    +          ':input[name="intelligence_metadata[use_region]"]' => ['checked' => TRUE],
    +        ],
    +      ],
    +    ];
    

    As agreed, let's make this a free textfield as the others.

  3. +++ b/src/Form/LingotekProfileFormBase.php
    @@ -193,4 +218,27 @@ class LingotekProfileFormBase extends EntityForm {
    -}
    \ No newline at end of file
    

    Ensure the newline is there.

  4. +++ b/src/Lingotek.php
    @@ -187,6 +188,17 @@ class Lingotek implements LingotekInterface {
    +    if ($profile !== NULL) {
    +      $json_content = json_decode($content);
    +      if (isset($json_content->_lingotek_metadata)) {
    +        foreach ($json_content->_lingotek_metadata as $key => $val) {
    +          if (substr($key,1,9) === 'api_data_'){
    +            $defaults[substr($key,10)] = $val;
    +          }
    +        }
    +      }
    +    }
    

    I didn't spot this before. We should remove the check for profile here anyway.

    But I'm wondering why we do this after already encoding, and why we cannot handle this in a different way.

    Instead of using a common prefix, let's add this to a different array ($data['_lingotek_metadata']['_intelligence']?)

    Also maybe it should be already given instead of embedded in the same array?

  5. +++ b/src/Lingotek.php
    @@ -214,6 +227,15 @@ class Lingotek implements LingotekInterface {
    +    $json_content = json_decode($content);
    +    if (isset($json_content->_lingotek_metadata)) {
    +      foreach ($json_content->_lingotek_metadata as $key => $val) {
    +        if (substr($key,0,9) === '_api_data_'){
    +          $args[substr($key,10)] = $val;
    +        }
    +      }
    +    }
    

    Whatever option we chose, let's remove this code duplication by creating a new method.

  6. +++ b/tests/src/Unit/LingotekUnitTest.php
    @@ -393,6 +401,7 @@ class LingotekUnitTest extends UnitTestCase {
    @@ -403,6 +412,7 @@ class LingotekUnitTest extends UnitTestCase {
    
    @@ -403,6 +412,7 @@ class LingotekUnitTest extends UnitTestCase {
    +        'external_application_id' => 'e39e24c7-6c69-4126-946d-cf8fbff38ef0'
    

    Let's add unit tests for ensuring we are passing the rest of the right parameters in the proper way.

t.murphy’s picture

Status: Needs work » Needs review
StatusFileSize
new1.34 KB
new130.18 KB
penyaskito’s picture

I almost forgot: we need to define the defaults in an upgrade and the upgrade tests!

Status: Needs review » Needs work

The last submitted patch, 44: 2903254-intelligence-metadata-43.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

t.murphy’s picture

penyaskito’s picture

Tests didn't run, something must be wrong.

  1. +++ b/src/Lingotek.php
    @@ -188,13 +188,11 @@
    +    $json_content = json_decode($content);
    +    if (isset($json_content->_lingotek_metadata)) {
    +      foreach ($json_content->_lingotek_metadata as $key => $val) {
    +        if (substr($key,1,9) === 'api_data_'){
    +          $defaults[substr($key,10)] = $val;
             }
           }
         }
    

    Let's call the method instead.

  2. +++ b/src/Lingotek.php
    @@ -246,6 +238,21 @@
    +  public function getIntelligenceMetadata($content, $args) {
    ...
    +      foreach ($json_content->_lingotek_metadata->_intelligence as $key => $val) {
    +        if ($val !== '' || $val !== NULL){
    +          $args[$key] = $val;
    +        }
    +      }
    +    }
    

    We don't need args as a param. Let's rename the variables to more proper names.

    Why can't we do this before the json is decoded?

  3. +++ b/src/Tests/LingotekIntelligenceMetadataTranslationTest.php
    --- a/src/LingotekInterface.php
    +++ b/src/LingotekInterface.php
    
    +++ b/src/LingotekInterface.php
    @@ -73,6 +73,19 @@ interface LingotekInterface {
    +  public function getIntelligenceMetadata($content, $args);
    

    I think this is not needed to be added to the interface. It's an implementation detail, not needed if we had a different implementation for the LingotekInterface.

t.murphy’s picture

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new9.83 KB
new136.23 KB

Fixed assertions in upgrade tests.

Fixed syntax errors on Lingotek.php

Removed getIntelligenceMetadata from interface.

Status: Needs review » Needs work

The last submitted patch, 50: 2903254-intelligence-metadata-50.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new2.16 KB
new136.25 KB

The upgrade path didn't save the config. Fixed coding standards (NULL instead of null, FALSE instead of false, TRUE instead of true).

Status: Needs review » Needs work

The last submitted patch, 52: 2903254-intelligence-metadata-52.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new4.89 KB
new136.57 KB

Fixed tests now that the structure of the array changed.

penyaskito’s picture

StatusFileSize
new6.67 KB
new140.74 KB

Let's extend the API so an array is accepted.
If we change how we use the API we avoid JSON encoding/decoding twice.

Status: Needs review » Needs work

The last submitted patch, 55: 2903254-intelligence-metadata-55.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new1.54 KB
new140.65 KB

This failed because we are assuming now in our tests that content will be always an array. We need to modify that mock as we modified the production code for ensuring we accept string and array.

Status: Needs review » Needs work

The last submitted patch, 57: 2903254-intelligence-metadata-57.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

penyaskito’s picture

Status: Needs work » Needs review
StatusFileSize
new7.72 KB
new142.64 KB

Fixed unit tests. We were testing with an invalid JSON string, so let's ensure that still works.

Probably we should add more testing with arrays and valid JSON strings, but not in this ticket.
Also we could add testing for update functions + metadata, we are only testing upload here. But let's try to close this as is.

  • penyaskito committed d5122fb on 8.x-2.x
    Issue #2903254 by t.murphy, penyaskito, mdahl328151: Upload Lingotek...
penyaskito’s picture

Status: Needs review » Fixed

TJ reviewed it.

Committed d5122fb and pushed to 8.x-2.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.