// install a new view definition
private ViewEntity installView(ViewConfig viewConfig, Configuration ambariConfig,
ClassLoader cl, String archivePath)
throws ClassNotFoundException, IntrospectionException {
ViewEntity viewDefinition = new ViewEntity(viewConfig, ambariConfig, cl, archivePath);
List<ParameterConfig> parameterConfigurations = viewConfig.getParameters();
Collection<ViewParameterEntity> parameters = new HashSet<ViewParameterEntity>();
for (ParameterConfig parameterConfiguration : parameterConfigurations) {
ViewParameterEntity viewParameterEntity = new ViewParameterEntity();
viewParameterEntity.setViewName(viewDefinition.getName());
viewParameterEntity.setName(parameterConfiguration.getName());
viewParameterEntity.setDescription(parameterConfiguration.getDescription());
viewParameterEntity.setRequired(parameterConfiguration.isRequired());
viewParameterEntity.setViewEntity(viewDefinition);
parameters.add(viewParameterEntity);
}
viewDefinition.setParameters(parameters);
List<ResourceConfig> resourceConfigurations = viewConfig.getResources();
Resource.Type externalResourceType = viewDefinition.getExternalResourceType();
ViewExternalSubResourceProvider viewExternalSubResourceProvider =
new ViewExternalSubResourceProvider(externalResourceType, viewDefinition);
viewDefinition.addResourceProvider(externalResourceType, viewExternalSubResourceProvider );
ResourceInstanceFactoryImpl.addResourceDefinition(externalResourceType,
new ViewExternalSubResourceDefinition(externalResourceType));
Collection<ViewResourceEntity> resources = new HashSet<ViewResourceEntity>();
for (ResourceConfig resourceConfiguration : resourceConfigurations) {
ViewResourceEntity viewResourceEntity = new ViewResourceEntity();
viewResourceEntity.setViewName(viewDefinition.getName());
viewResourceEntity.setName(resourceConfiguration.getName());
viewResourceEntity.setPluralName(resourceConfiguration.getPluralName());
viewResourceEntity.setIdProperty(resourceConfiguration.getIdProperty());
viewResourceEntity.setResource(resourceConfiguration.getResource());
viewResourceEntity.setService(resourceConfiguration.getService());
viewResourceEntity.setProvider(resourceConfiguration.getProvider());
viewResourceEntity.setSubResourceNames(resourceConfiguration.getSubResourceNames());
viewResourceEntity.setViewEntity(viewDefinition);
ViewSubResourceDefinition resourceDefinition = new ViewSubResourceDefinition(viewDefinition, resourceConfiguration);
viewDefinition.addResourceDefinition(resourceDefinition);
Resource.Type type = resourceDefinition.getType();
viewDefinition.addResourceConfiguration(type, resourceConfiguration);
if (resourceConfiguration.isExternal()) {
viewExternalSubResourceProvider.addResourceName(resourceConfiguration.getName());
} else {
ResourceInstanceFactoryImpl.addResourceDefinition(type, resourceDefinition);
Class<?> clazz = resourceConfiguration.getResourceClass(cl);
String idProperty = resourceConfiguration.getIdProperty();
viewDefinition.addResourceProvider(type, new ViewSubResourceProvider(type, clazz, idProperty, viewDefinition));
resources.add(viewResourceEntity);
}
viewDefinition.setResources(resources);
}
addDefinition(viewDefinition);
return viewDefinition;
}