Package org.jitterbit.integration.data.structure.database

Examples of org.jitterbit.integration.data.structure.database.DbTranRelations$Relation


 
  /**
   * {@inheritDoc}
   */
  public void process(RelationContainer relationContainer) {
    Relation relation;
    int memberSequenceId;
   
    relation = relationContainer.getEntity();
   
    relationWriter.writeField(relation.getId());
    relationWriter.writeField(relation.getVersion());
    relationWriter.writeField(relation.getUser().getId());
    relationWriter.writeField(relation.getTimestamp());
    relationWriter.writeField(relation.getChangesetId());
    relationWriter.endRecord();
   
    for (Tag tag : relation.getTags()) {
      relationTagWriter.writeField(relation.getId());
      relationTagWriter.writeField(tag.getKey());
      relationTagWriter.writeField(tag.getValue());
      relationTagWriter.endRecord();
    }
   
    memberSequenceId = 0;
    for (RelationMember member : relation.getMembers()) {
      relationMemberWriter.writeField(relation.getId());
      relationMemberWriter.writeField(member.getMemberId());
      relationMemberWriter.writeField(memberTypeValueMapper.getMemberType(member.getMemberType()));
      relationMemberWriter.writeField(member.getMemberRole());
      relationMemberWriter.writeField(memberSequenceId++);
      relationMemberWriter.endRecord();
View Full Code Here


            processedRelations = new ArrayList<Relation>(INSERT_BULK_ROW_COUNT_RELATION);

            prmIndex = 1;
            for (int i = 0; i < INSERT_BULK_ROW_COUNT_RELATION; i++) {
                Relation relation;

                relation = relationBuffer.remove(0);
                processedRelations.add(relation);

                populateRelationParameters(bulkRelationStatement, prmIndex, relation);
                prmIndex += INSERT_PRM_COUNT_RELATION;
            }

            try {
                bulkRelationStatement.executeUpdate();
            } catch (SQLException e) {
                throw new OsmosisRuntimeException("Unable to bulk insert relations into the database.", e);
            }

            for (Relation relation : processedRelations) {
                addRelationTags(relation);
                addRelationMembers(relation);
            }
        }

        if (complete) {
            while (relationBuffer.size() > 0) {
                Relation relation;

                relation = relationBuffer.remove(0);

                populateRelationParameters(singleRelationStatement, 1, relation);
View Full Code Here

    /**
     * {@inheritDoc}
     */
    public void process(RelationContainer relationContainer) {
        Relation relation;
        long relationId;

        flushWays(true);

        relation = relationContainer.getEntity();
        relationId = relation.getId();

        if (relationId >= maxRelationId) {
            maxRelationId = relationId + 1;
        }
        if (relationId < minRelationId) {
View Full Code Here

 
  /**
   * {@inheritDoc}
   */
  public void process(RelationContainer relationContainer) {
    Relation relation;
    long relationId;
    long objectOffset;
   
    relation = relationContainer.getEntity();
    relationId = relation.getId();
   
    // Write the relation to the object store and save the file offset in an
    // index keyed by relation id.
    objectOffset = relationObjectStore.add(relation);
    relationObjectOffsetIndexWriter.write(
      new LongLongIndexElement(relationId, objectOffset)
    );
   
    // Write the relation id to indexes keyed by each of the relation members.
    for (RelationMember member : relation.getMembers()) {
      EntityType memberType;
     
      memberType = member.getMemberType();
     
      if (memberType.equals(EntityType.Node)) {
View Full Code Here

 
  /**
   * {@inheritDoc}
   */
  public void process(RelationContainer container) {
    Relation relation;
    boolean inArea;
        boolean holdBackRelation;
   
    relation = container.getEntity();
   
    // First look through all the node and way members to see if any are within the filtered area
    inArea = false;
        holdBackRelation = false;

    for (RelationMember member : relation.getMembers()) {
      switch (member.getMemberType()) {
      case Node:
        inArea = availableNodes.get(member.getMemberId());
        break;
      case Way:
        inArea = availableWays.get(member.getMemberId());
        break;
      case Relation:
        inArea = availableRelations.get(member.getMemberId());
        break;
      default:
        break;
      }
     
      if (inArea) {
        break;
      }
    }

        if (cascadingRelations) { //  && referencesOtherRelation && (!inArea || clipIncompleteEntities)) {
            holdBackRelation = true;
        }

    // Check if we're storing entities for later.
    if (storeEntities || holdBackRelation) {
      allRelations.add(container);
        }
   
    // If the relation has at least one member in the filtered area.
    if (inArea) {
      availableRelations.set(relation.getId());
     
      // If we're not storing entities, we pass it on immediately.
      if (!storeEntities && !holdBackRelation) {
        emitRelation(container);
      }
View Full Code Here

   *            Relation to be sent.
   */
  private void emitRelation(RelationContainer relationContainer) {
      if (clipIncompleteEntities) {
        RelationContainer filteredRelationContainer;
        Relation filteredRelation;
       
        filteredRelationContainer = relationContainer.getWriteableInstance();
        filteredRelation = filteredRelationContainer.getEntity();
       
        // Remove members for entities that are unavailable.
        for (Iterator<RelationMember> i = filteredRelation.getMembers().iterator(); i.hasNext();) {
          RelationMember member = i.next();
          EntityType memberType;
          long memberId;
         
          memberType = member.getMemberType();
          memberId = member.getMemberId();
         
          switch (memberType) {
          case Node:
            if (!availableNodes.get(memberId)) {
            i.remove();
          }
            break;
          case Way:
            if (!availableWays.get(memberId)) {
            i.remove();
          }
            break;
          case Relation:
            if (!availableRelations.get(memberId)) {
            i.remove();
          }
            break;
          default:
              break;
          }
        }
     
      // Only add relations that contain entities.
      if (filteredRelation.getMembers().size() > 0) {
        sink.process(filteredRelationContainer);
      }
     
      } else {
        sink.process(relationContainer);
View Full Code Here

      int selectionCount;
     
      selectionCount = 0;
     
      while (i.hasNext()) {
        Relation relation = i.next().getEntity();
        long relationId = relation.getId();
       
        // Ignore relations that have already been selected.
        if (!availableRelations.get(relationId)) {
         
          // This relation becomes an available relation if one of its member
          // relations is also available.
          for (RelationMember member : relation.getMembers()) {
            if (member.getMemberType().equals(EntityType.Relation)) {
              if (availableRelations.get(member.getMemberId())) {
                availableRelations.set(relationId);
                selectionCount++;
              }
View Full Code Here

  /**
   * Test processing a Relation.
   */
  @Test
  public final void testProcess8() {
    Relation testRelation;
   
    testRelation = new Relation(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
    testRelation.getMembers().add(new RelationMember(1234, EntityType.Node, "role1"));
    testRelation.getTags().add(new Tag("test_key1", "test_value1"));
   
    testOsmWriter.process(new RelationContainer(testRelation));
    // Nothing to assert; just expect no exception
  }
View Full Code Here

      int selectionCount;
     
      selectionCount = 0;
     
      while (i.hasNext()) {
        Relation relation = i.next().getEntity();
        long relationId = relation.getId();
       
        // Only examine available relations.
        if (availableRelations.get(relationId)) {
          // Select the child if it hasn't already been selected.
          for (RelationMember member : relation.getMembers()) {
            if (member.getMemberType().equals(EntityType.Relation)) {
              long memberId = member.getMemberId();
             
              if (!availableRelations.get(memberId)) {
                availableRelations.set(memberId);
View Full Code Here

  /**
   * Test processing a Bound after a Relation.
   */
  @Test(expected = OsmosisRuntimeException.class)
  public final void testProcess9() {
    Relation testRelation;
   
    testRelation = new Relation(new CommonEntityData(3456, 0, new Date(), new OsmUser(12, "OsmosisTest"), 0));
    testRelation.getMembers().add(new RelationMember(1234, EntityType.Node, "role1"));
    testRelation.getTags().add(new Tag("test_key1", "test_value1"));
   
    testOsmWriter.process(new RelationContainer(testRelation));
    testOsmWriter.process(new BoundContainer(new Bound("source")));
  }
View Full Code Here

TOP

Related Classes of org.jitterbit.integration.data.structure.database.DbTranRelations$Relation

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.