<commit_before>package io.joynr.examples.jee;

/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2017 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;

import io.joynr.jeeintegration.api.ServiceLocator;
import joynr.exceptions.ApplicationException;
import joynr.vehicle.Country;
import joynr.vehicle.GeoPosition;
import joynr.vehicle.RadioStation;
import joynr.vehicle.RadioSync;

@Path("/radio-stations")
@Produces(MediaType.APPLICATION_JSON)
public class RadioConsumerRestEndpoint {

    private ServiceLocator serviceLocator;

    private RadioSync radioClient;

    @Inject
    public RadioConsumerRestEndpoint(ServiceLocator serviceLocator) {
        this.serviceLocator = serviceLocator;
    }

    @GET
    @Path("/current-station")
    public RadioStation getCurrentRadioStation() {
        return getRadioClient().getCurrentStation();
    }

    @GET
    @Path("/current-station/location")
    public GeoPosition getLocationOfCurrentStation() {
        return getRadioClient().getLocationOfCurrentStation().location;
    }

    @GET
    @Path("/current-station/country")
    public Country getCountryOfCurrentStation() {
        return getRadioClient().getLocationOfCurrentStation().country;
    }

    @POST
    @Path("/shuffle")
    public void shuffleRadioStations() {
        getRadioClient().shuffleStations();
    }

    @POST
    public boolean addRadioStation(RadioStation radioStation) {
        try {
            return getRadioClient().addFavoriteStation(radioStation);
        } catch (ApplicationException e) {
            throw new WebApplicationException(e.getMessage());
        }
    }

    private RadioSync getRadioClient() {
        if (radioClient == null) {
            radioClient = serviceLocator.get(RadioSync.class, "io.joynr.examples.jee.provider");
        }
        return radioClient;
    }

}<commit_msg>[JEE] modify radio jee consumer REST interface to take a simple string<commit_after>package io.joynr.examples.jee;

/*
 * #%L
 * %%
 * Copyright (C) 2011 - 2017 BMW Car IT GmbH
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;

import io.joynr.jeeintegration.api.ServiceLocator;
import joynr.exceptions.ApplicationException;
import joynr.vehicle.Country;
import joynr.vehicle.GeoPosition;
import joynr.vehicle.RadioStation;
import joynr.vehicle.RadioSync;

@Path("/radio-stations")
@Produces(MediaType.APPLICATION_JSON)
public class RadioConsumerRestEndpoint {

    private ServiceLocator serviceLocator;

    private RadioSync radioClient;

    @Inject
    public RadioConsumerRestEndpoint(ServiceLocator serviceLocator) {
        this.serviceLocator = serviceLocator;
    }

    @GET
    @Path("/current-station")
    public RadioStation getCurrentRadioStation() {
        try {
            return getRadioClient().getCurrentStation();
        } catch (Exception e) {
            throw new WebApplicationException(e);
        }
    }

    @GET
    @Path("/current-station/location")
    public GeoPosition getLocationOfCurrentStation() {
        return getRadioClient().getLocationOfCurrentStation().location;
    }

    @GET
    @Path("/current-station/country")
    public Country getCountryOfCurrentStation() {
        return getRadioClient().getLocationOfCurrentStation().country;
    }

    @POST
    @Path("/shuffle")
    public void shuffleRadioStations() {
        getRadioClient().shuffleStations();
    }

    @POST
    public boolean addRadioStation(String name) {
        try {
            return getRadioClient().addFavoriteStation(new RadioStation(name, true, Country.GERMANY));
        } catch (ApplicationException e) {
            throw new WebApplicationException(e.getMessage());
        }
    }

    private RadioSync getRadioClient() {
        if (radioClient == null) {
            radioClient = serviceLocator.get(RadioSync.class, "io.joynr.examples.jee.provider");
        }
        return radioClient;
    }

}
{'fraction_non_alphanumeric': 0.09813432835820896, 'fraction_numerical': 0.004477611940298508, 'mean_word_length': 3.3978671041837574, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '146100', 'n_tokens_mistral': 1524, 'n_tokens_neox': 1456, 'n_words': 391}