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

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


            if(criteria.contains(":") && !criteria.startsWith(MenuLevelFolder.TYPE+":") && !criteria.startsWith(MenuLevelImageFolder.TYPE+":")) {
                currentId = criteria;
            }
        }

        ArtistEntity entity = null;
        if (criteriaList.size() == 1 && (currentId.startsWith("Artist:") || currentId.startsWith("Artist."))) {
            BrowseService browseService = browseServiceManager.getBrowseService("Artist");
            if (browseService != null) {
                ResultItem currentItem = browseService.findById(currentId.substring(currentId.indexOf(":") + 1));
                entity = (ArtistEntity) currentItem.getItem();
            }
        }
        Result<LastFMArtist> result = new Result<LastFMArtist>();

        if (entity != null) {
            try {
                JSONObject object = Client.create().resource(getLastFmUrl("artist.search&artist=" + urlEncode(entity.getName()))).accept(MediaType.APPLICATION_JSON).get(JSONObject.class);
                List<ResultItem<LastFMArtist>> artists = new ArrayList<ResultItem<LastFMArtist>>();
                JSONArray array = object.getJSONObject("results").getJSONObject("artistmatches").getJSONArray("artist");
                result.setCount(array.length());
                for (int i = 0; i < array.length(); i++) {
                    if((firstItem==null || i>=firstItem) && (maxItems==null || maxItems>artists.size())) {
View Full Code Here


            if(criteria.contains(":") && !criteria.startsWith(MenuLevelFolder.TYPE+":") && !criteria.startsWith(MenuLevelImageFolder.TYPE+":")) {
                currentId = criteria;
            }
        }

        ArtistEntity entity = null;
        if (criteriaList.size() == 1 && (currentId.startsWith("Artist:") || currentId.startsWith("Artist."))) {
            BrowseService browseService = browseServiceManager.getBrowseService("Artist");
            if (browseService != null) {
                ResultItem currentItem = browseService.findById(currentId.substring(currentId.indexOf(":") + 1));
                entity = (ArtistEntity) currentItem.getItem();
            }
        }
        Result<LastFMImage> result = new Result<LastFMImage>();

        if (entity != null) {
            try {
                JSONObject object = Client.create().resource(getLastFmUrl("artist.getimages&artist=" + urlEncode(entity.getName()))).accept(MediaType.APPLICATION_JSON).get(JSONObject.class);
                List<ResultItem<LastFMImage>> images = new ArrayList<ResultItem<LastFMImage>>();
                if (object.getJSONObject("images").has("image")) {
                    JSONArray array = object.getJSONObject("images").getJSONArray("image");
                    result.setCount(array.length());
                    for (int i = 0; i < array.length(); i++) {
                        if((firstItem==null || i>=firstItem) && (maxItems==null || maxItems>images.size())) {
                            images.add(createFromJSON("artist="+urlEncode(entity.getName()),array.getJSONObject(i)));
                        }
                    }
                }
                result.setItems(images);
            } catch (UnsupportedEncodingException e) {
View Full Code Here

    public ArtistEntity create(ArtistEntity artist) {
        try {
            transactionManager.begin();
            artist.setLastUpdated(new Date());
            artist.setLastUpdatedBy(super.CHANGED_BY);
            ArtistEntity createdEntity = super.createEntity(artist);
            getRepository().refresh(createdEntity);
            return new CopyHelper().copy(createdEntity, Expose.class);
        }catch (RuntimeException e) {
            transactionManager.setRollbackOnly();
            throw e;
View Full Code Here

    public ArtistEntity update(@PathParam("id") String id, ArtistEntity artist) {
        try {
            transactionManager.begin();
            artist.setLastUpdated(new Date());
            artist.setLastUpdatedBy(super.CHANGED_BY);
            ArtistEntity updatedEntity = super.updateEntity(id, artist);
            getRepository().refresh(updatedEntity);
            return new CopyHelper().copy(updatedEntity, Expose.class);
        }catch (RuntimeException e) {
            transactionManager.setRollbackOnly();
            throw e;
View Full Code Here

            if(criteria.contains(":") && !criteria.startsWith(MenuLevelFolder.TYPE+":") && !criteria.startsWith(MenuLevelImageFolder.TYPE+":")) {
                currentId = criteria;
            }
        }

        ArtistEntity entity = null;
        if (criteriaList.size() == 1 && (currentId.startsWith("Artist:") || currentId.startsWith("Artist."))) {
            BrowseService browseService = browseServiceManager.getBrowseService("Artist");
            if (browseService != null) {
                ResultItem currentItem = browseService.findById(currentId.substring(currentId.indexOf(":") + 1));
                entity = (ArtistEntity) currentItem.getItem();
            }
        }
        Result<SpotifyArtist> result = new Result<SpotifyArtist>();

        if (entity != null) {
            try {
                JSONObject object = Client.create().resource("http://ws.spotify.com/search/1/artist.json?q=artist:" + URLEncoder.encode(entity.getName(), "utf8")).accept(MediaType.APPLICATION_JSON).get(JSONObject.class);
                result.setCount(object.getJSONObject("info").getInt("num_results"));
                List<ResultItem<SpotifyArtist>> artists = new ArrayList<ResultItem<SpotifyArtist>>();
                JSONArray array = object.getJSONArray("artists");
                result.setCount(array.length());
                for (int i = 0; i < array.length(); i++) {
View Full Code Here

TOP

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

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.