Search in sources :

Example 66 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project dhis2-core by dhis2.

the class ObjectBundleServiceUserTest method testCreateUsersWithInvalidPasswords.

@Test
public void testCreateUsersWithInvalidPasswords() throws IOException {
    createUserAndInjectSecurityContext(true);
    Map<Class<? extends IdentifiableObject>, List<IdentifiableObject>> metadata = renderService.fromMetadata(new ClassPathResource("dxf2/users_passwords.json").getInputStream(), RenderFormat.JSON);
    ObjectBundleParams params = new ObjectBundleParams();
    params.setObjectBundleMode(ObjectBundleMode.VALIDATE);
    params.setImportStrategy(ImportStrategy.CREATE);
    params.setObjects(metadata);
    ObjectBundle bundle = objectBundleService.create(params);
    ObjectBundleValidationReport validate = objectBundleValidationService.validate(bundle);
    assertEquals(1, validate.getErrorReportsByCode(User.class, ErrorCode.E4005).size());
}
Also used : ObjectBundleValidationReport(org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport) List(java.util.List) ClassPathResource(org.springframework.core.io.ClassPathResource) IdentifiableObject(org.hisp.dhis.common.IdentifiableObject) Test(org.junit.Test) DhisSpringTest(org.hisp.dhis.DhisSpringTest)

Example 67 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project ExoPlayer by google.

the class AtomParsers method parseIlst.

private static Metadata parseIlst(ParsableByteArray ilst, int limit) {
    ilst.skipBytes(Atom.HEADER_SIZE);
    ArrayList<Metadata.Entry> entries = new ArrayList<>();
    while (ilst.getPosition() < limit) {
        Metadata.Entry entry = MetadataUtil.parseIlstElement(ilst);
        if (entry != null) {
            entries.add(entry);
        }
    }
    return entries.isEmpty() ? null : new Metadata(entries);
}
Also used : ArrayList(java.util.ArrayList) Metadata(com.google.android.exoplayer2.metadata.Metadata)

Example 68 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project ExoPlayer by google.

the class EventLogger method onTracksChanged.

@Override
public void onTracksChanged(TrackGroupArray ignored, TrackSelectionArray trackSelections) {
    MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
    if (mappedTrackInfo == null) {
        Log.d(TAG, "Tracks []");
        return;
    }
    Log.d(TAG, "Tracks [");
    // Log tracks associated to renderers.
    for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.length; rendererIndex++) {
        TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(rendererIndex);
        TrackSelection trackSelection = trackSelections.get(rendererIndex);
        if (rendererTrackGroups.length > 0) {
            Log.d(TAG, "  Renderer:" + rendererIndex + " [");
            for (int groupIndex = 0; groupIndex < rendererTrackGroups.length; groupIndex++) {
                TrackGroup trackGroup = rendererTrackGroups.get(groupIndex);
                String adaptiveSupport = getAdaptiveSupportString(trackGroup.length, mappedTrackInfo.getAdaptiveSupport(rendererIndex, groupIndex, false));
                Log.d(TAG, "    Group:" + groupIndex + ", adaptive_supported=" + adaptiveSupport + " [");
                for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
                    String status = getTrackStatusString(trackSelection, trackGroup, trackIndex);
                    String formatSupport = getFormatSupportString(mappedTrackInfo.getTrackFormatSupport(rendererIndex, groupIndex, trackIndex));
                    Log.d(TAG, "      " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport);
                }
                Log.d(TAG, "    ]");
            }
            // Log metadata for at most one of the tracks selected for the renderer.
            if (trackSelection != null) {
                for (int selectionIndex = 0; selectionIndex < trackSelection.length(); selectionIndex++) {
                    Metadata metadata = trackSelection.getFormat(selectionIndex).metadata;
                    if (metadata != null) {
                        Log.d(TAG, "    Metadata [");
                        printMetadata(metadata, "      ");
                        Log.d(TAG, "    ]");
                        break;
                    }
                }
            }
            Log.d(TAG, "  ]");
        }
    }
    // Log tracks not associated with a renderer.
    TrackGroupArray unassociatedTrackGroups = mappedTrackInfo.getUnassociatedTrackGroups();
    if (unassociatedTrackGroups.length > 0) {
        Log.d(TAG, "  Renderer:None [");
        for (int groupIndex = 0; groupIndex < unassociatedTrackGroups.length; groupIndex++) {
            Log.d(TAG, "    Group:" + groupIndex + " [");
            TrackGroup trackGroup = unassociatedTrackGroups.get(groupIndex);
            for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
                String status = getTrackStatusString(false);
                String formatSupport = getFormatSupportString(RendererCapabilities.FORMAT_UNSUPPORTED_TYPE);
                Log.d(TAG, "      " + status + " Track:" + trackIndex + ", " + Format.toLogString(trackGroup.getFormat(trackIndex)) + ", supported=" + formatSupport);
            }
            Log.d(TAG, "    ]");
        }
        Log.d(TAG, "  ]");
    }
    Log.d(TAG, "]");
}
Also used : TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) Metadata(com.google.android.exoplayer2.metadata.Metadata) MappedTrackInfo(com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo) TrackSelection(com.google.android.exoplayer2.trackselection.TrackSelection)

