/** * Returns the set of all template names for this definition. * * @return set of template names. */ public Set<String> templateNamesSet() { return getTemplates().keySet(); }
/** * If there is a default template, return it, otherwise return null. * * @return a template if one is default, null otherwise */ @Nullable public ConfigurationTemplate getDefaultTemplate() { return getTemplates().get(ConfigurationTemplate.DEFAULT_TEMPLATE_NAME); }
/** * Returns the template indicated by the specified name * * @param name name of the template to return * * @return <code>ConfigurationTemplate</code> with the specified name; <code>null</code> if no template by that name * exists. */ public ConfigurationTemplate getTemplate(@NotNull String name) { return getTemplates().get(name); }
@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; }
@Override @Nullable public ConfigurationDefinition getResourceConfigurationDefinitionWithTemplatesForResourceType(Subject subject, int resourceTypeId) { Query query = entityManager.createNamedQuery(ConfigurationDefinition.QUERY_FIND_RESOURCE_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; }
public ConfigurationTemplate removeTemplate(ConfigurationTemplate template) { return getTemplates().remove(template.getName()); }
public void putTemplate(ConfigurationTemplate template) { template.setConfigurationDefinition(this); getTemplates().put(template.getName(), template); }
/** * Get a copy of this {@link ConfigurationDefinition}. The property definitions will be returned in * a new Map, which can be safely manipulated without affecting the original Map. It is not a deep copy, it * is backed by the same {@link #PropertyDefinition} objects as the original and changes to the Map entries will * modify the originals. The templates Map is treated the same way. The id is not copied. * * @return the copy */ public ConfigurationDefinition copy() { ConfigurationDefinition copy = new ConfigurationDefinition(this.getName(), this.getDescription()); copy.setPropertyDefinitions(this.getPropertyDefinitions()); copy.setConfigurationFormat(this.getConfigurationFormat()); copy.templates = new LinkedHashMap<String, ConfigurationTemplate>(this.getTemplates()); return copy; }
Map<String, ConfigurationTemplate> existingTemplates = existingDefinition.getTemplates(); Map<String, ConfigurationTemplate> newTemplates = newDefinition.getTemplates(); List<String> toRemove = new ArrayList<String>(); List<String> templatesToUpdate = new ArrayList<String>();