use of org.springframework.web.bind.annotation.PathVariable in project zhcet-web by zhcet-amu.
the class RealTimeStatusController method realTimeSse.
@GetMapping("/management/task/sse/{id}")
public SseEmitter realTimeSse(@PathVariable String id) {
SseEmitter emitter = new SseEmitter(TIMEOUT);
RealTimeStatus status = realTimeStatusService.get(id);
Consumer<RealTimeStatus> consumer = statusChange -> {
try {
emitter.send(statusChange);
} catch (IOException e) {
log.error("Error sending event", e);
emitter.complete();
}
};
Runnable completeListener = emitter::complete;
Runnable onComplete = () -> {
status.removeChangeListener(consumer);
status.removeStopListener(completeListener);
};
status.addChangeListener(consumer);
status.onStop(completeListener);
emitter.onCompletion(onComplete);
emitter.onTimeout(onComplete);
consumer.accept(status);
if (status.isInvalid() || status.isFailed() || status.isFinished())
emitter.complete();
return emitter;
}
use of org.springframework.web.bind.annotation.PathVariable in project ArachneCentralAPI by OHDSI.
the class BaseSubmissionController method createSubmission.
@ApiOperation("Create and send submission.")
@PostMapping("/api/v1/analysis-management/{analysisId}/submissions")
public JsonResult<List<DTO>> createSubmission(Principal principal, @RequestBody @Validated CreateSubmissionsDTO createSubmissionsDTO, @PathVariable("analysisId") Long analysisId) throws PermissionDeniedException, NotExistException, IOException, NoExecutableFileException, ValidationException {
final JsonResult<List<DTO>> result;
if (principal == null) {
throw new PermissionDeniedException();
}
IUser user = userService.getByUsername(principal.getName());
if (user == null) {
throw new PermissionDeniedException();
}
Analysis analysis = analysisService.getById(analysisId);
final List<Submission> submissions = AnalysisHelper.createSubmission(submissionService, createSubmissionsDTO.getDataSources(), user, analysis);
final List<DTO> submissionDTOs = submissions.stream().map(s -> conversionService.convert(s, getSubmissionDTOClass())).collect(Collectors.toList());
result = new JsonResult<>(NO_ERROR);
result.setResult(submissionDTOs);
return result;
}
use of org.springframework.web.bind.annotation.PathVariable in project ArachneCentralAPI by OHDSI.
the class BaseDataNodeController method getDataSourcesForDataNode.
@ApiOperation("List datasources for the specified data node")
@GetMapping(value = "/api/v1/data-nodes/{dataNodeId}/data-sources")
public List<DataSourceDTO> getDataSourcesForDataNode(@PathVariable("dataNodeId") Long dataNodeId) {
DataNode dataNode = baseDataNodeService.getById(dataNodeId);
List<DataSource> dataSources = dataNode.getDataSources().stream().filter(ds -> Boolean.TRUE.equals(ds.getPublished())).collect(Collectors.toList());
return converterUtils.convertList(dataSources, DataSourceDTO.class);
}
use of org.springframework.web.bind.annotation.PathVariable in project mica2 by obiba.
the class VariableController method variable.
@GetMapping("/variable/{id:.+}")
public ModelAndView variable(@PathVariable String id) {
Map<String, Object> params = newParameters();
DatasetVariable.IdResolver resolver = DatasetVariable.IdResolver.from(id);
String datasetId = resolver.getDatasetId();
String variableName = resolver.getName();
switch(resolver.getType()) {
case Collected:
if (!collectedDatasetService.isPublished(datasetId))
throw NoSuchDatasetException.withId(datasetId);
break;
case Dataschema:
case Harmonized:
if (!harmonizedDatasetService.isPublished(datasetId))
throw NoSuchDatasetException.withId(datasetId);
break;
}
DatasetVariable variable = resolver.getType().equals(DatasetVariable.Type.Harmonized) ? getHarmonizedDatasetVariable(resolver.getDatasetId(), id, variableName) : getDatasetVariable(id, variableName);
params.put("variable", variable);
params.put("type", resolver.getType().toString());
addStudyTableParameters(params, variable);
Map<String, Taxonomy> taxonomies = taxonomyService.getVariableTaxonomies().stream().collect(Collectors.toMap(TaxonomyEntity::getName, e -> e));
// annotations are attributes described by some taxonomies
List<Annotation> annotations = variable.hasAttributes() ? variable.getAttributes().asAttributeList().stream().filter(attr -> attr.hasNamespace() && taxonomies.containsKey(attr.getNamespace()) && taxonomies.get(attr.getNamespace()).hasVocabulary(attr.getName())).map(attr -> new Annotation(attr, taxonomies.get(attr.getNamespace()))).collect(Collectors.toList()) : Lists.newArrayList();
List<Annotation> harmoAnnotations = annotations.stream().filter(annot -> annot.getTaxonomyName().equals("Mlstr_harmo")).collect(Collectors.toList());
annotations = annotations.stream().filter(annot -> !annot.getTaxonomyName().equals("Mlstr_harmo")).collect(Collectors.toList());
StringBuilder query = new StringBuilder();
for (Annotation annot : annotations) {
String expr = "in(" + annot.getTaxonomyName() + "." + annot.getVocabularyName() + "," + annot.getTermName() + ")";
if (query.length() == 0)
query = new StringBuilder(expr);
else
query = new StringBuilder("and(" + query + "," + expr + ")");
}
params.put("annotations", annotations);
params.put("harmoAnnotations", new HarmonizationAnnotations(harmoAnnotations));
params.put("query", "variable(" + query.toString() + ")");
params.put("showDatasetContingencyLink", showDatasetContingencyLink());
return new ModelAndView("variable", params);
}
use of org.springframework.web.bind.annotation.PathVariable in project alf.io by alfio-event.
the class MolliePaymentWebhookController method receivePaymentConfirmation.
@SuppressWarnings("MVCPathVariableInspection")
@PostMapping(WEBHOOK_URL_TEMPLATE)
public ResponseEntity<String> receivePaymentConfirmation(HttpServletRequest request, @PathVariable("reservationId") String reservationId) {
return Optional.ofNullable(StringUtils.trimToNull(request.getParameter("id"))).flatMap(id -> purchaseContextManager.findByReservationId(reservationId).map(purchaseContext -> {
var content = "id=" + id;
var result = ticketReservationManager.processTransactionWebhook(content, null, PaymentProxy.MOLLIE, Map.of(ADDITIONAL_INFO_PURCHASE_CONTEXT_TYPE, purchaseContext.getType().getUrlComponent(), ADDITIONAL_INFO_PURCHASE_IDENTIFIER, purchaseContext.getPublicIdentifier(), ADDITIONAL_INFO_RESERVATION_ID, reservationId), new PaymentContext(purchaseContext, reservationId));
if (result.isSuccessful()) {
return ResponseEntity.ok("OK");
} else if (result.isError()) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(result.getReason());
}
return ResponseEntity.ok(result.getReason());
})).orElseGet(() -> ResponseEntity.badRequest().body("NOK"));
}
Aggregations