Package org.socialmusicdiscovery.server.business.model.core

Examples of org.socialmusicdiscovery.server.business.model.core.Release


    public void testModelGlobalIdentity() throws Exception {
        loadTestData(getClass().getPackage().getName(), "The Bodyguard.xml");
        em.getTransaction().begin();
        try {
            Artist artist = artistRepository.findByName("Whitney Houston").iterator().next();
            Release release = releaseRepository.findByName("The Bodyguard (Original Soundtrack Album)").iterator().next();

            GlobalIdentityEntity identity = new GlobalIdentityEntity();
            identity.setSource(GlobalIdentity.SOURCE_MUSICBRAINZ);
            identity.setEntityId(artist.getId());
            identity.setUri("0307edfc-437c-4b48-8700-80680e66a228");
            identity.setLastUpdated(new Date());
            identity.setLastUpdatedBy("JUnit");
            globalIdentityRepository.create(identity);

            identity = new GlobalIdentityEntity();
            identity.setSource(GlobalIdentity.SOURCE_MUSICBRAINZ);
            identity.setEntityId(release.getId());
            identity.setUri("11cafb9e-5fbc-49c7-b920-4ff754e03e93");
            identity.setLastUpdated(new Date());
            identity.setLastUpdatedBy("JUnit");
            globalIdentityRepository.create(identity);

            int identifiedTracks = 0;
            for (Track track : release.getTracks()) {
                identity = new GlobalIdentityEntity();
                identity.setSource(GlobalIdentity.SOURCE_MUSICBRAINZ);
                identity.setEntityId(track.getId());
                identity.setLastUpdated(new Date());
                identity.setLastUpdatedBy("JUnit");
                if (track.getNumber().equals(1)) {
                    identity.setUri("86cf33ac-5b7b-401b-9188-608bb2752063");
                } else if (track.getNumber().equals(5)) {
                    identity.setUri("bdd8624a-d0ac-480f-8fe5-253bd99b7d3f");
                } else if (track.getNumber().equals(9)) {
                    identity.setUri("f2ba4ef6-7017-4b93-9176-c079ed0a97e9");
                } else if (track.getNumber().equals(13)) {
                    identity.setUri("c3af5bb7-5711-495e-8fae-af8d730497cd");
                }
                if (identity.getUri() != null) {
                    identifiedTracks++;
                    globalIdentityRepository.create(identity);
                }
            }
            assert identifiedTracks == 4;

            identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_MUSICBRAINZ, artist);
            assert identity != null;
            assert identity.getUri().equals("0307edfc-437c-4b48-8700-80680e66a228");
            assert identity.getLastUpdated() != null;
            assert identity.getLastUpdatedBy() != null;

            identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_MUSICBRAINZ, release);
            assert identity != null;
            assert identity.getUri().equals("11cafb9e-5fbc-49c7-b920-4ff754e03e93");
            assert identity.getLastUpdated() != null;
            assert identity.getLastUpdatedBy() != null;

            for (Track track : release.getTracks()) {
                if (track.getNumber().equals(1)) {
                    identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_MUSICBRAINZ, track);
                    assert identity != null;
                    assert identity.getUri().equals("86cf33ac-5b7b-401b-9188-608bb2752063");
                    assert identity.getLastUpdated() != null;
View Full Code Here


        // Selection changes in release results should trigger refresh of artists and works
        releaseResultsTableView.getTableViewSelectionListeners().add(new TableViewSelectionListener.Adapter() {
            @Override
            public void selectedRangesChanged(TableView tableView, Sequence<Span> spanSequence) {
                Release release = (Release) tableView.getSelectedRow();
                if(release!=null) {
                    searchTextInput.setText("");
                    searchArtists(null, null, release.getId());
                    searchWorks(null, null, release.getId());
                }
            }
        });

        // Selection changes in artist results should trigger refresh of releases and works
        artistResultsTableView.getTableViewSelectionListeners().add(new TableViewSelectionListener.Adapter() {
            @Override
            public void selectedRangesChanged(TableView tableView, Sequence<Span> spanSequence) {
                Artist artist = (Artist) tableView.getSelectedRow();
                if(artist!=null) {
                    searchTextInput.setText("");
                    searchReleases(null, artist.getId(), null);
                    searchWorks(null, artist.getId(), null);
                }
            }
        });

        // Selection changes in work results should trigger refresh of artists and releases
        workResultsTableView.getTableViewSelectionListeners().add(new TableViewSelectionListener.Adapter() {
            @Override
            public void selectedRangesChanged(TableView tableView, Sequence<Span> spanSequence) {
                Work work = (Work) tableView.getSelectedRow();
                if(work!=null) {
                    searchTextInput.setText("");
                    searchReleases(null, null, work.getId());
                    searchArtists(null, work.getId(), null);
                }
            }
        });

        // Double click handler for releases
        releaseResultsTableView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener.Adapter() {
            @Override
            public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
                try {
                    if (count == 2) {
                        Release release = (Release) releaseResultsTableView.getSelectedRow();
                        BXMLSerializer wtkxSerializer = new BXMLSerializer();
                        EditReleaseWindow window = (EditReleaseWindow) wtkxSerializer.readObject(getClass().getResource("EditReleaseWindow.bxml"),new Resources(resources,EditReleaseWindow.class.getName()));
                        window.open(getDisplay(), getWindow(), release);
                        return true;
                    }
View Full Code Here

    @Test
    public void testModelClassification() throws Exception {
        loadTestData(getClass().getPackage().getName(), "The Bodyguard.xml");
        em.getTransaction().begin();
        try {
            Release release = releaseRepository.findByName("The Bodyguard (Original Soundtrack Album)").iterator().next();

            ClassificationEntity classification = new ClassificationEntity();
            classification.setName("Pop");
            classification.setType(Classification.GENRE);
            ClassificationReferenceEntity classificationReference = new ClassificationReferenceEntity();
            classificationReference.setReferenceTo(SMDIdentityReferenceEntity.forEntity(release));
            classificationReference.setLastUpdated(new Date());
            classificationReference.setLastUpdatedBy("JUnit");
            classification.addReference(classificationReference);
            classification.setLastUpdated(new Date());
            classification.setLastUpdatedBy("JUnit");

            for (Track track : release.getTracks()) {
                classificationReference = new ClassificationReferenceEntity();
                classificationReference.setReferenceTo(SMDIdentityReferenceEntity.forEntity(track));
                classificationReference.setLastUpdated(new Date());
                classificationReference.setLastUpdatedBy("JUnit");
                classification.addReference(classificationReference);
            }
            classificationRepository.create(classification);

            Collection<ClassificationEntity> classifications = classificationRepository.findByNameAndType("Pop", Classification.GENRE);
            assert classifications != null;
            assert classifications.size() == 1;
            classification = classifications.iterator().next();
            assert classification.getLastUpdated() != null;
            assert classification.getLastUpdatedBy() != null;
            Collection<ClassificationReference> references = classification.getReferences();
            assert references != null;
            assert references.size() == 5;
            int releaseMatches = 0;
            int trackMatches = 0;
            for (ClassificationReference reference : references) {
                assert ((ClassificationReferenceEntity)reference).getLastUpdated()!=null;
                assert ((ClassificationReferenceEntity)reference).getLastUpdatedBy()!=null;
                if (reference.getReferenceTo().getId().equals(release.getId())) {
                    releaseMatches++;
                    continue;
                } else {
                    for (Track track : release.getTracks()) {
                        if (reference.getReferenceTo().getId().equals(track.getId())) {
                            trackMatches++;
                            continue;
                        }
                    }
View Full Code Here

TOP

Related Classes of org.socialmusicdiscovery.server.business.model.core.Release

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.