/** * {@inheritDoc} */ public String getRenderedProperty() { if (renderedProperty == null) { return ((ICollectionDescriptorProvider<?>) getModelDescriptor()) .getCollectionDescriptor().getElementDescriptor() .getToStringProperty(); } return renderedProperty; }
/** * Gets the entity descriptor to execute the LOV action for from the context. * It allows sub classes to override in order to define the descriptor at * runtime. * * @param context * the action context. * @return the entity descriptor to execute the LOV action for. */ @SuppressWarnings("UnusedParameters") protected IComponentDescriptor<? extends IComponent> getEntityDescriptor(Map<String, Object> context) { if (entityDescriptor == null) { IModelDescriptor modelDescriptor = getModelDescriptor(context); if (modelDescriptor instanceof ICollectionDescriptorProvider<?>) { ICollectionDescriptor<?> collectionDescriptor = ((ICollectionDescriptorProvider<?>) modelDescriptor) .getCollectionDescriptor(); if (collectionDescriptor != null) { return (IComponentDescriptor<? extends IComponent>) collectionDescriptor.getElementDescriptor(); } } } return entityDescriptor; }
/** * This implementation returns a {@code ModelConnector} instance. * <p> * {@inheritDoc} */ @Override public IValueConnector createChildConnector(String connectorId) { if (connectorTank != null && !connectorTank.isEmpty()) { return connectorTank.remove(0); } IComponentDescriptor<?> componentDescriptor; componentDescriptor = ((ICollectionDescriptorProvider<?>) getModelDescriptor()) .getCollectionDescriptor().getElementDescriptor(); IValueConnector elementConnector = modelConnectorFactory .createModelConnector(connectorId, componentDescriptor, getSecurityHandler()); return elementConnector; }
private SecurityContextBuilder append(IModelDescriptor modelDescriptor) { if (modelDescriptor != null) { if (modelDescriptor instanceof IPropertyDescriptor) { currentSecurityContext.put(SecurityContextConstants.PROPERTY, ((IPropertyDescriptor) modelDescriptor).getPermId()); } if (modelDescriptor instanceof IComponentDescriptorProvider<?> && ((IComponentDescriptorProvider<?>) modelDescriptor) .getComponentDescriptor() != null) { if (!(currentSecurityContext.get(LAST_PUSHED_VIEW) instanceof IPropertyViewDescriptor)) { // only dig the model if we are not on a reference property view (LOV // field). see bug #560. currentSecurityContext.put(SecurityContextConstants.MODEL, ((IComponentDescriptorProvider<?>) modelDescriptor) .getComponentDescriptor().getPermId()); } } else if (modelDescriptor instanceof ICollectionDescriptorProvider<?>) { currentSecurityContext.put(SecurityContextConstants.MODEL, ((ICollectionDescriptorProvider<?>) modelDescriptor) .getCollectionDescriptor().getElementDescriptor().getPermId()); } } return this; }
@SuppressWarnings("rawtypes") private Map<String, IComponentDescriptor<?>> buildContractNameIdMap() { Map<String, IComponentDescriptor<?>> map = new HashMap<>(); Map<String, IComponentDescriptor> idToComponentDescriptors = componentApplicationContext.getBeansOfType( IComponentDescriptor.class, false, false); for (Map.Entry<String, IComponentDescriptor> descriptorEntry : idToComponentDescriptors.entrySet()) { IComponentDescriptor componentDescriptor = descriptorEntry.getValue(); if (componentDescriptor.getComponentContract() != null) { map.put(componentDescriptor.getComponentContract().getName(), componentDescriptor); if (componentDescriptor.isTranslatable()) { ICollectionPropertyDescriptor<?> collectionPropertyDescriptor = (ICollectionPropertyDescriptor<?>) componentDescriptor .getPropertyDescriptor(AbstractComponentDescriptor.getComponentTranslationsDescriptorTemplate().getName()); if (collectionPropertyDescriptor != null) { IComponentDescriptor<?> translationComponentDescriptor = collectionPropertyDescriptor .getReferencedDescriptor().getElementDescriptor(); if (translationComponentDescriptor.getComponentContract() != null) { map.put(translationComponentDescriptor.getComponentContract().getName(), translationComponentDescriptor); } } } } } map.put(BasicDescriptorDescriptor.INSTANCE.getName(), BasicDescriptorDescriptor.INSTANCE); return map; } }
/** * 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; }
/** * Gets the new entity to add. It is created using the informations contained * in the context. * * @param context * the action context. * @return the entity to add to the collection. */ @Override @SuppressWarnings("unchecked") protected List<?> getAddedComponents(Map<String, Object> context) { IComponentDescriptor elementDescriptor = (IComponentDescriptor) context .get(ActionContextConstants.ELEMENT_DESCRIPTOR); if (elementDescriptor == null) { elementDescriptor = ((ICollectionPropertyDescriptor) getModelDescriptor(context)) .getReferencedDescriptor().getElementDescriptor(); } IEntity newEntity = getEntityFactory(context).createEntityInstance( (Class<? extends IEntity>) elementDescriptor.getComponentContract()); return Collections.singletonList(newEntity); } }
/** * Gets the elementComponentDescriptor. * * @return the elementComponentDescriptor. */ public IComponentDescriptor<?> getElementComponentDescriptor() { if (elementComponentDescriptor == null) { IViewDescriptor projectedViewDescriptor = getProjectedViewDescriptor(); if (projectedViewDescriptor instanceof ICollectionViewDescriptor && projectedViewDescriptor.getModelDescriptor() != null) { return ((ICollectionDescriptorProvider<?>) projectedViewDescriptor.getModelDescriptor()) .getCollectionDescriptor().getElementDescriptor(); } } return elementComponentDescriptor; }
/** * {@inheritDoc} */ @Override public String getIconImageURL() { String iconImageURL = super.getIconImageURL(); if (iconImageURL == null) { iconImageURL = ((ICollectionDescriptorProvider<?>) getModelDescriptor()) .getCollectionDescriptor().getElementDescriptor().getIconImageURL(); setIconImageURL(iconImageURL); } return iconImageURL; } }
/** * 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()); } }
/** * 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); } }
/** * Process. * * @param componentDescriptor * the component descriptor */ protected void process(IComponentDescriptor<?> componentDescriptor) { String compPermId = componentDescriptor.getPermId(); if (compPermId != null) { if (isPermIdExcluded(compPermId) || modelPermIds.contains(compPermId)) { return; } modelPermIds.add(compPermId); } for (IPropertyDescriptor propertyDescriptor : componentDescriptor.getPropertyDescriptors()) { process(propertyDescriptor, compPermId, modelPermIds); if (propertyDescriptor instanceof IRelationshipEndPropertyDescriptor) { if (propertyDescriptor instanceof IReferencePropertyDescriptor<?>) { process(((IReferencePropertyDescriptor<?>) propertyDescriptor).getReferencedDescriptor()); } else if (propertyDescriptor instanceof ICollectionPropertyDescriptor<?>) { process( ((ICollectionPropertyDescriptor<?>) propertyDescriptor).getReferencedDescriptor().getElementDescriptor()); } } } }
/** * {@inheritDoc} */ public List<String> getRenderedChildProperties(String propertyName) { List<String> childProperties = null; if (renderedChildProperties != null) { childProperties = renderedChildProperties.get(propertyName); } if (childProperties == null) { IPropertyDescriptor childPropertyDescriptor = ((IComponentDescriptorProvider<?>) getModelDescriptor()) .getComponentDescriptor().getPropertyDescriptor(propertyName); if (childPropertyDescriptor instanceof ICollectionPropertyDescriptor) { return ((ICollectionDescriptor<?>) ((ICollectionPropertyDescriptor<?>) childPropertyDescriptor) .getCollectionDescriptor()).getElementDescriptor() .getRenderedProperties(); } else if (childPropertyDescriptor instanceof IReferencePropertyDescriptor) { return ((IReferencePropertyDescriptor<?>) childPropertyDescriptor) .getReferencedDescriptor().getRenderedProperties(); } } return childProperties; }
/** * Sets the columnViewDescriptors. * * @param columnViewDescriptors * the columnViewDescriptors to set. */ public void setColumnViewDescriptors( List<ISubViewDescriptor> columnViewDescriptors) { this.columnViewDescriptors = columnViewDescriptors; if (columnViewDescriptors != null) { ICollectionDescriptorProvider<?> modelDescriptor = ((ICollectionDescriptorProvider<?>) getModelDescriptor()); if (modelDescriptor != null) { IComponentDescriptor<?> rowModelDescriptor = modelDescriptor .getCollectionDescriptor().getElementDescriptor(); for (ISubViewDescriptor columnViewDescriptor : columnViewDescriptors) { columnViewDescriptor.setGrantedRoles(rowModelDescriptor .getPropertyDescriptor(columnViewDescriptor.getName()) .getGrantedRoles()); } } } }
/** * Retrieves the managed collection from the model connector then registers * the selected elements. * <p> * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { int[] selectedIndices = getSelectedIndices(context); ICollectionConnector collectionConnector = getModelConnector(context); if (selectedIndices == null || selectedIndices.length == 0 || collectionConnector == null) { return false; } List<Object> transferedComponents = new ArrayList<Object>(); for (int i = 0; i < selectedIndices.length; i++) { transferedComponents.add(collectionConnector.getChildConnector( selectedIndices[i]).getConnectorValue()); } getController(context).storeComponents( new ComponentTransferStructure(getModelDescriptor(context) .getCollectionDescriptor().getElementDescriptor(), transferedComponents, transferMode)); return super.execute(actionHandler, context); }
/** * Gets added element descriptor. * * @param context * the context * @return the added element descriptor */ protected IComponentDescriptor<?> getAddedElementDescriptor(Map<String, Object> context) { IComponentDescriptor<?> elementDescriptor; String collectionPropertyName = getModelDescriptor(context).getName(); Object master = getModelConnector(context).getModelProvider().getModel(); if (master instanceof IComponent) { // Component type should be refined depending on concrete master. See property translations for instance. elementDescriptor = ((ICollectionPropertyDescriptor<?>) getEntityFactory(context).getComponentDescriptor( ((IComponent) master).getComponentContract()).getPropertyDescriptor(collectionPropertyName)) .getReferencedDescriptor().getElementDescriptor(); } else { elementDescriptor = ((ICollectionPropertyDescriptor<?>) getModelDescriptor(context)).getReferencedDescriptor() .getElementDescriptor(); } return elementDescriptor; }
/** * Gets added element descriptor. * * @param context * the context * @return the added element descriptor */ protected IComponentDescriptor<?> getRemovedElementDescriptor(Map<String, Object> context) { IComponentDescriptor<?> elementDescriptor; String collectionPropertyName = getModelDescriptor(context).getName(); Object master = getModelConnector(context).getModelProvider().getModel(); if (master instanceof IComponent) { // Component type should be refined depending on concrete master. See property translations for instance. elementDescriptor = ((ICollectionPropertyDescriptor<?>) getEntityFactory(context).getComponentDescriptor( ((IComponent) master).getComponentContract()).getPropertyDescriptor(collectionPropertyName)) .getReferencedDescriptor().getElementDescriptor(); } else { elementDescriptor = ((ICollectionPropertyDescriptor<?>) getModelDescriptor(context)).getReferencedDescriptor() .getElementDescriptor(); } return elementDescriptor; } }
/** * Gets the new map component to add. * * @param context * the action context. * @return the map to add to the collection. */ @Override @SuppressWarnings("unchecked") protected List<?> getAddedComponents(Map<String, Object> context) { IComponentDescriptor componentDescriptor = getModelDescriptor(context) .getCollectionDescriptor().getElementDescriptor(); Map<String, Object> newMap = new ObjectEqualityMap<String, Object>(); if (componentDescriptor.getLifecycleInterceptors() != null) { List<ILifecycleInterceptor> interceptors = componentDescriptor .getLifecycleInterceptors(); if (interceptors != null) { for (ILifecycleInterceptor<Map<String, Object>> interceptor : interceptors) { interceptor.onCreate(newMap, getEntityFactory(context), getApplicationSession(context).getPrincipal(), getApplicationSession(context)); } } } return Collections.singletonList(newMap); }
private IView<SComponent> createListView(IListViewDescriptor viewDescriptor, @SuppressWarnings("unused") IActionHandler actionHandler, @SuppressWarnings("unused") Locale locale) { ICollectionDescriptorProvider<?> modelDescriptor = ((ICollectionDescriptorProvider<?>) viewDescriptor .getModelDescriptor()); ICompositeValueConnector rowConnectorPrototype = connectorFactory .createCompositeValueConnector(modelDescriptor.getName() + "Element", viewDescriptor.getRenderedProperty()); ICollectionConnector connector = connectorFactory .createCollectionConnector(modelDescriptor.getName(), mvcBinder, rowConnectorPrototype); SList viewComponent = createSList(); SScrollPane scrollPane = createSScrollPane(); scrollPane.setViewportView(viewComponent); IView<SComponent> view = constructView(scrollPane, viewDescriptor, connector); if (viewDescriptor.getRenderedProperty() != null) { IValueConnector cellConnector = createColumnConnector(viewDescriptor .getRenderedProperty(), modelDescriptor.getCollectionDescriptor() .getElementDescriptor()); rowConnectorPrototype.addChildConnector(cellConnector); } viewComponent.setCellRenderer(new EvenOddListCellRenderer()); viewComponent.setModel(new CollectionConnectorListModel(connector)); listSelectionModelBinder.bindSelectionModel(connector, viewComponent .getSelectionModel(), null); return view; }
.getElementDescriptor().createQueryDescriptor()); return queryDescriptor;