use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class ViewsRepository method createFactoriesMap.
private static ImmutableMap<ArrayKey, IViewFactory> createFactoriesMap(final Collection<IViewFactory> viewFactories) {
final Map<ArrayKey, IViewFactory> factories = new HashMap<>();
for (final IViewFactory factory : viewFactories) {
final ViewFactory annotation = factory.getClass().getAnnotation(ViewFactory.class);
if (annotation == null) {
// this might be a development bug
logger.warn("Skip {} because it's not annotated with {}", factory, ViewFactory.class);
continue;
}
final WindowId windowId = WindowId.fromJson(annotation.windowId());
JSONViewDataType[] viewTypes = annotation.viewTypes();
if (viewTypes.length == 0) {
viewTypes = JSONViewDataType.values();
}
for (final JSONViewDataType viewType : viewTypes) {
factories.put(mkFactoryKey(windowId, viewType), factory);
}
}
return ImmutableMap.copyOf(factories);
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class ViewsRepository method createView.
@Override
public IView createView(final CreateViewRequest request) {
logger.trace("Creating new view from {}", request);
final WindowId windowId = request.getViewId().getWindowId();
final JSONViewDataType viewType = request.getViewType();
final IViewFactory factory = getFactory(windowId, viewType);
final IView view = factory.createView(request);
if (view == null) {
throw new AdempiereException("Failed creating view").setParameter("request", request).setParameter("factory", factory.toString());
}
getViewsStorageFor(view.getViewId()).put(view);
logger.trace("Created view {}", view);
return view;
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class ViewRestController method getAvailableViewProfiles.
@GetMapping("/availableProfiles")
public JSONViewProfilesList getAvailableViewProfiles(@PathVariable(PARAM_WindowId) final String windowIdStr, @RequestParam(name = PARAM_ViewDataType, required = true) final JSONViewDataType viewDataType) {
final WindowId windowId = WindowId.fromJson(windowIdStr);
final List<ViewProfile> availableProfiles = viewsRepo.getAvailableProfiles(windowId, viewDataType);
return JSONViewProfilesList.of(availableProfiles, userSession.getAD_Language());
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class ViewRestController method extractWindowId.
private static final WindowId extractWindowId(final String pathWindowIdStr, final WindowId requestWindowId) {
final WindowId pathWindowId = WindowId.fromNullableJson(pathWindowIdStr);
WindowId windowIdEffective = requestWindowId;
if (windowIdEffective == null) {
windowIdEffective = WindowId.fromJson(pathWindowIdStr);
} else if (!Objects.equals(pathWindowId, windowIdEffective)) {
throw new IllegalArgumentException("Request's windowId is not matching the one from path");
}
return windowIdEffective;
}
use of de.metas.ui.web.window.datatypes.WindowId in project metasfresh-webui-api by metasfresh.
the class ViewRestController method getViewLayout.
@GetMapping("/layout")
public ResponseEntity<JSONViewLayout> getViewLayout(@PathVariable(PARAM_WindowId) final String windowIdStr, @RequestParam(name = PARAM_ViewDataType, required = true) final JSONViewDataType viewDataType, @RequestParam(name = "profileId", required = false) final String profileIdStr, final WebRequest request) {
userSession.assertLoggedIn();
final WindowId windowId = WindowId.fromJson(windowIdStr);
final ViewLayout viewLayout = viewsRepo.getViewLayout(windowId, viewDataType, ViewProfileId.fromJson(profileIdStr));
return ETagResponseEntityBuilder.ofETagAware(request, viewLayout).includeLanguageInETag().cacheMaxAge(userSession.getHttpCacheMaxAge()).jsonOptions(() -> newJSONOptions()).toJson(JSONViewLayout::of);
}
Aggregations