Search in sources :

Example 1 with DocumentMapper

use of org.eclipse.sirius.web.services.documents.DocumentMapper in project sirius-web by eclipse-sirius.

the class EditingContextPersistenceService method persist.

@Override
public void persist(IEditingContext editingContext) {
    long start = System.currentTimeMillis();
    if (editingContext instanceof EditingContext) {
        EditingDomain editingDomain = ((EditingContext) editingContext).getDomain();
        List<DocumentEntity> documentEntities = this.persist(editingDomain);
        List<Document> documents = documentEntities.stream().map(new DocumentMapper()::toDTO).collect(Collectors.toList());
        // @formatter:off
        new IDParser().parse(editingContext.getId()).map(editingContextId -> new DocumentsModifiedEvent(editingContextId, documents)).ifPresent(this.applicationEventPublisher::publishEvent);
    // @formatter:on
    }
    long end = System.currentTimeMillis();
    this.timer.record(end - start, TimeUnit.MILLISECONDS);
}
Also used : DocumentEntity(org.eclipse.sirius.web.persistence.entities.DocumentEntity) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) ByteArrayOutputStream(java.io.ByteArrayOutputStream) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) DocumentsModifiedEvent(org.eclipse.sirius.web.services.api.events.DocumentsModifiedEvent) ArrayList(java.util.ArrayList) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) Document(org.eclipse.sirius.web.services.api.document.Document) Timer(io.micrometer.core.instrument.Timer) IEditingContextPersistenceService(org.eclipse.sirius.components.core.api.IEditingContextPersistenceService) Service(org.springframework.stereotype.Service) DocumentMapper(org.eclipse.sirius.web.services.documents.DocumentMapper) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) EObjectIDManager(org.eclipse.sirius.components.emf.services.EObjectIDManager) Logger(org.slf4j.Logger) IDParser(org.eclipse.sirius.web.services.api.id.IDParser) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) JsonResource(org.eclipse.sirius.emfjson.resource.JsonResource) Objects(java.util.Objects) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) IDocumentRepository(org.eclipse.sirius.web.persistence.repositories.IDocumentRepository) MeterRegistry(io.micrometer.core.instrument.MeterRegistry) Resource(org.eclipse.emf.ecore.resource.Resource) Optional(java.util.Optional) DocumentsModifiedEvent(org.eclipse.sirius.web.services.api.events.DocumentsModifiedEvent) DocumentEntity(org.eclipse.sirius.web.persistence.entities.DocumentEntity) IEditingContext(org.eclipse.sirius.components.core.api.IEditingContext) EditingContext(org.eclipse.sirius.components.emf.services.EditingContext) DocumentMapper(org.eclipse.sirius.web.services.documents.DocumentMapper) IDParser(org.eclipse.sirius.web.services.api.id.IDParser) EditingDomain(org.eclipse.emf.edit.domain.EditingDomain) Document(org.eclipse.sirius.web.services.api.document.Document)

Aggregations

MeterRegistry (io.micrometer.core.instrument.MeterRegistry)1 Timer (io.micrometer.core.instrument.Timer)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Objects (java.util.Objects)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 Collectors (java.util.stream.Collectors)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 EditingDomain (org.eclipse.emf.edit.domain.EditingDomain)1 IEditingContext (org.eclipse.sirius.components.core.api.IEditingContext)1 IEditingContextPersistenceService (org.eclipse.sirius.components.core.api.IEditingContextPersistenceService)1 EObjectIDManager (org.eclipse.sirius.components.emf.services.EObjectIDManager)1 EditingContext (org.eclipse.sirius.components.emf.services.EditingContext)1 JsonResource (org.eclipse.sirius.emfjson.resource.JsonResource)1 DocumentEntity (org.eclipse.sirius.web.persistence.entities.DocumentEntity)1 IDocumentRepository (org.eclipse.sirius.web.persistence.repositories.IDocumentRepository)1