Search in sources :

Example 61 with DocumentPath

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

the class WindowRestController method deleteRootDocumentsList.

@DeleteMapping("/{windowId}")
public List<JSONDocument> deleteRootDocumentsList(// 
@PathVariable("windowId") final String windowIdStr, // 
@RequestParam(name = "ids") @ApiParam("comma separated documentIds") final String idsListStr) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final List<DocumentPath> documentPaths = DocumentPath.rootDocumentPathsList(windowId, idsListStr);
    if (documentPaths.isEmpty()) {
        throw new IllegalArgumentException("No ids provided");
    }
    return deleteDocuments(documentPaths);
}
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) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 62 with DocumentPath

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

the class WindowRestController method discardChanges.

@PostMapping("/{windowId}/{documentId}/discardChanges")
public void discardChanges(@PathVariable("windowId") final String windowIdStr, @PathVariable("documentId") final String documentIdStr) {
    userSession.assertLoggedIn();
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(WindowId.fromJson(windowIdStr), DocumentId.of(documentIdStr));
    documentCollection.invalidateRootDocument(documentPath);
}
Also used : DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) JSONDocumentPath(de.metas.ui.web.window.datatypes.json.JSONDocumentPath) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 63 with DocumentPath

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

the class WindowRestController method deleteRootDocument.

@DeleteMapping("/{windowId}/{documentId}")
public List<JSONDocument> deleteRootDocument(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentId);
    return deleteDocuments(ImmutableList.of(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) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping)

Example 64 with DocumentPath

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

the class WindowRestController method getDocumentFieldDropdown.

@GetMapping("/{windowId}/{documentId}/field/{fieldName}/dropdown")
public JSONLookupValuesList getDocumentFieldDropdown(// 
@PathVariable("windowId") final String windowIdStr, // 
@PathVariable("documentId") final String documentId, // 
@PathVariable("fieldName") final String fieldName) {
    final WindowId windowId = WindowId.fromJson(windowIdStr);
    final DocumentPath documentPath = DocumentPath.rootDocumentPath(windowId, documentId);
    return getDocumentFieldDropdown(documentPath, fieldName);
}
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 65 with DocumentPath

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

the class DocumentPermissionsHelper method checkCanEdit.

private static String checkCanEdit(@NonNull final Document document, @NonNull final IUserRolePermissions permissions) {
    // In case document type is not Window, return OK because we cannot validate
    final DocumentPath documentPath = document.getDocumentPath();
    if (documentPath.getDocumentType() != DocumentType.Window) {
        // OK
        return null;
    }
    // Check if we have window write permission
    final AdWindowId adWindowId = documentPath.getWindowId().toAdWindowIdOrNull();
    if (adWindowId != null && !permissions.checkWindowPermission(adWindowId).hasWriteAccess()) {
        return "no window edit permission";
    }
    final int adTableId = getAdTableId(document);
    if (adTableId <= 0) {
        // not table based => OK
        return null;
    }
    final int recordId = getRecordId(document);
    final ClientId adClientId = document.getClientId();
    final OrgId adOrgId = document.getOrgId();
    if (adOrgId == null) {
        // the user cleared the field; field is flagged as mandatory; until user set the field, don't make a fuss.
        return null;
    }
    return permissions.checkCanUpdate(adClientId, adOrgId, adTableId, recordId);
}
Also used : OrgId(de.metas.organization.OrgId) DocumentPath(de.metas.ui.web.window.datatypes.DocumentPath) ClientId(org.adempiere.service.ClientId) AdWindowId(org.adempiere.ad.element.api.AdWindowId)

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