/** * {@inheritDoc} */ @Override public IApplicationSession getApplicationSession() { return getBackendController().getApplicationSession(); }
/** * {@inheritDoc} */ @Override protected void invokeNlsSetter(Object proxy, IStringPropertyDescriptor propertyDescriptor, String translatedValue) { setNlsPropertyValue(proxy, propertyDescriptor, translatedValue, getBackendController().getEntityFactory(), getBackendController().getLocale()); } }
/** * Executes a backend action. * * @param action * the backend action to execute. * @param initialContext * the initial action context. * @param subject * the JAAS subject to execute the action for. * @param locale * the locale used to execute the action. * @return true if the action execution was successful. */ protected boolean executeAction(BackendAction action, Map<String, Object> initialContext, Subject subject, Locale locale) { configureApplicationSession(subject, locale); Map<String, Object> startupActionContext = new HashMap<>(); startupActionContext.putAll(getBackendController() .getInitialActionContext()); startupActionContext.putAll(initialContext); boolean success = getBackendController().execute(action, startupActionContext); return success; }
/** * Binds to the backend controller and ask it to start. * <p> * {@inheritDoc} */ @Override public boolean start(IBackendController peerController, Locale theClientLocale, TimeZone theClientTimeZone) { this.clientLocale = theClientLocale; Locale initialLocale = theClientLocale; if (forcedStartingLocale != null) { initialLocale = LocaleUtils.toLocale(forcedStartingLocale); } started = peerController.start(initialLocale, theClientTimeZone); peerController.addDirtInterceptor(dirtInterceptor); BackendControllerHolder.setSessionBackendController(peerController); return started; }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { if (getBackendController(context).isUnitOfWorkActive()) { getBackendController(context).rollbackUnitOfWork(); } return actionHandler.execute(delegate, context); }
/** * {@inheritDoc} */ @Override protected void displayWorkspace(String workspaceName) { if (workspaceViews == null) { workspaceViews = new HashSet<String>(); } if (!workspaceViews.contains(workspaceName)) { IViewDescriptor workspaceViewDescriptor = getWorkspace(workspaceName) .getViewDescriptor(); IValueConnector workspaceConnector = getBackendController() .getWorkspaceConnector(workspaceName); IView<SComponent> workspaceView = createWorkspaceView(workspaceName, workspaceViewDescriptor, (Workspace) workspaceConnector .getConnectorValue()); // getViewFactory().decorateWithTitle(moduleView, getLocale()); workspaceViews.add(workspaceName); cardPanel.add(workspaceView.getPeer(), workspaceName); getMvcBinder().bind(workspaceView.getConnector(), workspaceConnector); } setSelectedWorkspaceName(workspaceName); }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { List<IDisplayableAction> actions = getDialogActions(context); context.put(ModalDialogAction.DIALOG_ACTIONS, actions); IViewDescriptor editViewDescriptor = getViewDescriptor(context); IView<E> dialogView = getViewFactory(context).createView(editViewDescriptor, actionHandler, getLocale(context)); String dialogTitle = getI18nName(getTranslationProvider(context), getLocale(context)); if (dialogTitle != null && dialogTitle.length() > 0) { context.put(ModalDialogAction.DIALOG_TITLE, dialogTitle); } context.put(ModalDialogAction.DIALOG_VIEW, dialogView); Object component = getComponentToEdit(context); IModelDescriptor modelDescriptor = getEditModelDescriptor(context); if (modelDescriptor == null && editViewDescriptor instanceof ICardViewDescriptor) { ICardViewDescriptor cvd = (ICardViewDescriptor) editViewDescriptor; String cardName = cvd.getCardNameForModel(component, getBackendController(context).getApplicationSession() .getSubject()); IViewDescriptor vd = cvd.getCardViewDescriptor(cardName); modelDescriptor = vd.getModelDescriptor(); } IValueConnector componentConnector = getBackendController(context).createModelConnector(ACTION_MODEL_NAME, modelDescriptor); componentConnector.setConnectorValue(component); getMvcBinder(context).bind(dialogView.getConnector(), componentConnector); return super.execute(actionHandler, context); }
/** * This method installs the security subject into the application session. * * @param subject * the authenticated user subject. */ protected void loginSuccess(Subject subject) { getBackendController().getApplicationSession().setSubject(subject); String userPreferredLanguageCode = (String) getBackendController() .getApplicationSession().getPrincipal().getCustomProperty( UserPrincipal.LANGUAGE_PROPERTY); if (userPreferredLanguageCode != null) { getBackendController().getApplicationSession().setLocale( new Locale(userPreferredLanguageCode)); } if (workspaces != null) { for (Workspace workspace : workspaces.values()) { translateWorkspace(workspace); } getBackendController().installWorkspaces(workspaces); } }
/** * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { IValueConnector modelConnector = getBackendController(context) .createModelConnector(ACTION_MODEL_NAME, firstWizardStep.getViewDescriptor().getModelDescriptor()); Map<String, Object> wizardModelInit = (Map<String, Object>) context .get(IWizardStepDescriptor.INITIAL_WIZARD_MODEL); Map<String, Object> wizardModel = new ObjectEqualityMap<>(); if (wizardModelInit != null) { wizardModel.putAll(wizardModelInit); } completeInitialWizardModel(wizardModel, context); modelConnector.setConnectorValue(wizardModel); displayWizardStep(firstWizardStep, modelConnector, actionHandler, context, false); return super.execute(actionHandler, context); }
/** * Gets the entityFactory. * * @param context * the action context. * @return the entityFactory. */ protected IEntityFactory getEntityFactory(Map<String, Object> context) { return getController(context).getEntityFactory(); }
IValueConnector modelConnector = mockBackController.createModelConnector( IValueConnector.MODEL_CONNECTOR_PROPERTY, viewDescriptor.getModelDescriptor()); IEntityFactory entityFactory = mockBackController.getEntityFactory();
/** * {@inheritDoc} */ @Override public Locale getLocale(Map<String, Object> context) { return getController(context).getLocale(); }
/** * Gets entity. * * @param entityName * the entity name * @param id * the id * @return the entity */ @SuppressWarnings("unchecked") protected IEntity getEntity(String entityName, Serializable id) { IEntity registeredEntity = null; try { if (getBackendController().isUnitOfWorkActive()) { registeredEntity = getBackendController().getUnitOfWorkEntity((Class<? extends IEntity>) Class.forName( entityName), id); } else { registeredEntity = getBackendController().getRegisteredEntity((Class<? extends IEntity>) Class.forName( entityName), id); if (registeredEntity instanceof HibernateProxy) { HibernateProxy proxy = (HibernateProxy) registeredEntity; LazyInitializer li = proxy.getHibernateLazyInitializer(); registeredEntity = (IEntity) li.getImplementation(); } } } catch (ClassNotFoundException ex) { LOG.error("Class for entity {} was not found", entityName, ex); } return registeredEntity; }
if (entity instanceof IEntity) { IBackendController backendController = getBackendController(); if (backendController.isUnitOfWorkActive()) { Map<String, Object> properties = new HashMap<>(); for (int i = 0; i < propertyNames.length; i++) { backendController.registerEntity((IEntity) entity); } else { if (backendController.getRegisteredEntity(((IEntity) entity).getComponentContract(), id) == null) { Map<String, Object> properties = new HashMap<>(); for (int i = 0; i < propertyNames.length; i++) { if (state[i] instanceof IEntity) { IEntity refEntity = (IEntity) state[i]; IEntity mergedEntity = backendController.getRegisteredEntity(HibernateHelper.getComponentContract( refEntity), refEntity.getId()); if (mergedEntity != null && mergedEntity != refEntity) { backendController.registerEntity((IEntity) entity);
if (!backendController.isUnitOfWorkActive() && entities.hasNext()) { backendController.addDirtInterceptor(dirtInterceptor); boolean lifeCycleTriggered = triggerLifecycle(preFlushedEntities, persistedEntities, lifecycledEntities); int i = 0; backendController.removeDirtInterceptor(dirtInterceptor);
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { if (!getBackendController(context).isUnitOfWorkActive()) { getBackendController(context).beginUnitOfWork(); } try { return super.execute(actionHandler, context); } catch (RuntimeException ex) { getBackendController(context).rollbackUnitOfWork(); throw ex; } }
if (entitiesToSave != null) { IBackendController bc = getController(context); if (bc.isUnitOfWorkActive()) { entitiesToSave = bc.cloneInUnitOfWork(entitiesToSave); getController(context).registerForUpdate(entityToSave);
/** * {@inheritDoc} */ @Override protected boolean isCollectionSortOnReadEnabled() { // To prevent erratic sort of collections during flush return !getBackendController().isUnitOfWorkActive(); }
/** * displays the selected workspace. * <p> * {@inheritDoc} */ public void actionPerformed(@SuppressWarnings("unused") ActionEvent e) { try { getBackendController().checkWorkspaceAccess(workspaceName); displayWorkspace(workspaceName); } catch (SecurityException ex) { handleException(ex, null); } } }
Object selectedElement = resultConnector.getChildConnector(resultSelectedIndex).getConnectorValue(); if (selectedElement instanceof IEntity) { if (!bc.isUnitOfWorkActive()) { selectedElement = bc.merge((IEntity) selectedElement, EMergeMode.MERGE_LAZY);