Search in sources :

Example 1 with FormService

use of com.walmartlabs.concord.runtime.common.FormService in project concord by walmartlabs.

the class FormCallCommand method execute.

@Override
protected void execute(Runtime runtime, State state, ThreadId threadId) {
    String eventRef = UUID.randomUUID().toString();
    Context ctx = runtime.getService(Context.class);
    ExpressionEvaluator expressionEvaluator = runtime.getService(ExpressionEvaluator.class);
    EvalContext evalContext = EvalContextFactory.global(ctx);
    FormCall call = getStep();
    String formName = expressionEvaluator.eval(evalContext, call.getName(), String.class);
    ProcessDefinition processDefinition = runtime.getService(ProcessDefinition.class);
    ProcessConfiguration processConfiguration = runtime.getService(ProcessConfiguration.class);
    List<FormField> fields = assertFormFields(expressionEvaluator, evalContext, processConfiguration, processDefinition, formName, call);
    Form form = Form.builder().name(formName).eventName(eventRef).options(buildFormOptions(expressionEvaluator, evalContext, call)).fields(buildFormFields(expressionEvaluator, evalContext, fields, Objects.requireNonNull(call.getOptions()).values())).build();
    FormService formService = runtime.getService(FormService.class);
    formService.save(form);
    state.peekFrame(threadId).pop();
    state.setEventRef(threadId, eventRef);
    state.setStatus(threadId, ThreadStatus.SUSPENDED);
}
Also used : EvalContext(com.walmartlabs.concord.runtime.v2.runner.el.EvalContext) Context(com.walmartlabs.concord.runtime.v2.sdk.Context) ProcessConfiguration(com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration) Form(com.walmartlabs.concord.forms.Form) FormService(com.walmartlabs.concord.runtime.common.FormService) EvalContext(com.walmartlabs.concord.runtime.v2.runner.el.EvalContext) ExpressionEvaluator(com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator)

Example 2 with FormService

use of com.walmartlabs.concord.runtime.common.FormService in project concord by walmartlabs.

the class MainTest method setUp.

@BeforeEach
public void setUp() throws IOException {
    workDir = Files.createTempDirectory("test");
    instanceId = UUID.randomUUID();
    Path formsDir = workDir.resolve(Constants.Files.JOB_ATTACHMENTS_DIR_NAME).resolve(Constants.Files.JOB_STATE_DIR_NAME).resolve(Constants.Files.JOB_FORMS_V2_DIR_NAME);
    formService = new FormService(formsDir);
    processStatusCallback = mock(ProcessStatusCallback.class);
    checkpointService = spy(new TestCheckpointUploader());
    testServices = new AbstractModule() {

        @Override
        protected void configure() {
            install(new BaseRunnerModule());
            bind(ClassLoader.class).annotatedWith(Names.named("runtime")).toInstance(MainTest.class.getClassLoader());
            bind(CheckpointUploader.class).toInstance(checkpointService);
            bind(CheckpointService.class).to(DefaultCheckpointService.class);
            bind(DependencyManager.class).to(DefaultDependencyManager.class);
            bind(DockerService.class).to(DefaultDockerService.class);
            bind(FileService.class).to(DefaultFileService.class);
            bind(LockService.class).to(DefaultLockService.class);
            bind(PersistenceService.class).toInstance(mock(PersistenceService.class));
            bind(ProcessStatusCallback.class).toInstance(processStatusCallback);
            bind(SecretService.class).to(DefaultSecretService.class);
            Multibinder<TaskProvider> taskProviders = Multibinder.newSetBinder(binder(), TaskProvider.class);
            taskProviders.addBinding().to(TaskV2Provider.class);
            Multibinder<TaskCallListener> taskCallListeners = Multibinder.newSetBinder(binder(), TaskCallListener.class);
            taskCallListeners.addBinding().to(TaskCallPolicyChecker.class);
            taskCallListeners.addBinding().to(TaskResultListener.class);
            Multibinder.newSetBinder(binder(), ExecutionListener.class);
        }
    };
    allLogs = null;
}
Also used : Path(java.nio.file.Path) DefaultCheckpointService(com.walmartlabs.concord.runtime.v2.runner.checkpoints.DefaultCheckpointService) Multibinder(com.google.inject.multibindings.Multibinder) TaskV2Provider(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskV2Provider) FormService(com.walmartlabs.concord.runtime.common.FormService) TaskCallListener(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallListener) TaskResultListener(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskResultListener) AbstractModule(com.google.inject.AbstractModule) BaseRunnerModule(com.walmartlabs.concord.runtime.v2.runner.guice.BaseRunnerModule) ExecutionListener(com.walmartlabs.concord.svm.ExecutionListener) TaskCallPolicyChecker(com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallPolicyChecker) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with FormService

use of com.walmartlabs.concord.runtime.common.FormService in project concord by walmartlabs.

the class FormServiceProvider method get.

@Override
public FormService get() {
    Path attachmentsDir = workingDirectory.getValue().resolve(Constants.Files.JOB_ATTACHMENTS_DIR_NAME);
    Path stateDir = attachmentsDir.resolve(Constants.Files.JOB_STATE_DIR_NAME);
    Path formsDir = stateDir.resolve(Constants.Files.JOB_FORMS_V2_DIR_NAME);
    return new FormService(formsDir);
}
Also used : Path(java.nio.file.Path) FormService(com.walmartlabs.concord.runtime.common.FormService)

Aggregations

FormService (com.walmartlabs.concord.runtime.common.FormService)3 Path (java.nio.file.Path)2 AbstractModule (com.google.inject.AbstractModule)1 Multibinder (com.google.inject.multibindings.Multibinder)1 Form (com.walmartlabs.concord.forms.Form)1 DefaultCheckpointService (com.walmartlabs.concord.runtime.v2.runner.checkpoints.DefaultCheckpointService)1 EvalContext (com.walmartlabs.concord.runtime.v2.runner.el.EvalContext)1 ExpressionEvaluator (com.walmartlabs.concord.runtime.v2.runner.el.ExpressionEvaluator)1 BaseRunnerModule (com.walmartlabs.concord.runtime.v2.runner.guice.BaseRunnerModule)1 TaskCallListener (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallListener)1 TaskCallPolicyChecker (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskCallPolicyChecker)1 TaskResultListener (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskResultListener)1 TaskV2Provider (com.walmartlabs.concord.runtime.v2.runner.tasks.TaskV2Provider)1 Context (com.walmartlabs.concord.runtime.v2.sdk.Context)1 ProcessConfiguration (com.walmartlabs.concord.runtime.v2.sdk.ProcessConfiguration)1 ExecutionListener (com.walmartlabs.concord.svm.ExecutionListener)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1