Package org.jitterbit.integration.data.structure

Examples of org.jitterbit.integration.data.structure.SimpleTextStructure


            delimQualifierPanel.applyToTextDocument(document);
        }
    }

    private void applyStructure(TextDocument document) {
        SimpleTextStructure structure = getTextStructure(document);
        structure.setFieldList(fieldModel.getFields());
        // HACK: This should really be done by PropertyChangeListeners:
        // The document need to listen to changes in its SimpleTextStructure,
        // and fire those changes to its own listeners
        document.documentStructureChanged();
    }
View Full Code Here


            BufferedReader reader = null;
            try {
                Factory factory = factories.get(ui.getPrototype());
                File file = ui.getFile();
                reader = new BufferedReader(new FileReader(file));
                SimpleTextStructure structure = factory.createStructure(name, reader);
                document.setDelimiter(ui.getDelimiter());
                callback.succeeded(structure);
            } catch (Exception ex) {
                callback.failed(ex);
            } finally {
View Full Code Here

    }

    @Test
    public void testDelimiterValidation() {
        TextDocument doc = createValidSimpleDelimitedDocument(2);
        SimpleTextStructure struct = (SimpleTextStructure) doc.getDataStructure();
        doc.setProperty(TextDocument.DELIMITER, null);
        runValidation(doc, ValidationStatus.INVALID);
        doc.setDelimiter(FieldDelimiter.NEW_LINE);
        runValidation(doc, ValidationStatus.INVALID); // Invalid because the document has two fields
        struct.getSegment().getFieldList().remove(0);
        runValidation(doc, ValidationStatus.VALID); // Valid because now the document has only one field
        doc = createValidSimpleFixedFieldDocument();
        doc.setProperty(TextDocument.DELIMITER, null);
        runValidation(doc, ValidationStatus.VALID); // Valid because fixed field documents do not use a delimiter
        doc.setProperty(TextDocument.DELIMITER, FieldDelimiter.NEW_LINE);
View Full Code Here

    }

    @Test
    public void testSimpleDelimitedStructureValidation() {
        TextDocument doc = createValidSimpleDelimitedDocument(2);
        SimpleTextStructure struct = (SimpleTextStructure) doc.getDataStructure();
        Field f0 = struct.getSegment().getFieldList().get(0);
        Field f1 = struct.getSegment().getFieldList().get(1);
        f1.setName(f0.getName());
        runValidation(doc, ValidationStatus.INVALID);
    }
View Full Code Here

    }

    @Test
    public void testSimpleFixedFieldStructureValidation() {
        TextDocument doc = createValidSimpleFixedFieldDocument();
        SimpleTextStructure struct = (SimpleTextStructure) doc.getDataStructure();
        Field f0 = struct.getSegment().getFieldList().get(0);
        Field f1 = struct.getSegment().getFieldList().get(1);
        f1.setName(f0.getName());
        runValidation(doc, ValidationStatus.INVALID);
    }
View Full Code Here

        assertEquals(c.result().status(), expected);
    }

    private static TextDocument createValidSimpleDelimitedDocument(int numberOfFields) {
        TextDocument doc = new TextDocument("Test");
        SimpleTextStructure struct = new SimpleTextStructure(doc.getName(), false);
        Segment seg = new Segment("seg_1");
        for (int n = 0; n < numberOfFields; ++n) {
            Field f = new Field(n, "F" + n, FieldDataType.String.name(), "", "", 0, false);
            seg.getFieldList().add(f);
        }
        struct.setSegment(seg);
        doc.setStructure(struct);
        doc.setDelimiter(FieldDelimiter.COMMA);
        return doc;
    }
View Full Code Here

    }

    private static TextDocument createValidSimpleFixedFieldDocument() {
        TextDocument doc = new TextDocument("Test");
        Segment seg = new Segment("seg_1");
        SimpleTextStructure struct = new SimpleTextStructure(doc.getName(), true);
        Field field_1 = new Field(1, "A", FieldDataType.String.name(), "", "", 0, true);
        field_1.setBeginPosition(0);
        field_1.setLength(2);
        seg.getFieldList().add(field_1);
        Field field_2 = new Field(1, "B", FieldDataType.String.name(), "", "", 0, true);
        field_2.setBeginPosition(2);
        field_2.setLength(4);
        seg.getFieldList().add(field_2);
        struct.setSegment(seg);
        doc.setStructure(struct);
        doc.setDelimiter(FieldDelimiter.COMMA);
        return doc;
    }
View Full Code Here

        }
    }

    private TextStructure createFlatText(DatabaseObject table) {
        Segment segment = createSegment(table, null);
        SimpleTextStructure struct = new SimpleTextStructure("", false);
        struct.setSegment(segment);
        return struct;
    }
View Full Code Here

    synchronized (getDataLock()) {
            if (isUnknownDoc()) {
                return null;
            }
            if (isSimpleDoc()) {
                textStructure = new SimpleTextStructure(getName(), isFixedField(), lines);
            } else {
                textStructure = new ComplexTextStructure(getName(), isFixedField(), lines);
            }
            updateTextStructureDelimiterAndQualifier();
            setDeployDirty(true);
View Full Code Here

            // If saved in versions 2.0.0.5 - 2.0.0.7, the persistor was saved as part of
            // the key-value pairs.
        }
        // TODO: Make sure this works (i.e. that this property is restored by the call to super.restoreFrom)
        if (isSimpleDoc()) {
            textStructure = new SimpleTextStructure("", false);
        } else {
            textStructure = new ComplexTextStructure("", false);
        }
        textStructure.restoreFrom(p.getFirstChild("Structure"));
        updateTextStructureDelimiterAndQualifier();
View Full Code Here

TOP

Related Classes of org.jitterbit.integration.data.structure.SimpleTextStructure

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.