Package org.jitterbit.integration.data.structure.text

Examples of org.jitterbit.integration.data.structure.text.Segment


    private void addSegmentForTable(Node tableNode, String parentName, ComplexTextStructure structure, Set<String> identifiers) {
        DatabaseObject table = tableNode.getTable();
        SchemaAndTableNameSeparator nameSeparator = new SchemaAndTableNameSeparator(table.getName(), quotes);
        String tableName = nameSeparator.getTable();
        String id = getSegmentId(tableName, identifiers);
        Segment segment = createSegment(table, id);
        String segmentName = TextStructureNameUtils.replaceIllegalCharacters(tableName);
        segment.setName(segmentName);
        segment.setParentName(parentName);
        SegmentOccurrence occurrence = getSegmentOccurrence(tableNode.getCardinality());
        segment.setOccurrence(occurrence);
        structure.addSegment(segment);
        for (Node child : tableNode.getChildren()) {
            addSegmentForTable(child, segmentName, structure, identifiers);
        }
    }
View Full Code Here


        taken.add(id);
        return id;
    }

    private Segment createSegment(DatabaseObject table, String id) {
        Segment segment = new Segment("");
        if (id != null) {
            Field idField = Field.newDelimitedIdentifier(id);
            segment.fieldList.add(idField);
        }
        for (DatabaseColumn column : table.getAllColumns()) {
View Full Code Here

            throw new RuntimeException("Unexpected cardinality: " + cardinality);
        }
    }

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

    public static SimpleTextStructure fromSampleDataFile(String name, Prototype p, FieldDelimiter delimiter,
                    BufferedReader reader) throws IOException, InvalidTemplateException {
        try {
            SimpleTextStructure structure = new SimpleTextStructure(name, false);
            structure.segment = new Segment(name);
            boolean withHeader=true;
            switch (p) {
            case SampleFlatFile:
                withHeader = false;
                break;
View Full Code Here

    public static SimpleTextStructure fromDefinitionFile(String name, boolean fixedField, BufferedReader reader)
                    throws IOException, InvalidTemplateException {
        try {
            SimpleTextStructure structure = new SimpleTextStructure(name, fixedField);
            structure.segment = new Segment(name);
            structure.segment.createFromSimpleTextDef(reader, fixedField);
            return structure;
        } catch (RuntimeException ex) {
            throw new InvalidTemplateException(ex);
        }
View Full Code Here

        }
    }

    public SimpleTextStructure(String name, boolean fixedField) {
        super(DataStructureType.Text, name, fixedField);
        segment = new Segment("");
    }
View Full Code Here

        segment = new Segment("");
    }

    public SimpleTextStructure(String name, boolean fixedField, List<String> lines) {
        super(DataStructureType.Text, name, fixedField);
        segment = new Segment("");
        if (lines != null) {
            defineFieldList(lines);
        }
    }
View Full Code Here

    @Override
    public SimpleTextStructure clone() {
        synchronized (getDataLock()) {
            SimpleTextStructure clone = (SimpleTextStructure)super.clone();
            clone.segment = new Segment(segment);
            return clone;
        }
    }
View Full Code Here

  private void defineSegmentList(List<String> lines) {
    String[]columns;
    for(String line : lines){
      // shall skip the first line if it is a list of column name
      columns=KongaStringUtils.split(line);
      Segment tmpSegment;
      Field tmpField;
      String fieldName=columns[3],defaultValue=columns[9],format=columns[10];
      int fieldId=Integer.parseInt(columns[1]),
        parentId=Integer.parseInt(columns[2]),
        sequence=KongaStringUtils.parseInt(columns[4], 0),
        varTypeId=KongaStringUtils.parseInt(columns[5], 0),
        startPos=KongaStringUtils.parseInt(columns[6], 0),
        endPos=KongaStringUtils.parseInt(columns[7], 0),
        required=KongaStringUtils.parseInt(columns[8], 0);
      String dataType=Field.Variable_TypeTab[varTypeId];

      if(dataType.equals("Segment")){ // define a Segment in the ComplexTextStructure
        tmpSegment=new Segment(fieldName);
        tmpSegment.setId(fieldId);
        if(parentId>0){
          Segment parent=getSegment(parentId);
          if(parent!=null){
            tmpSegment.setParentName(parent.getName());
          } else {
            tmpSegment.setParentName(c_rootName);
            parentId=1;
          }
        }
View Full Code Here

          // Seems like segment ids are not updated correctly. We have to do it here.
            // It does not matter though since parents are referenced by name.
          segment.setId(++id);
          String[] data = new String[12];
          data[1] = Integer.toString( segment.getId() );
          Segment parent = segment.findParent(this);
          if (parent == null) {
                    data[2] = "0";
          }
                else {
                    data[2] = Integer.toString(parent.getId());
                }

          data[3] = segment.getName();
          Segment aliasSegment = segment.getAlias();
          if (aliasSegment != null) {
                    data[4] = Integer.toString(aliasSegment.getId());
                }
                else {
                    data[4] = "0";
                }
          data[5] = "8"// This is always 8 for segments.
View Full Code Here

TOP

Related Classes of org.jitterbit.integration.data.structure.text.Segment

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.