Package org.apache.ambari.server.orm.entities

Examples of org.apache.ambari.server.orm.entities.ViewInstanceEntity


          }
          if (instanceName == null) {
            instanceDefinitions.addAll(viewInstanceDefinitions);
            break;
          } else {
            ViewInstanceEntity instanceDefinition = viewDefinition.getInstanceDefinition(instanceName);
            if (instanceDefinition != null) {
              instanceDefinitions.add(instanceDefinition);
            }
          }
        }
      }

      Set<Resource> results = new HashSet<Resource>();
      ReadRequest readRequest = new ViewReadRequest(requestedIds, predicate == null ? "" : predicate.toString());
      for (ViewInstanceEntity instanceDefinition : instanceDefinitions) {

        Set<?> beans = instanceDefinition.getResourceProvider(type).getResources(readRequest);

        for (Object bean : beans) {
          Resource resource = getResource(bean, viewDefinition.getName(), instanceDefinition.getName(), requestedIds);
          if (predicate.evaluate(resource)) {
            results.add(resource);
          }
        }
      }
View Full Code Here


            Unmarshaller   jaxbUnmarshaller = jaxbContext.createUnmarshaller();
            ViewConfig     viewConfig       = (ViewConfig) jaxbUnmarshaller.unmarshal(configStream);
            ViewEntity viewDefinition       = installView(viewConfig, configuration, cl, fileEntry.getAbsolutePath());

            for (InstanceConfig instanceConfig : viewConfig.getInstances()) {
              ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);

              for (PropertyConfig propertyConfig : instanceConfig.getProperties()) {
                viewInstanceDefinition.putProperty(propertyConfig.getKey(), propertyConfig.getValue());
              }

              _installViewInstance(viewDefinition, viewInstanceDefinition);
              instanceDefinitions.add(viewInstanceDefinition);
            }
View Full Code Here

    String       viewName   = instanceEntity.getViewName();
    ViewEntity   viewEntity = getDefinition(viewName);

    if (viewEntity != null) {
      String instanceName = instanceEntity.getName();
      ViewInstanceEntity entity = getInstanceDefinition(viewName, instanceName);
      if (entity != null) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Updating view instance " + viewName + "/" + instanceName);
        }

        entity.setProperties(instanceEntity.getProperties());
        entity.setData(instanceEntity.getData());

        instanceDAO.merge(entity);
      }
    }
  }
View Full Code Here

public class ViewContextImplTest {
  @Test
  public void testGetViewName() throws Exception {
    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0);
    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
    ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
    ViewRegistry viewRegistry = createNiceMock(ViewRegistry.class);

    ViewContextImpl viewContext = new ViewContextImpl(viewInstanceDefinition, viewRegistry);

    Assert.assertEquals("MY_VIEW", viewContext.getViewName());
View Full Code Here

  @Test
  public void testGetInstanceName() throws Exception {
    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0);
    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
    ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
    ViewRegistry viewRegistry = createNiceMock(ViewRegistry.class);

    ViewContextImpl viewContext = new ViewContextImpl(viewInstanceDefinition, viewRegistry);

    Assert.assertEquals("INSTANCE1", viewContext.getInstanceName());
View Full Code Here

  @Test
  public void testGetProperties() throws Exception {
    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0);
    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
    ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
    ViewRegistry viewRegistry = createNiceMock(ViewRegistry.class);
    viewInstanceDefinition.putProperty("p1", "v1");
    viewInstanceDefinition.putProperty("p2", "v2");
    viewInstanceDefinition.putProperty("p3", "v3");

    ViewContextImpl viewContext = new ViewContextImpl(viewInstanceDefinition, viewRegistry);

    Map<String, String> properties = viewContext.getProperties();
    Assert.assertEquals(3, properties.size());
View Full Code Here

  @Test
  public void testGetResourceProvider() throws Exception {
    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0);
    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
    ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
    ViewRegistry viewRegistry = createNiceMock(ViewRegistry.class);

    ResourceProvider provider = createNiceMock(ResourceProvider.class);
    Resource.Type type = new Resource.Type("MY_VIEW/myType");

    viewInstanceDefinition.addResourceProvider(type, provider);

    ViewContextImpl viewContext = new ViewContextImpl(viewInstanceDefinition, viewRegistry);

    Assert.assertEquals(provider, viewContext.getResourceProvider("myType"));
  }
View Full Code Here

  @Test
  public void testGetURLStreamProvider() throws Exception {
    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0);
    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
    ViewInstanceEntity viewInstanceDefinition = new ViewInstanceEntity(viewDefinition, instanceConfig);
    ViewRegistry viewRegistry = createNiceMock(ViewRegistry.class);

    ResourceProvider provider = createNiceMock(ResourceProvider.class);
    Resource.Type type = new Resource.Type("MY_VIEW/myType");

    viewInstanceDefinition.addResourceProvider(type, provider);

    ViewContextImpl viewContext = new ViewContextImpl(viewInstanceDefinition, viewRegistry);

    Assert.assertNotNull(viewContext.getURLStreamProvider());
  }
View Full Code Here

  }

  @Test
  public void testAddGetInstanceDefinitions() throws Exception {
    ViewEntity viewDefinition = ViewEntityTest.getViewEntity();
    ViewInstanceEntity viewInstanceDefinition = ViewInstanceEntityTest.getViewInstanceEntity();

    ViewRegistry registry = ViewRegistry.getInstance();

    registry.addDefinition(viewDefinition);
View Full Code Here

    ViewRegistry registry = ViewRegistry.getInstance();

    ViewEntity viewEntity = ViewEntityTest.getViewEntity();
    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0);

    ViewInstanceEntity viewInstanceEntity = new ViewInstanceEntity(viewEntity, instanceConfig);

    registry.addDefinition(viewEntity);
    registry.addInstanceDefinition(viewEntity, viewInstanceEntity);

    Collection<ViewInstanceEntity> viewInstanceDefinitions = registry.getInstanceDefinitions(viewEntity);
View Full Code Here

TOP

Related Classes of org.apache.ambari.server.orm.entities.ViewInstanceEntity

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.