Search in sources :

Example 46 with WindowId

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

the class ViewRestController method createView.

@PostMapping
public JSONViewResult createView(// 
@PathVariable(PARAM_WindowId) final String windowIdStr, // 
@RequestBody final JSONCreateViewRequest jsonRequest) {
    userSession.assertLoggedIn();
    final WindowId windowId = extractWindowId(windowIdStr, jsonRequest.getWindowId());
    final CreateViewRequest request = CreateViewRequest.builder(windowId, jsonRequest.getViewType()).setProfileId(jsonRequest.getProfileId()).setReferencingDocumentPaths(jsonRequest.getReferencingDocumentPaths()).setFiltersFromJSON(jsonRequest.getFilters()).setFilterOnlyIds(jsonRequest.getFilterOnlyIds()).setUseAutoFilters(true).build();
    final IView view = viewsRepo.createView(request);
    // 
    // Fetch result if requested
    final ViewResult result;
    if (jsonRequest.getQueryPageLength() > 0) {
        final List<DocumentQueryOrderBy> orderBys = ImmutableList.of();
        result = view.getPage(jsonRequest.getQueryFirstRow(), jsonRequest.getQueryPageLength(), orderBys);
    } else {
        result = ViewResult.ofView(view);
    }
    final IViewRowOverrides rowOverrides = ViewRowOverridesHelper.getViewRowOverrides(view);
    return JSONViewResult.of(result, rowOverrides, userSession.getAD_Language());
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) DocumentQueryOrderBy(de.metas.ui.web.window.model.DocumentQueryOrderBy) JSONCreateViewRequest(de.metas.ui.web.view.json.JSONCreateViewRequest) JSONViewResult(de.metas.ui.web.view.json.JSONViewResult) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 47 with WindowId

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

the class ViewId method ofViewIdString.

public static ViewId ofViewIdString(@NonNull final String viewIdStr, @Nullable final WindowId expectedWindowId) {
    final List<String> parts = SPLITTER.splitToList(viewIdStr);
    if (parts.size() < 2) {
        throw new AdempiereException("Invalid viewId: " + viewIdStr);
    }
    final WindowId windowId = WindowId.fromJson(parts.get(0));
    if (expectedWindowId != null) {
        Preconditions.checkArgument(Objects.equals(windowId, expectedWindowId), "Invalid windowId: %s (viewId=%s). Expected windowId was %s", windowId, viewIdStr, expectedWindowId);
    }
    return new ViewId(viewIdStr, ImmutableList.copyOf(parts), windowId);
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) AdempiereException(org.adempiere.exceptions.AdempiereException) ToString(lombok.ToString)

Example 48 with WindowId

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

the class ViewsRepository method registerViewsIndexStorages.

/**
 * @param viewsIndexStorages view index storages discovered in spring context
 */
@Autowired
private void registerViewsIndexStorages(final Collection<IViewsIndexStorage> viewsIndexStorages) {
    if (viewsIndexStorages.isEmpty()) {
        logger.info("No {} discovered", IViewsIndexStorage.class);
        return;
    }
    for (final IViewsIndexStorage viewsIndexStorage : viewsIndexStorages) {
        if (viewsIndexStorage instanceof DefaultViewsRepositoryStorage) {
            logger.warn("Skipping {} because it shall not be in spring context", viewsIndexStorage);
            continue;
        }
        final WindowId windowId = viewsIndexStorage.getWindowId();
        Check.assumeNotNull(windowId, "Parameter windowId is not null");
        viewsIndexStorage.setViewsRepository(this);
        this.viewsIndexStorages.put(windowId, viewsIndexStorage);
        logger.info("Registered {} for windowId={}", viewsIndexStorage, windowId);
    }
}
Also used : WindowId(de.metas.ui.web.window.datatypes.WindowId) Autowired(org.springframework.beans.factory.annotation.Autowired)

Aggregations

WindowId (de.metas.ui.web.window.datatypes.WindowId)48 DocumentPath (de.metas.ui.web.window.datatypes.DocumentPath)22 JSONDocumentPath (de.metas.ui.web.window.datatypes.json.JSONDocumentPath)13 GetMapping (org.springframework.web.bind.annotation.GetMapping)13 DocumentId (de.metas.ui.web.window.datatypes.DocumentId)9 DocumentEntityDescriptor (de.metas.ui.web.window.descriptor.DocumentEntityDescriptor)9 List (java.util.List)9 Set (java.util.Set)9 ImmutableList (com.google.common.collect.ImmutableList)8 ImmutableSet (com.google.common.collect.ImmutableSet)8 AdempiereException (org.adempiere.exceptions.AdempiereException)8 TableRecordReference (org.adempiere.util.lang.impl.TableRecordReference)8 NonNull (lombok.NonNull)7 Services (org.adempiere.util.Services)7 LogManager (de.metas.logging.LogManager)6 EntityNotFoundException (de.metas.ui.web.exceptions.EntityNotFoundException)6 DetailId (de.metas.ui.web.window.descriptor.DetailId)6 Logger (org.slf4j.Logger)6 Autowired (org.springframework.beans.factory.annotation.Autowired)6 JSONViewDataType (de.metas.ui.web.view.json.JSONViewDataType)5