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

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


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


    public TrackEntity update(@PathParam("id") String id, TrackEntity track) {
        try {
            transactionManager.begin();
            track.setLastUpdated(new Date());
            track.setLastUpdatedBy(super.CHANGED_BY);
            TrackEntity updatedEntity = super.updateEntity(id, track);
            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;
            }
        }

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

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

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

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

        if (entity != null) {
            try {
                JSONObject object = Client.create().resource("http://ws.spotify.com/search/1/track.json?q=track:" + URLEncoder.encode(entity.getRecording().getWorks().iterator().next().getName(), "utf8")).accept(MediaType.APPLICATION_JSON).get(JSONObject.class);
                result.setCount(object.getJSONObject("info").getInt("num_results"));
                List<ResultItem<SpotifyTrack>> tracks = new ArrayList<ResultItem<SpotifyTrack>>();
                JSONArray array = object.getJSONArray("tracks");
                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.TrackEntity

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.