@Override
public ConfigurationDefinition getPluginConfigurationDefinitionForResourceType(Subject subject, int resourceTypeId) {
Query query = entityManager.createNamedQuery(ConfigurationDefinition.QUERY_FIND_PLUGIN_BY_RESOURCE_TYPE_ID);
query.setParameter("resourceTypeId", resourceTypeId);
ConfigurationDefinition configurationDefinition = null;
try {
configurationDefinition = (ConfigurationDefinition) query.getSingleResult();
} catch (NoResultException e) {
ResourceType resourceType = entityManager.find(ResourceType.class, resourceTypeId);
if (resourceType == null) {
throw new EntityNotFoundException("A resource type with id " + resourceTypeId + " does not exist.");
}
}
// Eager Load the templates
if ((configurationDefinition != null) && (configurationDefinition.getTemplates() != null)) {
configurationDefinition.getTemplates().size();
}
return configurationDefinition;
}