use of com.haulmont.cuba.security.entity.ScreenHistoryEntity in project cuba by cuba-platform.
the class ScreenHistorySupport method saveScreenHistory.
public void saveScreenHistory(Window window, WindowManager.OpenMode openMode) {
Security security = AppBeans.get(Security.NAME);
if (security.isEntityOpPermitted(ScreenHistoryEntity.class, EntityOp.CREATE) && window.getFrame() != null && (window.getFrame() instanceof Window.Editor) && openMode != WindowManager.OpenMode.DIALOG && (screenIds == null || screenIds.contains(window.getId()))) {
String caption = window.getCaption();
UUID entityId = null;
Frame frame = window.getFrame();
Entity entity = null;
if (frame instanceof Window.Editor) {
entity = ((Window.Editor) frame).getItem();
if (entity != null) {
if (PersistenceHelper.isNew(entity)) {
return;
}
if (StringUtils.isBlank(caption))
caption = messages.getTools().getEntityCaption(entity.getMetaClass()) + " " + entity.getInstanceName();
entityId = (UUID) entity.getId();
}
}
ScreenHistoryEntity screenHistoryEntity = metadata.create(ScreenHistoryEntity.class);
screenHistoryEntity.setCaption(StringUtils.abbreviate(caption, 255));
screenHistoryEntity.setUrl(makeLink(window));
screenHistoryEntity.setEntityId(entityId);
addAdditionalFields(screenHistoryEntity, entity);
CommitContext cc = new CommitContext(Collections.singleton(screenHistoryEntity));
DataService dataService = AppBeans.get(DataService.NAME);
dataService.commit(cc);
}
}
use of com.haulmont.cuba.security.entity.ScreenHistoryEntity in project cuba by cuba-platform.
the class ScreenHistorySupport method saveScreenHistory.
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();
Object 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 = referenceToEntitySupport.getReferenceIdForLink(entity);
}
ScreenHistoryEntity screenHistoryEntity = metadata.create(ScreenHistoryEntity.class);
screenHistoryEntity.setCaption(StringUtils.abbreviate(caption, 255));
screenHistoryEntity.setUrl(makeLink(frameOwner));
screenHistoryEntity.setObjectEntityId(entityId);
addAdditionalFields(screenHistoryEntity, entity);
CommitContext cc = new CommitContext(Collections.singleton(screenHistoryEntity));
dataManager.commit(cc);
}
}
use of com.haulmont.cuba.security.entity.ScreenHistoryEntity in project cuba by cuba-platform.
the class ScreenHistoryBrowse method openUrl.
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();
}
}
use of com.haulmont.cuba.security.entity.ScreenHistoryEntity in project cuba by cuba-platform.
the class ScreenHistoryBrowse method init.
@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() : ""));
}
Aggregations