Skip to content

Commit

Permalink
Updates for Pharo 12
Browse files Browse the repository at this point in the history
  • Loading branch information
JanBliznicenko committed May 7, 2024
1 parent 73305ce commit 566d264
Show file tree
Hide file tree
Showing 29 changed files with 358 additions and 294 deletions.
38 changes: 20 additions & 18 deletions repository/OpenPonk-BormModel/BormActivity.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -4,49 +4,51 @@ Activity represents some behavior in the model being executed when traversing fr
Activity can also communicate with activities in other participants using communications.
"
Class {
#name : #BormActivity,
#superclass : #BormProcessNode,
#name : 'BormActivity',
#superclass : 'BormProcessNode',
#instVars : [
'communications'
],
#category : #'OpenPonk-BormModel-Models'
#category : 'OpenPonk-BormModel-Models',
#package : 'OpenPonk-BormModel',
#tag : 'Models'
}

{ #category : #associating }
{ #category : 'associating' }
BormActivity >> ==> anActivity [
^ BormFactory communicationFrom: self to: anActivity
]

{ #category : #accessing }
{ #category : 'accessing' }
BormActivity >> allElements [
"should return all elements recursively (incl. sub-elements)"

^ super allElements , (self communications flatCollect: [ :each |
(Set with: each) , each allElements ])
]

{ #category : #accessing }
{ #category : 'accessing' }
BormActivity >> allEntities [
^ super allEntities , (self sent flatCollect: #allEntities)
]

{ #category : #accessing }
{ #category : 'accessing' }
BormActivity >> communications [
^ communications copy
]

{ #category : #accessing }
{ #category : 'accessing' }
BormActivity >> has: anElement [
^ (super has: anElement) or: [ communications includes: anElement ]
]

{ #category : #initialization }
{ #category : 'initialization' }
BormActivity >> initialize [
super initialize.
communications := OrderedCollection new
]

{ #category : #inspection }
{ #category : 'inspection' }
BormActivity >> inspectionCommunications [

<inspectorPresentationOrder: 35 title: 'Communications'>
Expand All @@ -73,12 +75,12 @@ BormActivity >> inspectionCommunications [
yourself
]

{ #category : #accessing }
{ #category : 'accessing' }
BormActivity >> isActivity [
^ true
]

{ #category : #adding }
{ #category : 'adding' }
BormActivity >> receive: aCommunication [
(communications includes: aCommunication)
ifTrue: [ ^ self ].
Expand All @@ -87,20 +89,20 @@ BormActivity >> receive: aCommunication [
self changed
]

{ #category : #accessing }
{ #category : 'accessing' }
BormActivity >> received [
^ communications select: [ :each | each receiver = self ]
]

{ #category : #removing }
{ #category : 'removing' }
BormActivity >> removeAllCommunications [
communications copy
do: [ :each |
each sender removeCommunication: each.
each receiver removeCommunication: each ]
]

{ #category : #adding }
{ #category : 'adding' }
BormActivity >> removeCommunication: aCommunication [
communications remove: aCommunication.
aCommunication sender = self
Expand All @@ -109,7 +111,7 @@ BormActivity >> removeCommunication: aCommunication [
self announceRemoved: aCommunication ]
]

{ #category : #removing }
{ #category : 'removing' }
BormActivity >> removedFrom: aParticipant [
super
removedFrom: aParticipant
Expand All @@ -118,7 +120,7 @@ BormActivity >> removedFrom: aParticipant [
self removeAllCommunications ]
]

{ #category : #adding }
{ #category : 'adding' }
BormActivity >> send: aCommunication [
(communications includes: aCommunication)
ifTrue: [ ^ self ].
Expand All @@ -128,7 +130,7 @@ BormActivity >> send: aCommunication [
self announceAdded: aCommunication
]

{ #category : #accessing }
{ #category : 'accessing' }
BormActivity >> sent [
^ communications select: [ :each | each sender = self ]
]
24 changes: 13 additions & 11 deletions repository/OpenPonk-BormModel/BormActivityTest.class.st
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
Class {
#name : #BormActivityTest,
#superclass : #BormProcessNodeTest,
#name : 'BormActivityTest',
#superclass : 'BormProcessNodeTest',
#instVars : [
'sender',
'receiver',
'communication'
],
#category : #'OpenPonk-BormModel-Tests'
#category : 'OpenPonk-BormModel-Tests',
#package : 'OpenPonk-BormModel',
#tag : 'Tests'
}

{ #category : #accessing }
{ #category : 'accessing' }
BormActivityTest >> emptyNode [
^ emptyActivity
]

{ #category : #running }
{ #category : 'running' }
BormActivityTest >> setUp [
super setUp.
sender := BormActivity new.
Expand All @@ -24,12 +26,12 @@ BormActivityTest >> setUp [
receiver receive: communication
]

{ #category : #tests }
{ #category : 'tests' }
BormActivityTest >> testAllEntities [
self assert: emptyActivity allEntities equals: (Set with: emptyActivity entity)
]

{ #category : #tests }
{ #category : 'tests' }
BormActivityTest >> testCommunication [
self assert: communication sender equals: sender.
self assert: communication receiver equals: receiver.
Expand All @@ -40,27 +42,27 @@ BormActivityTest >> testCommunication [
self assert: receiver received anyOne equals: communication
]

{ #category : #tests }
{ #category : 'tests' }
BormActivityTest >> testEmptyActivity [
self assert: emptyActivity sent isEmpty.
self assert: emptyActivity received isEmpty
]

{ #category : #tests }
{ #category : 'tests' }
BormActivityTest >> testRemoveAllCommunications [
sender removeAllCommunications.
self assert: sender sent isEmpty.
self assert: receiver received isEmpty
]

{ #category : #tests }
{ #category : 'tests' }
BormActivityTest >> testRemoveAllCommunications2 [
receiver removeAllCommunications.
self assert: sender sent isEmpty.
self assert: receiver received isEmpty
]

{ #category : #tests }
{ #category : 'tests' }
BormActivityTest >> testRemoveCommunication [
self assert: sender sent size equals: 1.
self assert: receiver received size equals: 1.
Expand Down
50 changes: 26 additions & 24 deletions repository/OpenPonk-BormModel/BormCommunication.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,31 @@
Communication is a channel between two activities. Activites can send data flows in both directions through this channel
"
Class {
#name : #BormCommunication,
#superclass : #BormElement,
#name : 'BormCommunication',
#superclass : 'BormElement',
#traits : 'TBormRelationship',
#classTraits : 'TBormRelationship classTrait',
#instVars : [
'constraint',
'sender',
'receiver'
],
#category : #'OpenPonk-BormModel-Models'
#category : 'OpenPonk-BormModel-Models',
#package : 'OpenPonk-BormModel',
#tag : 'Models'
}

{ #category : #adding }
{ #category : 'adding' }
BormCommunication >> addDataFlow: aDataFlow [
^ self add: aDataFlow
]

{ #category : #adding }
{ #category : 'adding' }
BormCommunication >> addDataFlowNamed: aString [
^ self add: (BormDataFlow named: aString)
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> allEntities [
^ (Set with: self entity) , (self dataFlows flatCollect: #allEntities)
,
Expand All @@ -33,12 +35,12 @@ BormCommunication >> allEntities [
ifFalse: [ {} ])
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> constraint [
^ constraint
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> constraint: aConstraint [
self hasConstraint
ifTrue: [ ^ self ].
Expand All @@ -47,50 +49,50 @@ BormCommunication >> constraint: aConstraint [
self announceAdded: aConstraint
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> constraints [
^ constraint ifNil: [ #() ] ifNotNil: [ ^ {constraint} ]
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> dataFlows [

^ elements
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> elements [

self hasConstraint ifFalse: [ ^ super elements ].
^ super elements , { self constraint }
]

{ #category : #testing }
{ #category : 'testing' }
BormCommunication >> has: anEntity [
^ (super has: anEntity) or: [ constraint = anEntity ]
]

{ #category : #testing }
{ #category : 'testing' }
BormCommunication >> hasConstraint [
^ constraint isNotNil
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> receiver [
^ receiver
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> receiver: anActivity [
receiver := anActivity
]

{ #category : #removing }
{ #category : 'removing' }
BormCommunication >> removeAllDataFlows [
^ self removeAll
]

{ #category : #removing }
{ #category : 'removing' }
BormCommunication >> removeConstraint [
self hasConstraint
ifFalse: [ ^ self ].
Expand All @@ -99,37 +101,37 @@ BormCommunication >> removeConstraint [
constraint := nil
]

{ #category : #removing }
{ #category : 'removing' }
BormCommunication >> removeDataFlow: aDataFlow [
^ self remove: aDataFlow
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> sender [
^ sender
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> sender: anActivity [
sender := anActivity
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> source [
^ self sender
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> source: aSource [
self sender: aSource
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> target [
^ self receiver
]

{ #category : #accessing }
{ #category : 'accessing' }
BormCommunication >> target: aSource [
self receiver: aSource
]
Loading

0 comments on commit 566d264

Please sign in to comment.