Search in sources :

Example 1 with ExcelField

use of org.pentaho.di.trans.steps.exceloutput.ExcelField in project pentaho-kettle by pentaho.

the class ExcelOutputDialog method getData.

/**
 * Copy information from the meta-data input to the dialog fields.
 */
public void getData() {
    if (input.getFileName() != null) {
        wFilename.setText(input.getFileName());
    }
    wDoNotOpenNewFileInit.setSelection(input.isDoNotOpenNewFileInit());
    if (input.getExtension() != null) {
        wExtension.setText(input.getExtension());
    }
    if (input.getEncoding() != null) {
        wEncoding.setText(input.getEncoding());
    }
    if (input.getTemplateFileName() != null) {
        wTemplateFilename.setText(input.getTemplateFileName());
    }
    wuseTempFiles.setSelection(input.isUseTempFiles());
    if (input.getTempDirectory() != null) {
        wTempDirectory.setText(input.getTempDirectory());
    }
    wSplitEvery.setText("" + input.getSplitEvery());
    wAppend.setSelection(input.isAppend());
    wHeader.setSelection(input.isHeaderEnabled());
    wFooter.setSelection(input.isFooterEnabled());
    wAddDate.setSelection(input.isDateInFilename());
    wAddTime.setSelection(input.isTimeInFilename());
    if (input.getDateTimeFormat() != null) {
        wDateTimeFormat.setText(input.getDateTimeFormat());
    }
    wSpecifyFormat.setSelection(input.isSpecifyFormat());
    wCreateParentFolder.setSelection(input.isCreateParentFolder());
    wAddToResult.setSelection(input.isAddToResultFiles());
    wAutoSize.setSelection(input.isAutoSizeColums());
    wNullIsBlank.setSelection(input.isNullBlank());
    wAddStepnr.setSelection(input.isStepNrInFilename());
    wTemplate.setSelection(input.isTemplateEnabled());
    wTemplateAppend.setSelection(input.isTemplateAppend());
    if (input.getSheetname() != null) {
        wSheetname.setText(input.getSheetname());
    } else {
        wSheetname.setText("Sheet1");
    }
    wProtectSheet.setSelection(input.isSheetProtected());
    EnablePassword();
    EnableTemplate();
    if (input.getPassword() != null) {
        wPassword.setText(input.getPassword());
    }
    if (isDebug()) {
        logDebug("getting fields info...");
    }
    for (int i = 0; i < input.getOutputFields().length; i++) {
        ExcelField field = input.getOutputFields()[i];
        TableItem item = wFields.table.getItem(i);
        if (field.getName() != null) {
            item.setText(1, field.getName());
        }
        item.setText(2, field.getTypeDesc());
        if (field.getFormat() != null) {
            item.setText(3, field.getFormat());
        }
    }
    wFields.optWidth(true);
    // Header Font settings
    wHeaderFontName.setText(ExcelOutputMeta.getFontNameDesc(input.getHeaderFontName()));
    wHeaderFontSize.setText(input.getHeaderFontSize());
    wHeaderFontBold.setSelection(input.isHeaderFontBold());
    wHeaderFontItalic.setSelection(input.isHeaderFontItalic());
    wHeaderFontUnderline.setText(ExcelOutputMeta.getFontUnderlineDesc(input.getHeaderFontUnderline()));
    wHeaderFontOrientation.setText(ExcelOutputMeta.getFontOrientationDesc(input.getHeaderFontOrientation()));
    wHeaderFontColor.setText(ExcelOutputMeta.getFontColorDesc(input.getHeaderFontColor()));
    wHeaderBackGroundColor.setText(ExcelOutputMeta.getFontColorDesc(input.getHeaderBackGroundColor()));
    wHeaderRowHeight.setText(Const.NVL(input.getHeaderRowHeight(), "" + ExcelOutputMeta.DEFAULT_ROW_HEIGHT));
    wHeaderAlignment.setText(ExcelOutputMeta.getFontAlignmentDesc(input.getHeaderAlignment()));
    if (input.getHeaderImage() != null) {
        wImage.setText(input.getHeaderImage());
    }
    // Row font settings
    wRowFontName.setText(ExcelOutputMeta.getFontNameDesc(input.getRowFontName()));
    wRowFontSize.setText(input.getRowFontSize());
    wRowFontColor.setText(ExcelOutputMeta.getFontColorDesc(input.getRowFontColor()));
    wRowBackGroundColor.setText(ExcelOutputMeta.getFontColorDesc(input.getRowBackGroundColor()));
    wStepname.selectAll();
    wStepname.setFocus();
}
Also used : ExcelField(org.pentaho.di.trans.steps.exceloutput.ExcelField) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point)

