Search in sources :

Example 16 with Metadata

use of com.google.android.exoplayer2.metadata.Metadata in project dhis2-core by dhis2.

the class DefaultGmlImportService method importGml.

// -------------------------------------------------------------------------
// GmlImportService implementation
// -------------------------------------------------------------------------
@Transactional
@Override
public void importGml(InputStream inputStream, MetadataImportParams importParams) {
    if (!importParams.getImportStrategy().isUpdate()) {
        importParams.setImportStrategy(ImportStrategy.UPDATE);
        log.warn("Changed GML import strategy to update. Only updates are supported.");
    }
    PreProcessingResult preProcessed = preProcessGml(inputStream);
    if (preProcessed.isSuccess && preProcessed.dxf2MetaData != null) {
        Metadata metadata = dxf2ToMetaData(preProcessed.dxf2MetaData);
        importParams.addMetadata(schemaService.getMetadataSchemas(), metadata);
        importService.importMetadata(importParams);
    } else {
        Throwable throwable = preProcessed.throwable;
        notifier.notify(importParams.getTaskId(), NotificationLevel.ERROR, createNotifierErrorMessage(throwable), false);
        log.error("GML import failed: ", throwable);
    }
}
Also used : Metadata(org.hisp.dhis.dxf2.metadata.Metadata) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with Metadata

use of com.google.android.exoplayer2.metadata.Metadata in project dhis2-core by dhis2.

the class MetadataImportController method postXmlMetadata.

@RequestMapping(value = "", method = RequestMethod.POST, consumes = MediaType.APPLICATION_XML_VALUE)
public void postXmlMetadata(HttpServletRequest request, HttpServletResponse response) throws IOException {
    MetadataImportParams params = metadataImportService.getParamsFromMap(contextService.getParameterValuesMap());
    Metadata metadata = renderService.fromXml(StreamUtils.wrapAndCheckCompressionFormat(request.getInputStream()), Metadata.class);
    params.addMetadata(schemaService.getMetadataSchemas(), metadata);
    if (params.hasTaskId()) {
        startAsync(params);
        response.setStatus(HttpServletResponse.SC_NO_CONTENT);
    } else {
        ImportReport importReport = metadataImportService.importMetadata(params);
        renderService.toXml(response.getOutputStream(), importReport);
    }
}
Also used : MetadataImportParams(org.hisp.dhis.dxf2.metadata.MetadataImportParams) ImportReport(org.hisp.dhis.dxf2.metadata.feedback.ImportReport) Metadata(org.hisp.dhis.dxf2.metadata.Metadata) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with Metadata

use of com.google.android.exoplayer2.metadata.Metadata in project dhis2-core by dhis2.

the class FilledOrganisationUnitLevelController method setList.

@RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.CREATED)
public void setList(HttpServletRequest request, HttpServletResponse response) throws Exception {
    Metadata metadata = DefaultRenderService.getJsonMapper().readValue(request.getInputStream(), Metadata.class);
    List<OrganisationUnitLevel> levels = metadata.getOrganisationUnitLevels();
    for (OrganisationUnitLevel level : levels) {
        if (level.getLevel() <= 0) {
            throw new WebMessageException(WebMessageUtils.conflict("Level must be greater than zero"));
        }
        if (StringUtils.isBlank(level.getName())) {
            throw new WebMessageException(WebMessageUtils.conflict("Name must be specified"));
        }
        organisationUnitService.addOrUpdateOrganisationUnitLevel(new OrganisationUnitLevel(level.getLevel(), level.getName(), level.getOfflineLevels()));
    }
}
Also used : WebMessageException(org.hisp.dhis.dxf2.webmessage.WebMessageException) OrganisationUnitLevel(org.hisp.dhis.organisationunit.OrganisationUnitLevel) Metadata(org.hisp.dhis.dxf2.metadata.Metadata) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with Metadata

use of com.google.android.exoplayer2.metadata.Metadata in project ExoPlayer by google.

the class Id3DecoderTest method testDecodeTextInformationFrame.

public void testDecodeTextInformationFrame() throws MetadataDecoderException {
    byte[] rawId3 = new byte[] { 73, 68, 51, 4, 0, 0, 0, 0, 0, 23, 84, 73, 84, 50, 0, 0, 0, 13, 0, 0, 3, 72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 0 };
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertEquals(1, metadata.length());
    TextInformationFrame textInformationFrame = (TextInformationFrame) metadata.get(0);
    assertEquals("TIT2", textInformationFrame.id);
    assertNull(textInformationFrame.description);
    assertEquals("Hello World", textInformationFrame.value);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 20 with Metadata

use of com.google.android.exoplayer2.metadata.Metadata in project ExoPlayer by google.

the class Id3DecoderTest method testDecodePrivFrame.

public void testDecodePrivFrame() throws MetadataDecoderException {
    byte[] rawId3 = new byte[] { 73, 68, 51, 4, 0, 0, 0, 0, 0, 19, 80, 82, 73, 86, 0, 0, 0, 9, 0, 0, 116, 101, 115, 116, 0, 1, 2, 3, 4 };
    Id3Decoder decoder = new Id3Decoder();
    Metadata metadata = decoder.decode(rawId3, rawId3.length);
    assertEquals(1, metadata.length());
    PrivFrame privFrame = (PrivFrame) metadata.get(0);
    assertEquals("test", privFrame.owner);
    MoreAsserts.assertEquals(new byte[] { 1, 2, 3, 4 }, privFrame.privateData);
}
Also used : Metadata(com.google.android.exoplayer2.metadata.Metadata)

Aggregations

Metadata (com.google.android.exoplayer2.metadata.Metadata)18 Metadata (org.hisp.dhis.dxf2.metadata.Metadata)10 ParsableByteArray (com.google.android.exoplayer2.util.ParsableByteArray)6 IOException (java.io.IOException)5 Format (com.google.android.exoplayer2.Format)3 ArrayList (java.util.ArrayList)3 MediaFormat (android.media.MediaFormat)2 DrmInitData (com.google.android.exoplayer2.drm.DrmInitData)2 ApicFrame (com.google.android.exoplayer2.metadata.id3.ApicFrame)2 Id3Frame (com.google.android.exoplayer2.metadata.id3.Id3Frame)2 PrivFrame (com.google.android.exoplayer2.metadata.id3.PrivFrame)2 TextInformationFrame (com.google.android.exoplayer2.metadata.id3.TextInformationFrame)2 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)2 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)2 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)2 FlacStreamInfo (com.google.android.exoplayer2.util.FlacStreamInfo)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ByteBuffer (java.nio.ByteBuffer)2 MetadataImportParams (org.hisp.dhis.dxf2.metadata.MetadataImportParams)2