コード例 #1
0
  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);
  }
コード例 #2
0
  private boolean writeModel(Metadata metadata, TVAMainType tva) {

    try {
      JAXBContext context = JAXBContext.newInstance("tva.metadata._2011");
      Marshaller m = context.createMarshaller();
      m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
      metadata.getSource().createNewFile();
      m.marshal(tvaFactory.createTVAMain(tva), metadata.getSource());
    } catch (JAXBException e) {
      logger.error(e, Messages.ERROR_EXPORTING_TVA);
      return false;
    } catch (IOException e) {
      logger.error(e, Messages.ERROR_EXPORTING_TVA);
      return false;
    }

    return true;
  }
コード例 #3
0
  @Override
  public boolean saveMetadata(Project project) {
    if (project == null || project.getMetadata() == null) return false;

    Metadata metadata = project.getMetadata();

    TVAMainType tva = null;
    if (metadata.getContent() == null) {
      tva = tvaFactory.createTVAMainType();
    } else {
      tva = (TVAMainType) metadata.getContent();
    }
    if (tva.getProgramDescription() == null)
      tva.setProgramDescription(activaFactory.createExtendedProgramDescriptionType());

    createProgramInformation(project, tva);
    createEntityInformation(project, tva);
    createSegmentInformation(project, tva);

    return writeModel(metadata, tva);
  }
コード例 #4
0
  private void createProgramInformation(Project project, TVAMainType tva) {
    ProgramInformationTableType programInformationTable =
        tvaFactory.createProgramInformationTableType();

    tva.getProgramDescription().setProgramInformationTable(programInformationTable);
  }