Example 2 with ExcelField

use of org.pentaho.di.trans.steps.exceloutput.ExcelField in project pentaho-kettle by pentaho.

the class ExcelOutputDialog method getInfo.

private void getInfo(ExcelOutputMeta tfoi) {
    tfoi.setFileName(wFilename.getText());
    tfoi.setEncoding(wEncoding.getText());
    tfoi.setDoNotOpenNewFileInit(wDoNotOpenNewFileInit.getSelection());
    tfoi.setExtension(wExtension.getText());
    tfoi.setTemplateFileName(wTemplateFilename.getText());
    tfoi.setSplitEvery(Const.toInt(wSplitEvery.getText(), 0));
    tfoi.setAppend(wAppend.getSelection());
    tfoi.setHeaderEnabled(wHeader.getSelection());
    tfoi.setFooterEnabled(wFooter.getSelection());
    tfoi.setStepNrInFilename(wAddStepnr.getSelection());
    tfoi.setDateInFilename(wAddDate.getSelection());
    tfoi.setTimeInFilename(wAddTime.getSelection());
    tfoi.setUseTempFiles(wuseTempFiles.getSelection());
    tfoi.setTempDirectory(wTempDirectory.getText());
    tfoi.setDateTimeFormat(wDateTimeFormat.getText());
    tfoi.setSpecifyFormat(wSpecifyFormat.getSelection());
    tfoi.setAutoSizeColums(wAutoSize.getSelection());
    tfoi.setNullIsBlank(wNullIsBlank.getSelection());
    tfoi.setAddToResultFiles(wAddToResult.getSelection());
    tfoi.setCreateParentFolder(wCreateParentFolder.getSelection());
    tfoi.setProtectSheet(wProtectSheet.getSelection());
    tfoi.setPassword(wPassword.getText());
    tfoi.setTemplateEnabled(wTemplate.getSelection());
    tfoi.setTemplateAppend(wTemplateAppend.getSelection());
    if (wSheetname.getText() != null) {
        tfoi.setSheetname(wSheetname.getText());
    } else {
        tfoi.setSheetname("Sheet 1");
    }
    int i;
    // Table table = wFields.table;
    int nrfields = wFields.nrNonEmpty();
    tfoi.allocate(nrfields);
    for (i = 0; i < nrfields; i++) {
        ExcelField field = new ExcelField();
        TableItem item = wFields.getNonEmpty(i);
        field.setName(item.getText(1));
        field.setType(item.getText(2));
        field.setFormat(item.getText(3));
        // CHECKSTYLE:Indentation:OFF
        tfoi.getOutputFields()[i] = field;
    }
    // Header font
    tfoi.setHeaderFontName(ExcelOutputMeta.getFontNameByDesc(wHeaderFontName.getText()));
    tfoi.setHeaderFontSize(wHeaderFontSize.getText());
    tfoi.setHeaderFontBold(wHeaderFontBold.getSelection());
    tfoi.setHeaderFontItalic(wHeaderFontItalic.getSelection());
    tfoi.setHeaderFontUnderline(ExcelOutputMeta.getFontUnderlineByDesc(wHeaderFontUnderline.getText()));
    tfoi.setHeaderFontOrientation(ExcelOutputMeta.getFontOrientationByDesc(wHeaderFontOrientation.getText()));
    tfoi.setHeaderFontColor(ExcelOutputMeta.getFontColorByDesc(wHeaderFontColor.getText()));
    tfoi.setHeaderBackGroundColor(ExcelOutputMeta.getFontColorByDesc(wHeaderBackGroundColor.getText()));
    tfoi.setHeaderRowHeight(wHeaderRowHeight.getText());
    tfoi.setHeaderAlignment(ExcelOutputMeta.getFontAlignmentByDesc(wHeaderAlignment.getText()));
    tfoi.setHeaderImage(wImage.getText());
    // Row font
    tfoi.setRowFontName(ExcelOutputMeta.getFontNameByDesc(wRowFontName.getText()));
    tfoi.setRowFontSize(wRowFontSize.getText());
    tfoi.setRowFontColor(ExcelOutputMeta.getFontColorByDesc(wRowFontColor.getText()));
    tfoi.setRowBackGroundColor(ExcelOutputMeta.getFontColorByDesc(wRowBackGroundColor.getText()));
}
Also used : ExcelField(org.pentaho.di.trans.steps.exceloutput.ExcelField) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point)

Example 3 with ExcelField

use of org.pentaho.di.trans.steps.exceloutput.ExcelField in project pentaho-metaverse by pentaho.

