Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-134307

[BE] Make ScriptBuilder usage consistent when add/update a task in TaskWorkflowMetricsIndexerImpl

    Details

      Description

      The aim of this is to change the script usage to respect the Schema defined in mappings.json

      Add task:

      ScriptBuilder builder = scripts.builder();
      
      UpdateDocumentRequest updateDocumentRequest =
      	new UpdateDocumentRequest(
      		_instanceWorkflowMetricsIndex.getIndexName(companyId),
      		WorkflowMetricsIndexerUtil.digest(
      			_instanceWorkflowMetricsIndex.getIndexType(),
      			companyId, instanceId),
      		builder.idOrCode(
      			StringUtil.read(
      				getClass(),
      				"dependencies/workflow-metrics-add-task-" +
      					"script.painless")
      		).language(
      			"painless"
      		).putParameter(
      			"task",
      			HashMapBuilder.<String, Object>put(
      				"assigneeIds", assigneeIds
      			).put(
      				"assigneeType", assigneeType
      			).put(
      				"taskId", taskId
      			).put(
      				"taskName", name
      			).build()
      		).scriptType(
      			ScriptType.INLINE
      		).build());
      
      updateDocumentRequest.setScriptedUpsert(true);
      
      searchEngineAdapter.execute(updateDocumentRequest);
      

      Update Task:

      ScriptBuilder builder = scripts.builder();
      
      searchEngineAdapter.execute(
      	new UpdateByQueryDocumentRequest(
      		queries.nested(
      			"tasks", queries.term("tasks.taskId", taskId)),
      		builder.idOrCode(
      			StringUtil.read(
      				getClass(),
      				"dependencies/workflow-metrics-update-task-" +
      					"script.painless")
      		).language(
      			"painless"
      		).putParameter(
      			"assigneeIds", assigneeIds
      		).putParameter(
      			"assigneeType", assigneeType
      		).putParameter(
      			"taskId", taskId
      		).scriptType(
      			ScriptType.INLINE
      		).build(),
      		_instanceWorkflowMetricsIndex.getIndexName(companyId)));
      

        Attachments

          Activity

            People

            Assignee:
            team-workflow Product Team Workflow
            Reporter:
            rafael.praxedes Rafael Praxedes
            Engineering Assignee:
            Feliphe Marinho
            Recent user:
            Sophia Zhang
            Participants of an Issue:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package
                7.4.13 DXP GA1
                Master