<commit_before>package fi.mml.map.mapwindow.service.db;

import java.io.Reader;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import fi.mml.portti.service.db.permissions.PermissionsService;
import fi.mml.portti.service.db.permissions.PermissionsServiceIbatisImpl;
import fi.nls.oskari.domain.User;
import fi.nls.oskari.domain.map.MyPlace;
import fi.nls.oskari.domain.map.MyPlaceCategory;
import fi.nls.oskari.domain.map.OskariLayer;
import fi.nls.oskari.log.LogFactory;
import fi.nls.oskari.log.Logger;
import fi.nls.oskari.map.layer.formatters.LayerJSONFormatterWMS;
import fi.nls.oskari.permission.domain.Resource;
import fi.nls.oskari.service.db.BaseIbatisService;
import fi.nls.oskari.util.ConversionHelper;
import fi.nls.oskari.util.JSONHelper;
import fi.nls.oskari.util.PropertyUtil;
import fi.nls.oskari.wms.WMSCapabilities;
import org.json.JSONObject;

public class MyPlacesServiceIbatisImpl extends BaseIbatisService<MyPlaceCategory>
        implements MyPlacesService {

    private final static Logger log = LogFactory.getLogger(
            MyPlacesServiceIbatisImpl.class);

    private static String MYPLACES_WMS_NAME = PropertyUtil.get("myplaces.xmlns.prefix", "ows")+":my_places_categories";
    private static String MYPLACES_CLIENT_WMS_URL = PropertyUtil.get("myplaces.client.wmsurl");
    private static String MYPLACES_ACTUAL_WMS_URL = PropertyUtil.get("myplaces.wms.url");

    private static final String MYPLACES_LAYERID_PREFIX = "myplaces_";

    private final static LayerJSONFormatterWMS JSON_FORMATTER = new LayerJSONFormatterWMS();
    private PermissionsService permissionsService = new PermissionsServiceIbatisImpl();

    @Override
    protected String getNameSpace() {
        return "MyPlace";
    }

    private SqlMapClient client = null;

    /*
     * The purpose of this method is to allow many SqlMapConfig.xml files in a
     * single portlet
     */
    protected String getSqlMapLocation() {
        return "META-INF/SqlMapConfig_MyPlace.xml";
    }
    /**
     * Returns SQLmap
     * 
     * @return
     */
    @Override
    protected SqlMapClient getSqlMapClient() {
        if (client != null) {
            return client;
        }

        Reader reader = null;
        try {
            String sqlMapLocation = getSqlMapLocation();
            reader = Resources.getResourceAsReader(sqlMapLocation);
            client = SqlMapClientBuilder.buildSqlMapClient(reader);<commit_msg>Alternate tile url for client based on ajax url<commit_after>package fi.mml.map.mapwindow.service.db;

import java.io.Reader;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ibatis.common.resources.Resources;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapClientBuilder;

import fi.mml.portti.service.db.permissions.PermissionsService;
import fi.mml.portti.service.db.permissions.PermissionsServiceIbatisImpl;
import fi.nls.oskari.domain.User;
import fi.nls.oskari.domain.map.MyPlace;
import fi.nls.oskari.domain.map.MyPlaceCategory;
import fi.nls.oskari.domain.map.OskariLayer;
import fi.nls.oskari.log.LogFactory;
import fi.nls.oskari.log.Logger;
import fi.nls.oskari.map.layer.formatters.LayerJSONFormatterWMS;
import fi.nls.oskari.permission.domain.Resource;
import fi.nls.oskari.service.db.BaseIbatisService;
import fi.nls.oskari.util.ConversionHelper;
import fi.nls.oskari.util.JSONHelper;
import fi.nls.oskari.util.PropertyUtil;
import fi.nls.oskari.wms.WMSCapabilities;
import org.json.JSONObject;

public class MyPlacesServiceIbatisImpl extends BaseIbatisService<MyPlaceCategory>
        implements MyPlacesService {

    private final static Logger log = LogFactory.getLogger(
            MyPlacesServiceIbatisImpl.class);

    private static String MYPLACES_WMS_NAME = PropertyUtil.get("myplaces.xmlns.prefix", "ows")+":my_places_categories";
    private static String MYPLACES_CLIENT_WMS_URL = PropertyUtil.getOptional("myplaces.client.wmsurl");
    private static String MYPLACES_ACTUAL_WMS_URL = PropertyUtil.get("myplaces.wms.url");

    private static final String MYPLACES_LAYERID_PREFIX = "myplaces_";

    private final static LayerJSONFormatterWMS JSON_FORMATTER = new LayerJSONFormatterWMS();
    private PermissionsService permissionsService = new PermissionsServiceIbatisImpl();

    public MyPlacesServiceIbatisImpl() {
        super();
        // default 'myplaces.client.wmsurl' to ajax url for tiles if not configured
        if(MYPLACES_CLIENT_WMS_URL == null) {
            // action_route name points to fi.nls.oskari.control.myplaces.MyPlacesTileHandler
            MYPLACES_CLIENT_WMS_URL = PropertyUtil.get("oskari.ajax.url.prefix") + "action_route=MyPlacesTile";
        }
    }
    @Override
    protected String getNameSpace() {
        return "MyPlace";
    }

    private SqlMapClient client = null;

    /*
     * The purpose of this method is to allow many SqlMapConfig.xml files in a
     * single portlet
     */
    protected String getSqlMapLocation() {
        return "META-INF/SqlMapConfig_MyPlace.xml";
    }
    /**
     * Returns SQLmap
     * 
     * @return
     */
    @Override
    protected SqlMapClient getSqlMapClient() {
        if (client != null) {
            return client;
        }

        Reader reader = null;
        try {
            String sqlMapLocation = getSqlMapLocation();
            reader = Resources.getResourceAsReader(sqlMapLocation);
            client = SqlMapClientBuilder.buildSqlMapClient(reader);
{'fraction_non_alphanumeric': 0.0934219734079776, 'fraction_numerical': 0.0, 'mean_word_length': 3.8122895622895623, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2502039', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1806, 'n_words': 332}