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

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


  }

  @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

    ViewRegistry.init(viewDAO, viewInstanceDAO);

    ViewRegistry registry = ViewRegistry.getInstance();

    ViewInstanceEntity viewInstanceEntity = ViewInstanceEntityTest.getViewInstanceEntity();

    viewInstanceEntity.putInstanceData("foo", "value");

    ViewInstanceDataEntity dataEntity = viewInstanceEntity.getInstanceData("foo");

    viewInstanceDAO.removeData(dataEntity);
    expect(viewInstanceDAO.merge(viewInstanceEntity)).andReturn(viewInstanceEntity);
    replay(viewDAO, viewInstanceDAO);

    registry.removeInstanceData(viewInstanceEntity, "foo");

    Assert.assertNull(viewInstanceEntity.getInstanceData("foo"));
    verify(viewDAO, viewInstanceDAO);
  }
View Full Code Here

   */
  @Path("{instanceName}/{resources}")
  public Object getResourceHandler(@PathParam("instanceName") String instanceName,
                                            @PathParam("resources") String resources) {

    ViewInstanceEntity instanceDefinition =
        ViewRegistry.getInstance().getInstanceDefinition(viewName, version, instanceName);

    if (instanceDefinition == null) {
      throw new IllegalArgumentException("A view instance " +
          viewName + "/" + instanceName + " can not be found.");
    }

    Object service = instanceDefinition.getService(resources);

    if (service == null) {
      throw new IllegalArgumentException("A resource type " + resources + " for view instance " +
          viewName + "/" + instanceName + " can not be found.");
    }
View Full Code Here

          }
          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.getCommonName(),
              viewDefinition.getVersion(), instanceDefinition.getName(), requestedIds);
          if (predicate.evaluate(resource)) {
            results.add(resource);
          }
        }
      }
View Full Code Here

                ClassLoader cl = extractViewArchive(archiveFile, helper.getFile(archivePath));

                ViewEntity viewDefinition = installView(viewConfig, configuration, cl, archivePath);

                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

    if (viewEntity != null) {
      String instanceName = instanceEntity.getName();
      String viewName     = viewEntity.getCommonName();
      String version      = viewEntity.getVersion();

      ViewInstanceEntity entity = getInstanceDefinition(viewName, version, instanceName);

      if (entity != null) {
        if (LOG.isDebugEnabled()) {
          LOG.debug("Updating view instance " + viewName + "/" +
              version + "/" + instanceName);
        }

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

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

        persistedViews.add(name);

        ViewEntity viewDefinition = ViewRegistry.getInstance().viewDefinitions.get(name);

        for (ViewInstanceEntity viewInstanceEntity : viewEntity.getInstances()){
          ViewInstanceEntity instanceEntity = viewDefinition.getInstanceDefinition(viewInstanceEntity.getName());
          if (instanceEntity == null) {
            viewInstanceEntity.setViewEntity(viewDefinition);
            installViewInstance(viewDefinition, viewInstanceEntity);
            instanceDefinitions.add(viewInstanceEntity);
          } else {
            // apply overrides to the in-memory view instance entities
            instanceEntity.setData(viewInstanceEntity.getData());
            instanceEntity.setProperties(viewInstanceEntity.getProperties());
            instanceEntity.setEntities(viewInstanceEntity.getEntities());
          }
        }
      }
    }
View Full Code Here

    if (viewName == null || viewName.isEmpty()) {
      throw new IllegalArgumentException("View name must be provided");
    }
    viewName = ViewEntity.getViewName(viewName, version);

    ViewInstanceEntity viewInstanceEntity = new ViewInstanceEntity();
    viewInstanceEntity.setName(name);
    viewInstanceEntity.setViewName(viewName);

    ViewEntity viewEntity = new ViewEntity();
    viewEntity.setName(viewName);
    viewEntity.setVersion(version);

    viewInstanceEntity.setViewEntity(viewEntity);

    Collection<ViewInstancePropertyEntity> instanceProperties = new HashSet<ViewInstancePropertyEntity>();
    Collection<ViewInstanceDataEntity>     instanceData       = new HashSet<ViewInstanceDataEntity>();

    for (Map.Entry<String, Object> entry : properties.entrySet()) {

      String propertyName = entry.getKey();

      if (propertyName.startsWith(PROPERTIES_PREFIX)) {
        ViewInstancePropertyEntity viewInstancePropertyEntity = new ViewInstancePropertyEntity();

        viewInstancePropertyEntity.setViewName(viewName);
        viewInstancePropertyEntity.setViewInstanceName(name);
        viewInstancePropertyEntity.setName(entry.getKey().substring(PROPERTIES_PREFIX.length()));
        viewInstancePropertyEntity.setValue((String) entry.getValue());
        viewInstancePropertyEntity.setViewInstanceEntity(viewInstanceEntity);

        instanceProperties.add(viewInstancePropertyEntity);
      } else if (propertyName.startsWith(DATA_PREFIX)) {
        ViewInstanceDataEntity viewInstanceDataEntity = new ViewInstanceDataEntity();

        viewInstanceDataEntity.setViewName(viewName);
        viewInstanceDataEntity.setViewInstanceName(name);
        viewInstanceDataEntity.setName(entry.getKey().substring(DATA_PREFIX.length()));
        viewInstanceDataEntity.setValue((String) entry.getValue());
        viewInstanceDataEntity.setViewInstanceEntity(viewInstanceEntity);

        instanceData.add(viewInstanceDataEntity);
      }
    }
    viewInstanceEntity.setProperties(instanceProperties);
    viewInstanceEntity.setData(instanceData);

    return viewInstanceEntity;
  }
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.