Search in sources :

Example 6 with BeanInjectionInfo

use of org.pentaho.di.core.injection.bean.BeanInjectionInfo in project pentaho-kettle by pentaho.

the class BaseMetadataInjectionTest method setup.

protected void setup(T meta) {
    KettleLogStore.init();
    this.meta = meta;
    info = new BeanInjectionInfo(meta.getClass());
    injector = new BeanInjector(info);
    nonTestedProperties = new HashSet<>(info.getProperties().keySet());
}
Also used : BeanInjector(org.pentaho.di.core.injection.bean.BeanInjector) BeanInjectionInfo(org.pentaho.di.core.injection.bean.BeanInjectionInfo)

Example 7 with BeanInjectionInfo

use of org.pentaho.di.core.injection.bean.BeanInjectionInfo in project pentaho-kettle by pentaho.

the class MetaAnnotationInjectionTest method testInjectionDescription.

@Test
public void testInjectionDescription() throws Exception {
    BeanInjectionInfo ri = new BeanInjectionInfo(MetaBeanLevel1.class);
    assertEquals(3, ri.getGroups().size());
    assertEquals("", ri.getGroups().get(0).getName());
    assertEquals("FILENAME_LINES", ri.getGroups().get(1).getName());
    assertEquals("FILENAME_LINES2", ri.getGroups().get(2).getName());
    assertTrue(ri.getProperties().containsKey("SEPARATOR"));
    assertTrue(ri.getProperties().containsKey("FILENAME"));
    assertTrue(ri.getProperties().containsKey("BASE"));
    assertTrue(ri.getProperties().containsKey("FIRST"));
    assertEquals("FILENAME_LINES", ri.getProperties().get("FILENAME").getGroupName());
    assertEquals("!DESCRIPTION!", ri.getDescription("DESCRIPTION"));
}
Also used : BeanInjectionInfo(org.pentaho.di.core.injection.bean.BeanInjectionInfo) Test(org.junit.Test)

Example 8 with BeanInjectionInfo

use of org.pentaho.di.core.injection.bean.BeanInjectionInfo in project pentaho-kettle by pentaho.

the class MetaInjectDialog method processNewMDIDescription.

private void processNewMDIDescription(StepMeta stepMeta, TreeItem stepItem, StepMetaInterface metaInterface) {
    BeanInjectionInfo stepInjectionInfo = new BeanInjectionInfo(metaInterface.getClass());
    for (BeanInjectionInfo.Group gr : stepInjectionInfo.getGroups()) {
        boolean rootGroup = StringUtils.isEmpty(gr.getName());
        TreeItem groupItem;
        if (!rootGroup) {
            groupItem = new TreeItem(stepItem, SWT.NONE);
            groupItem.setText(gr.getName());
            groupItem.setText(1, gr.getDescription());
        } else {
            groupItem = null;
        }
        for (BeanInjectionInfo.Property property : gr.getGroupProperties()) {
            TreeItem treeItem = new TreeItem(rootGroup ? stepItem : groupItem, SWT.NONE);
            treeItem.setText(property.getName());
            treeItem.setText(1, property.getDescription());
            TargetStepAttribute target = new TargetStepAttribute(stepMeta.getName(), property.getName(), !rootGroup);
            treeItemTargetMap.put(treeItem, target);
            SourceStepField source = targetSourceMapping.get(target);
            if (source != null) {
                treeItem.setText(2, Const.NVL(source.getStepname() == null ? CONST_VALUE : source.getStepname(), ""));
                treeItem.setText(3, Const.NVL(source.getField(), ""));
            }
        }
    }
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) BeanInjectionInfo(org.pentaho.di.core.injection.bean.BeanInjectionInfo) TargetStepAttribute(org.pentaho.di.trans.steps.metainject.TargetStepAttribute) SourceStepField(org.pentaho.di.trans.steps.metainject.SourceStepField)

Example 9 with BeanInjectionInfo

use of org.pentaho.di.core.injection.bean.BeanInjectionInfo in project pentaho-kettle by pentaho.

the class MetaAnnotationInjectionTest method testGenerics.

@Test
public void testGenerics() throws Exception {
    BeanInjectionInfo ri = new BeanInjectionInfo(MetaBeanChild.class);
    assertTrue(ri.getProperties().size() == 7);
    assertTrue(ri.getProperties().containsKey("BASE_ITEM_NAME"));
    assertTrue(ri.getProperties().containsKey("ITEM_CHILD_NAME"));
    assertTrue(ri.getProperties().containsKey("A"));
    assertTrue(ri.getProperties().containsKey("ITEM.BASE_ITEM_NAME"));
    assertTrue(ri.getProperties().containsKey("ITEM.ITEM_CHILD_NAME"));
    assertTrue(ri.getProperties().containsKey("SUB.BASE_ITEM_NAME"));
    assertTrue(ri.getProperties().containsKey("SUB.ITEM_CHILD_NAME"));
    assertEquals(String.class, ri.getProperties().get("A").getPropertyClass());
}
Also used : BeanInjectionInfo(org.pentaho.di.core.injection.bean.BeanInjectionInfo) Test(org.junit.Test)

Aggregations

BeanInjectionInfo (org.pentaho.di.core.injection.bean.BeanInjectionInfo)9 BeanInjector (org.pentaho.di.core.injection.bean.BeanInjector)5 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)1 SourceStepField (org.pentaho.di.trans.steps.metainject.SourceStepField)1 TargetStepAttribute (org.pentaho.di.trans.steps.metainject.TargetStepAttribute)1