the class ExcelOutputStepAnalyzer method getOutputResourceFields.

@Override
public Set<String> getOutputResourceFields(ExcelOutputMeta meta) {
    Set<String> fields = new HashSet<>();
    ExcelField[] outputFields = meta.getOutputFields();
    for (int i = 0; i < outputFields.length; i++) {
        ExcelField outputField = outputFields[i];
        fields.add(outputField.getName());
    }
    return fields;
}
Also used : ExcelField(org.pentaho.di.trans.steps.exceloutput.ExcelField) HashSet(java.util.HashSet)

Example 4 with ExcelField

use of org.pentaho.di.trans.steps.exceloutput.ExcelField in project pentaho-metaverse by pentaho.

the class MetaverseValidationIT method testExcelOutputStepNode.

@Test
public void testExcelOutputStepNode() throws Exception {
    ExcelOutputStepNode excelOutputStepNode = root.getExcelOutputStepNode();
    assertNotNull(excelOutputStepNode);
    ExcelOutputMeta meta = (ExcelOutputMeta) getStepMeta(excelOutputStepNode);
    TransMeta tm = meta.getParentStepMeta().getParentTransMeta();
    String[] fileNames = meta.getFiles(tm);
    RowMetaInterface incomingFields = tm.getStepFields(meta.getParentStepMeta());
    ExcelField[] outputFields = meta.getOutputFields();
    // should write to one file
    Iterable<FramedMetaverseNode> outputFiles = excelOutputStepNode.getOutputFiles();
    assertEquals(fileNames.length, getIterableSize(outputFiles));
    int i = 0;
    for (FramedMetaverseNode node : outputFiles) {
        assertEquals(normalizeFilePath(fileNames[i++]), normalizeFilePath(node.getName()));
    }
    Iterable<StreamFieldNode> outFields = excelOutputStepNode.getOutputStreamFields();
    int outFieldCount = getIterableSize(outFields);
    // should have output stream nodes as well as file nodes
    assertEquals(outputFields.length * 2, outFieldCount);
    int fileFieldCount = 0;
    for (StreamFieldNode outField : outFields) {
        if (DictionaryConst.NODE_TYPE_FILE_FIELD.equals(outField.getType())) {
            ValueMetaInterface vmi = incomingFields.searchValueMeta(outField.getName());
            assertEquals(vmi.getName(), outField.getFieldPopulatesMe().getName());
            fileFieldCount++;
        }
    }
    assertEquals(fileFieldCount, outFieldCount / 2);
}
Also used : ExcelField(org.pentaho.di.trans.steps.exceloutput.ExcelField) ExcelOutputMeta(org.pentaho.di.trans.steps.exceloutput.ExcelOutputMeta) TransMeta(org.pentaho.di.trans.TransMeta) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ExcelOutputStepNode(org.pentaho.metaverse.frames.ExcelOutputStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) Test(org.junit.Test)

Example 5 with ExcelField

use of org.pentaho.di.trans.steps.exceloutput.ExcelField in project pentaho-metaverse by pentaho.

the class ExcelOutputStepAnalyzerTest method testGetOutputResourceFields.

@Test
public void testGetOutputResourceFields() throws Exception {
    ExcelField[] outputFields = new ExcelField[2];
    ExcelField field1 = mock(ExcelField.class);
    ExcelField field2 = mock(ExcelField.class);
    outputFields[0] = field1;
    outputFields[1] = field2;
    when(field1.getName()).thenReturn("field1");
    when(field2.getName()).thenReturn("field2");
    when(meta.getOutputFields()).thenReturn(outputFields);
    Set<String> outputResourceFields = analyzer.getOutputResourceFields(meta);
    assertEquals(outputFields.length, outputResourceFields.size());
    for (ExcelField outputField : outputFields) {
        assertTrue(outputResourceFields.contains(outputField.getName()));
    }
}
Also used : ExcelField(org.pentaho.di.trans.steps.exceloutput.ExcelField) Test(org.junit.Test)

Aggregations

ExcelField (org.pentaho.di.trans.steps.exceloutput.ExcelField)5 Point (org.eclipse.swt.graphics.Point)2 TableItem (org.eclipse.swt.widgets.TableItem)2 Test (org.junit.Test)2 HashSet (java.util.HashSet)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1 TransMeta (org.pentaho.di.trans.TransMeta)1 ExcelOutputMeta (org.pentaho.di.trans.steps.exceloutput.ExcelOutputMeta)1 ExcelOutputStepNode (org.pentaho.metaverse.frames.ExcelOutputStepNode)1 FramedMetaverseNode (org.pentaho.metaverse.frames.FramedMetaverseNode)1 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)1