<commit_before>package sg.ncl.service.adapter;

import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;


/**
 * This is to invoke python scripts on the BOSS
 * Created by <NAME> on 15-Jun-16.
 */
public class AdapterDeterlab {

    private RestTemplate restTemplate = new RestTemplate();
    private ConnectionProperties properties = new ConnectionProperties();

    public String addUsers(String jsonString) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        HttpEntity<String> request = new HttpEntity<String>(jsonString, headers);

        ResponseEntity responseEntity = restTemplate.exchange(properties.getADD_USERS_URI(), HttpMethod.POST, request, String.class);

        // Will return the following JSON:
        // msg: no user created, uid: xxx
        // msg: user is created, uid: xxx
        // msg: user not found, uid: xxx
//        System.out.println(responseEntity.getBody().toString());
        return responseEntity.getBody().toString();
    }
}<commit_msg>add the mapping function from ncl user id to deter user id<commit_after>package sg.ncl.service.adapter;

import org.json.JSONObject;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;
import sg.ncl.service.adapter.data.jpa.DeterlabUserRepository;
import sg.ncl.service.adapter.domain.DeterlabUser;
import sg.ncl.service.adapter.dtos.entities.DeterlabUserEntity;

import javax.inject.Inject;


/**
 * This is to invoke python scripts on the BOSS
 * Created by <NAME> on 15-Jun-16.
 */
public class AdapterDeterlab {

    private DeterlabUserRepository deterlabUserRepository;
    private RestTemplate restTemplate = new RestTemplate();
    private ConnectionProperties properties = new ConnectionProperties();

    public String addUsers(String jsonString) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_JSON);
        HttpEntity<String> request = new HttpEntity<String>(jsonString, headers);

        ResponseEntity responseEntity = restTemplate.exchange(properties.getADD_USERS_URI(), HttpMethod.POST, request, String.class);

        // Will return the following JSON:
        // msg: no user created, uid: xxx
        // msg: user is created, uid: xxx
        // msg: user not found, uid: xxx
//        System.out.println(responseEntity.getBody().toString());
        return responseEntity.getBody().toString();
    }

    public void saveDeterUserIdMapping(String deterUserId, String nclUserId) {
        DeterlabUserEntity deterlabUserEntity = new DeterlabUserEntity();
        deterlabUserEntity.setNclUserId(nclUserId);
        deterlabUserEntity.setDeterUserId(deterUserId);
        deterlabUserRepository.save(deterlabUserEntity);
    }
}
{'fraction_non_alphanumeric': 0.09659090909090909, 'fraction_numerical': 0.002840909090909091, 'mean_word_length': 3.798977853492334, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '4266300', 'n_tokens_mistral': 773, 'n_tokens_neox': 749, 'n_words': 195}