protected void openUrl(Entity entity) { ScreenHistoryEntity screenHistoryEntity = (ScreenHistoryEntity) entity; Map<String, String> paramsScreen = new HashMap<>(); String url = screenHistoryEntity.getUrl(); url = url.substring(url.indexOf("\u003f") + 1); paramsScreen.put("local", "true"); String[] params = url.split("&"); for (String param : params) { String name = param.split("=")[0]; String value = param.split("=")[1]; paramsScreen.put(name, value); } List<String> actions = configuration.getConfig(WebConfig.class).getLinkHandlerActions(); LinkHandler linkHandler = AppBeans.getPrototype(LinkHandler.NAME, App.getInstance(), actions.isEmpty() ? "open" : actions.get(0), paramsScreen); if (linkHandler.canHandleLink()) { linkHandler.handle(); } } }
@PostConstruct protected void init() { UserSession userSession = AppBeans.get(UserSessionSource.class).getUserSession(); setUser(userSession.getUser()); setSubstitutedUser(userSession.getSubstitutedUser()); } }
public void saveScreenHistory(Screen frameOwner) { WindowContext windowContext = frameOwner.getWindow().getContext(); if (security.isEntityOpPermitted(ScreenHistoryEntity.class, EntityOp.CREATE) && (frameOwner instanceof EditorScreen) && windowContext.getLaunchMode() != OpenMode.DIALOG && (screenIds.contains(frameOwner.getId()))) { String caption = frameOwner.getWindow().getCaption(); UUID entityId = null; Entity entity = ((EditorScreen) frameOwner).getEditedEntity(); if (entity != null) { if (PersistenceHelper.isNew(entity)) { return; } if (StringUtils.isBlank(caption)) { caption = messages.getTools().getEntityCaption(entity.getMetaClass()) + " " + metadata.getTools().getInstanceName(entity); } entityId = (UUID) entity.getId(); } ScreenHistoryEntity screenHistoryEntity = metadata.create(ScreenHistoryEntity.class); screenHistoryEntity.setCaption(StringUtils.abbreviate(caption, 255)); screenHistoryEntity.setUrl(makeLink(frameOwner)); screenHistoryEntity.setEntityId(entityId); addAdditionalFields(screenHistoryEntity, entity); CommitContext cc = new CommitContext(Collections.singleton(screenHistoryEntity)); dataManager.commit(cc); } }
@Override public void init(Map<String, Object> params) { LinkColumnHelper.initColumn(historyTable, "caption", entity -> { close("windowClose"); openUrl(entity); }); historyTable.addAction(new ShowLinkAction(historyTable.getDatasource(), entity -> entity != null ? ((ScreenHistoryEntity) entity).getUrl() : "") ); }