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

io.vertx.tp.workflow.uca.deployment.DeployFormService Maven / Gradle / Ivy

The newest version!
package io.vertx.tp.workflow.uca.deployment;

import io.vertx.core.Future;
import io.vertx.up.unity.Ux;
import io.vertx.up.util.Ut;
import org.camunda.bpm.engine.repository.DeploymentBuilder;

import java.io.InputStream;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;

import static io.vertx.tp.workflow.refine.Wf.LOG;

/**
 * @author Lang
 */
class DeployFormService implements DeployOn {
    private final transient DeploymentBuilder builderRef;
    private final transient Set formFiles = new HashSet<>();
    private final transient String workflow;

    DeployFormService(final String workflow, final DeploymentBuilder builder) {
        this.builderRef = builder;
        this.workflow = workflow;
    }

    public DeployOn forms(final Set formFiles) {
        if (Objects.nonNull(formFiles)) {
            this.formFiles.addAll(formFiles);
        }
        return this;
    }

    @Override
    public Future initialize() {
        Objects.requireNonNull(this.builderRef);
        if (this.formFiles.isEmpty()) {
            return Ux.futureT();
        }
        this.formFiles.forEach(formFile -> {
            final String filePath = this.workflow + "/" + formFile;
            final InputStream istream = Ut.ioStream(filePath);
            if (Objects.nonNull(istream)) {
                this.builderRef.addInputStream(formFile, istream);
            } else {
                LOG.Deploy.warn(this.getClass(), "Ignored: `{0}` does not exist.", filePath);
            }
        });
        return Ux.futureT();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy