Search in sources :

Example 11 with IEntityService

use of org.jowidgets.cap.common.api.service.IEntityService in project jo-client-platform by jo-source.

the class EntityComponentNodesFactoryImpl method createNode.

@Override
public IComponentNodeModel createNode(final Object entityId) {
    Assert.paramNotNull(entityId, "entityId");
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final IBeanDtoDescriptor beanDtoDescriptor = entityService.getDescriptor(entityId);
        if (beanDtoDescriptor != null) {
            final String labelPlural = beanDtoDescriptor.getLabelPlural().get();
            if (!EmptyCheck.isEmpty(labelPlural)) {
                final IEntityApplicationNodeBuilder applicationNodeBuilder = CapCommonToolkit.entityApplicationNodeBuilder();
                applicationNodeBuilder.setEntityId(entityId).setLabel(labelPlural);
                applicationNodeBuilder.setDescription(beanDtoDescriptor.getDescription().get());
                applicationNodeBuilder.setIconDescriptor(beanDtoDescriptor.getIconDescriptor());
                return createNodeFromEntity(applicationNodeBuilder.build());
            } else {
                throw new IllegalArgumentException("The was no label plural found for the entityId '" + entityId + "'");
            }
        } else {
            throw new IllegalArgumentException("The was no bean dto descriptor found for the entityId '" + entityId + "'");
        }
    } else {
        throw new IllegalStateException("There was no entity service found");
    }
}
Also used : IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) IEntityApplicationNodeBuilder(org.jowidgets.cap.common.api.entity.IEntityApplicationNodeBuilder)

Aggregations

IEntityService (org.jowidgets.cap.common.api.service.IEntityService)11 IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)8 IEntityLinkDescriptor (org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor)3 ICapActionFactory (org.jowidgets.cap.ui.api.command.ICapActionFactory)3 IImageConstant (org.jowidgets.common.image.IImageConstant)2 IAction (org.jowidgets.api.command.IAction)1 IActionItemModel (org.jowidgets.api.model.item.IActionItemModel)1 IMenuItemModel (org.jowidgets.api.model.item.IMenuItemModel)1 IMenuModel (org.jowidgets.api.model.item.IMenuModel)1 IProperty (org.jowidgets.cap.common.api.bean.IProperty)1 IEntityApplicationNode (org.jowidgets.cap.common.api.entity.IEntityApplicationNode)1 IEntityApplicationNodeBuilder (org.jowidgets.cap.common.api.entity.IEntityApplicationNodeBuilder)1 IBeanServicesProvider (org.jowidgets.cap.common.api.service.IBeanServicesProvider)1 IDeleterService (org.jowidgets.cap.common.api.service.IDeleterService)1 IMessage (org.jowidgets.i18n.api.IMessage)1 MenuModel (org.jowidgets.tools.model.item.MenuModel)1 IComponentNodeModelBuilder (org.jowidgets.workbench.toolkit.api.IComponentNodeModelBuilder)1 ComponentNodeModelBuilder (org.jowidgets.workbench.tools.ComponentNodeModelBuilder)1