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

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


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

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

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

    Object service = instanceDefinition.getService(resources);

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


    String viewName = (String) properties.get(VIEW_NAME_PROPERTY_ID);
    if (viewName == null || viewName.isEmpty()) {
      throw new IllegalArgumentException("View name must be provided");
    }

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


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

    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

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

    ViewRegistry       viewRegistry       = ViewRegistry.getInstance();
    ViewInstanceEntity viewInstanceEntity = viewRegistry.getInstanceDefinition(viewName, version, name);

    viewName = ViewEntity.getViewName(viewName, version);

    if (viewInstanceEntity == null) {
      viewInstanceEntity = new ViewInstanceEntity();
      viewInstanceEntity.setName(name);
      viewInstanceEntity.setViewName(viewName);
      ViewEntity viewEntity = new ViewEntity();
      viewEntity.setName(viewName);
      viewEntity.setVersion(version);
      viewInstanceEntity.setViewEntity(viewEntity);
    }
    if (properties.containsKey(LABEL_PROPERTY_ID)) {
      viewInstanceEntity.setLabel((String) properties.get(LABEL_PROPERTY_ID));
    }

    if (properties.containsKey(DESCRIPTION_PROPERTY_ID)) {
      viewInstanceEntity.setDescription((String) properties.get(DESCRIPTION_PROPERTY_ID));
    }

    String visible = (String) properties.get(VISIBLE_PROPERTY_ID);
    viewInstanceEntity.setVisible(visible==null ? true : Boolean.valueOf(visible));

    if (properties.containsKey(ICON_PATH_ID)) {
      viewInstanceEntity.setIcon((String) properties.get(ICON_PATH_ID));
    }

    if (properties.containsKey(ICON64_PATH_ID)) {
      viewInstanceEntity.setIcon64((String) properties.get(ICON64_PATH_ID));
    }

    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);
      }
    }
    if (!instanceProperties.isEmpty()) {
      viewInstanceEntity.setProperties(instanceProperties);
    }
    if (!instanceData.isEmpty()) {
      viewInstanceEntity.setData(instanceData);
    }

    return viewInstanceEntity;
  }
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(request, 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

      throws Exception {
    ViewConfig viewConfig = ViewConfigTest.getConfig(xml);
    ViewEntity viewDefinition = ViewEntityTest.getViewEntity(viewConfig);

    InstanceConfig instanceConfig = InstanceConfigTest.getInstanceConfigs().get(0);
    ViewInstanceEntity viewInstanceEntity = new ViewInstanceEntity(viewDefinition, instanceConfig);

    setPersistenceEntities(viewInstanceEntity);

    Injector injector = Guice.createInjector(
        new TestModule(viewInstanceEntity, entityManagerFactory, jpaDynamicHelper, classLoader, schemaManager));
View Full Code Here

public class ViewExternalSubResourceServiceTest {
  @Test
  public void testAddResourceService() throws Exception {
    Resource.Type type = new Resource.Type("resource");

    ViewInstanceEntity definition = ViewInstanceEntityTest.getViewInstanceEntity();
    ViewExternalSubResourceService service = new ViewExternalSubResourceService(type, definition);

    Object fooService = new Object();

    service.addResourceService("foo", fooService);
View Full Code Here

  @Override
  public List<ServiceTestInvocation> getTestInvocations() throws Exception {
    List<ServiceTestInvocation> listInvocations = new ArrayList<ServiceTestInvocation>();

    ViewInstanceEntity viewInstanceEntity = ViewInstanceEntityTest.getViewInstanceEntity();

    Resource.Type type = new Resource.Type("subResource");

    // get resource
    ViewSubResourceService service = new TestViewSubResourceService(type, viewInstanceEntity);
View Full Code Here

    expect(resource.getType()).andReturn(Resource.Type.Cluster).anyTimes();

    replay(uriInfo, resource);

    //execute test
    ViewInstanceEntity viewInstanceEntity = ViewInstanceEntityTest.getViewInstanceEntity();

    Resource.Type type = new Resource.Type("subResource");

    // get resource
    ViewSubResourceService service = new ViewSubResourceService(type, viewInstanceEntity);
View Full Code Here

    expect(resource.getType()).andReturn(Resource.Type.Cluster).anyTimes();

    replay(uriInfo, resource);

    //execute test
    ViewInstanceEntity viewInstanceEntity = ViewInstanceEntityTest.getViewInstanceEntity();

    Resource.Type type = new Resource.Type("subResource");

    // get resource
    ViewSubResourceService service = new ViewSubResourceService(type, 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.