use of org.springframework.web.bind.annotation.PathVariable in project vorto by eclipse.
the class ModelRepositoryController method getModelContentByModelAndMappingId.
@ApiOperation(value = "Returns the model content including target platform specific attributes for the given model- and mapping modelID")
@ApiResponses(value = { @ApiResponse(code = 400, message = "Wrong input"), @ApiResponse(code = 404, message = "Model not found") })
@RequestMapping(value = "/content/{modelId:.+}/mapping/{mappingId:.+}", method = RequestMethod.GET)
public AbstractModel getModelContentByModelAndMappingId(@ApiParam(value = "The model ID (prettyFormat)", required = true) @PathVariable final String modelId, @ApiParam(value = "The mapping Model ID (prettyFormat)", required = true) @PathVariable final String mappingId) {
ModelInfo vortoModelInfo = modelRepository.getById(ModelId.fromPrettyFormat(modelId));
ModelInfo mappingModelInfo = modelRepository.getById(ModelId.fromPrettyFormat(mappingId));
if (vortoModelInfo == null) {
throw new ModelNotFoundException("Could not find vorto model with ID: " + modelId);
} else if (mappingModelInfo == null) {
throw new ModelNotFoundException("Could not find mapping with ID: " + mappingId);
}
byte[] mappingContentZip = createZipWithAllDependencies(mappingModelInfo.getId(), ContentType.DSL);
IModelWorkspace workspace = IModelWorkspace.newReader().addZip(new ZipInputStream(new ByteArrayInputStream(mappingContentZip))).read();
MappingModel mappingModel = (MappingModel) workspace.get().stream().filter(p -> p instanceof MappingModel).findFirst().get();
byte[] modelContent = createZipWithAllDependencies(vortoModelInfo.getId(), ContentType.DSL);
workspace = IModelWorkspace.newReader().addZip(new ZipInputStream(new ByteArrayInputStream(modelContent))).read();
return ModelDtoFactory.createResource(workspace.get().stream().filter(p -> p.getName().equals(vortoModelInfo.getId().getName())).findFirst().get(), Optional.of(mappingModel));
}
use of org.springframework.web.bind.annotation.PathVariable in project data-prep by Talend.
the class DataSetService method preview.
/**
* Returns preview of the the data set content for given id (first 100 rows). Service might return
* {@link org.apache.http.HttpStatus#SC_ACCEPTED} if the data set exists but analysis is not yet fully
* completed so content is not yet ready to be served.
*
* @param metadata If <code>true</code>, includes data set metadata information.
* @param sheetName the sheet name to preview
* @param dataSetId A data set id.
*/
@RequestMapping(value = "/datasets/{id}/preview", method = RequestMethod.GET)
@ApiOperation(value = "Get a data preview set by id", notes = "Get a data set preview content based on provided id. Not valid or non existing data set id returns empty content. Data set not in drat status will return a redirect 301")
@Timed
@ResponseBody
public DataSet preview(@RequestParam(defaultValue = "true") @ApiParam(name = "metadata", value = "Include metadata information in the response") boolean metadata, @RequestParam(defaultValue = "") @ApiParam(name = "sheetName", value = "Sheet name to preview") String sheetName, @PathVariable(value = "id") @ApiParam(name = "id", value = "Id of the requested data set") String dataSetId) {
DataSetMetadata dataSetMetadata = dataSetMetadataRepository.get(dataSetId);
if (dataSetMetadata == null) {
HttpResponseContext.status(HttpStatus.NO_CONTENT);
// No data set, returns empty content.
return DataSet.empty();
}
if (!dataSetMetadata.isDraft()) {
// Moved to get data set content operation
HttpResponseContext.status(HttpStatus.MOVED_PERMANENTLY);
HttpResponseContext.header("Location", "/datasets/" + dataSetId + "/content");
// dataset not anymore a draft so preview doesn't make sense.
return DataSet.empty();
}
if (StringUtils.isNotEmpty(sheetName)) {
dataSetMetadata.setSheetName(sheetName);
}
// take care of previous data without schema parser result
if (dataSetMetadata.getSchemaParserResult() != null) {
// sheet not yet set correctly so use the first one
if (StringUtils.isEmpty(dataSetMetadata.getSheetName())) {
String theSheetName = dataSetMetadata.getSchemaParserResult().getSheetContents().get(0).getName();
LOG.debug("preview for dataSetMetadata: {} with sheetName: {}", dataSetId, theSheetName);
dataSetMetadata.setSheetName(theSheetName);
}
String theSheetName = dataSetMetadata.getSheetName();
Optional<Schema.SheetContent> sheetContentFound = dataSetMetadata.getSchemaParserResult().getSheetContents().stream().filter(sheetContent -> theSheetName.equals(sheetContent.getName())).findFirst();
if (!sheetContentFound.isPresent()) {
HttpResponseContext.status(HttpStatus.NO_CONTENT);
// No sheet found, returns empty content.
return DataSet.empty();
}
List<ColumnMetadata> columnMetadatas = sheetContentFound.get().getColumnMetadatas();
if (dataSetMetadata.getRowMetadata() == null) {
dataSetMetadata.setRowMetadata(new RowMetadata(emptyList()));
}
dataSetMetadata.getRowMetadata().setColumns(columnMetadatas);
} else {
LOG.warn("dataset#{} has draft status but any SchemaParserResult");
}
// Build the result
DataSet dataSet = new DataSet();
if (metadata) {
dataSet.setMetadata(conversionService.convert(dataSetMetadata, UserDataSetMetadata.class));
}
dataSet.setRecords(contentStore.stream(dataSetMetadata).limit(100));
return dataSet;
}
use of org.springframework.web.bind.annotation.PathVariable in project metasfresh-webui-api by metasfresh.
the class WindowRestController method processRecord.
/**
* @task https://github.com/metasfresh/metasfresh/issues/1090
*/
@GetMapping("/{windowId}/{documentId}/processNewRecord")
public int processRecord(//
@PathVariable("windowId") final String windowIdStr, //
@PathVariable("documentId") final String documentIdStr) {
userSession.assertLoggedIn();
final WindowId windowId = WindowId.fromJson(windowIdStr);
final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
final IDocumentChangesCollector changesCollector = NullDocumentChangesCollector.instance;
return Execution.callInNewExecution("window.processTemplate", () -> documentCollection.forDocumentWritable(documentPath, changesCollector, document -> {
document.saveIfValidAndHasChanges();
if (document.hasChangesRecursivelly()) {
throw new AdempiereException("Not saved");
}
final int newRecordId = newRecordDescriptorsProvider.getNewRecordDescriptor(document.getEntityDescriptor()).getProcessor().processNewRecordDocument(document);
return newRecordId;
}));
}
use of org.springframework.web.bind.annotation.PathVariable in project metasfresh-webui-api by metasfresh.
the class ProcessRestController method getParameterTypeahead.
@RequestMapping(value = "/{processId}/{pinstanceId}/field/{parameterName}/typeahead", method = RequestMethod.GET)
public JSONLookupValuesList getParameterTypeahead(//
@PathVariable("processId") final String processIdStr, //
@PathVariable("pinstanceId") final String pinstanceIdStr, //
@PathVariable("parameterName") final String parameterName, //
@RequestParam(name = "query", required = true) final String query) {
userSession.assertLoggedIn();
final ProcessId processId = ProcessId.fromJson(processIdStr);
final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
final IProcessInstancesRepository instancesRepository = getRepository(processId);
return instancesRepository.forProcessInstanceReadonly(pinstanceId, processInstance -> processInstance.getParameterLookupValuesForQuery(parameterName, query)).transform(JSONLookupValuesList::ofLookupValuesList);
}
use of org.springframework.web.bind.annotation.PathVariable in project metasfresh-webui-api by metasfresh.
the class BoardRestController method getBoard.
@GetMapping("/{boardId}")
public JSONBoard getBoard(@PathVariable("boardId") final int boardId) {
userSession.assertLoggedIn();
final String adLanguage = userSession.getAD_Language();
final BoardDescriptor boardDescriptor = boardsRepo.getBoardDescriptor(boardId);
final Multimap<Integer, JSONBoardCard> cardsByLaneId = boardsRepo.getCards(boardId).stream().map(card -> JSONBoardCard.of(card, adLanguage)).collect(GuavaCollectors.toImmutableListMultimap(JSONBoardCard::getLaneId));
final JSONBoardBuilder jsonBoard = JSONBoard.builder().boardId(boardId).caption(boardDescriptor.getCaption().translate(adLanguage)).websocketEndpoint(boardDescriptor.getWebsocketEndpoint());
boardDescriptor.getLanes().values().stream().map(lane -> JSONBoardLane.builder().laneId(lane.getLaneId()).caption(lane.getCaption().translate(adLanguage)).cards(cardsByLaneId.get(lane.getLaneId())).build()).forEach(jsonBoard::lane);
return jsonBoard.build();
}
Aggregations