-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c1d6a7
commit b3d6ecb
Showing
14 changed files
with
1,574 additions
and
1,574 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
repository/BaselineOfOpenPonkUMLXMI/BaselineOfOpenPonkUMLXMI.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
" | ||
Baseline for https://github.com/OpenPonk/uml-xmi | ||
" | ||
Class { | ||
#name : 'BaselineOfOpenPonkUMLXMI', | ||
#superclass : 'BaselineOf', | ||
#category : 'BaselineOfOpenPonkUMLXMI', | ||
#package : 'BaselineOfOpenPonkUMLXMI' | ||
} | ||
|
||
{ #category : 'baselines' } | ||
BaselineOfOpenPonkUMLXMI >> baseline: spec [ | ||
<baseline> | ||
spec | ||
for: #common | ||
do: [ spec baseline: 'OpenPonkXMI' with: [ spec repository: 'github://openponk/xmi' ]. | ||
spec | ||
baseline: 'OpenPonkUMLMetamodel' | ||
with: [ spec repository: 'github://openponk/uml-metamodel' ]. | ||
spec package: 'OpenPonk-UML-XMI' with: [ spec requires: #('OpenPonkXMI' 'OpenPonkUMLMetamodel') ]. | ||
spec group: 'default' with: #('OpenPonk-UML-XMI') ] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Package { #name : 'BaselineOfOpenPonkUMLXMI' } |
This file was deleted.
Oops, something went wrong.
138 changes: 69 additions & 69 deletions
138
...ry/OP-UML-XMI/OPUMLXMIMetaReader.class.st → ...nPonk-UML-XMI/OPUMLXMIMetaReader.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,69 @@ | ||
Class { | ||
#name : 'OPUMLXMIMetaReader', | ||
#superclass : 'OPUMLXMIReader', | ||
#category : 'OP-UML-XMI-Reader', | ||
#package : 'OP-UML-XMI', | ||
#tag : 'Reader' | ||
} | ||
|
||
{ #category : 'instance creation' } | ||
OPUMLXMIMetaReader >> createNewInstanceFor: anItem property: aProperty [ | ||
|
||
| name | | ||
name := (#( Package Model Profile ) includes: anItem xmiName) | ||
ifTrue: [ anItem xmiName ] | ||
ifFalse: [ | ||
anItem xmiType | ||
ifNil: [ self error: 'Unknown element type.' ] | ||
ifNotNil: [ :type | (type splitOn: ':') last ] ]. | ||
^ (Smalltalk at: (self classPrefix , name) asSymbol) new | ||
] | ||
|
||
{ #category : 'reading' } | ||
OPUMLXMIMetaReader >> readItem: anItem property: aProperty [ | ||
| instance groups | | ||
anItem isValueItem | ||
ifTrue: [ ^ self valueFor: anItem value ]. | ||
anItem isReferenceItem | ||
ifTrue: [ ^ anItem referencedElements | ||
collect: [ :each | self readItem: each property: nil ] ]. | ||
instanceCache at: (self uniqueIdOf: anItem) ifPresent: [ :match | ^ match ]. | ||
instance := self instanceFor: anItem property: nil. | ||
groups := self groupedChildrenIn: anItem. | ||
groups | ||
keysAndValuesDo: [ :key :values | | ||
| selector arguments pluralSelector sg pl isMultivalued | | ||
selector := (key , ':') asSymbol. | ||
pluralSelector := ((self asPlural: key) , ':') asSymbol. | ||
sg := (instance class selectors includes: selector) | ||
or: [ instance class superclass name = (self classPrefix , 'Element') | ||
and: [ instance class superclass selectors includes: selector ] ]. | ||
pl := (instance class selectors includes: pluralSelector) | ||
or: [ instance class superclass name = (self classPrefix , 'Element') | ||
and: [ instance class superclass selectors includes: pluralSelector ] ]. | ||
isMultivalued := sg not & pl. | ||
isMultivalued | ||
ifTrue: [ selector := pluralSelector ]. | ||
self assert: [ sg | pl ]. | ||
arguments := values collect: [ :each | self readItem: each property: nil ]. | ||
(arguments anyOne isArray or: [ arguments anyOne isKindOf: OrderedCollection ]) | ||
ifTrue: [ arguments := arguments gather: #yourself ]. | ||
isMultivalued | ||
ifTrue: [ instance perform: selector with: arguments ] | ||
ifFalse: [ self assert: [ values size = 1 ]. | ||
self flag: 'Because unresolved references...'. | ||
arguments size > 0 | ||
ifTrue: [ instance perform: selector with: arguments first ] ] ]. | ||
^ instance | ||
] | ||
|
||
{ #category : 'reading' } | ||
OPUMLXMIMetaReader >> valueFor: anObject [ | ||
anObject = 'true' | ||
ifTrue: [ ^ true ]. | ||
anObject = 'false' | ||
ifTrue: [ ^ false ]. | ||
(NumberParser isNumber: anObject) | ||
ifTrue: [ ^ Number readFromString: anObject ]. | ||
^ anObject | ||
] | ||
Class { | ||
#name : 'OPUMLXMIMetaReader', | ||
#superclass : 'OPUMLXMIReader', | ||
#category : 'OpenPonk-UML-XMI-Reader', | ||
#package : 'OpenPonk-UML-XMI', | ||
#tag : 'Reader' | ||
} | ||
|
||
{ #category : 'instance creation' } | ||
OPUMLXMIMetaReader >> createNewInstanceFor: anItem property: aProperty [ | ||
|
||
| name | | ||
name := (#( Package Model Profile ) includes: anItem xmiName) | ||
ifTrue: [ anItem xmiName ] | ||
ifFalse: [ | ||
anItem xmiType | ||
ifNil: [ self error: 'Unknown element type.' ] | ||
ifNotNil: [ :type | (type splitOn: ':') last ] ]. | ||
^ (Smalltalk at: (self classPrefix , name) asSymbol) new | ||
] | ||
|
||
{ #category : 'reading' } | ||
OPUMLXMIMetaReader >> readItem: anItem property: aProperty [ | ||
| instance groups | | ||
anItem isValueItem | ||
ifTrue: [ ^ self valueFor: anItem value ]. | ||
anItem isReferenceItem | ||
ifTrue: [ ^ anItem referencedElements | ||
collect: [ :each | self readItem: each property: nil ] ]. | ||
instanceCache at: (self uniqueIdOf: anItem) ifPresent: [ :match | ^ match ]. | ||
instance := self instanceFor: anItem property: nil. | ||
groups := self groupedChildrenIn: anItem. | ||
groups | ||
keysAndValuesDo: [ :key :values | | ||
| selector arguments pluralSelector sg pl isMultivalued | | ||
selector := (key , ':') asSymbol. | ||
pluralSelector := ((self asPlural: key) , ':') asSymbol. | ||
sg := (instance class selectors includes: selector) | ||
or: [ instance class superclass name = (self classPrefix , 'Element') | ||
and: [ instance class superclass selectors includes: selector ] ]. | ||
pl := (instance class selectors includes: pluralSelector) | ||
or: [ instance class superclass name = (self classPrefix , 'Element') | ||
and: [ instance class superclass selectors includes: pluralSelector ] ]. | ||
isMultivalued := sg not & pl. | ||
isMultivalued | ||
ifTrue: [ selector := pluralSelector ]. | ||
self assert: [ sg | pl ]. | ||
arguments := values collect: [ :each | self readItem: each property: nil ]. | ||
(arguments anyOne isArray or: [ arguments anyOne isKindOf: OrderedCollection ]) | ||
ifTrue: [ arguments := arguments gather: #yourself ]. | ||
isMultivalued | ||
ifTrue: [ instance perform: selector with: arguments ] | ||
ifFalse: [ self assert: [ values size = 1 ]. | ||
self flag: 'Because unresolved references...'. | ||
arguments size > 0 | ||
ifTrue: [ instance perform: selector with: arguments first ] ] ]. | ||
^ instance | ||
] | ||
|
||
{ #category : 'reading' } | ||
OPUMLXMIMetaReader >> valueFor: anObject [ | ||
anObject = 'true' | ||
ifTrue: [ ^ true ]. | ||
anObject = 'false' | ||
ifTrue: [ ^ false ]. | ||
(NumberParser isNumber: anObject) | ||
ifTrue: [ ^ Number readFromString: anObject ]. | ||
^ anObject | ||
] |
78 changes: 39 additions & 39 deletions
78
...itory/OP-UML-XMI/OPUMLXMIPathmap.class.st → ...OpenPonk-UML-XMI/OPUMLXMIPathmap.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
Class { | ||
#name : 'OPUMLXMIPathmap', | ||
#superclass : 'Object', | ||
#instVars : [ | ||
'mapping' | ||
], | ||
#category : 'OP-UML-XMI-Utility', | ||
#package : 'OP-UML-XMI', | ||
#tag : 'Utility' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
OPUMLXMIPathmap class >> default [ | ||
^ self new | ||
add: 'http://www.omg.org/spec/UML/20131001/PrimitiveTypes.xmi'; | ||
add: 'http://www.omg.org/spec/UML/20131001/UML.xmi'; | ||
yourself | ||
] | ||
|
||
{ #category : 'adding' } | ||
OPUMLXMIPathmap >> add: aPath [ | ||
self add: aPath retrieveUsing: [ OPUMLXMISpecsStorage current at: aPath ] | ||
] | ||
|
||
{ #category : 'adding' } | ||
OPUMLXMIPathmap >> add: aPath retrieveUsing: aBlock [ | ||
mapping at: aPath put: aBlock value | ||
] | ||
|
||
{ #category : 'initialization' } | ||
OPUMLXMIPathmap >> initialize [ | ||
super initialize. | ||
mapping := OrderedDictionary new | ||
] | ||
|
||
{ #category : 'accessing' } | ||
OPUMLXMIPathmap >> mapping [ | ||
^ mapping | ||
] | ||
Class { | ||
#name : 'OPUMLXMIPathmap', | ||
#superclass : 'Object', | ||
#instVars : [ | ||
'mapping' | ||
], | ||
#category : 'OpenPonk-UML-XMI-Utility', | ||
#package : 'OpenPonk-UML-XMI', | ||
#tag : 'Utility' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
OPUMLXMIPathmap class >> default [ | ||
^ self new | ||
add: 'http://www.omg.org/spec/UML/20131001/PrimitiveTypes.xmi'; | ||
add: 'http://www.omg.org/spec/UML/20131001/UML.xmi'; | ||
yourself | ||
] | ||
|
||
{ #category : 'adding' } | ||
OPUMLXMIPathmap >> add: aPath [ | ||
self add: aPath retrieveUsing: [ OPUMLXMISpecsStorage current at: aPath ] | ||
] | ||
|
||
{ #category : 'adding' } | ||
OPUMLXMIPathmap >> add: aPath retrieveUsing: aBlock [ | ||
mapping at: aPath put: aBlock value | ||
] | ||
|
||
{ #category : 'initialization' } | ||
OPUMLXMIPathmap >> initialize [ | ||
super initialize. | ||
mapping := OrderedDictionary new | ||
] | ||
|
||
{ #category : 'accessing' } | ||
OPUMLXMIPathmap >> mapping [ | ||
^ mapping | ||
] |
Oops, something went wrong.