Compare commits
3 commits
develop
...
feature/xm
Author | SHA1 | Date | |
---|---|---|---|
|
bacaf75db3 | ||
|
1102218720 | ||
|
b87482cb48 |
4 changed files with 76 additions and 1 deletions
|
@ -70,6 +70,11 @@ const Import = {
|
||||||
Import.handle(results)
|
Import.handle(results)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
handleXML: function(text) {
|
||||||
|
const results = XMLParser.parseSchema(text)
|
||||||
|
Import.handle(results)
|
||||||
|
},
|
||||||
|
|
||||||
handle: function(results) {
|
handle: function(results) {
|
||||||
var self = Import
|
var self = Import
|
||||||
var topics = results.topics.map(topic => self.normalizeKeys(topic))
|
var topics = results.topics.map(topic => self.normalizeKeys(topic))
|
||||||
|
|
18
frontend/src/Metamaps/XMLParser.js
Normal file
18
frontend/src/Metamaps/XMLParser.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
import parseXML from 'xml-parser'
|
||||||
|
|
||||||
|
const XMLParser = {
|
||||||
|
parseSchema = (text) => {
|
||||||
|
// see format of data at https://www.npmjs.com/package/xml-parser
|
||||||
|
const data = parseXML(text)
|
||||||
|
|
||||||
|
// TODO algorithm to transform `data` to `returnValue`
|
||||||
|
|
||||||
|
// TODO this is the output format, but we still need to fill it in with real data
|
||||||
|
const returnValue = {
|
||||||
|
topics: [],
|
||||||
|
synapses: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default XMLParser
|
51
frontend/test/Metamaps/XMLParser.spec.js
Normal file
51
frontend/test/Metamaps/XMLParser.spec.js
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* global describe, it */
|
||||||
|
|
||||||
|
import { expect } from 'chai'
|
||||||
|
import outdent from 'outdent'
|
||||||
|
|
||||||
|
import XMLParser from '../../src/MetamapsXMLParser'
|
||||||
|
|
||||||
|
describe('Metamaps.XMLParser.js', function() {
|
||||||
|
describe('parseSchema', function() {
|
||||||
|
it('View:Projection nodes', function() {
|
||||||
|
const xml = outdent`
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<View:ColumnView name="ZPalletToBoxes">
|
||||||
|
<viewNode xsi:type="View:Projection" name="NTREE_DATA">
|
||||||
|
<element name="MANDT">
|
||||||
|
<inlineType primitiveType="NVARCHAR" length="3" precision="3" scale="0"/>
|
||||||
|
</element>
|
||||||
|
</viewNode>
|
||||||
|
</View:ColumnView>`
|
||||||
|
|
||||||
|
{ topics, synapses } = XMLParser.parseSchema(xml)
|
||||||
|
|
||||||
|
expect(topics[0].name).to.equal("NTREE_DATA")
|
||||||
|
expect(topics[0].metacode).to.equal("Activity")
|
||||||
|
|
||||||
|
expect(topics[1].name).to.equal("MANDT")
|
||||||
|
expect(topics[1].metacode).to.equal("Wildcard")
|
||||||
|
|
||||||
|
expect(synapses.length).to.equal(0)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('lays nodes out correctly', function() {
|
||||||
|
const xml = outdent`
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<View:ColumnView name="ZPalletToBoxes">
|
||||||
|
<viewNode xsi:type="View:Projection" name="NTREE_DATA">
|
||||||
|
<element name="MANDT">
|
||||||
|
<inlineType primitiveType="NVARCHAR" length="3" precision="3" scale="0"/>
|
||||||
|
</element>
|
||||||
|
<layout xCoordinate="176" yCoordinate="569" width="-1" height="-1" expanded="true"/>
|
||||||
|
</viewNode>
|
||||||
|
</View:ColumnView>`
|
||||||
|
{ topics, synapses } = XMLParser.parseSchema(xml)
|
||||||
|
|
||||||
|
expect(topics[0].x).to.equal(176)
|
||||||
|
expect(topics[0].y).to.equal(569)
|
||||||
|
expect(topics[1].x).to.equal(176 + 20)
|
||||||
|
expect(topics[1].y).to.equal(569)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
|
@ -52,7 +52,8 @@
|
||||||
"riek": "1.0.7",
|
"riek": "1.0.7",
|
||||||
"simplewebrtc": "2.2.2",
|
"simplewebrtc": "2.2.2",
|
||||||
"socket.io": "1.3.7",
|
"socket.io": "1.3.7",
|
||||||
"webpack": "2.2.1"
|
"webpack": "2.2.1",
|
||||||
|
"xml-parser": "1.2.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-eslint": "^7.1.1",
|
"babel-eslint": "^7.1.1",
|
||||||
|
|
Loading…
Reference in a new issue