Processors

Processor is a handler that processes a message in an arbitrary way.

More details - https://camel.apache.org/manual/processor.html

CsvToListOfDataProcessor

This processor is designed to read CSV data and convert it into a list of DataValue objects:

../../_images/Proc_02.png

The first row of the file contains headers, the subsequent rows contain data corresponding to the headers

Parameters:

Key

Value

delimiter

Delimiter. Default is comma

Example:

- beans:
    - name: "csvToListOfDataProcessor"
      type: ru.citeck.ecos.camel.processor.reader.CsvToListOfDataProcessor
      properties:
        delimiter: ";"
- route:
    from:
      uri: "file-from-camel-dsl:randomName"
      steps:
        - process:
            ref: csvToListOfDataProcessor
        - split:
            simple: "${body}"
            steps:
              - to: ecos-records-mutate:?sourceId=emodel/camel-example-employee

ExcelToListOfDataProcessor

This processor is designed to read data from Excel format (XLSX) and convert it into a list of DataValue objects:

../../_images/Proc_03.png

Parameters:

Key

Value

sheetName

Excel sheet name. The first sheet is used by default

tableStartCellReference

Reference to the starting cell of the table (where the row with headers begins). Default is “A1”

customAttNames

Associative array of custom attribute names, where the key is the column letter (e.g., “A”), and the value is the desired attribute name.

Example:

- beans:
    - name: "excelProcessor"
      type: ru.citeck.ecos.camel.processor.reader.ExcelToListOfDataProcessor
      properties:
        sheetName: SomeRandomSheetName
        tableStartCellReference: C11
        customAttNames:
          B: employeeSalary
          F: employeeManager
- route:
    from:
      uri: "file-from-camel-dsl:randomName"
      steps:
        - process:
            ref: excelProcessor
        - split:
            simple: "${body}"
            steps:
              - to: "ecos-records-mutate:?sourceId=emodel/camel-example-employee"

AssocRefByAttributeProcessor

This processor accepts a DataValue object and, based on the provided (mandatory) headers, finds the EntityRef of the required association and sets this value in the DataValue:

../../_images/Proc_04.png

Header parameters (“setHeader” must be under the name “AssocRefByAttributeConfig”):

Key

Value

sourceId

ID of the data source where we will search for the association

findByAttribute

System name of the attribute by which we will search for the association

attributeKey

Name of the attribute key in the provided DataValue

Example:

- beans:
    - name: "csvToListOfDataProcessor"
      type: ru.citeck.ecos.camel.processor.reader.CsvToListOfDataProcessor
    - name: "assocRefByAttributeProcessor"
      type: ru.citeck.ecos.camel.processor.data.AssocRefByAttributeProcessor
- route:
    from:
      uri: "file-from-camel-dsl:randomName"
      steps:
        - process:
            ref: csvToListOfDataProcessor
        - setHeader:
            name: AssocRefByAttributeConfig
            constant:
              sourceId: "emodel/camel-example-position"
              findByAttribute: "name"
              attributeKey: "position"
        - process:
            ref: assocRefByAttributeProcessor
        - split:
            simple: "${body}"
            steps:
              - to: "ecos-records-mutate:?sourceId=emodel/camel-example-employee"

CopyJournalSettingsProcessor

This processor transforms journal template data, thereby helping to copy templates from one journal to another.

To use it, you need to add it with the appropriate configuration to your yml configuration file:

- beans:
    - name: copyJournalSettings
      type: ru.citeck.ecos.camel.processor.data.CopyJournalSettingsProcessor
      properties:
        journalSettingMappingConfigs:
          - journalId: test-journal
            journalOldId: test-old-journal
            mapping:
              attFieldName: attOldFieldName
          - journalId: signerType
            journalOldId: old-signerType
            mapping:
              stTitle: old:stType
              stDescription: old:stDescription

Where:

  • name - The processor name that we will use in Camel DSL routes

  • type - The class on which the processor is based (Immutable parameter)

  • properties - Configuration of our class. We need to fill the journalSettingMappingConfigs variable, which is a list of settings for copying templates for journals. The setting variables are:

    • journalId - Id of the journal where we want to create templates

    • journalOldId - Id of the journal from which we will take templates and transfer them to the new journal

    • mapping - mapping of column correspondence between the old journal and the new one. The key is the Id of the column from the journal we are migrating to, and the value is from the one we are migrating from

Then we simply use this processor in our Camel DSL route.

Example of a complete route with this processor:

---
- beans:
    - name: copyJournalSettings
      type: ru.citeck.ecos.camel.processor.data.CopyJournalSettingsProcessor
      properties:
        journalSettingMappingConfigs:
          - journalId: test-journal
            journalOldId: test-old-journal
            mapping:
              attFieldName: attOldFieldName
          - journalId: signerType
            journalOldId: old-signerType
            mapping:
              stTitle: old:stType
              stDescription: old:stDescription

