-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP, changes to actually make it work on the dummy service (#7283)
* WIP, changes to actually make it work on the dummy service * Added option to deactivate the service * Removed unused includes * Included ATConfig injection * Fixed typing errors * Removed access to async context before tenant * Delete ATSemanticConfig.json * Upped version. * Added environmnent to test. --------- Co-authored-by: RafaPolit <rafaelpolit@gmail.com>
- Loading branch information
Showing
11 changed files
with
108 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { EventsBus } from './eventsbus'; | ||
import { AutomaticTranslationFactory } from './externalIntegrations.v2/automaticTranslation/AutomaticTranslationFactory'; | ||
import { registerEventListeners as registerSegmentationListeners } from './services/pdfsegmentation/eventListeners'; | ||
import { Suggestions } from './suggestions/suggestions'; | ||
|
||
const registerEventListeners = (eventsBus: EventsBus) => { | ||
Suggestions.registerEventListeners(eventsBus); | ||
registerSegmentationListeners(eventsBus); | ||
AutomaticTranslationFactory.defaultATEntityCreationListener(eventsBus).start(); | ||
}; | ||
|
||
export { registerEventListeners }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 18 additions & 9 deletions
27
...externalIntegrations.v2/automaticTranslation/adapters/driving/ATEntityCreationListener.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,34 @@ | ||
import { EntityCreatedEvent } from 'api/entities/events/EntityCreatedEvent'; | ||
import { EventsBus } from 'api/eventsbus'; | ||
import { RequestEntityTranslation } from '../../RequestEntityTranslation'; | ||
import { permissionsContext } from 'api/permissions/permissionsContext'; | ||
import { AutomaticTranslationFactory } from '../../AutomaticTranslationFactory'; | ||
|
||
export class ATEntityCreationListener { | ||
private requestEntityTranslation: RequestEntityTranslation; | ||
|
||
private eventBus: EventsBus; | ||
|
||
constructor(requestEntityTranslation: RequestEntityTranslation, eventBus: EventsBus) { | ||
this.requestEntityTranslation = requestEntityTranslation; | ||
private ATFactory: typeof AutomaticTranslationFactory; | ||
|
||
constructor( | ||
eventBus: EventsBus, | ||
ATFactory: typeof AutomaticTranslationFactory = AutomaticTranslationFactory | ||
) { | ||
this.eventBus = eventBus; | ||
this.ATFactory = ATFactory; | ||
} | ||
|
||
start() { | ||
this.eventBus.on(EntityCreatedEvent, async event => { | ||
const entityFrom = event.entities.find(e => e.language === event.targetLanguageKey) || {}; | ||
const { active } = await this.ATFactory.defaultATConfigService().get(); | ||
|
||
if (active) { | ||
permissionsContext.setCommandContext(); | ||
const entityFrom = event.entities.find(e => e.language === event.targetLanguageKey) || {}; | ||
|
||
entityFrom._id = entityFrom._id?.toString(); | ||
entityFrom.template = entityFrom.template?.toString(); | ||
entityFrom._id = entityFrom._id?.toString(); | ||
entityFrom.template = entityFrom.template?.toString(); | ||
|
||
await this.requestEntityTranslation.execute(entityFrom); | ||
await this.ATFactory.defaultRequestEntityTranslation().execute(entityFrom); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters