+1

How to find memoQ project GUID via XTRF API

Bartosz Gumula 1 year ago in API updated by Ben Miller 1 year ago 6

Hi!

I wonder if anyone knows the option to identify the memoQ project GUID through XTRF API - we would like to create a memoQ wrap-up automation, but I am struggling to find any way to do it.

I can see that we can extract the bilingual document ID, but I did not find any clear way to use it to find memoQ project.

Any suggestion, either from XTRF API or memoQ API is very much welcome!

Hi Bartosz, unfortunately, the memoQ project GUID is not available directly via the XTRF API, even though XTRF created the memoQ project… The workaround I found is a little complicated:

  1. create a custom column that returns the memoQ project GUID, this was not easy, but XTRF support helped me out
  2. create a project view that contains this custom column, as well as the Smart Project internal ID
  3. use the `browse/` endpoint of the XTRF API to look up the project you need and extract the project number from the returned tabular data

Here's the Groovy code for the custom column:

import com.radzisz.xtrf.model.project.Project
import com.radzisz.xtrf.utils.velocity.VelocityTagUtils
import eu.xtrf.pa.cattools.project.presentation.query.CatToolProjectQueryService
import eu.xtrf.pa.project.management.api.dto.ProjectId
import eu.xtrf.pa.project.management.presentation.project.query.ProjectQueryService

class LinkedMemoqGUIDColumn {
    Project processedEntity
    VelocityTagUtils utils = new VelocityTagUtils()
    CatToolProjectQueryService catToolProjectQueryService
    ProjectQueryService projectQueryService

    LinkedMemoqGUIDColumn(processedEntity) {
        this.processedEntity = processedEntity
    }

    def runColumn() {
        Locale locale = utils.getLocale("English")
        if (processedEntity.isAssistedProject()) {
            ProjectId id = new ProjectId(processedEntity.getAssistedProjectId().get())
            if (projectQueryService.projectInCatToolAndOpportunity(id) && projectQueryService.process(id, locale).get().linkedCATToolType.get().toString() == "MemoQCATToolType")
                return catToolProjectQueryService.catToolProjectIdForProject(id).get()
            else
                return "-"
        } else {
            return "-"
        }
    }
}

LinkedMemoqGUIDColumn column = new LinkedMemoqGUIDColumn(unwrappedThis) 
column.setCatToolProjectQueryService(utils.getService("eu.xtrf.pa.cattools.project.presentation.query.CatToolProjectQueryService") as CatToolProjectQueryService)
column.setProjectQueryService(utils.getService("eu.xtrf.pa.project.management.presentation.project.query.ProjectQueryService") as ProjectQueryService)
column.runColumn()

I imagine you could use this code in a parameterized macro instead, and use the `macros/{macro_id}/run/` endpoint of the XTRF API to get the memoQ project GUID directly if that fits your use case better.

Hope this helps.

Best,

-Ben

Hi Ben!

Thanks for sharing the code, it works great for projects, I have tried to manipulate the code to achieve the same results for quotes but my knowledge about this is so limited that I failed.

As the queue times for waiting for any kind of customizations from XTRF Support nowadays are... not short ;), I would like to ask you if you maybe have the same solution for Quotes instead

Thanks for your help!

Sure, here's the same code for quotes:

import com.radzisz.xtrf.model.quote.Quote
import com.radzisz.xtrf.utils.velocity.VelocityTagUtils
import eu.xtrf.pa.cattools.project.presentation.query.CatToolProjectQueryService
import eu.xtrf.pa.project.management.api.dto.ProjectId
import eu.xtrf.pa.project.management.presentation.project.query.ProjectQueryService

class LinkedMemoqGUIDColumn {
    Quote processedEntity
    VelocityTagUtils utils = new VelocityTagUtils()
    CatToolProjectQueryService catToolProjectQueryService
    ProjectQueryService projectQueryService

    LinkedMemoqGUIDColumn(processedEntity) {
        this.processedEntity = processedEntity
    }

    def runColumn() {
        Locale locale = utils.getLocale("English")
        if (processedEntity.isAssistedProject()) {
            ProjectId id = new ProjectId(processedEntity.getAssistedProjectId().get())
            if (projectQueryService.projectInCatToolAndOpportunity(id) && projectQueryService.process(id, locale).get().linkedCATToolType.get().toString() == "MemoQCATToolType")
                return catToolProjectQueryService.catToolProjectIdForProject(id).get()
            else
                return "-"
        } else {
            return "-"
        }
    }
}

LinkedMemoqGUIDColumn column = new LinkedMemoqGUIDColumn(unwrappedThis) 
column.setCatToolProjectQueryService(utils.getService("eu.xtrf.pa.cattools.project.presentation.query.CatToolProjectQueryService") as CatToolProjectQueryService)
column.setProjectQueryService(utils.getService("eu.xtrf.pa.project.management.presentation.project.query.ProjectQueryService") as ProjectQueryService)
column.runColumn()

-Ben

Thanks Ben,

I really appreciate your help! 

Have a great day!

Hi Ben,

After the newest XTRF patch, we can finally get memoQ GUID via get v2/projects/{projectID} - I thought it might be of use to you!

+1

Yes, that is excellent, thank you for reaching out Bartosz! However, two issues require me to still use the macro workaround:

  1. the endpoint appears to only work for projects, based on the documentation (this may be incorrect, but I haven't gotten around to testing it yet)
  2. the endpoint only returns the project GUID, but not the memoQ server on which the project is located – we have multiple memoQ integrations configured, and without that information the GUID is not that useful

Could someone from the XTRF team confirm whether the endpoint works for quotes as well, and if so how?