Search in sources :

Example 1 with PathVariable

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));
}
Also used : ZipOutputStream(java.util.zip.ZipOutputStream) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) URLDecoder(java.net.URLDecoder) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) ModelInfo(org.eclipse.vorto.repository.api.ModelInfo) IModelRepository(org.eclipse.vorto.repository.core.IModelRepository) Value(org.springframework.beans.factory.annotation.Value) Logger(org.apache.log4j.Logger) ApiOperation(io.swagger.annotations.ApiOperation) AbstractRepositoryController(org.eclipse.vorto.repository.web.AbstractRepositoryController) ByteArrayInputStream(java.io.ByteArrayInputStream) AbstractModel(org.eclipse.vorto.repository.api.AbstractModel) Api(io.swagger.annotations.Api) ZipEntry(java.util.zip.ZipEntry) ModelId(org.eclipse.vorto.repository.api.ModelId) UploadTooLargeException(org.eclipse.vorto.repository.web.core.exceptions.UploadTooLargeException) ContentType(org.eclipse.vorto.repository.core.IModelRepository.ContentType) HttpServletResponse(javax.servlet.http.HttpServletResponse) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) RestController(org.springframework.web.bind.annotation.RestController) ModelNotFoundException(org.eclipse.vorto.repository.api.exception.ModelNotFoundException) IModelWorkspace(org.eclipse.vorto.server.commons.reader.IModelWorkspace) Objects(java.util.Objects) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) ApiResponse(io.swagger.annotations.ApiResponse) Optional(java.util.Optional) MultipartFile(org.springframework.web.multipart.MultipartFile) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ModelInfo(org.eclipse.vorto.repository.api.ModelInfo) ZipInputStream(java.util.zip.ZipInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ModelNotFoundException(org.eclipse.vorto.repository.api.exception.ModelNotFoundException) IModelWorkspace(org.eclipse.vorto.server.commons.reader.IModelWorkspace) MappingModel(org.eclipse.vorto.core.api.model.mapping.MappingModel) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with PathVariable

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;
}
Also used : VolumeMetered(org.talend.dataprep.metrics.VolumeMetered) RequestParam(org.springframework.web.bind.annotation.RequestParam) ImportBuilder(org.talend.dataprep.api.dataset.Import.ImportBuilder) FormatFamilyFactory(org.talend.dataprep.schema.FormatFamilyFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) StringUtils(org.apache.commons.lang3.StringUtils) TEXT_PLAIN_VALUE(org.springframework.http.MediaType.TEXT_PLAIN_VALUE) SortAndOrderHelper.getDataSetMetadataComparator(org.talend.dataprep.util.SortAndOrderHelper.getDataSetMetadataComparator) Collections.singletonList(java.util.Collections.singletonList) SemanticDomain(org.talend.dataprep.api.dataset.statistics.SemanticDomain) BeanConversionService(org.talend.dataprep.conversions.BeanConversionService) PipedInputStream(java.io.PipedInputStream) DistributedLock(org.talend.dataprep.lock.DistributedLock) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) DataprepBundle.message(org.talend.dataprep.i18n.DataprepBundle.message) UserData(org.talend.dataprep.api.user.UserData) TaskExecutor(org.springframework.core.task.TaskExecutor) MAX_STORAGE_MAY_BE_EXCEEDED(org.talend.dataprep.exception.error.DataSetErrorCodes.MAX_STORAGE_MAY_BE_EXCEEDED) DataSet(org.talend.dataprep.api.dataset.DataSet) LocalStoreLocation(org.talend.dataprep.api.dataset.location.LocalStoreLocation) FormatFamily(org.talend.dataprep.schema.FormatFamily) Resource(javax.annotation.Resource) Set(java.util.Set) DatasetUpdatedEvent(org.talend.dataprep.dataset.event.DatasetUpdatedEvent) RestController(org.springframework.web.bind.annotation.RestController) QuotaService(org.talend.dataprep.dataset.store.QuotaService) Stream(java.util.stream.Stream) StreamSupport.stream(java.util.stream.StreamSupport.stream) FlagNames(org.talend.dataprep.api.dataset.row.FlagNames) UNEXPECTED_CONTENT(org.talend.dataprep.exception.error.CommonErrorCodes.UNEXPECTED_CONTENT) Analyzers(org.talend.dataquality.common.inference.Analyzers) DataSetLocatorService(org.talend.dataprep.api.dataset.location.locator.DataSetLocatorService) Callable(java.util.concurrent.Callable) Schema(org.talend.dataprep.schema.Schema) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) RequestBody(org.springframework.web.bind.annotation.RequestBody) DataSetLocationService(org.talend.dataprep.api.dataset.location.DataSetLocationService) AnalyzerService(org.talend.dataprep.quality.AnalyzerService) UserDataRepository(org.talend.dataprep.user.store.UserDataRepository) Markers(org.talend.dataprep.log.Markers) Api(io.swagger.annotations.Api) DraftValidator(org.talend.dataprep.schema.DraftValidator) HttpResponseContext(org.talend.dataprep.http.HttpResponseContext) Sort(org.talend.dataprep.util.SortAndOrderHelper.Sort) IOException(java.io.IOException) PipedOutputStream(java.io.PipedOutputStream) FormatAnalysis(org.talend.dataprep.dataset.service.analysis.synchronous.FormatAnalysis) ContentAnalysis(org.talend.dataprep.dataset.service.analysis.synchronous.ContentAnalysis) SchemaAnalysis(org.talend.dataprep.dataset.service.analysis.synchronous.SchemaAnalysis) HttpStatus(org.springframework.http.HttpStatus) FilterService(org.talend.dataprep.api.filter.FilterService) Marker(org.slf4j.Marker) NullOutputStream(org.apache.commons.io.output.NullOutputStream) StatisticsAdapter(org.talend.dataprep.dataset.StatisticsAdapter) Timed(org.talend.dataprep.metrics.Timed) ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) PathVariable(org.springframework.web.bind.annotation.PathVariable) DataSetMetadataBuilder(org.talend.dataprep.dataset.DataSetMetadataBuilder) URLDecoder(java.net.URLDecoder) DataSetErrorCodes(org.talend.dataprep.exception.error.DataSetErrorCodes) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) LoggerFactory(org.slf4j.LoggerFactory) SEMANTIC(org.talend.dataprep.quality.AnalyzerService.Analysis.SEMANTIC) ApiOperation(io.swagger.annotations.ApiOperation) UNABLE_TO_CREATE_OR_UPDATE_DATASET(org.talend.dataprep.exception.error.DataSetErrorCodes.UNABLE_TO_CREATE_OR_UPDATE_DATASET) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) StrictlyBoundedInputStream(org.talend.dataprep.dataset.store.content.StrictlyBoundedInputStream) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) UNSUPPORTED_CONTENT(org.talend.dataprep.exception.error.DataSetErrorCodes.UNSUPPORTED_CONTENT) TimeToLive(org.talend.dataprep.cache.ContentCache.TimeToLive) Order(org.talend.dataprep.util.SortAndOrderHelper.Order) Collections.emptyList(java.util.Collections.emptyList) PublicAPI(org.talend.dataprep.security.PublicAPI) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) ContentCache(org.talend.dataprep.cache.ContentCache) INVALID_DATASET_NAME(org.talend.dataprep.exception.error.DataSetErrorCodes.INVALID_DATASET_NAME) List(java.util.List) Optional(java.util.Optional) Analyzer(org.talend.dataquality.common.inference.Analyzer) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) Pattern(java.util.regex.Pattern) Security(org.talend.dataprep.security.Security) Spliterator(java.util.Spliterator) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) ComponentProperties(org.talend.dataprep.parameters.jsonschema.ComponentProperties) TDPException(org.talend.dataprep.exception.TDPException) JsonErrorCodeDescription(org.talend.dataprep.exception.json.JsonErrorCodeDescription) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) UNABLE_CREATE_DATASET(org.talend.dataprep.exception.error.DataSetErrorCodes.UNABLE_CREATE_DATASET) HashMap(java.util.HashMap) GET(org.springframework.web.bind.annotation.RequestMethod.GET) Import(org.talend.dataprep.api.dataset.Import) ExceptionContext.build(org.talend.daikon.exception.ExceptionContext.build) ExceptionContext(org.talend.daikon.exception.ExceptionContext) Charset(java.nio.charset.Charset) UpdateColumnParameters(org.talend.dataprep.dataset.service.api.UpdateColumnParameters) VersionService(org.talend.dataprep.api.service.info.VersionService) POST(org.springframework.web.bind.annotation.RequestMethod.POST) OutputStream(java.io.OutputStream) DataSetLocation(org.talend.dataprep.api.dataset.DataSetLocation) Logger(org.slf4j.Logger) LocaleContextHolder.getLocale(org.springframework.context.i18n.LocaleContextHolder.getLocale) UpdateDataSetCacheKey(org.talend.dataprep.dataset.service.cache.UpdateDataSetCacheKey) IOUtils(org.apache.commons.compress.utils.IOUtils) APPLICATION_JSON_VALUE(org.springframework.http.MediaType.APPLICATION_JSON_VALUE) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) Certification(org.talend.dataprep.api.dataset.DataSetGovernance.Certification) EncodingSupport(org.talend.dataprep.configuration.EncodingSupport) Comparator(java.util.Comparator) InputStream(java.io.InputStream) ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) DataSet(org.talend.dataprep.api.dataset.DataSet) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 3 with PathVariable

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;
    }));
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) WebRequest(org.springframework.web.context.request.WebRequest) DocumentZoomIntoInfo(de.metas.ui.web.window.model.lookup.DocumentZoomIntoInfo) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) JSONZoomInto(de.metas.ui.web.window.datatypes.json.JSONZoomInto) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) ReasonSupplier(de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier) ApiOperation(io.swagger.annotations.ApiOperation) DocumentWebsocketPublisher(de.metas.ui.web.window.events.DocumentWebsocketPublisher) IDocumentFieldView(de.metas.ui.web.window.model.IDocumentFieldView) JSONDocumentReferencesGroupList(de.metas.ui.web.window.datatypes.json.JSONDocumentReferencesGroupList) DocumentReference(de.metas.ui.web.window.model.DocumentReference) TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) PostMapping(org.springframework.web.bind.annotation.PostMapping) ImmutableSet(com.google.common.collect.ImmutableSet) Predicate(java.util.function.Predicate) HttpHeaders(org.springframework.http.HttpHeaders) MediaType(org.springframework.http.MediaType) DocumentDescriptor(de.metas.ui.web.window.descriptor.DocumentDescriptor) Set(java.util.Set) ProcessRestController(de.metas.ui.web.process.ProcessRestController) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) UserSession(de.metas.ui.web.session.UserSession) Services(org.adempiere.util.Services) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) DocumentPrint(de.metas.ui.web.window.model.DocumentCollection.DocumentPrint) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) IMsgBL(de.metas.i18n.IMsgBL) MenuTreeRepository(de.metas.ui.web.menu.MenuTreeRepository) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) IADTableDAO(org.adempiere.ad.table.api.IADTableDAO) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) DocumentReferencesService(de.metas.ui.web.window.model.DocumentReferencesService) WebConfig(de.metas.ui.web.config.WebConfig) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ButtonFieldActionDescriptor(de.metas.ui.web.window.descriptor.ButtonFieldActionDescriptor) MenuTree(de.metas.ui.web.menu.MenuTree) InvalidDocumentPathException(de.metas.ui.web.window.exceptions.InvalidDocumentPathException) PatchMapping(org.springframework.web.bind.annotation.PatchMapping) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) RequestBody(org.springframework.web.bind.annotation.RequestBody) ImmutableList(com.google.common.collect.ImmutableList) DetailId(de.metas.ui.web.window.descriptor.DetailId) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONDocumentReferencesGroup(de.metas.ui.web.window.datatypes.json.JSONDocumentReferencesGroup) NewRecordDescriptorsProvider(de.metas.ui.web.window.descriptor.factory.NewRecordDescriptorsProvider) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) Api(io.swagger.annotations.Api) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) WindowId(de.metas.ui.web.window.datatypes.WindowId) ETagResponseEntityBuilder(de.metas.ui.web.cache.ETagResponseEntityBuilder) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) HttpStatus(org.springframework.http.HttpStatus) JSONDocumentActionsList(de.metas.ui.web.process.json.JSONDocumentActionsList) DocumentPreconditionsAsContext(de.metas.ui.web.process.DocumentPreconditionsAsContext) AdempiereException(org.adempiere.exceptions.AdempiereException) JSONDocumentReference(de.metas.ui.web.window.datatypes.json.JSONDocumentReference) ResponseEntity(org.springframework.http.ResponseEntity) JSONDocumentLayout(de.metas.ui.web.window.datatypes.json.JSONDocumentLayout) Document(de.metas.ui.web.window.model.Document) WindowId(de.metas.ui.web.window.datatypes.WindowId) AdempiereException(org.adempiere.exceptions.AdempiereException) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 4 with PathVariable

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);
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) WebRequest(org.springframework.web.context.request.WebRequest) Env(org.compiere.util.Env) Autowired(org.springframework.beans.factory.annotation.Autowired) DocumentCollection(de.metas.ui.web.window.model.DocumentCollection) OpenReportAction(de.metas.ui.web.process.ProcessInstanceResult.OpenReportAction) ReasonSupplier(de.metas.ui.web.window.model.IDocumentChangesCollector.ReasonSupplier) IView(de.metas.ui.web.view.IView) ProcessDescriptor(de.metas.ui.web.process.descriptor.ProcessDescriptor) Util(org.compiere.util.Util) HttpHeaders(org.springframework.http.HttpHeaders) NonNull(lombok.NonNull) Collection(java.util.Collection) MediaType(org.springframework.http.MediaType) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) UserSession(de.metas.ui.web.session.UserSession) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) List(java.util.List) Stream(java.util.stream.Stream) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) JSONDocument(de.metas.ui.web.window.datatypes.json.JSONDocument) JSONProcessLayout(de.metas.ui.web.process.json.JSONProcessLayout) IViewsRepository(de.metas.ui.web.view.IViewsRepository) LogManager(de.metas.logging.LogManager) JSONProcessInstanceResult(de.metas.ui.web.process.json.JSONProcessInstanceResult) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) WebConfig(de.metas.ui.web.config.WebConfig) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) Execution(de.metas.ui.web.window.controller.Execution) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) NullDocumentChangesCollector(de.metas.ui.web.window.model.NullDocumentChangesCollector) RequestBody(org.springframework.web.bind.annotation.RequestBody) JSONCreateProcessInstanceRequest(de.metas.ui.web.process.json.JSONCreateProcessInstanceRequest) JSONProcessInstance(de.metas.ui.web.process.json.JSONProcessInstance) Api(io.swagger.annotations.Api) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ViewRowIdsSelection(de.metas.ui.web.view.ViewRowIdsSelection) Logger(org.slf4j.Logger) ETagResponseEntityBuilder(de.metas.ui.web.cache.ETagResponseEntityBuilder) ApplicationContext(org.springframework.context.ApplicationContext) WebuiRelatedProcessDescriptor(de.metas.ui.web.process.descriptor.WebuiRelatedProcessDescriptor) HttpStatus(org.springframework.http.HttpStatus) Check(org.adempiere.util.Check) ResponseEntity(org.springframework.http.ResponseEntity) ViewId(de.metas.ui.web.view.ViewId) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with PathVariable

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();
}
Also used : JSONNewCardsViewLayout(de.metas.ui.web.board.json.JSONNewCardsViewLayout) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) JSONDocumentFilterDescriptor(de.metas.ui.web.document.filter.json.JSONDocumentFilterDescriptor) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) ApiOperation(io.swagger.annotations.ApiOperation) IView(de.metas.ui.web.view.IView) Map(java.util.Map) ViewRowOverridesHelper(de.metas.ui.web.view.ViewRowOverridesHelper) IViewRowOverrides(de.metas.ui.web.view.IViewRowOverrides) ViewLayout(de.metas.ui.web.view.descriptor.ViewLayout) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) JSONBoardCardOrderBy(de.metas.ui.web.board.json.JSONBoardCardOrderBy) ViewResult(de.metas.ui.web.view.ViewResult) PostMapping(org.springframework.web.bind.annotation.PostMapping) Predicate(java.util.function.Predicate) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) RestController(org.springframework.web.bind.annotation.RestController) JSONLookupValuesList(de.metas.ui.web.window.datatypes.json.JSONLookupValuesList) JSONBoardCardAddRequest(de.metas.ui.web.board.json.JSONBoardCardAddRequest) UserSession(de.metas.ui.web.session.UserSession) List(java.util.List) IViewsRepository(de.metas.ui.web.view.IViewsRepository) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) BoardCardChangeRequestBuilder(de.metas.ui.web.board.BoardCardChangeRequest.BoardCardChangeRequestBuilder) WebConfig(de.metas.ui.web.config.WebConfig) GuavaCollectors(org.adempiere.util.GuavaCollectors) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) JSONViewDataType(de.metas.ui.web.view.json.JSONViewDataType) Multimap(com.google.common.collect.Multimap) PatchMapping(org.springframework.web.bind.annotation.PatchMapping) RequestBody(org.springframework.web.bind.annotation.RequestBody) JSONBoardCard(de.metas.ui.web.board.json.JSONBoardCard) ImmutableList(com.google.common.collect.ImmutableList) JSONBoardBuilder(de.metas.ui.web.board.json.JSONBoard.JSONBoardBuilder) GetMapping(org.springframework.web.bind.annotation.GetMapping) JSONFilterViewRequest(de.metas.ui.web.view.json.JSONFilterViewRequest) JSONBoard(de.metas.ui.web.board.json.JSONBoard) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) WeakHashMap(java.util.WeakHashMap) DocumentIdsSelection(de.metas.ui.web.window.datatypes.DocumentIdsSelection) ViewProfileId(de.metas.ui.web.view.ViewProfileId) AdempiereException(org.adempiere.exceptions.AdempiereException) FixedOrderByKeyComparator(org.adempiere.util.comparator.FixedOrderByKeyComparator) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) JSONBoardLane(de.metas.ui.web.board.json.JSONBoardLane) ViewChangesCollector(de.metas.ui.web.view.event.ViewChangesCollector) CreateViewRequest(de.metas.ui.web.view.CreateViewRequest) Collections(java.util.Collections) ViewId(de.metas.ui.web.view.ViewId) JSONBoardCard(de.metas.ui.web.board.json.JSONBoardCard) JSONBoardBuilder(de.metas.ui.web.board.json.JSONBoard.JSONBoardBuilder) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Aggregations

PathVariable (org.springframework.web.bind.annotation.PathVariable)73 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)55 List (java.util.List)51 RequestParam (org.springframework.web.bind.annotation.RequestParam)44 Collectors (java.util.stream.Collectors)43 RequestMethod (org.springframework.web.bind.annotation.RequestMethod)39 Autowired (org.springframework.beans.factory.annotation.Autowired)36 RestController (org.springframework.web.bind.annotation.RestController)34 RequestBody (org.springframework.web.bind.annotation.RequestBody)33 MediaType (org.springframework.http.MediaType)32 IOException (java.io.IOException)30 ApiOperation (io.swagger.annotations.ApiOperation)27 HttpServletResponse (javax.servlet.http.HttpServletResponse)27 Set (java.util.Set)26 HttpStatus (org.springframework.http.HttpStatus)25 Map (java.util.Map)24 GetMapping (org.springframework.web.bind.annotation.GetMapping)24 Optional (java.util.Optional)22 HttpServletRequest (javax.servlet.http.HttpServletRequest)21 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)21