Skip to content

Commit

Permalink
Baseline and package renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed Nov 10, 2024
1 parent 5c1d6a7 commit b3d6ecb
Show file tree
Hide file tree
Showing 14 changed files with 1,574 additions and 1,574 deletions.
22 changes: 0 additions & 22 deletions repository/BaselineOfOPUMLXMI/BaselineOfOPUMLXMI.class.st

This file was deleted.

1 change: 0 additions & 1 deletion repository/BaselineOfOPUMLXMI/package.st

This file was deleted.

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') ]
]
1 change: 1 addition & 0 deletions repository/BaselineOfOpenPonkUMLXMI/package.st
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Package { #name : 'BaselineOfOpenPonkUMLXMI' }
1 change: 0 additions & 1 deletion repository/OP-UML-XMI/package.st

This file was deleted.

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
]
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
]
Loading

0 comments on commit b3d6ecb

Please sign in to comment.