# copy-journal-settings
- route:
    from:
      uri: ecos-records-sync-consumer:copy-journal-settings
      parameters:
        delay: 60000
        sourceId: uiserv/journal-settings
        predicate:
          t: and
          v:
            - t: not
              v:
                t: ends
                a: id
                v: -mgr
            - t: in
              a: journalId
              v:
                - old-signerType
        attributes:
          id: ?localId
          name: name?json
          authority: authority
          journalId: journalId
          settings: settings
      steps:
        - split:
            simple: "${body}"
            steps:
              - process:
                  ref: copyJournalSettings
              - to:
                  uri: ecos-records-mutate:?sourceId=uiserv/journal-settings

Notes:

  • In the search predicate, we specify 2 predicates: 1st checks that the template id does not end with -mgr, since copied templates will have this suffix and they should not be processed. 2nd specifies the list of journals from which we want to take templates for copying (Ideally, these should be the journals from the processor configuration that are written in the journalOldId parameters).

  • attributes remain unchanged because these fields are processed in the processor and transferred to the new journal.

  • The route step uses split to process each template individually.

CreateEcosHistoryDocumentMirrorProcessor

Class

ru.citeck.ecos.camel.processor.data.CreateEcosHistoryDocumentMirrorProcessor

Input/Output

The input accepts either objects convertible to DataValue, or a list of such objects.

If the input is a Collection, the output is List<DataValue>.

If the input is a DataValue in the form of a list, the output is a new list with DataValue objects after processing.

If the input is an object convertible to DataValue, the output is a new DataValue object after processing.

Description

Creates a link between two records DocumentRef and DocumentMirrorRef in the ecos-history database so that when loading history for the DocumentMirrorRef record, the history of the DocumentRef record is also pulled in.

During processing, the history records themselves do not change, and this processor can be safely called multiple times for the same record.

The processor is used when migrating entities from one storage to another.

Properties

Name

Type

Description

documentMirrorSourceId

String

see headers → CreateEcosHistoryDocumentMirrorMirrorSourceId

documentMirrorRefIdPrefix

String

see headers → CreateEcosHistoryDocumentMirrorDocumentMirrorRefIdPrefix

documentRefIdPrefix

String

see headers → CreateEcosHistoryDocumentMirrorDocumentRefIdPrefix

Headers

Name

Type

Default

Description

CreateEcosHistoryDocumentMirrorConfig

Object:

documentMirrorRefIdPrefix: String = "",
documentRefIdPrefix: String = "",
documentMirrorSourceId: String = "",
documentRef: String = "",
documentMirrorRef: String = ""

{}

Common configuration object for all settings described below.
Has lower priority compared to the corresponding headers below.

CreateEcosHistoryDocumentMirrorDocumentRef

String

The “id” attribute is taken from the value and the prefix specified in
documentRefIdPrefix (CreateEcosHistoryDocumentMirrorDocumentRefIdPrefix)

The document from which we want to transfer history

CreateEcosHistoryDocumentMirrorDocumentRefIdPrefix

String

“”

Used to form the full ref in documentRef based on the “id” attribute in the processed value.

CreateEcosHistoryDocumentMirrorDocumentMirrorRef

String

The “id” attribute is taken from the value and the prefix specified in
documentMirrorRefIdPrefix (CreateEcosHistoryDocumentMirrorDocumentMirrorRefIdPrefix)
If the prefix is not set or the id attribute is missing, then documentRef is taken and its sourceId is changed to
documentMirrorSourceId (CreateEcosHistoryDocumentMirrorMirrorSourceId)

The document to which we want to transfer history

CreateEcosHistoryDocumentMirrorDocumentMirrorRefIdPrefix

String

“”

Used to form the full ref in documentMirrorRef based on the “id” attribute in the processed value.

CreateEcosHistoryDocumentMirrorMirrorSourceId

String

“”

Used to form the full ref in documentMirrorRef based on the documentRef value with the sourceId replaced by the value specified here.

Example Camel YAML DSL Config

---
- beans:
    - name: createHistoryDocumentMirror
      type: ru.citeck.ecos.camel.processor.data.CreateEcosHistoryDocumentMirrorProcessor
- route:
    from:
      uri: ecos-records-sync-consumer:alf-route-template-code
      parameters:
        sourceId: alfresco/
        predicate:
          t: eq
          a: _type
          v: route-template-code
        addAuditAttributes: true
        attributes:
          id: ?localId
      steps:
        - setHeader:
            name: CreateEcosHistoryDocumentMirrorConfig
            constant:
              documentRefIdPrefix: 'alfresco/@workspace://SpacesStore/'
              documentMirrorRefIdPrefix: 'emodel/route-template-code@'
        - process:
            ref: createHistoryDocumentMirror