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");
}
}
Aggregations