private void createSegmentInformation(Project project, TVAMainType tva) {
    if (project.getVideo().getAnimations() == null) return;

    SegmentInformationTableType segmentInformationTable =
        tvaFactory.createSegmentInformationTableType();
    SegmentListType segmentList = tvaFactory.createSegmentListType();

    for (Integer frame : project.getVideo().getAnimations().keySet()) {
      ExtendedSegmentInformationType segmentInformation =
          activaFactory.createExtendedSegmentInformationType();
      segmentInformation.setSegmentId(frame.toString());

      boolean hasContent = false;
      for (Animation animation : project.getVideo().getAnimations().get(frame)) {

        if (animation.getEntityId() == 0) continue;

        IEntity entity = entityServices.getByAnimation(animation);
        if (entity == null) continue;

        EntityRegionType entityRegion = activaFactory.createEntityRegionType();
        // entityRegion.setEntityRef("entity_" + animation.getEntityId());
        entityRegion.setEntityRef(addedEntities.get(Long.valueOf(animation.getEntityId())));

        RegionLocatorType regionLocator = activaMpeg7Factory.createRegionLocatorType();

        if (animation.getKind() == ShapeKind.RECTANGLE) {
          regionLocator.getBox().add(createBox(project, animation));

        } else if (animation.getKind() == ShapeKind.POLYGON) {
          regionLocator.getPolygon().add(createPolygon(project, animation));
        }
        entityRegion.setRegion(regionLocator);
        segmentInformation.getEntityRegion().add(entityRegion);
        hasContent = true;
      }
      if (hasContent) segmentList.getSegmentInformation().add(segmentInformation);
    }

    segmentInformationTable.setSegmentList(segmentList);
    tva.getProgramDescription().setSegmentInformationTable(segmentInformationTable);
  }
  private void createEntityInformation(Project project, TVAMainType tva) {
    List<Animation> animations = project.getVideo().getAllAnimations();
    if (animations.size() <= 0) return;

    ExtendedProgramDescriptionType programDescription =
        (ExtendedProgramDescriptionType) tva.getProgramDescription();
    EntityInformationTableType entityInformation = activaFactory.createEntityInformationTableType();

    addedEntities = new HashMap<Long, EntityType>();
    for (int i = 0; i < animations.size(); i++) {
      Animation animation = animations.get(i);
      if (animation.getEntityId() == 0) continue;

      IEntity entity = entityServices.getByAnimation(animation);
      if (entity == null || addedEntities.containsKey(Long.valueOf(entity.getEntityId()))) continue;

      EntityType tvaEntity = activaFactory.createEntityType();
      tvaEntity.setEntityId("entity_" + entity.getEntityId());
      tvaEntity.setType(entity.getType().getLabel());

      addedEntities.put(Long.valueOf(entity.getEntityId()), tvaEntity);

      tvaEntity.setName(entity.getName());
      TextualType description = mpeg7Factory.createTextualType();
      description.setValue(entity.getDescription());
      tvaEntity.setDescription(description);

      IResource image = entityServices.getEntityImage(entity);
      if (image != null && image.getFile() != null) {
        tvaEntity.setImage(image.getFile().getName());
      }

      // properties
      if (entity.getProperties().size() > 0) {
        PropertiesType properties = activaFactory.createPropertiesType();
        for (IProperty property : entity.getProperties()) {
          Property tvaProperty = activaFactory.createPropertiesTypeProperty();
          tvaProperty.setKey(property.getKey());
          tvaProperty.setValue(property.getValue());

          properties.getProperty().add(tvaProperty);
        }
        tvaEntity.setProperties(properties);
      }

      // resources
      if (entity.getTaggedResources().size() > 0) {
        ResourcesType resources = activaFactory.createResourcesType();
        for (ITaggedResource taggedResource : entity.getTaggedResources()) {
          Resource tvaResource = activaFactory.createResourcesTypeResource();
          tvaResource.setHREF(taggedResource.getResource().getFile().getName());
          tvaResource.setName(taggedResource.getResource().getName());
          resources.getResource().add(tvaResource);
        }
        tvaEntity.setResources(resources);
      }

      entityInformation.getEntity().add(tvaEntity);
    }

    programDescription.setEntityInformationTable(entityInformation);
  }