Search in sources :

Example 1 with ApplicationDetailDescriptor

use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.

the class VisitableDetailTest method visit.

@Test
public void visit() throws AssemblyException, ActivationException {
    ApplicationDescriptor application = new Energy4Java().newApplicationModel(new ApplicationAssembler() {

        @Override
        public ApplicationAssembly assemble(ApplicationAssemblyFactory applicationFactory) throws AssemblyException {
            ApplicationAssembly app = applicationFactory.newApplicationAssembly();
            app.setName("UnderTestApp");
            app.withActivators(ApplicationActivator.class);
            LayerAssembly layer = app.layer("LayerName");
            layer.withActivators(LayerActivator.class);
            ModuleAssembly module = layer.module("ModuleName");
            module.withActivators(ModuleActivator.class);
            return app;
        }
    });
    ApplicationDetailDescriptor detail = createApplicationDetailDescriptor(application);
    Visitor visitor = new Visitor();
    detail.accept(visitor);
    assertThat(visitor.events, equalTo(Arrays.asList(// Application
    "visitEnter( UnderTestApp )", "visit( " + ApplicationActivator.class.getName() + " )", // Layer
    "visitEnter( LayerName )", "visit( " + LayerActivator.class.getName() + " )", // Module
    "visitEnter( ModuleName )", "visit( " + ModuleActivator.class.getName() + " )", // Leaving Structure
    "visitLeave( ModuleName )", "visitLeave( LayerName )", "visitLeave( UnderTestApp )")));
}
Also used : ApplicationAssemblyFactory(org.qi4j.bootstrap.ApplicationAssemblyFactory) ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor) ApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor) HierarchicalVisitor(org.qi4j.functional.HierarchicalVisitor) ApplicationAssembly(org.qi4j.bootstrap.ApplicationAssembly) ApplicationDescriptor(org.qi4j.api.structure.ApplicationDescriptor) LayerAssembly(org.qi4j.bootstrap.LayerAssembly) AssemblyException(org.qi4j.bootstrap.AssemblyException) ModuleAssembly(org.qi4j.bootstrap.ModuleAssembly) ApplicationAssembler(org.qi4j.bootstrap.ApplicationAssembler) Energy4Java(org.qi4j.bootstrap.Energy4Java) Test(org.junit.Test)

Example 2 with ApplicationDetailDescriptor

use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.

the class EntityViewer method initEntityCombo.

private void initEntityCombo(DefaultComboBoxModel entityComboModel) {
    // create the visitor to traverse the QI4J to find the module
    ApplicationDetailDescriptor visitor = ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor(model);
    // find all entities
    Iterable<LayerDetailDescriptor> layerDescIter = visitor.layers();
    for (LayerDetailDescriptor layerDesc : layerDescIter) {
        Iterable<ModuleDetailDescriptor> moduleDescIter = layerDesc.modules();
        for (ModuleDetailDescriptor moduleDesc : moduleDescIter) {
            Iterable<EntityDetailDescriptor> entityDescIter = moduleDesc.entities();
            for (EntityDetailDescriptor entity : entityDescIter) {
                entityComboModel.addElement(entity);
            }
        }
    }
}
Also used : ApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor) EntityDetailDescriptor(org.qi4j.tools.model.descriptor.EntityDetailDescriptor) LayerDetailDescriptor(org.qi4j.tools.model.descriptor.LayerDetailDescriptor) ModuleDetailDescriptor(org.qi4j.tools.model.descriptor.ModuleDetailDescriptor)

Example 3 with ApplicationDetailDescriptor

use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.

the class TreePanel method reload.

public void reload() {
    // build the visitor which allow traverse qi4j model
    ApplicationDetailDescriptor visitor = ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor(model);
    DefaultTreeModel treeModel = new DefaultTreeModel(new TreeModelBuilder().build(visitor));
    applicationTree.setModel(treeModel);
}
Also used : ApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor) DefaultTreeModel(javax.swing.tree.DefaultTreeModel)

Example 4 with ApplicationDetailDescriptor

use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.

the class ServiceUsageFinder method findServiceUsage.

public List<ServiceUsage> findServiceUsage(ServiceDetailDescriptor descriptor) {
    usages = new ArrayList<ServiceUsage>();
    this.descriptor = descriptor;
    // traverse the appDescritor/model to find the usage
    ApplicationDetailDescriptor appDescriptor = descriptor.module().layer().application();
    collectUsage(appDescriptor);
    return usages;
}
Also used : ApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor) ServiceUsage(org.qi4j.tools.model.descriptor.ServiceUsage)

Example 5 with ApplicationDetailDescriptor

use of org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor in project qi4j-sdk by Qi4j.

the class ServiceConfigurationFinder method findConfigurationDescriptor.

public Object findConfigurationDescriptor(ServiceDetailDescriptor descriptor) {
    Class<?> configType = descriptor.descriptor().configurationType();
    if (configType == null) {
        return null;
    }
    // traverse the appDescritor to find the configurationDescriptor
    ApplicationDetailDescriptor appDescriptor = descriptor.module().layer().application();
    Object obj = findConfigurationDescriptor(appDescriptor, configType);
    if (obj == null) {
        return null;
    }
    return obj;
}
Also used : ApplicationDetailDescriptor(org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor)

Aggregations

ApplicationDetailDescriptor (org.qi4j.tools.model.descriptor.ApplicationDetailDescriptor)5 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)1 Test (org.junit.Test)1 ApplicationDescriptor (org.qi4j.api.structure.ApplicationDescriptor)1 ApplicationAssembler (org.qi4j.bootstrap.ApplicationAssembler)1 ApplicationAssembly (org.qi4j.bootstrap.ApplicationAssembly)1 ApplicationAssemblyFactory (org.qi4j.bootstrap.ApplicationAssemblyFactory)1 AssemblyException (org.qi4j.bootstrap.AssemblyException)1 Energy4Java (org.qi4j.bootstrap.Energy4Java)1 LayerAssembly (org.qi4j.bootstrap.LayerAssembly)1 ModuleAssembly (org.qi4j.bootstrap.ModuleAssembly)1 HierarchicalVisitor (org.qi4j.functional.HierarchicalVisitor)1 ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor (org.qi4j.tools.model.descriptor.ApplicationDetailDescriptorBuilder.createApplicationDetailDescriptor)1 EntityDetailDescriptor (org.qi4j.tools.model.descriptor.EntityDetailDescriptor)1 LayerDetailDescriptor (org.qi4j.tools.model.descriptor.LayerDetailDescriptor)1 ModuleDetailDescriptor (org.qi4j.tools.model.descriptor.ModuleDetailDescriptor)1 ServiceUsage (org.qi4j.tools.model.descriptor.ServiceUsage)1