96 lines
3.1 KiB
JavaScript
Raw Normal View History

2021-07-16 11:41:58 -03:00
/*
* Copyright [2015] [wisemapping]
*
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
* It is basically the Apache License, Version 2.0 (the "License") plus the
* "powered by wisemapping" text requirement on every single page;
* you may not use this file except in compliance with the License.
* You may obtain a copy of the license at
*
* http://www.wisemapping.org/license
*
* 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.
*/
2021-12-19 08:06:42 -08:00
import { $defined } from '@wisemapping/core-js';
import ModelCodeName from './ModelCodeName';
import Beta2PelaMigrator from './Beta2PelaMigrator';
import Pela2TangoMigrator from './Pela2TangoMigrator';
2021-12-19 09:56:22 -08:00
import XMLSerializerBeta from './XMLSerializer_Beta';
import XMLSerializerPela from './XMLSerializer_Pela';
import XMLSerializerTango from './XMLSerializer_Tango';
2021-07-16 11:41:58 -03:00
/**
* @class mindplot.persistence.XMLSerializerFactory
*/
const XMLSerializerFactory = {};
2021-10-04 17:05:34 -07:00
/**
2021-07-16 11:41:58 -03:00
* @param {mindplot.model.IMindmap} mindmap
* @return {mindplot.persistence.XMLSerializer_Beta|mindplot.persistence.XMLSerializer_Pela|
* mindplot.persistence.XMLSerializer_Tango} serializer corresponding to the mindmap's version
*/
2021-12-19 09:56:22 -08:00
XMLSerializerFactory.getSerializerFromMindmap = function getSerializerFromMindmap(mindmap) {
2021-10-04 17:05:34 -07:00
return XMLSerializerFactory.getSerializer(mindmap.getVersion());
2021-07-16 11:41:58 -03:00
};
/**
* @param domDocument
* @return serializer corresponding to the mindmap's version
*/
2021-12-19 09:56:22 -08:00
XMLSerializerFactory.getSerializerFromDocument = function getSerializerFromDocument(domDocument) {
2021-10-04 17:05:34 -07:00
const rootElem = domDocument.documentElement;
return XMLSerializerFactory.getSerializer(rootElem.getAttribute('version'));
2021-07-16 11:41:58 -03:00
};
/**
* retrieves the serializer for the mindmap's version and migrates to the current version,
2021-10-04 17:05:34 -07:00
* e.g. for a Beta mindmap and current version Tango:
2021-07-16 11:41:58 -03:00
* serializer = new Pela2TangoMigrator(new Beta2PelaMigrator(new XMLSerializer_Beta()))
* @param {String} version the version name
* @return serializer
*/
Squashed commit of the following: commit 81e9041e19344df18d8e91a31edb69ea0bce6bf7 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sun Dec 5 14:35:11 2021 -0800 Fix serialization bug commit 290223f15aa3902ef3291e0f392a92d04e9ccd0e Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sun Dec 5 09:36:59 2021 -0800 Fix serialization bug commit 3c1a2e37cf7be34780b760eb6f2fd3e3ac577ed1 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sun Dec 5 09:24:13 2021 -0800 Fix missing references commit 98a7fd3e1659eb32cee43144da4a10b98cfcfed0 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sun Dec 5 09:08:38 2021 -0800 Fix compile commit 9f5146b353f0fdb34a5b83db6d120bc09a96a073 Merge: 218e074 d3dc44c Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sun Dec 5 09:03:17 2021 -0800 Merge branch 'develop' into feature/mindplot_tests_playground commit 218e074b7330d0a02ac7afee0b644737f3bb6b03 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sat Dec 4 17:46:22 2021 -0800 Add jquery missing dependency commit c01a748a84a2359dcf1a49d9593369c9fefe1e76 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sat Dec 4 17:41:47 2021 -0800 Remove undercore commit d680b063b819563f4fae38571055aad4c55180b7 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sat Dec 4 17:36:58 2021 -0800 Add missing dependencies commit be9aa21245e84c97fa9fe3545299c6bb01772ef1 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sat Dec 4 17:25:23 2021 -0800 Fix missign dependencies. commit 2472fa453c43b64286552edb7120d4d2c395eba4 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sat Dec 4 17:08:48 2021 -0800 Fix compilation commit a013d07dc15a3bddda1e42cad373abbdfc525c74 Merge: f2ac8fe a81e984 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Sat Dec 4 16:57:19 2021 -0800 Merge branch 'develop' into feature/mindplot_tests_playground commit f2ac8fe17de071a09f80a20f49eb42c66b5f2f2b Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Thu Dec 2 18:59:03 2021 -0800 Hack: Add declaration of designer as global variable. commit 432167acbb055fba19f1e8469db4ffe8ad7793b7 Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Thu Dec 2 18:51:13 2021 -0800 Hack the initialization of extended hotkey pluggin. commit 794db35e88f6bd232094b4f104c8fe6a8fab34be Author: Paulo Gustavo Veiga <pveiga@wisemapping.com> Date: Thu Dec 2 17:57:21 2021 -0800 Add keyboard function commit e47a48d51f1af0ebde4ebea07cb467a8e5a7a372 Author: Matias Arriola <matias.arriola@gmail.com> Date: Thu Dec 2 14:50:43 2021 -0300 Fix editor snapshot commit 9bf8baef1216352ed1f9dde4658c479c0044b093 Author: Matias Arriola <matias.arriola@gmail.com> Date: Thu Dec 2 13:14:13 2021 -0300 Add editor test to mindplot playground Add missing imports and fix BootstrapDialog references commit b2dcc3034fc638f58cdb59e96ab7d6e2435f634a Author: Matias Arriola <matias.arriola@gmail.com> Date: Thu Dec 2 11:56:10 2021 -0300 Add embedded test to mindplot playground commit 08b514e1aa7b51c4df56b2b3cb7f28c191adeae7 Author: Matias Arriola <matias.arriola@gmail.com> Date: Thu Dec 2 10:27:31 2021 -0300 Fix mindplot layout test Upgrade raphael to avoid error Load raphael from context-loader
2021-12-05 15:50:37 -08:00
XMLSerializerFactory.getSerializer = function getSerializer(version) {
2021-10-04 17:05:34 -07:00
if (!$defined(version)) {
version = ModelCodeName.BETA;
}
const codeNames = XMLSerializerFactory._codeNames;
let found = false;
let serializer = null;
for (let i = 0; i < codeNames.length; i++) {
if (!found) {
found = codeNames[i].codeName == version;
if (found) serializer = new (codeNames[i].serializer)();
} else {
const { migrator } = codeNames[i];
serializer = new migrator(serializer);
2021-07-16 11:41:58 -03:00
}
2021-10-04 17:05:34 -07:00
}
2021-07-16 11:41:58 -03:00
2021-10-04 17:05:34 -07:00
return serializer;
2021-07-16 11:41:58 -03:00
};
2021-10-04 17:05:34 -07:00
XMLSerializerFactory._codeNames = [
{
codeName: ModelCodeName.BETA,
2021-12-19 09:56:22 -08:00
serializer: XMLSerializerBeta,
2021-10-04 17:05:34 -07:00
migrator() {
},
},
{
codeName: ModelCodeName.PELA,
2021-12-19 09:56:22 -08:00
serializer: XMLSerializerPela,
2021-10-04 17:05:34 -07:00
migrator: Beta2PelaMigrator,
},
{
codeName: ModelCodeName.TANGO,
2021-12-19 09:56:22 -08:00
serializer: XMLSerializerTango,
2021-10-04 17:05:34 -07:00
migrator: Pela2TangoMigrator,
},
];
2021-07-16 11:41:58 -03:00
2021-10-04 17:05:34 -07:00
export default XMLSerializerFactory;