/** * Constructs a new {@code RemoveFromModuleObjectsAction} instance. */ public RemoveFromModuleObjectsAction() { // Disable bad frontend access checks. setBadFrontendAccessChecked(false); }
/** * Finds the existing module for a module object. * * @param rootModule * the root module to start the search from. * @param moduleObject * the module object. * @param context * the action context. * @return the stack of modules containing the found module. */ @SuppressWarnings("UnusedParameters") public Stack<Module> findCurrentModule(Module rootModule, Object moduleObject, Map<String, Object> context) { Stack<Module> stack = new Stack<>(); findCurrentModule(rootModule, moduleObject, stack); return stack; }
/** * Finds the parent module where to add the selected component. * * @param component * the component to add as module object. * @param context * the action context. * @return the parent module to add the new module to. */ @SuppressWarnings("UnusedParameters") protected Module findDestinationModule(Object component, Map<String, Object> context) { Workspace workspace = getParentWorkspace(context); String moduleName = getParentModuleName(context); if (workspace == null || moduleName == null) { return getCurrentModule(context); } for (Module m : workspace.getModules()) { Module m2 = findModule(m, moduleName, null); if (m2 != null) { return m2; } } return null; }
public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { List<?> selectedModels = getActionParameter(context); if (selectedModels == null) { selectedModels = getSelectedModels(context); for (Object nextSelectedModuleObject : selectedModels) { preSelectModuleObject(nextSelectedModuleObject, context); Module parentModule = findDestinationModule(nextSelectedModuleObject, context); if (parentModule == null) { Workspace parentWorkspace = getParentWorkspace(context); String parentWorkspaceName = parentWorkspace!=null ? parentWorkspace.getName() : "null"; throw new BackendException("Destination module not found for workpace '" + parentWorkspaceName + "' and module '" + getParentModuleName(context) + "'"); IComponentDescriptor<?> beanComponentDescriptor = getBeanComponentDescriptor( parentModule, context); Module nextSubModule = createChildModule(parentModule, beanComponentDescriptor, nextSelectedModuleObject, context); int nextSubModuleIndex = -1; postSelectModuleObject(nextSelectedModuleObject, context); setActionParameter(moduleToSelect, context); return super.execute(actionHandler, context);
public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { int[] selectedIndices = getSelectedIndices(context); ICollectionConnector collectionConnector = getModelConnector(context); BeanCollectionModule module = (BeanCollectionModule) getModule(context); selectedIndice).getConnectorValue(); projectedCollection.remove(removedObject); removeFromSubModules(module, removedObject); getModelConnector(context).setConnectorValue(projectedCollection); return super.execute(actionHandler, context);
/** * Creates a new entity to add to the projected object collection. * * @param actionHandler * the action handler (generally the controller). * @param context * the action context. * @return the created entity. */ @SuppressWarnings("unchecked") protected Object createNewModuleObject(IActionHandler actionHandler, Map<String, Object> context) { IComponentDescriptor projectedComponentDescriptor = ((ICollectionDescriptorProvider<?>) getModelDescriptor(context)) .getCollectionDescriptor().getElementDescriptor(); return getEntityFactory(context).createEntityInstance( (Class<? extends IEntity>) projectedComponentDescriptor .getComponentContract()); } }
/** * Adds a new object in the projected collection. * <p> * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { BeanCollectionModule module = (BeanCollectionModule) getModule(context); List<Object> projectedCollection; if (module.getModuleObjects() == null) { projectedCollection = new ArrayList<>(); } else { projectedCollection = new ArrayList<>(module.getModuleObjects()); } Object newModuleObject = createNewModuleObject(actionHandler, context); projectedCollection.add(newModuleObject); module.setModuleObjects(projectedCollection); setSelectedModels(Collections.singleton(newModuleObject), context); return super.execute(actionHandler, context); }
/** * Checks dirty state of all the modules content and informs the user if state * is dirty. * <p> * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { Collection<Module> modulesToCheck = getModulesToCheck(context); if (modulesToCheck != null) { for (Module module : modulesToCheck) { if (module != null) { module.refreshDirtinessInDepth(getController(context).getBackendController()); } } } return super.execute(actionHandler, context); }
/** * Extracts the result list out of the module. * <p> * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override protected List<? extends IComponent> getExistingResultList( IQueryComponent queryComponent, Map<String, Object> context) { FilterableBeanCollectionModule module = (FilterableBeanCollectionModule) getModule(context); return (List<? extends IComponent>) module.getModuleObjects(); }
/** * Returns current module. * <p> * {@inheritDoc} */ @Override protected Collection<Module> getModulesToCheck(Map<String, Object> context) { Module module = getModule(context); if (module != null) { // Retrieve the top module while (module.getParent() != null) { module = module.getParent(); } } return Collections.singleton(module); } }
/** * Returns all application modules. * <p> * {@inheritDoc} */ @Override protected Collection<Module> getModulesToCheck(Map<String, Object> context) { Collection<Module> modulesToCheck = new ArrayList<>(); for (String workspaceName : getController(context).getWorkspaceNames()) { Workspace ws = getController(context).getWorkspace(workspaceName); List<Module> modules = ws.getModules(); if (modules != null) { modulesToCheck.addAll(modules); } } return modulesToCheck; } }
/** * Fills the context with the filter reference descriptor. * <p> * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { IModelValueConnector filterModelConnector = (IModelValueConnector) getModuleConnector( context).getChildConnector("filter"); context.put(ActionContextConstants.QUERY_MODEL_CONNECTOR, filterModelConnector); context.put(ActionContextConstants.COMPONENT_REF_DESCRIPTOR, filterModelConnector.getModelDescriptor()); BeanCollectionModule beanCollectionModule = (BeanCollectionModule) getModuleConnector( context).getConnectorValue(); beanCollectionModule.setModuleObjects(null); return super.execute(actionHandler, context); }
/** * Retrieves the bean component descriptor to create the child bean module. * * @param parentModule * the parent module to add the child bean module to. * @param context * the action context. * @return the bean module component descriptor. */ @SuppressWarnings("UnusedParameters") protected IComponentDescriptor<?> getBeanComponentDescriptor( Module parentModule, Map<String, Object> context) { IModelDescriptor modelDescriptor = getModelDescriptor(context); IComponentDescriptor<?> childComponentDescriptor; if (modelDescriptor instanceof ICollectionDescriptorProvider<?>) { childComponentDescriptor = ((ICollectionDescriptorProvider<?>) modelDescriptor) .getCollectionDescriptor().getElementDescriptor(); } else { childComponentDescriptor = ((IComponentDescriptorProvider<?>) modelDescriptor) .getComponentDescriptor(); } return childComponentDescriptor; }
/** * Finds the existing module for a module object or name. * * @param rootModule * the root module to start the search from. * @param moduleObject * the module object. * @param moduleName * the module name. * @return the stack of modules containing the found module. */ protected Module findModule(Module rootModule, String moduleName, Object moduleObject) { if (moduleName != null && moduleName.equals(rootModule.getName())) { return rootModule; } if (moduleObject != null && (rootModule instanceof BeanModule) && moduleObject.equals(((BeanModule) rootModule).getModuleObject())) { return rootModule; } if (rootModule.getSubModules() != null) { for (Module sub : rootModule.getSubModules()) { Module parentModule = findModule(sub, moduleName, moduleObject); if (parentModule != null) { return parentModule; } } } return null; }
/** * {@inheritDoc} */ @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { if (queryAction != null) { FilterableBeanCollectionModule module = (FilterableBeanCollectionModule) getModuleConnector( context).getConnectorValue(); IValueConnector filterConnector = getModuleConnector(context) .getChildConnector("filter"); context .put(ActionContextConstants.QUERY_MODEL_CONNECTOR, filterConnector); IQueryComponent filter = (IQueryComponent) module.getFilter(); if (actionHandler.execute(queryAction, context)) { module.setModuleObjects(filter.getQueriedComponents()); filter.setQueriedComponents(null); } } return super.execute(actionHandler, context); }
Object childModuleObject, Map<String, Object> context) { BeanModule childModule = new BeanModule(); IViewDescriptor projectedViewDescriptor = getChildModuleProjectedViewDescriptor(context); if (projectedViewDescriptor != null) { childModule.setProjectedViewDescriptor(projectedViewDescriptor);
/** * Creates a new entity to add to the projected object collection. * * @param actionHandler * the action handler (generally the controller). * @param context * the action context. * @return the created entity. */ @SuppressWarnings({"unchecked", "UnusedParameters"}) protected Object createNewModuleObject(IActionHandler actionHandler, Map<String, Object> context) { IComponentDescriptor<? extends IEntity> projectedDesc = ((ICollectionDescriptorProvider<IEntity>) getModelDescriptor(context)) .getCollectionDescriptor().getElementDescriptor(); Class<? extends IEntity> componentContract = projectedDesc.getComponentContract(); return getEntityFactory(context).createEntityInstance( componentContract); } }
/** * Retrieves the query component out of the context. * * @param context * the action context. * @return the query component. */ @Override protected IQueryComponent getQueryComponent(Map<String, Object> context) { FilterableBeanCollectionModule module = (FilterableBeanCollectionModule) getModule(context); return module.getFilter(); }
private Module findCurrentModule(Module rootModule, Object nextSelectedModuleObject, Stack<Module> stack) { stack.push(rootModule); if (rootModule instanceof BeanModule && nextSelectedModuleObject.equals(((BeanModule) rootModule) .getModuleObject())) { return rootModule; } if (rootModule.getSubModules() != null) { for (Module sub : rootModule.getSubModules()) { Module parentModule = findCurrentModule(sub, nextSelectedModuleObject, stack); if (parentModule != null) { return parentModule; } } } stack.pop(); return null; }
/** * Assigns the result list to the module. * <p> * {@inheritDoc} */ @Override protected void queryPerformed(IQueryComponent queryComponent, Map<String, Object> context) { FilterableBeanCollectionModule module = (FilterableBeanCollectionModule) getModule(context); List<?> currentModuleObjects = module.getModuleObjects(); List<Object> targetModuleObjects = new ArrayList<>( queryComponent.getQueriedComponents()); // We need to preserve transient entities from being lost. if (currentModuleObjects != null) { for (Object comp : currentModuleObjects) { if (comp instanceof IEntity && !((IEntity) comp).isPersistent() && !targetModuleObjects.contains(comp)) { targetModuleObjects.add(comp); } } } module.setModuleObjects(targetModuleObjects); //queryComponent.setQueriedComponents(null); } }