@ncardoz
CQL
Nicolás Cardozo
Declarative language for context
activation
10th International Workshop on Context-Oriented Programming (COP’18) - Amsterdam, the Netherlands
n.cardozo@uniandes.edu.co
16-07-2018
Context activation2
https://collabide.herokuapp.com
Context activation2
https://collabide.herokuapp.com
manual activation of multiple
contexts
Context activation3
Transport management system, to
control independent events in the
network
Reroute all busses in a line due to
an accident?
Context activation3
Individual objects may
require different specialized
behavior at different times
Transport management system, to
control independent events in the
network
Reroute all busses in a line due to
an accident?
Context traits4
DevContext	+	name	=	new	cop.Context({	
name:	“developer”	+	name	
})
[Gonzalez et al. Context Traits: dynamic adaptation behavior through trait recomposition]
Context traits4
DevContext	+	name	=	new	cop.Context({	
name:	“developer”	+	name	
})
Context object
[Gonzalez et al. Context Traits: dynamic adaptation behavior through trait recomposition]
Context traits4
DevContext	+	name	=	new	cop.Context({	
name:	“developer”	+	name	
})
Context object
properties describing the context
[Gonzalez et al. Context Traits: dynamic adaptation behavior through trait recomposition]
Context traits5
DevContext	+	name	=	new	cop.Context({	
name:	“developer”	+	name	
})
HighlightTrait	=	Trait({	
defineVisibility	:	function()	{	
developerRule.style.display	=	“inline”;	
this.proceed();	
}	
})
[Gonzalez et al. Context Traits: dynamic adaptation behavior through trait recomposition]
Context traits5
DevContext	+	name	=	new	cop.Context({	
name:	“developer”	+	name	
})
HighlightTrait	=	Trait({	
defineVisibility	:	function()	{	
developerRule.style.display	=	“inline”;	
this.proceed();	
}	
})
[Gonzalez et al. Context Traits: dynamic adaptation behavior through trait recomposition]
Specialized partial behavior
Context traits6
DevContext	+	name	=	new	cop.Context({	
name:	“developer”	+	name	
})
DevContext.adapt(highlighter,	HighlightTrait)
[Gonzalez et al. Context Traits: dynamic adaptation behavior through trait recomposition]
HighlightTrait	=	Trait({	
defineVisibility	:	function()	{	
developerRule.style.display	=	“inline”;	
this.proceed();	
}	
})
Adaptation context
object to adapt
Modified behavior
Context traits7
Context traits7
DevContextBlue.activate()
Context traits7
DevContextBlue.activate()DevContextBlue.deactivate()
CQL8
Select and activate multiple
contexts complying to a specified
pattern
Context creation9
Context objects are declared within a context. Such context can be
used to enrich the knowledge about the context object
new cop.Context({
name: “developerBlue”
date: 160420171425
sensor: “login”
last_update: “260420181138”
})
{
Object properties describe the context’s context
CQL language10
activate: date > 160420171425 for: highlighter
CQL language10
activate: date > 160420171425 for: highlighter
Action
CQL language10
activate: date > 160420171425 for: highlighter
Action Expression
CQL language10
activate: date > 160420171425 for: highlighter
Action Expression ForStatement
CQL language10
activate: date > 160420171425 for: highlighter
Action Expression ForStatement
What to do Which context to use Which entity to affect
CQL and context traits11
activate: date between(010420170001,250520172350)
Activate all the contexts
created within the given date
range
CQL and context traits11
activate: date between(010420170001,250520172350)
Activate all the contexts
created within the given date
range
DevContextYellow
DevContextBlue
DevContextRed
DevContextPurple
DevContextOrange
CQL and context traits11
activate: date between(010420170001,250520172350)
Activate all the contexts
created within the given date
range
DevContextBlue.activate()
DevContextYellow.activate()
DevContextPurple.activate()
DevContextYellow
DevContextBlue
DevContextRed
DevContextPurple
DevContextOrange
Public transport management system12
FullStation
FullBus
RoadClosed AccidentOnRoad
NoBus
StationClosed
contexts
Public transport management system13
redBus
blueBus
whiteBus
yellowBus
Street
Avenue
station1
station2
station3
entities
14
Context scoping mechanisms
activate: FullStation
Global context activation
Activate the FullStation context for all available stations
FullStation.adapt(Station, FullStationTrait)
FullStation.activate()
15
Context scoping mechanisms
Per type context activation
activate: RoadClosed for: Avenue
Close all the ‘avenue’ roads
RoadClosed.adapt(Avenue, RoadClosedTrait)
RoadClosed.activate()
16
Context scoping mechanisms
Per instance context activation
activate: FullBus for: redBus
Activate the FullBus context to the particular redBus instance
FullBus.adapt(redBus, FullBusTrait)
FullBus.activate()
17
Context scoping mechanisms
Group context activation
activate: FullStation for: station1 & FullBus
for: line5
a particular station is full, and all the buses in the line with
that station are full
FullStation.activate()
Wrap-up18
@ncardoz
➡ Soundness of the unified scoping model
➡ Extension for different types of applications
(e.g., testing)
Wrap-up18
@ncardoz
Activation of multiple contexts at once
Unified scoping mechanism for adaptations
Reduced development complexity
➡ Soundness of the unified scoping model
➡ Extension for different types of applications
(e.g., testing)
Wrap-up18
@ncardoz
Activation of multiple contexts at once
Unified scoping mechanism for adaptations
Reduced development complexity
➡ Soundness of the unified scoping model
➡ Extension for different types of applications
(e.g., testing)
Questions ?

CQL