All Downloads are FREE. Search and download functionalities are using the official Maven repository.

poussecafe.doc.model.processstepdoc.InternalProcessStepDocDataAccess Maven / Gradle / Ivy

The newest version!
package poussecafe.doc.model.processstepdoc;

import java.util.List;
import poussecafe.discovery.DataAccessImplementation;
import poussecafe.doc.model.aggregatedoc.AggregateDocId;
import poussecafe.doc.model.moduledoc.ModuleDocId;
import poussecafe.storage.internal.InternalDataAccess;
import poussecafe.storage.internal.InternalStorage;

import static java.util.stream.Collectors.toList;

@DataAccessImplementation(
    aggregateRoot = ProcessStepDoc.class,
    dataImplementation = ProcessStepDocData.class,
    storageName = InternalStorage.NAME
)
public class InternalProcessStepDocDataAccess extends InternalDataAccess implements ProcessStepDataAccess {

    @Override
    public List findByDomainProcess(ModuleDocId moduleDocId,
            String processName) {
        return findAll().stream()
                .filter(data -> data.moduleComponentDoc().value().moduleDocId().equals(moduleDocId))
                .filter(data -> data.processNames().value().contains(processName))
                .collect(toList());
    }

    @Override
    public List findConsuming(ModuleDocId moduleDocId,
            String eventName) {
        return findAll().stream()
                .filter(data -> data.moduleComponentDoc().value().moduleDocId().equals(moduleDocId))
                .filter(data -> data.stepMethodSignature().value().isPresent())
                .filter(data -> data.stepMethodSignature().value().get().consumedEventName().isPresent())
                .filter(data -> data.stepMethodSignature().value().get().consumedEventName().get().equals(eventName))
                .collect(toList());
    }

    @Override
    public List findProducing(ModuleDocId moduleDocId,
            String eventName) {
        return findAll().stream()
                .filter(data -> data.moduleComponentDoc().value().moduleDocId().equals(moduleDocId))
                .filter(data -> data.producedEvents().value().stream().map(NameRequired::name).anyMatch(eventName::equals))
                .collect(toList());
    }

    @Override
    public List findByAggregateDocId(AggregateDocId aggregateDocId) {
        return findAll().stream()
                .filter(data -> data.aggregate().value().isPresent())
                .filter(data -> data.aggregate().value().get().equals(aggregateDocId))
                .collect(toList());
    }

    @Override
    public List findByModule(ModuleDocId moduleDocId) {
        return findAll().stream()
                .filter(data -> data.moduleComponentDoc().value().moduleDocId().equals(moduleDocId))
                .collect(toList());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy