<commit_before>/**
 * @class Oskari.catalogue.bundle.metadataflyout.MetadataFlyoutBundleInstance
 */
Oskari.clazz.define("Oskari.catalogue.bundle.metadataflyout.MetadataFlyoutBundleInstance", function () {
    this.map = null;
    this.core = null;
    this.sandbox = null;
    this.mapmodule = null;
    this.started = false;
    this.plugins = {};
    this._locale = null;
    this._requestHandlers = {};
    this.loader = null;

    this.layerPlugin = null;
    this.layer = null;
}, {
    /**
     * @static
     * @property __name
     *
     */
    __name: 'catalogue.bundle.metadataflyout',
    "getName": function () {
        return this.__name;
    },
    /**
     * @method getSandbox
     */
    getSandbox: function () {
        return this.sandbox;
    },
    getLocale: function () {
        return this._locale;
    },
    getLoader: function () {
        return this.loader;
    },
    /**
     * @property defaults
     *
     * some defaults for this bundle
     */

    layerSpec: {
        "text": "",
        "name": "Metadata",
        "wmsName": "1",
        "type": "vectorlayer",
        "styles": {
            "title": "Trains",
            "legend": "",
            "name": "1"
        },
        "descriptionLink": "",
        "orgName": "Metadata",
        "inspire": "Metadata",
        "legendImage": "",
        "info": "",
        "isQueryable": true,
        "formats": {
            "value": "text/html"
        },
        "id": 'catalogue_metadataflyout_layer',
        "minScale": 36000000,
        "maxScale": 1,
        "style": "",
        "dataUrl": "",
        "wmsUrl": "x",
        "opacity": 60,
        "checked": "false",
        "styledLayerDescriptor": '<StyledLayerDescriptor version="1.0.0" ' + 'xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" ' + '    xmlns="http://www.opengis.net/sld" ' + '    xmlns:ogc="http://www.opengis.net/ogc" ' + '    xmlns:xlink="http://www.w3.org/1999/xlink" ' + '    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ' + '  <NamedLayer> ' + '    <Name>Simple point with stroke</Name> ' + '   <UserStyle><Title>GeoServer SLD Cook Book: Simple point with stroke</Title> ' + '    <FeatureTypeStyle><Rule>' + '<PolygonSymbolizer>' + ' <Graphic><Mark><WellKnownName>circle</WellKnownName>' + '<Fill>' + '        <CssParameter name="fill">#000040</CssParameter>' + '       </Fill>' + '<Stroke>' + '          <CssParameter name="stroke">#000040</CssParameter>' + '           <CssParameter name="stroke-width">2</CssParameter>' + '          </Stroke>' + '</Mark><Size>12</Size></Graphic>' + '     </PolygonSymbolizer>' + '<TextSymbolizer><Label><ogc:PropertyName>title</ogc:PropertyName></Label>' + '<Fill><CssParameter name="fill">#000000</CssParameter></Fill></TextSymbolizer>' + '</Rule></FeatureTypeStyle>' + '</UserStyle></NamedLayer></StyledLayerDescriptor>'
    },

    /**
     * @method implements BundleInstance start methdod
     *
     */
    "start": function () {
        if (this.started) {
            return;
        }

        this.started = true;

        /* locale */
        this._locale = Oskari.getLocalization(this.getName());

        /* sandbox */
        var conf = this.conf;
        var sandboxName = (conf ? conf.sandbox : null) || 'sandbox';
        var sandbox = Oskari.getSandbox(sandboxName),
            p;

        this.sandbox = sandbox;

        /* loader */
        this.loader = Oskari.clazz.create("Oskari.catalogue.bundle.metadataflyout.service.MetadataLoader",
            this.getLocale().loader, sandbox);

        sandbox.register(this);

        for (p in this.eventHandlers) {
            if (this.eventHandlers.hasOwnProperty(p)) {
                sandbox.registerForEventByName(this, p);
            }
        }

        /* request handler */
        /*this._requestHandlers['catalogue.ShowMetadataRequest'] =
            Oskari.clazz.create('Oskari.catalogue.bundle.metadataflyout.request.ShowMetadataRequestHandler', sandbox, this);

        sandbox.addRequestHandler('catalogue.ShowMetadataRequest', this._requestHandlers['catalogue.ShowMetadataRequest']);


        var layerSpec = {};

        for (p in this.layerSpec) {
            if (this.layerSpec.hasOwnProperty(p)) {
                layerSpec[p] = this.layerSpec[p];
            }
        }

        var layerLocale = this.getLocale().layer;
        for (p in layerLocale) {
            if (layerLocale.hasOwnProperty(p)) {
                layerSpec[p] = layerLocale[p];
            }
        }

        var mapLayerService = sandbox.getService('Oskari.mapframework.service.MapLayerService');
        var mapLayer = mapLayerService.createMapLayer(layerSpec);
        mapLayerService.addLayer(mapLayer, true);
        this.layer = mapLayer;

        var mapModule = sandbox.findRegisteredModuleInstance('MainMapModule');
        var layerPlugin = Oskari.clazz.create('Oskari.mapframework.mapmodule.MetadataLayerPlugin');
        layerPlugin.setMapLayer(mapLayer);


        mapModule.registerPlugin(layerPlugin);
        mapModule.startPlugin(layerPlugin);
        this.layerPlugin = layerPlugin;
*/
        /*layerPlugin.addMapLayerToMap(mapLayer, true, false);*/

        /* */

        var request = sandbox.getRequestBuilder('userinterface.AddExtensionRequest')(this);

        sandbox.request(this, request);

        /* stateful */
        sandbox.registerAsStateful(this.mediator.bundleId, this);

    },
    "init": function () {
        return null;
    },
    /**
     * @method update
     *
     * implements bundle instance update method
     */
    "update": function () {

    },
    /**
     * @method onEvent
     */
    onEvent: function (event) {

        var handler = this.eventHandlers[event.getName()];
        if (!handler) {
            return;
        }

        return handler.apply(this, [event]);

    },
    /**
     * @property eventHandlers
     * @static
     *
     */
    eventHandlers: {
        'AfterMapLayerAddEvent': function (event) {
            /* this might react when layer added */
            /* this.scheduleShowMetadata(event.getMapLayer().getMetadataResourceUUID(); */
        },
        /**
         * @method AfterMapLayerRemoveEvent
         */
        'AfterMapLayerRemoveEvent': function (event) {
            /* this might react when layer removed */
            /* this.scheduleShowMetadata(event.getMapLayer().getMetadataResourceUUID(); */
        },
        /**
         * @method AfterMapLayerRemoveEvent
         */
        'AfterMapMoveEvent': function (event) {
            /* this might react when map moved */

        }
    },

    /**
     * @method stop
     *
     * implements bundle instance stop method
     */
    "stop": function () {

        var sandbox = this.sandbox,
            p;

        /* request handler cleanup */
/*        sandbox.removeRequestHandler('catalogue.ShowMetadataRequest', this._requestHandlers['catalogue.ShowMetadataRequest']);
*/
        /* sandbox cleanup */

        for (p in this.eventHandlers) {
            if (this.eventHandlers.hasOwnProperty(p)) {
                sandbox.unregisterFromEventByName(this, p);
            }
        }

        var request = sandbox.getRequestBuilder('userinterface.RemoveExtensionRequest')(this);<commit_msg>[AH-1583] removal of metadata layer fixed removed accidentally metadata show request handlig<commit_after>/**
 * @class Oskari.catalogue.bundle.metadataflyout.MetadataFlyoutBundleInstance
 */
Oskari.clazz.define("Oskari.catalogue.bundle.metadataflyout.MetadataFlyoutBundleInstance", function () {
    this.map = null;
    this.core = null;
    this.sandbox = null;
    this.mapmodule = null;
    this.started = false;
    this.plugins = {};
    this._locale = null;
    this._requestHandlers = {};
    this.loader = null;

    this.layerPlugin = null;
    this.layer = null;
}, {
    /**
     * @static
     * @property __name
     *
     */
    __name: 'catalogue.bundle.metadataflyout',
    "getName": function () {
        return this.__name;
    },
    /**
     * @method getSandbox
     */
    getSandbox: function () {
        return this.sandbox;
    },
    getLocale: function () {
        return this._locale;
    },
    getLoader: function () {
        return this.loader;
    },
    /**
     * @property defaults
     *
     * some defaults for this bundle
     */

    layerSpec: {
        "text": "",
        "name": "Metadata",
        "wmsName": "1",
        "type": "vectorlayer",
        "styles": {
            "title": "Trains",
            "legend": "",
            "name": "1"
        },
        "descriptionLink": "",
        "orgName": "Metadata",
        "inspire": "Metadata",
        "legendImage": "",
        "info": "",
        "isQueryable": true,
        "formats": {
            "value": "text/html"
        },
        "id": 'catalogue_metadataflyout_layer',
        "minScale": 36000000,
        "maxScale": 1,
        "style": "",
        "dataUrl": "",
        "wmsUrl": "x",
        "opacity": 60,
        "checked": "false",
        "styledLayerDescriptor": '<StyledLayerDescriptor version="1.0.0" ' + 'xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" ' + '    xmlns="http://www.opengis.net/sld" ' + '    xmlns:ogc="http://www.opengis.net/ogc" ' + '    xmlns:xlink="http://www.w3.org/1999/xlink" ' + '    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ' + '  <NamedLayer> ' + '    <Name>Simple point with stroke</Name> ' + '   <UserStyle><Title>GeoServer SLD Cook Book: Simple point with stroke</Title> ' + '    <FeatureTypeStyle><Rule>' + '<PolygonSymbolizer>' + ' <Graphic><Mark><WellKnownName>circle</WellKnownName>' + '<Fill>' + '        <CssParameter name="fill">#000040</CssParameter>' + '       </Fill>' + '<Stroke>' + '          <CssParameter name="stroke">#000040</CssParameter>' + '           <CssParameter name="stroke-width">2</CssParameter>' + '          </Stroke>' + '</Mark><Size>12</Size></Graphic>' + '     </PolygonSymbolizer>' + '<TextSymbolizer><Label><ogc:PropertyName>title</ogc:PropertyName></Label>' + '<Fill><CssParameter name="fill">#000000</CssParameter></Fill></TextSymbolizer>' + '</Rule></FeatureTypeStyle>' + '</UserStyle></NamedLayer></StyledLayerDescriptor>'
    },

    /**
     * @method implements BundleInstance start methdod
     *
     */
    "start": function () {
        if (this.started) {
            return;
        }

        this.started = true;

        /* locale */
        this._locale = Oskari.getLocalization(this.getName());

        /* sandbox */
        var conf = this.conf;
        var sandboxName = (conf ? conf.sandbox : null) || 'sandbox';
        var sandbox = Oskari.getSandbox(sandboxName),
            p;

        this.sandbox = sandbox;

        /* loader */
        this.loader = Oskari.clazz.create("Oskari.catalogue.bundle.metadataflyout.service.MetadataLoader",
            this.getLocale().loader, sandbox);

        sandbox.register(this);

        for (p in this.eventHandlers) {
            if (this.eventHandlers.hasOwnProperty(p)) {
                sandbox.registerForEventByName(this, p);
            }
        }

        /* request handler */
        this._requestHandlers['catalogue.ShowMetadataRequest'] =
            Oskari.clazz.create('Oskari.catalogue.bundle.metadataflyout.request.ShowMetadataRequestHandler', sandbox, this);

        sandbox.addRequestHandler('catalogue.ShowMetadataRequest', this._requestHandlers['catalogue.ShowMetadataRequest']);

        /*
        var layerSpec = {};

        for (p in this.layerSpec) {
            if (this.layerSpec.hasOwnProperty(p)) {
                layerSpec[p] = this.layerSpec[p];
            }
        }

        var layerLocale = this.getLocale().layer;
        for (p in layerLocale) {
            if (layerLocale.hasOwnProperty(p)) {
                layerSpec[p] = layerLocale[p];
            }
        }

        var mapLayerService = sandbox.getService('Oskari.mapframework.service.MapLayerService');
        var mapLayer = mapLayerService.createMapLayer(layerSpec);
        mapLayerService.addLayer(mapLayer, true);
        this.layer = mapLayer;

        var mapModule = sandbox.findRegisteredModuleInstance('MainMapModule');
        var layerPlugin = Oskari.clazz.create('Oskari.mapframework.mapmodule.MetadataLayerPlugin');
        layerPlugin.setMapLayer(mapLayer);


        mapModule.registerPlugin(layerPlugin);
        mapModule.startPlugin(layerPlugin);
        this.layerPlugin = layerPlugin;
*/
        /*layerPlugin.addMapLayerToMap(mapLayer, true, false);*/

        /* */

        var request = sandbox.getRequestBuilder('userinterface.AddExtensionRequest')(this);

        sandbox.request(this, request);

        /* stateful */
        sandbox.registerAsStateful(this.mediator.bundleId, this);

    },
    "init": function () {
        return null;
    },
    /**
     * @method update
     *
     * implements bundle instance update method
     */
    "update": function () {

    },
    /**
     * @method onEvent
     */
    onEvent: function (event) {

        var handler = this.eventHandlers[event.getName()];
        if (!handler) {
            return;
        }

        return handler.apply(this, [event]);

    },
    /**
     * @property eventHandlers
     * @static
     *
     */
    eventHandlers: {
        'AfterMapLayerAddEvent': function (event) {
            /* this might react when layer added */
            /* this.scheduleShowMetadata(event.getMapLayer().getMetadataResourceUUID(); */
        },
        /**
         * @method AfterMapLayerRemoveEvent
         */
        'AfterMapLayerRemoveEvent': function (event) {
            /* this might react when layer removed */
            /* this.scheduleShowMetadata(event.getMapLayer().getMetadataResourceUUID(); */
        },
        /**
         * @method AfterMapLayerRemoveEvent
         */
        'AfterMapMoveEvent': function (event) {
            /* this might react when map moved */

        }
    },

    /**
     * @method stop
     *
     * implements bundle instance stop method
     */
    "stop": function () {

        var sandbox = this.sandbox,
            p;

        /* request handler cleanup */
        sandbox.removeRequestHandler('catalogue.ShowMetadataRequest', this._requestHandlers['catalogue.ShowMetadataRequest']);

        /* sandbox cleanup */

        for (p in this.eventHandlers) {
            if (this.eventHandlers.hasOwnProperty(p)) {
                sandbox.unregisterFromEventByName(this, p);
            }
        }

        var request = sandbox.getRequestBuilder('userinterface.RemoveExtensionRequest')(this);
{'fraction_non_alphanumeric': 0.14428405281521517, 'fraction_numerical': 0.006704522131764384, 'mean_word_length': 2.2162816281628164, 'pattern_counts': {'":': 60, '<': 91, '<?xml version=': 0, '>': 91, 'https://': 0, 'lorem ipsum': 0, 'www.': 10, 'xml': 8}, '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': '6608299', 'n_tokens_mistral': 4359, 'n_tokens_neox': 4185, 'n_words': 686}