Package org.socialmusicdiscovery.server.business.model

Examples of org.socialmusicdiscovery.server.business.model.GlobalIdentityEntity


    @Override
    protected void handleReleaseIdentities(Map<String, Collection<String>> tags, ReleaseEntity release) {
        if (tags.containsKey(TagData.SPOTIFY_ALBUM_ID)) {
            String releaseId = tags.get(TagData.SPOTIFY_ALBUM_ID).iterator().next();
            GlobalIdentityEntity identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_SPOTIFY, release);
            if (identity == null) {
                identity = new GlobalIdentityEntity();
                identity.setSource(GlobalIdentity.SOURCE_SPOTIFY);
                identity.setEntityId(release.getId());
                identity.setUri(releaseId);
                identity.setLastUpdated(new Date());
                identity.setLastUpdatedBy(getId());
                validate(identity);
                globalIdentityRepository.create(identity);
            }
        }
    }
View Full Code Here


            }
            release.setLastUpdated(currentTime);
            release.setLastUpdatedBy(SPOTIFY_SOURCE);
            releaseRepository.create(release);

            GlobalIdentityEntity globalIdentity = new GlobalIdentityEntity();
            globalIdentity.setSource(SPOTIFY_SOURCE);
            globalIdentity.setUri(jsonAlbum.getString("href"));
            globalIdentity.setEntityId(release.getId());
            globalIdentity.setLastUpdated(currentTime);
            globalIdentity.setLastUpdatedBy(SPOTIFY_SOURCE);
            globalIdentityRepository.create(globalIdentity);

            JSONArray array = jsonAlbum.getJSONArray("tracks");
            for (int i = 0; i < array.length(); i++) {
                JSONObject jsonTrack = array.getJSONObject(i);

                WorkEntity work = new WorkEntity();
                work.setName(jsonTrack.getString("name"));
                work.setLastUpdated(currentTime);
                work.setLastUpdatedBy(SPOTIFY_SOURCE);
                workRepository.create(work);

                RecordingEntity recording = new RecordingEntity();
                recording.setLastUpdated(currentTime);
                recording.setLastUpdatedBy(SPOTIFY_SOURCE);
                recordingRepository.create(recording);
                recording.getWorks().add(work);

                TrackEntity track = new TrackEntity();
                if (jsonTrack.has("track-number")) {
                    track.setNumber(jsonTrack.getInt("track-number"));
                }
                track.setRecording(recording);
                release.addTrack(track);
                track.setLastUpdated(currentTime);
                track.setLastUpdatedBy(SPOTIFY_SOURCE);
                trackRepository.create(track);

                PlayableElementEntity playableElement = new PlayableElementEntity();
                playableElement.setSmdID(jsonTrack.getString("href"));
                playableElement.setUri(jsonTrack.getString("href"));
                playableElement.setFormat(SPOTIFY_SOURCE);
                playableElement.setLastUpdated(currentTime);
                playableElement.setLastUpdatedBy(SPOTIFY_SOURCE);
                playableElementRepository.create(playableElement);
                track.getPlayableElements().add(playableElement);

                JSONArray jsonArtists = jsonTrack.optJSONArray("artists");
                if (jsonArtists != null && jsonArtists.length() > 0) {
                    for (int j = 0; j < jsonArtists.length(); j++) {
                        JSONObject jsonArtist = jsonArtists.getJSONObject(j);
                        String name = jsonArtist.getString("name");
                        Collection<ArtistEntity> artists = artistRepository.findByName(name);
                        if (artists.size() == 0) {
                            artists = new ArrayList<ArtistEntity>();
                            ArtistEntity artist = new ArtistEntity();
                            artist.setName(name);
                            artist.setLastUpdated(currentTime);
                            artist.setLastUpdatedBy(SPOTIFY_SOURCE);
                            artistRepository.create(artist);
                            artists.add(artist);

                            globalIdentity = new GlobalIdentityEntity();
                            globalIdentity.setSource(SPOTIFY_SOURCE);
                            globalIdentity.setUri(jsonArtist.getString("href"));
                            globalIdentity.setEntityId(artist.getId());
                            globalIdentity.setLastUpdated(currentTime);
                            globalIdentity.setLastUpdatedBy(SPOTIFY_SOURCE);
                            globalIdentityRepository.create(globalIdentity);
                        }
                        for (ArtistEntity artist : artists) {
                            ContributorEntity contributor = new ContributorEntity(artist, Contributor.PERFORMER);
                            recording.addContributor(contributor);
View Full Code Here

        }
    }

    protected void handleTrackIdentities(Map<String, Collection<String>> tags, TrackEntity track) {
        if (tags.containsKey(TagData.MUSICBRAINZ_TRACK_ID)) {
            GlobalIdentityEntity identity = new GlobalIdentityEntity();
            identity.setSource(GlobalIdentity.SOURCE_MUSICBRAINZ);
            identity.setEntityId(track.getId());
            identity.setUri(tags.get(TagData.MUSICBRAINZ_TRACK_ID).iterator().next());
            identity.setLastUpdated(new Date());
            identity.setLastUpdatedBy(getId());
            validate(identity);
            globalIdentityRepository.create(identity);
        }
    }
View Full Code Here

    protected void handleReleaseIdentities(Map<String, Collection<String>> tags, ReleaseEntity release) {
        if (tags.containsKey(TagData.MUSICBRAINZ_ALBUM_ID)) {
            String releaseId = tags.get(TagData.MUSICBRAINZ_ALBUM_ID).iterator().next();
            if (!releaseMusicbrainzCache.contains(releaseId)) {
                GlobalIdentityEntity identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_MUSICBRAINZ, release);
                if (identity == null) {
                    identity = new GlobalIdentityEntity();
                    identity.setSource(GlobalIdentity.SOURCE_MUSICBRAINZ);
                    identity.setEntityId(release.getId());
                    identity.setUri(releaseId);
                    identity.setLastUpdated(new Date());
                    identity.setLastUpdatedBy(getId());
                    validate(identity);
                    globalIdentityRepository.create(identity);
                }
                releaseMusicbrainzCache.add(releaseId);
            }
        }
        if (tags.containsKey(TagData.DISCOGS_RELEASE_ID)) {
            String releaseId = tags.get(TagData.DISCOGS_RELEASE_ID).iterator().next();
            if (!releaseDiscogsCache.contains(releaseId)) {
                GlobalIdentityEntity identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_DISCOGS, release);
                if (identity == null) {
                    identity = new GlobalIdentityEntity();
                    identity.setSource(GlobalIdentity.SOURCE_DISCOGS);
                    identity.setEntityId(release.getId());
                    identity.setUri(releaseId);
                    identity.setLastUpdated(new Date());
                    identity.setLastUpdatedBy(getId());
                    validate(identity);
                    globalIdentityRepository.create(identity);
                }
                releaseDiscogsCache.add(releaseId);
            }
View Full Code Here

    protected void handleAlbumArtistIdentities(Map<String, Collection<String>> tags, Set<Contributor> albumArtistContributors) {
        if (albumArtistContributors.size() == 1 && tags.containsKey(TagData.MUSICBRAINZ_ALBUMARTIST_ID)) {
            String artistId = tags.get(TagData.MUSICBRAINZ_ALBUMARTIST_ID).iterator().next();
            if (!artistMusicbrainzCache.contains(artistId)) {
                Artist artist = artistRepository.findById(artistCache.get(tags.get(TagData.ALBUMARTIST).iterator().next().toLowerCase()).iterator().next());
                GlobalIdentityEntity identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_MUSICBRAINZ, artist);
                if (identity == null) {
                    identity = new GlobalIdentityEntity();
                    identity.setSource(GlobalIdentity.SOURCE_MUSICBRAINZ);
                    identity.setEntityId(artist.getId());
                    identity.setUri(artistId);
                    identity.setLastUpdated(new Date());
                    identity.setLastUpdatedBy(getId());
                    validate(identity);
                    globalIdentityRepository.create(identity);
                }
                artistMusicbrainzCache.add(artistId);
            }
View Full Code Here

    protected void handleArtistIdentities(Map<String, Collection<String>> tags, Set<Contributor> artistContributors) {
        if (artistContributors.size() == 1 && tags.containsKey(TagData.MUSICBRAINZ_ARTIST_ID)) {
            String artistId = tags.get(TagData.MUSICBRAINZ_ARTIST_ID).iterator().next();
            if (!artistMusicbrainzCache.contains(artistId)) {
                Artist artist = artistRepository.findById(artistCache.get(tags.get(TagData.ARTIST).iterator().next().toLowerCase()).iterator().next());
                GlobalIdentityEntity identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_MUSICBRAINZ, artist);
                if (identity == null) {
                    identity = new GlobalIdentityEntity();
                    identity.setSource(GlobalIdentity.SOURCE_MUSICBRAINZ);
                    identity.setEntityId(artist.getId());
                    identity.setUri(artistId);
                    identity.setLastUpdated(new Date());
                    identity.setLastUpdatedBy(getId());
                    validate(identity);
                    globalIdentityRepository.create(identity);
                }
                artistMusicbrainzCache.add(artistId);
            }
View Full Code Here

    }

    @Override
    protected void handleTrackIdentities(Map<String, Collection<String>> tags, TrackEntity track) {
        if (tags.containsKey(TagData.SPOTIFY_TRACK_ID)) {
            GlobalIdentityEntity identity = new GlobalIdentityEntity();
            identity.setSource(GlobalIdentity.SOURCE_SPOTIFY);
            identity.setEntityId(track.getId());
            identity.setUri(tags.get(TagData.SPOTIFY_TRACK_ID).iterator().next());
            identity.setLastUpdated(new Date());
            identity.setLastUpdatedBy(getId());
            validate(identity);
            globalIdentityRepository.create(identity);
        }
        super.handleTrackIdentities(tags, track);
    }
View Full Code Here

    @Override
    protected void handleArtistIdentities(Map<String, Collection<String>> tags, Set<Contributor> artistContributors) {
        if (artistContributors.size() == 1 && tags.containsKey(TagData.SPOTIFY_ARTIST_ID)) {
            String artistId = tags.get(TagData.SPOTIFY_ARTIST_ID).iterator().next();
            Artist artist = artistContributors.iterator().next().getArtist();
            GlobalIdentityEntity identity = globalIdentityRepository.findBySourceAndEntity(GlobalIdentity.SOURCE_SPOTIFY, artist);
            if (identity == null) {
                identity = new GlobalIdentityEntity();
                identity.setSource(GlobalIdentity.SOURCE_SPOTIFY);
                identity.setEntityId(artist.getId());
                identity.setUri(artistId);
                identity.setLastUpdated(new Date());
                identity.setLastUpdatedBy(getId());
                validate(identity);
                globalIdentityRepository.create(identity);
            }
        }
        super.handleArtistIdentities(tags, artistContributors);
View Full Code Here

TOP

Related Classes of org.socialmusicdiscovery.server.business.model.GlobalIdentityEntity

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.