Search in sources :

Example 6 with IBeanDtoDescriptor

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

the class BeanTableDeleterActionBuilderFactory method createBuilder.

static <BEAN_TYPE> IDeleterActionBuilder<BEAN_TYPE> createBuilder(final IBeanTable<BEAN_TYPE> table) {
    final IBeanTableModel<BEAN_TYPE> model = table.getModel();
    final ICapActionFactory actionFactory = CapUiToolkit.actionFactory();
    final IDeleterActionBuilder<BEAN_TYPE> builder = actionFactory.deleterActionBuilder(model);
    builder.setEntityLabelSingular(model.getEntityLabelSingular());
    builder.setEntityLabelPlural(model.getEntityLabelPlural());
    builder.setDeleterService(model.getDeleterService());
    final Object entityId = model.getEntityId();
    if (entityId != null) {
        final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
        if (entityService != null) {
            final IBeanDtoDescriptor descriptor = entityService.getDescriptor(entityId);
            if (descriptor != null) {
                final Object icon = descriptor.getDeleteIconDescriptor();
                if (icon != null) {
                    final IImageConstant imageConstant = ImageResolver.resolve(icon);
                    if (imageConstant != null) {
                        builder.setIcon(imageConstant);
                    }
                }
            }
        }
    }
    return builder;
}
Also used : IImageConstant(org.jowidgets.common.image.IImageConstant) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) ICapActionFactory(org.jowidgets.cap.ui.api.command.ICapActionFactory)

Example 7 with IBeanDtoDescriptor

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

the class AttributeToolkitImpl method createAttributes.

@Override
public List<IAttribute<Object>> createAttributes(final Object entityID, final IAttributeCollectionModifier attributeCollectionModifier) {
    Assert.paramNotNull(entityID, "entityID");
    final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
    if (entityService != null) {
        final IBeanDtoDescriptor descriptor = entityService.getDescriptor(entityID);
        if (descriptor != null) {
            final List<IProperty> properties = descriptor.getProperties();
            if (properties != null) {
                return createAttributes(properties, attributeCollectionModifier);
            }
        }
    }
    throw new IllegalArgumentException("Could not retrieve properties for entityId '" + entityID + "'");
}
Also used : IProperty(org.jowidgets.cap.common.api.bean.IProperty) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)

Example 8 with IBeanDtoDescriptor

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

the class BeanProxyFactoryBuilderImpl method configureFromEntityService.

@Override
public IBeanProxyFactoryBuilder<BEAN_TYPE> configureFromEntityService(final Object entityId) {
    final IBeanDtoDescriptor dtoDescriptor = EntityServiceHelper.getDtoDescriptor(entityId);
    final List<IAttribute<Object>> entityAttributes = EntityServiceHelper.createAttributes(entityId);
    if (dtoDescriptor != null && entityAttributes != null) {
        final Class<?> descritporBeanType = dtoDescriptor.getBeanType();
        if (descritporBeanType == null || !descritporBeanType.isAssignableFrom(beanType)) {
            throw new IllegalArgumentException("The entity id '" + entityId + "' has a bean type '" + descritporBeanType + "' that is not compatible with the bean type '" + beanType + "' of this builder");
        }
        setBeanTypeId(dtoDescriptor.getBeanTypeId());
        final IAttributeSet attributeSet = AttributeSet.create(entityAttributes);
        setAttributes(attributeSet);
        addValidators(dtoDescriptor, attributeSet);
        setDefaultValuesForTransientBeans(attributeSet);
    } else {
        throw new IllegalArgumentException("TFor the entity id '" + entityId + "' no descriptor or attributes was found");
    }
    return this;
}
Also used : IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute) IAttributeSet(org.jowidgets.cap.ui.api.attribute.IAttributeSet)

Example 9 with IBeanDtoDescriptor

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

the class MoveOrderedBeanActionBuilderImpl method setEntityLabels.

@Override
public IMoveOrderedBeanActionBuilder<BEAN_TYPE> setEntityLabels(final Object entityId) {
    checkExhausted();
    if (entityId != null) {
        final IEntityService entityService = ServiceProvider.getService(IEntityService.ID);
        if (entityService != null) {
            final IBeanDtoDescriptor descriptor = entityService.getDescriptor(entityId);
            if (descriptor != null) {
                final IMessage labelSingular = descriptor.getLabelSingular();
                if (labelSingular != null && !EmptyCheck.isEmpty(labelSingular.get())) {
                    setEntityLabelSingular(labelSingular.get());
                }
                final IMessage labelPlural = descriptor.getLabelPlural();
                if (labelPlural != null && !EmptyCheck.isEmpty(labelPlural.get())) {
                    setEntityLabelPlural(labelPlural.get());
                }
            }
        }
    }
    return this;
}
Also used : IMessage(org.jowidgets.i18n.api.IMessage) IEntityService(org.jowidgets.cap.common.api.service.IEntityService) IBeanDtoDescriptor(org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)

Example 10 with IBeanDtoDescriptor

use of org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor 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

IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)10 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)8 ICapActionFactory (org.jowidgets.cap.ui.api.command.ICapActionFactory)3 IBeanServicesProvider (org.jowidgets.cap.common.api.service.IBeanServicesProvider)2 IImageConstant (org.jowidgets.common.image.IImageConstant)2 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 IEntityLinkDescriptor (org.jowidgets.cap.common.api.entity.IEntityLinkDescriptor)1 IDeleterService (org.jowidgets.cap.common.api.service.IDeleterService)1 IAttribute (org.jowidgets.cap.ui.api.attribute.IAttribute)1 IAttributeSet (org.jowidgets.cap.ui.api.attribute.IAttributeSet)1 IMessage (org.jowidgets.i18n.api.IMessage)1 IComponentNodeModelBuilder (org.jowidgets.workbench.toolkit.api.IComponentNodeModelBuilder)1 ComponentNodeModelBuilder (org.jowidgets.workbench.tools.ComponentNodeModelBuilder)1