Search in sources :

Example 66 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class AddressRepository method processAddressDocumentChanges.

public void processAddressDocumentChanges(final int addressDocIdInt, final List<JSONDocumentChangedEvent> events, final IDocumentChangesCollector changesCollector) {
    final DocumentId addressDocId = DocumentId.of(addressDocIdInt);
    final Document addressDoc = getAddressDocumentForWriting(addressDocId, changesCollector);
    addressDoc.processValueChanges(events, REASON_ProcessAddressDocumentChanges);
    Services.get(ITrxManager.class).getCurrentTrxListenerManagerOrAutoCommit().newEventListener(TrxEventTiming.AFTER_COMMIT).registerHandlingMethod(trx -> putAddressDocument(addressDoc));
}
Also used : ITrxManager(org.adempiere.ad.trx.api.ITrxManager) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) Document(de.metas.ui.web.window.model.Document)

Example 67 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class DocumentAttachmentsRestController method getAttachmentById.

@GetMapping("/{id}")
public ResponseEntity<byte[]> getAttachmentById(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId, @PathVariable("id") final String entryIdStr) {
    userSession.assertLoggedIn();
    final DocumentId entryId = DocumentId.of(entryIdStr);
    final IDocumentAttachmentEntry entry = getDocumentAttachments(windowIdStr, documentId).getEntry(entryId);
    final AttachmentEntryType type = entry.getType();
    if (type == AttachmentEntryType.Data) {
        return extractResponseEntryFromData(entry);
    } else if (type == AttachmentEntryType.URL) {
        return extractResponseEntryFromURL(entry);
    } else {
        throw new AdempiereException("Invalid attachment entry").setParameter("reason", "invalid type").setParameter("type", type).setParameter("entry", entry);
    }
}
Also used : AttachmentEntryType(de.metas.attachments.AttachmentEntryType) AdempiereException(org.adempiere.exceptions.AdempiereException) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 68 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class DocumentAttachmentsRestController method deleteAttachmentById.

@DeleteMapping("/{id}")
public void deleteAttachmentById(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId, // 
@PathVariable("id") final String entryIdStr) {
    userSession.assertLoggedIn();
    final DocumentId entryId = DocumentId.of(entryIdStr);
    getDocumentAttachments(windowIdStr, documentId).deleteEntry(entryId);
}
Also used : DocumentId(de.metas.ui.web.window.datatypes.DocumentId) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 69 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class ProcessRestController method getReport.

@RequestMapping(value = "/{processId}/{pinstanceId}/print/{filename:.*}", method = RequestMethod.GET)
public ResponseEntity<byte[]> getReport(// 
@PathVariable("processId") final String processIdStr, // 
@PathVariable("pinstanceId") final String pinstanceIdStr, // 
@PathVariable("filename") final String filename) {
    userSession.assertLoggedIn();
    final ProcessId processId = ProcessId.fromJson(processIdStr);
    final DocumentId pinstanceId = DocumentId.of(pinstanceIdStr);
    final IProcessInstancesRepository instancesRepository = getRepository(processId);
    final ProcessInstanceResult executionResult = instancesRepository.forProcessInstanceReadonly(pinstanceId, processInstance -> processInstance.getExecutionResult());
    final OpenReportAction action = executionResult.getAction(OpenReportAction.class);
    final String reportFilename = action.getFilename();
    final String reportContentType = action.getContentType();
    final byte[] reportData = action.getReportData();
    final String reportFilenameEffective = Util.coalesce(filename, reportFilename, "");
    final HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.parseMediaType(reportContentType));
    headers.set(HttpHeaders.CONTENT_DISPOSITION, "inline; filename=\"" + reportFilenameEffective + "\"");
    headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
    final ResponseEntity<byte[]> response = new ResponseEntity<>(reportData, headers, HttpStatus.OK);
    return response;
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) JSONProcessInstanceResult(de.metas.ui.web.process.json.JSONProcessInstanceResult) DocumentId(de.metas.ui.web.window.datatypes.DocumentId) OpenReportAction(de.metas.ui.web.process.ProcessInstanceResult.OpenReportAction) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 70 with DocumentId

use of de.metas.ui.web.window.datatypes.DocumentId in project metasfresh-webui-api by metasfresh.

the class ProcessRestController method getParameterDropdown.

@RequestMapping(value = "/{processId}/{pinstanceId}/field/{parameterName}/dropdown", method = RequestMethod.GET)
public JSONLookupValuesList getParameterDropdown(// 
@PathVariable("processId") final String processIdStr, // 
@PathVariable("pinstanceId") final String pinstanceIdStr, // 
@PathVariable("parameterName") final String parameterName) {
    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.getParameterLookupValues(parameterName)).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)

Aggregations

DocumentId (de.metas.ui.web.window.datatypes.DocumentId)99 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)18 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)14 List (java.util.List)14 ImmutableList (com.google.common.collect.ImmutableList)12 GetMapping (org.springframework.web.bind.annotation.GetMapping)12 AdempiereException (org.adempiere.exceptions.AdempiereException)11 JSONLookupValuesList (de.metas.ui.web.window.datatypes.json.JSONLookupValuesList)9 ArrayList (java.util.ArrayList)9 Set (java.util.Set)9 NonNull (lombok.NonNull)9 Test (org.junit.Test)9 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)9 UserSession (de.metas.ui.web.session.UserSession)8 ViewId (de.metas.ui.web.view.ViewId)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)8 IDocumentChangesCollector (de.metas.ui.web.window.model.IDocumentChangesCollector)8 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)8 Autowired (org.springframework.beans.factory.annotation.Autowired)8