Search in sources :

Example 41 with DocumentPath

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

the class WindowRestController method getDocumentReferences.

@GetMapping(value = "/{windowId}/{documentId}/{tabId}/{rowId}/references")
public JSONDocumentReferencesGroup getDocumentReferences(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr, @PathVariable("tabId") final String tabIdStr, @PathVariable("rowId") final String rowIdStr) {
    userSession.assertLoggedIn();
    // Get document references
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.includedDocumentPath(windowId, documentIdStr, tabIdStr, rowIdStr);
    final List<DocumentReference> documentReferences = documentReferencesService.getDocumentReferences(documentPath);
    final JSONOptions jsonOpts = newJSONOptions().build();
    return JSONDocumentReferencesGroup.builder().caption("References").references(JSONDocumentReference.ofList(documentReferences, jsonOpts)).build();
}
Also used : JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) DocumentReference(de.metas.ui.web.window.model.DocumentReference) JSONDocumentReference(de.metas.ui.web.window.datatypes.json.JSONDocumentReference) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 42 with DocumentPath

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

the class WindowRestController method getDocumentChangeLog.

@GetMapping("/{windowId}/{documentId}/changeLog")
public JSONDocumentChangeLog getDocumentChangeLog(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
    return getDocumentChangeLog(documentPath);
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) GetMapping(org.springframework.web.bind.annotation.GetMapping)

Example 43 with DocumentPath

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

the class DocumentAttachmentsRestController method getDocumentAttachments.

private DocumentAttachments getDocumentAttachments(final String windowIdStr, final String documentId) {
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), documentId);
    final TableRecordReference recordRef = documentDescriptorFactory.getTableRecordReference(documentPath);
    return DocumentAttachments.builder().documentPath(documentPath).recordRef(recordRef).entityDescriptor(documentDescriptorFactory.getDocumentEntityDescriptor(documentPath)).websocketPublisher(websocketPublisher).build();
}
Also used : TableRecordReference(org.adempiere.util.lang.impl.TableRecordReference) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath)

Example 44 with DocumentPath

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

the class WindowQuickInputRestController method create.

@PostMapping
public JSONDocument create(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentIdStr, // 
@PathVariable("tabId") final String tabIdStr) {
    userSession.assertLoggedIn();
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath rootDocumentPath = DocumentPath.rootDocumentPath(windowId, documentIdStr);
    final DetailId detailId = DetailId.fromJson(tabIdStr);
    return Execution.callInNewExecution("quickInput.create", () -> {
        final QuickInput quickInput = documentsCollection.forRootDocumentReadonly(rootDocumentPath, rootDocument -> {
            // Make sure we can edit our root document. Fail fast.
            DocumentPermissionsHelper.assertCanEdit(rootDocument, userSession.getUserRolePermissions());
            final DocumentEntityDescriptor includedDocumentDescriptor = rootDocument.getEntityDescriptor().getIncludedEntityByDetailId(detailId);
            final QuickInputDescriptor quickInputDescriptor = quickInputDescriptors.getQuickInputEntityDescriptor(includedDocumentDescriptor);
            try {
                return QuickInput.builder().setQuickInputDescriptor(quickInputDescriptor).setRootDocumentPath(rootDocument.getDocumentPath()).build().bindRootDocument(rootDocument).assertTargetWritable();
            } catch (Exception ex) {
                // see https://github.com/metasfresh/metasfresh-webui-frontend/issues/487
                throw EntityNotFoundException.wrapIfNeeded(ex);
            }
        });
        commit(quickInput);
        return JSONDocument.ofDocument(quickInput.getQuickInputDocument(), newJSONOptions());
    });
}
Also used : DetailId(de.metas.ui.web.window.descriptor.DetailId) WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) DocumentEntityDescriptor(de.metas.ui.web.window.descriptor.DocumentEntityDescriptor) EntityNotFoundException(de.metas.ui.web.exceptions.EntityNotFoundException) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 45 with DocumentPath

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

the class HUEditorRowAttributes method toJson.

