Search in sources :

Example 1 with FunctionTaskExecutor

use of io.lumeer.core.task.executor.FunctionTaskExecutor in project engine by Lumeer.

the class FunctionTask method process.

@Override
public void process(final TaskExecutor taskExecutor, final ChangesTracker changesTracker) {
    if (daoContextSnapshot.getSelectedWorkspace() != null && daoContextSnapshot.getSelectedWorkspace().getOrganization().isPresent() && daoContextSnapshot.getSelectedWorkspace().getProject().isPresent()) {
        log.info(String.format("Running function task on %s/%s > Resource '%s', Attribute '%s'.", daoContextSnapshot.getSelectedWorkspace().getOrganization().get().getCode(), daoContextSnapshot.getSelectedWorkspace().getProject().get().getCode(), collection != null ? collection.getName() : linkType.getName(), attribute.getName()));
    }
    if (documents != null && collection != null) {
        getDocumentsWithData(collection, documents).forEach(document -> {
            originalDocuments.put(document.getId(), new Document(document));
            final FunctionTaskExecutor executor = new FunctionTaskExecutor(this, collection, document);
            changesTracker.merge(executor.execute(taskExecutor));
        });
    } else if (linkType != null && linkInstances != null) {
        getLinkInstancesWithData(linkType, linkInstances).forEach(linkInstance -> {
            originalLinkInstances.put(linkInstance.getId(), new LinkInstance(linkInstance));
            final FunctionTaskExecutor executor = new FunctionTaskExecutor(this, linkType, linkInstance);
            changesTracker.merge(executor.execute(taskExecutor));
        });
    }
    if (parent != null) {
        parent.process(taskExecutor, changesTracker);
    }
}
Also used : ChangesTracker(io.lumeer.core.task.executor.ChangesTracker) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document) Set(java.util.Set) HashMap(java.util.HashMap) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) LinkInstance(io.lumeer.api.model.LinkInstance) Function(io.lumeer.api.model.function.Function) LinkType(io.lumeer.api.model.LinkType) FunctionTaskExecutor(io.lumeer.core.task.executor.FunctionTaskExecutor) HashSet(java.util.HashSet) DefaultConfigurationProducer(io.lumeer.core.facade.configuration.DefaultConfigurationProducer) List(java.util.List) Map(java.util.Map) Attribute(io.lumeer.api.model.Attribute) Collections(java.util.Collections) Collection(io.lumeer.api.model.Collection) ConstraintManager(io.lumeer.core.constraint.ConstraintManager) FunctionTaskExecutor(io.lumeer.core.task.executor.FunctionTaskExecutor) LinkInstance(io.lumeer.api.model.LinkInstance) DataDocument(io.lumeer.engine.api.data.DataDocument) Document(io.lumeer.api.model.Document)

Aggregations

Attribute (io.lumeer.api.model.Attribute)1 Collection (io.lumeer.api.model.Collection)1 Document (io.lumeer.api.model.Document)1 LinkInstance (io.lumeer.api.model.LinkInstance)1 LinkType (io.lumeer.api.model.LinkType)1 Function (io.lumeer.api.model.function.Function)1 ConstraintManager (io.lumeer.core.constraint.ConstraintManager)1 DefaultConfigurationProducer (io.lumeer.core.facade.configuration.DefaultConfigurationProducer)1 ChangesTracker (io.lumeer.core.task.executor.ChangesTracker)1 FunctionTaskExecutor (io.lumeer.core.task.executor.FunctionTaskExecutor)1 DataDocument (io.lumeer.engine.api.data.DataDocument)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1