Example 69 with Metadata

use of org.hisp.dhis.dxf2.metadata.Metadata in project ExoPlayer by google.

the class EventLogger method printMetadata.

private void printMetadata(Metadata metadata, String prefix) {
    for (int i = 0; i < metadata.length(); i++) {
        Metadata.Entry entry = metadata.get(i);
        if (entry instanceof TextInformationFrame) {
            TextInformationFrame textInformationFrame = (TextInformationFrame) entry;
            Log.d(TAG, prefix + String.format("%s: value=%s", textInformationFrame.id, textInformationFrame.value));
        } else if (entry instanceof UrlLinkFrame) {
            UrlLinkFrame urlLinkFrame = (UrlLinkFrame) entry;
            Log.d(TAG, prefix + String.format("%s: url=%s", urlLinkFrame.id, urlLinkFrame.url));
        } else if (entry instanceof PrivFrame) {
            PrivFrame privFrame = (PrivFrame) entry;
            Log.d(TAG, prefix + String.format("%s: owner=%s", privFrame.id, privFrame.owner));
        } else if (entry instanceof GeobFrame) {
            GeobFrame geobFrame = (GeobFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, filename=%s, description=%s", geobFrame.id, geobFrame.mimeType, geobFrame.filename, geobFrame.description));
        } else if (entry instanceof ApicFrame) {
            ApicFrame apicFrame = (ApicFrame) entry;
            Log.d(TAG, prefix + String.format("%s: mimeType=%s, description=%s", apicFrame.id, apicFrame.mimeType, apicFrame.description));
        } else if (entry instanceof CommentFrame) {
            CommentFrame commentFrame = (CommentFrame) entry;
            Log.d(TAG, prefix + String.format("%s: language=%s, description=%s", commentFrame.id, commentFrame.language, commentFrame.description));
        } else if (entry instanceof Id3Frame) {
            Id3Frame id3Frame = (Id3Frame) entry;
            Log.d(TAG, prefix + String.format("%s", id3Frame.id));
        } else if (entry instanceof EventMessage) {
            EventMessage eventMessage = (EventMessage) entry;
            Log.d(TAG, prefix + String.format("EMSG: scheme=%s, id=%d, value=%s", eventMessage.schemeIdUri, eventMessage.id, eventMessage.value));
        }
    }
}
Also used : GeobFrame(com.google.android.exoplayer2.metadata.id3.GeobFrame) EventMessage(com.google.android.exoplayer2.metadata.emsg.EventMessage) ApicFrame(com.google.android.exoplayer2.metadata.id3.ApicFrame) Metadata(com.google.android.exoplayer2.metadata.Metadata) CommentFrame(com.google.android.exoplayer2.metadata.id3.CommentFrame) UrlLinkFrame(com.google.android.exoplayer2.metadata.id3.UrlLinkFrame) PrivFrame(com.google.android.exoplayer2.metadata.id3.PrivFrame) Id3Frame(com.google.android.exoplayer2.metadata.id3.Id3Frame) TextInformationFrame(com.google.android.exoplayer2.metadata.id3.TextInformationFrame)

Example 70 with Metadata

use of org.hisp.dhis.dxf2.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)

Aggregations

DhisSpringTest (org.hisp.dhis.DhisSpringTest)55 Test (org.junit.Test)55 List (java.util.List)46 IdentifiableObject (org.hisp.dhis.common.IdentifiableObject)46 ClassPathResource (org.springframework.core.io.ClassPathResource)42 ObjectBundleValidationReport (org.hisp.dhis.dxf2.metadata.objectbundle.feedback.ObjectBundleValidationReport)37 DataElement (org.hisp.dhis.dataelement.DataElement)25 User (org.hisp.dhis.user.User)20 Metadata (com.google.android.exoplayer2.metadata.Metadata)19 MetadataVersion (org.hisp.dhis.metadata.version.MetadataVersion)19 OrganisationUnit (org.hisp.dhis.organisationunit.OrganisationUnit)19 DataSet (org.hisp.dhis.dataset.DataSet)15 ArrayList (java.util.ArrayList)14 MetadataVersionServiceException (org.hisp.dhis.dxf2.metadata.version.exception.MetadataVersionServiceException)14 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)14 IOException (java.io.IOException)10 Metadata (org.hisp.dhis.dxf2.metadata.Metadata)10 DhisHttpResponse (org.hisp.dhis.system.util.DhisHttpResponse)10 UserAuthorityGroup (org.hisp.dhis.user.UserAuthorityGroup)10 IntegrationTest (org.hisp.dhis.IntegrationTest)9