@Override
public JSONViewRowAttributes toJson(final JSONOptions jsonOpts) {
    final JSONViewRowAttributes jsonDocument = new JSONViewRowAttributes(documentPath);
    final List<JSONDocumentField> jsonFields = attributesStorage.getAttributeValues().stream().map(attributeValue -> toJSONDocumentField(attributeValue, jsonOpts)).collect(Collectors.toList());
    jsonDocument.setFields(jsonFields);
    return jsonDocument;
}
Also used : X_M_Attribute(org.compiere.model.X_M_Attribute) JSONOptions(de.metas.ui.web.window.datatypes.json.JSONOptions) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) Execution(de.metas.ui.web.window.controller.Execution) Getter(lombok.Getter) JSONDocumentChangedEvent(de.metas.ui.web.window.datatypes.json.JSONDocumentChangedEvent) IAttributeStorage(de.metas.handlingunits.attribute.storage.IAttributeStorage) IHUAware(de.metas.handlingunits.IHUAware) Supplier(java.util.function.Supplier) JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) ExtendedMemorizingSupplier(org.adempiere.util.lang.ExtendedMemorizingSupplier) ProductId(de.metas.product.ProductId) LookupValueFilterPredicates(de.metas.ui.web.window.model.lookup.LookupValueFilterPredicates) IAttributeStorageListener(de.metas.handlingunits.attribute.storage.IAttributeStorageListener) ViewRowAttributesLayout(de.metas.ui.web.view.descriptor.ViewRowAttributesLayout) DocumentFieldReadonlyException(de.metas.ui.web.window.exceptions.DocumentFieldReadonlyException) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField) IAttributeValueContext(org.adempiere.mm.attributes.spi.IAttributeValueContext) LookupValuesList(de.metas.ui.web.window.datatypes.LookupValuesList) DateTimeConverters(de.metas.ui.web.window.datatypes.json.DateTimeConverters) I_M_HU(de.metas.handlingunits.model.I_M_HU) LookupValue(de.metas.ui.web.window.datatypes.LookupValue) MutableDocumentFieldChangedEvent(de.metas.ui.web.window.model.MutableDocumentFieldChangedEvent) Check(de.metas.util.Check) I_M_Attribute(org.compiere.model.I_M_Attribute) ImmutableSet(com.google.common.collect.ImmutableSet) JSONLayoutWidgetType(de.metas.ui.web.window.datatypes.json.JSONLayoutWidgetType) DefaultAttributeValueContext(org.adempiere.mm.attributes.spi.impl.DefaultAttributeValueContext) NonNull(lombok.NonNull) Collection(java.util.Collection) IAttributeValue(de.metas.handlingunits.attribute.IAttributeValue) MoreObjects(com.google.common.base.MoreObjects) AttributeConstants(org.adempiere.mm.attributes.api.AttributeConstants) EqualsAndHashCode(lombok.EqualsAndHashCode) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) UserSession(de.metas.ui.web.session.UserSession) HUAttributeConstants(de.metas.handlingunits.attribute.HUAttributeConstants) List(java.util.List) X_M_HU(de.metas.handlingunits.model.X_M_HU) IDocumentChangesCollector(de.metas.ui.web.window.model.IDocumentChangesCollector) LocalDate(java.time.LocalDate) DocumentFieldWidgetType(de.metas.ui.web.window.descriptor.DocumentFieldWidgetType) Optional(java.util.Optional) IViewRowAttributes(de.metas.ui.web.view.IViewRowAttributes) JSONViewRowAttributes(de.metas.ui.web.view.json.JSONViewRowAttributes) JSONDocumentField(de.metas.ui.web.window.datatypes.json.JSONDocumentField)

Aggregations

DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)65 WindowId (de.metas.ui.web.window.datatypes.WindowId)29 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)22 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)20 GetMapping (org.springframework.web.bind.annotation.GetMapping)14 List (java.util.List)13 ImmutableList (com.google.common.collect.ImmutableList)12 ImmutableSet (com.google.common.collect.ImmutableSet)12 DetailId (de.metas.ui.web.window.descriptor.DetailId)12 Set (java.util.Set)11 NonNull (lombok.NonNull)10 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)10 AdempiereException (org.adempiere.exceptions.AdempiereException)9 PostMapping (org.springframework.web.bind.annotation.PostMapping)9 DocumentIdsSelection (de.metas.ui.web.window.datatypes.DocumentIdsSelection)8 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)8 Document (de.metas.ui.web.window.model.Document)7 ViewId (de.metas.ui.web.view.ViewId)6 Services (de.metas.util.Services)6 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)5