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());
}
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);
}
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);
}
}
Aggregations