package fi.nls.oskari.util;

import fi.mml.map.mapwindow.service.db.OskariMapLayerGroupServiceIbatisImpl;
import fi.mml.map.mapwindow.service.db.OskariMapLayerGroupService;
import fi.mml.portti.service.db.permissions.PermissionsService;
import fi.mml.portti.service.db.permissions.PermissionsServiceIbatisImpl;
import fi.mml.portti.service.search.SearchService;
import fi.mml.portti.service.search.SearchServiceImpl;
import fi.nls.oskari.map.layer.DataProviderService;
import fi.nls.oskari.map.layer.DataProviderServiceIbatisImpl;
import fi.nls.oskari.map.layer.OskariLayerService;
import fi.nls.oskari.map.layer.OskariLayerServiceIbatisImpl;
import fi.nls.oskari.service.capabilities.CapabilitiesCacheService;
import fi.nls.oskari.service.capabilities.CapabilitiesCacheServiceMybatisImpl;
import fi.nls.oskari.wfs.WFSLayerConfigurationService;
import fi.nls.oskari.wfs.WFSLayerConfigurationServiceIbatisImpl;

public class ServiceFactory {
	
	private static DataProviderService dataProviderService;
	private static OskariLayerService mapLayerService;
	private static OskariMapLayerGroupService oskariMapLayerGroupService;
    private static PermissionsService permissionsService;
    private static SearchService searchService;
    private static CapabilitiesCacheService capabilitiesCacheService;
    private static WFSLayerConfigurationService wfsLayerService;
 
	public static DataProviderService getDataProviderService() {
		if (dataProviderService == null) {
            dataProviderService = new DataProviderServiceIbatisImpl();
		}
		return dataProviderService;
	}
	
	public static OskariLayerService getMapLayerService() {
		if (mapLayerService == null) {
			mapLayerService = new OskariLayerServiceIbatisImpl();
		}
		return mapLayerService;
	}

	public static OskariMapLayerGroupService getOskariMapLayerGroupService() {
		if (oskariMapLayerGroupService == null) {
			oskariMapLayerGroupService = new OskariMapLayerGroupServiceIbatisImpl();
		}
		return oskariMapLayerGroupService;
	}

    public static PermissionsService getPermissionsService() {
        if (permissionsService == null) {
            permissionsService = new PermissionsServiceIbatisImpl();
        }
        return permissionsService;
    }

    public static SearchService getSearchService() {
        if (searchService == null) {
            searchService = new SearchServiceImpl();
        }
        return searchService;
    }

    public static CapabilitiesCacheService getCapabilitiesCacheService() {
        if (capabilitiesCacheService == null) {
            capabilitiesCacheService = new CapabilitiesCacheServiceMybatisImpl();
        }
        return capabilitiesCacheService;
    }

    public static WFSLayerConfigurationService getWfsLayerService() {
        if (wfsLayerService == null) {
            wfsLayerService = new WFSLayerConfigurationServiceIbatisImpl();
        }
        return wfsLayerService;
    }
}

@@ -628,32 +628,128 @@
 viceIbatisImpl;%0A
+import fi.nls.oskari.map.view.ViewService;%0Aimport fi.nls.oskari.map.view.ViewServiceIbatisImpl;%0A
 import fi.nls.os
@@ -1030,19 +1030,21 @@
 ctory %7B%0A
-%09%0A%09
+%0A    
 private 
@@ -1083,33 +1083,36 @@
 roviderService;%0A
-%09
+    
 private static O
@@ -1146,17 +1146,64 @@
 ervice;%0A
-%09
+    private static ViewService viewService;%0A    
 private 
@@ -1509,11 +1509,13 @@
 ce;%0A
- %0A%09
+%0A    
 publ
@@ -1567,26 +1567,32 @@
 Service() %7B%0A
-%09%09
+        
 if (dataProv
@@ -1681,30 +1681,42 @@
 atisImpl();%0A
-%09%09%7D%0A%09%09
+        %7D%0A        
 return dataP
@@ -1735,14 +1735,19 @@
 ce;%0A
-%09%7D%0A%09%0A%09
+    %7D%0A%0A    
 publ
@@ -1794,26 +1794,32 @@
 Service() %7B%0A
-%09%09
+        
 if (mapLayer
@@ -1837,19 +1837,28 @@
 null) %7B%0A
-%09%09%09
+            
 mapLayer
@@ -1899,30 +1899,42 @@
 atisImpl();%0A
-%09%09%7D%0A%09%09
+        %7D%0A        
 return mapLa
@@ -1949,13 +1949,203 @@
 ce;%0A
-%09%7D%0A%0A%09
+    %7D%0A%0A    public static ViewService getViewService() %7B%0A        if (viewService == null) %7B%0A            viewService = new ViewServiceIbatisImpl();%0A        %7D%0A        return viewService;%0A    %7D%0A%0A    
 publ
@@ -2215,18 +2215,24 @@
 ice() %7B%0A
-%09%09
+        
 if (oska
@@ -2269,11 +2269,20 @@
 ) %7B%0A
-%09%09%09
+            
 oska
@@ -2354,14 +2354,26 @@
 ();%0A
-%09%09%7D%0A%09%09
+        %7D%0A        
 retu
@@ -2407,9 +2407,12 @@
 ce;%0A
-%09
+    
 %7D%0A%0A 

Add ViewService to ServiceFactory