use of com.walmartlabs.concord.server.sdk.ProcessKey in project concord by walmartlabs.
the class ProcessResource method listAttachments.
/**
* Lists process attachments.
*
* @param instanceId
* @return
*/
@GET
@ApiOperation(value = "List attachments", responseContainer = "list", response = String.class)
@javax.ws.rs.Path("/{id}/attachment")
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public List<String> listAttachments(@ApiParam @PathParam("id") UUID instanceId) {
ProcessEntry processEntry = processManager.assertProcess(instanceId);
assertProcessAccess(processEntry, "attachments");
PartialProcessKey processKey = new ProcessKey(processEntry.instanceId(), processEntry.createdAt());
String resource = Constants.Files.JOB_ATTACHMENTS_DIR_NAME + "/";
List<String> l = stateManager.list(processKey, resource);
return l.stream().map(s -> s.substring(resource.length())).collect(Collectors.toList());
}
use of com.walmartlabs.concord.server.sdk.ProcessKey in project concord by walmartlabs.
the class ProcessCheckpointV2Resource method processCheckpoint.
@GET
@ApiOperation(value = "Process checkpoint")
@javax.ws.rs.Path("{id}/checkpoint")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public GenericCheckpointResponse processCheckpoint(@ApiParam @PathParam("id") UUID instanceId, @ApiParam @QueryParam("name") String checkpointName, @ApiParam @QueryParam("action") String action) {
ProcessEntry entry = processManager.assertProcess(instanceId);
ProcessKey processKey = new ProcessKey(entry.instanceId(), entry.createdAt());
switch(action) {
case RESTORE_PROCESS_ACTION:
{
return restore(processKey, checkpointName);
}
default:
{
throw new ConcordApplicationException("Invalid action type: " + action);
}
}
}
use of com.walmartlabs.concord.server.sdk.ProcessKey in project concord by walmartlabs.
the class ProcessEventDao method list.
public List<ProcessEventEntry> list(ProcessEventFilter filter) {
ProcessKey processKey = filter.processKey();
SelectConditionStep<Record5<Long, UUID, String, OffsetDateTime, JSONB>> q = dsl().select(PROCESS_EVENTS.EVENT_SEQ, PROCESS_EVENTS.EVENT_ID, PROCESS_EVENTS.EVENT_TYPE, PROCESS_EVENTS.EVENT_DATE, function("jsonb_strip_nulls", JSONB.class, PROCESS_EVENTS.EVENT_DATA)).from(PROCESS_EVENTS).where(PROCESS_EVENTS.INSTANCE_ID.eq(processKey.getInstanceId()).and(PROCESS_EVENTS.INSTANCE_CREATED_AT.eq(processKey.getCreatedAt())));
OffsetDateTime after = filter.after();
if (after != null) {
q.and(PROCESS_EVENTS.EVENT_DATE.ge(after));
}
Long fromId = filter.fromId();
if (fromId != null) {
q.and(PROCESS_EVENTS.EVENT_SEQ.greaterThan(fromId));
}
String eventType = filter.eventType();
if (eventType != null) {
q.and(PROCESS_EVENTS.EVENT_TYPE.eq(eventType));
}
UUID eventCorrelationId = filter.eventCorrelationId();
if (eventCorrelationId != null) {
q.and(PgUtils.jsonbText(PROCESS_EVENTS.EVENT_DATA, "correlationId").eq(eventCorrelationId.toString()));
}
EventPhase eventPhase = filter.eventPhase();
if (eventPhase != null) {
q.and(PgUtils.jsonbText(PROCESS_EVENTS.EVENT_DATA, "phase").eq(eventPhase.getKey()));
}
int limit = filter.limit();
if (limit > 0) {
q.limit(limit);
}
int offset = filter.offset();
if (offset > 0) {
q.offset(offset);
}
return q.orderBy(PROCESS_EVENTS.EVENT_SEQ).fetch(this::toEntry);
}
use of com.walmartlabs.concord.server.sdk.ProcessKey in project concord by walmartlabs.
the class ProcessEventResource method event.
/**
* Register a process event.
*/
@POST
@ApiOperation(value = "Register a process event", authorizations = { @Authorization("session_key"), @Authorization("api_key") })
@Path("/{processInstanceId}/event")
@Consumes(MediaType.APPLICATION_JSON)
@WithTimer
public void event(@ApiParam @PathParam("processInstanceId") UUID processInstanceId, @ApiParam ProcessEventRequest req) {
ProcessKey processKey = assertProcessKey(processInstanceId);
NewProcessEvent e = NewProcessEvent.builder().processKey(processKey).eventType(req.getEventType()).eventDate(req.getEventDate()).data(req.getData()).build();
eventManager.event(Collections.singletonList(e));
}
use of com.walmartlabs.concord.server.sdk.ProcessKey in project concord by walmartlabs.
the class ProjectProcessResource method proceed.
private Response proceed(PartialProcessKey processKey) {
ProcessEntry entry = processQueueManager.get(processKey);
if (entry == null) {
throw new ConcordApplicationException("Process not found: " + processKey, Status.NOT_FOUND);
}
ProcessKey pk = new ProcessKey(entry.instanceId(), entry.createdAt());
ProcessStatus s = entry.status();
if (s == ProcessStatus.FAILED || s == ProcessStatus.CANCELLED || s == ProcessStatus.TIMED_OUT) {
return processError(processKey, "Process failed: " + s, null);
} else if (s == ProcessStatus.FINISHED) {
return processFinished(processKey);
} else if (s == ProcessStatus.SUSPENDED) {
String nextFormId = nextFormId(pk);
if (nextFormId == null) {
return processError(processKey, "Invalid process state: no forms found", null);
}
String url = "/#/process/" + entry.instanceId() + "/wizard";
return Response.status(Status.MOVED_PERMANENTLY).header(HttpHeaders.LOCATION, url).build();
} else {
Map<String, Object> args = prepareArgumentsForInProgressTemplate(entry);
return responseTemplates.inProgressWait(Response.ok(), args).build();
}
}
Aggregations