Search in sources :

Example 1 with IProperty

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

the class JpaEntityService method createServicesProvider.

private <T extends IBean> IBeanServicesProvider createServicesProvider(final Class<? extends IBean> beanInterface, final Class<T> beanType, final IBeanDtoDescriptor descriptor) {
    final IBeanServicesProviderBuilder builder = CapServiceToolkit.beanServicesProviderBuilder(SpringServiceProvider.getInstance(), IEntityService.ID, beanType, beanInterface);
    final List<String> propertyNames = new LinkedList<String>();
    for (final IProperty property : descriptor.getProperties()) {
        propertyNames.add(property.getName());
    }
    final IJpaServiceFactory serviceFactory = JpaServiceToolkit.serviceFactory();
    final TransactionProxyFactory tpf = new TransactionProxyFactory(transactionManager);
    final ICreatorService creatorService = serviceFactory.creatorService(beanType, propertyNames);
    builder.setCreatorService(tpf.createProxy(creatorService, "create"));
    final IDeleterService deleterService = serviceFactory.deleterService(beanType);
    builder.setDeleterService(tpf.createProxy(deleterService, "delete"));
    // TODO: MvR -> Check genericity...
    final ICriteriaQueryCreatorBuilder<Void> queryBuilder = JpaQueryToolkit.criteriaQueryCreatorBuilder(beanType);
    if (ParentLinkHelper.hasParent(beanType)) {
        queryBuilder.setParentPropertyName("parent");
    }
    final IReaderService<Void> readerService = serviceFactory.readerService(beanType, queryBuilder.build(), propertyNames);
    builder.setReaderService(readerService);
    final IBeanAccess<T> beanAccess = serviceFactory.beanAccess(beanType);
    builder.setRefreshService(CapServiceToolkit.refreshServiceBuilder(beanAccess).setBeanDtoFactory(propertyNames).build());
    final IUpdaterService updaterService = CapServiceToolkit.updaterServiceBuilder(beanAccess).setBeanDtoFactoryAndBeanModifier(propertyNames).build();
    builder.setUpdaterService(tpf.createProxy(updaterService, "update"));
    return builder.build();
}
Also used : TransactionProxyFactory(org.jowidgets.cap.service.spring.TransactionProxyFactory) IUpdaterService(org.jowidgets.cap.common.api.service.IUpdaterService) LinkedList(java.util.LinkedList) IBeanServicesProviderBuilder(org.jowidgets.cap.service.api.entity.IBeanServicesProviderBuilder) IProperty(org.jowidgets.cap.common.api.bean.IProperty) IDeleterService(org.jowidgets.cap.common.api.service.IDeleterService) ICreatorService(org.jowidgets.cap.common.api.service.ICreatorService) IJpaServiceFactory(org.jowidgets.cap.service.jpa.api.IJpaServiceFactory)

Example 2 with IProperty

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

the class AttributesFactory method createAttributes.

List<IAttribute<Object>> createAttributes(final Collection<? extends IProperty> properties, final IAttributeCollectionModifier attributeCollectionModifier) {
    Assert.paramNotNull(properties, "properties");
    final List<IAttribute<Object>> result = new LinkedList<IAttribute<Object>>();
    for (final IProperty property : properties) {
        final AttributeBuilderImpl<Object> attributeBuilder = new AttributeBuilderImpl<Object>(property);
        if (attributeCollectionModifier != null) {
            final IAttribute<Object> attribute = applyCollectionModifier(property, attributeBuilder, attributeCollectionModifier);
            if (attribute != null) {
                result.add(attribute);
            }
        } else {
            result.add(attributeBuilder.build());
        }
    }
    return result;
}
Also used : IProperty(org.jowidgets.cap.common.api.bean.IProperty) IAttribute(org.jowidgets.cap.ui.api.attribute.IAttribute) LinkedList(java.util.LinkedList)

Example 3 with IProperty

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

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

the class LinkCreatorActionBuilderImpl method hasAdditionalProperties.

private static boolean hasAdditionalProperties(final IBeanDtoDescriptor descriptor, final IEntityLinkDescriptor linkDescriptor) {
    final Set<String> ignoreProperties = new HashSet<String>();
    ignoreProperties.add(IBean.ID_PROPERTY);
    ignoreProperties.add(IBean.VERSION_PROPERTY);
    if (linkDescriptor.getSourceProperties() != null) {
        ignoreProperties.add(linkDescriptor.getSourceProperties().getForeignKeyPropertyName());
    }
    if (linkDescriptor.getDestinationProperties() != null) {
        ignoreProperties.add(linkDescriptor.getDestinationProperties().getForeignKeyPropertyName());
    }
    for (final IProperty property : descriptor.getProperties()) {
        if (property.isEditable() && !ignoreProperties.contains(property.getName())) {
            return true;
        }
    }
    return false;
}
Also used : IProperty(org.jowidgets.cap.common.api.bean.IProperty) HashSet(java.util.HashSet)

Aggregations

IProperty (org.jowidgets.cap.common.api.bean.IProperty)4 LinkedList (java.util.LinkedList)2 HashSet (java.util.HashSet)1 IBeanDtoDescriptor (org.jowidgets.cap.common.api.bean.IBeanDtoDescriptor)1 ICreatorService (org.jowidgets.cap.common.api.service.ICreatorService)1 IDeleterService (org.jowidgets.cap.common.api.service.IDeleterService)1 IEntityService (org.jowidgets.cap.common.api.service.IEntityService)1 IUpdaterService (org.jowidgets.cap.common.api.service.IUpdaterService)1 IBeanServicesProviderBuilder (org.jowidgets.cap.service.api.entity.IBeanServicesProviderBuilder)1 IJpaServiceFactory (org.jowidgets.cap.service.jpa.api.IJpaServiceFactory)1 TransactionProxyFactory (org.jowidgets.cap.service.spring.TransactionProxyFactory)1 IAttribute (org.jowidgets.cap.ui.api.attribute.IAttribute)1