Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
monticore
EmbeddedMontiArc
languages
EmbeddedMontiArc
Commits
ffff063c
Commit
ffff063c
authored
Sep 27, 2019
by
Mike Grüne
Browse files
Removed msgField from Tagging
parent
07e67b03
Pipeline
#188352
failed with stage
in 1 minute and 36 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/main/java/de/monticore/lang/embeddedmontiarc/tagging/middleware/mqtt/MqttConnectionSymbol.java
View file @
ffff063c
/**
* (c) https://github.com/MontiCore/monticore
*
* The license generally applicable for this project
* can be found under https://github.com/MontiCore/monticore.
*/
/* (c) https://github.com/MontiCore/monticore */
/* (c) https://github.com/MontiCore/monticore */
package
de.monticore.lang.embeddedmontiarc.tagging.middleware.mqtt
;
package
de.monticore.lang.embeddedmontiarc.tagging.middleware.mqtt
;
...
@@ -18,22 +24,14 @@ public class MqttConnectionSymbol extends MiddlewareSymbol {
...
@@ -18,22 +24,14 @@ public class MqttConnectionSymbol extends MiddlewareSymbol {
this
(
KIND
,
topicName
);
this
(
KIND
,
topicName
);
}
}
public
MqttConnectionSymbol
(
MqttConnectionKind
kind
,
String
topicName
)
{
protected
MqttConnectionSymbol
(
MqttConnectionKind
kind
,
String
topicName
)
{
super
(
kind
,
Optional
.
ofNullable
(
topicName
),
Optional
.
empty
());
super
(
kind
,
Optional
.
ofNullable
(
topicName
));
}
public
MqttConnectionSymbol
(
String
topicName
,
String
msgField
)
{
this
(
KIND
,
topicName
,
msgField
);
}
protected
MqttConnectionSymbol
(
MqttConnectionKind
kind
,
String
topicName
,
String
msgField
)
{
super
(
kind
,
Optional
.
ofNullable
(
topicName
),
Optional
.
ofNullable
(
msgField
));
}
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
String
.
format
(
"MqttConnection =
%s,
%s"
,
return
String
.
format
(
"MqttConnection = %s"
,
getTopicName
()
,
getMsgField
()
);
getTopicName
());
}
}
public
Optional
<
String
>
getTopicName
()
{
public
Optional
<
String
>
getTopicName
()
{
...
@@ -44,14 +42,6 @@ public class MqttConnectionSymbol extends MiddlewareSymbol {
...
@@ -44,14 +42,6 @@ public class MqttConnectionSymbol extends MiddlewareSymbol {
this
.
values
.
set
(
0
,
Optional
.
ofNullable
(
topicName
));
this
.
values
.
set
(
0
,
Optional
.
ofNullable
(
topicName
));
}
}
public
Optional
<
String
>
getMsgField
()
{
return
getValue
(
1
);
}
public
void
setMsgField
(
String
msgField
)
{
this
.
values
.
set
(
1
,
Optional
.
ofNullable
(
msgField
));
}
public
static
class
MqttConnectionKind
extends
TagKind
{
public
static
class
MqttConnectionKind
extends
TagKind
{
public
static
final
MqttConnectionKind
INSTANCE
=
new
MqttConnectionKind
();
public
static
final
MqttConnectionKind
INSTANCE
=
new
MqttConnectionKind
();
...
...
src/main/java/de/monticore/lang/embeddedmontiarc/tagging/middleware/mqtt/MqttConnectionSymbolCreator.java
View file @
ffff063c
...
@@ -34,8 +34,8 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
...
@@ -34,8 +34,8 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
* at http://www.regexplanet.com/advanced/java/index.html
* at http://www.regexplanet.com/advanced/java/index.html
*/
*/
// \s*\{\s*topic\s*=\s*([a-z
|
A-Z
|~|/][0-9|a-z|A-Z|_|/]*)\s*(s*,\s*msgField\s*=\s*([a-z|A-Z][a-z|A-Z|1-9|_|\.|::|\(|\)]*)\s*)?
\s*\}\s*
// \s*\{\s*topic\s*=\s*([a-zA-Z
~0-9_\/]*)
\s*\}\s*
public
static
final
Pattern
pattern
=
Pattern
.
compile
(
"\\s*\\{\\s*topic\\s*=\\s*([a-z
|
A-Z
|~|/][0-9|a-z|A-Z|_|/]*)\\s*(s*,\\s*msgField\\s*=\\s*([a-z|A-Z][a-z|A-Z|1-9|_|\\.|::|\\(|\\)]*)\\s*)?
\\s*\\}\\s*"
);
public
static
final
Pattern
pattern
=
Pattern
.
compile
(
"\\s*\\{\\s*topic\\s*=\\s*([a-zA-Z
~0-9_\\/]*)
\\s*\\}\\s*"
);
public
static
Scope
getGlobalScope
(
final
Scope
scope
)
{
public
static
Scope
getGlobalScope
(
final
Scope
scope
)
{
Scope
s
=
scope
;
Scope
s
=
scope
;
...
@@ -111,7 +111,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
...
@@ -111,7 +111,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
.
forEachOrdered
(
m
->
.
forEachOrdered
(
m
->
taggedSymbols
.
stream
()
taggedSymbols
.
stream
()
.
forEachOrdered
(
s
->
{
.
forEachOrdered
(
s
->
{
MqttConnectionSymbol
tmpSymbol
=
new
MqttConnectionSymbol
(
m
.
group
(
1
)
,
m
.
group
(
3
)
);
// topicName, msgField
MqttConnectionSymbol
tmpSymbol
=
new
MqttConnectionSymbol
(
m
.
group
(
1
));
// topicName, msgField
tagging
.
addTag
(
s
,
tmpSymbol
);
tagging
.
addTag
(
s
,
tmpSymbol
);
if
(
s
.
isKindOf
(
EMAPortSymbol
.
KIND
))
{
if
(
s
.
isKindOf
(
EMAPortSymbol
.
KIND
))
{
EMAPortSymbol
p
=
(
EMAPortSymbol
)
s
;
EMAPortSymbol
p
=
(
EMAPortSymbol
)
s
;
...
@@ -131,7 +131,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
...
@@ -131,7 +131,7 @@ public class MqttConnectionSymbolCreator implements TagSymbolCreator {
}
}
Log
.
error
(
String
.
format
(
"'%s' does not match the specified regex pattern '%s'"
,
Log
.
error
(
String
.
format
(
"'%s' does not match the specified regex pattern '%s'"
,
regex
,
regex
,
"{topic = {name}
, msgField = {msgField}
}"
));
"{topic = {name}}"
));
return
null
;
return
null
;
}
}
...
...
src/test/java/de/monticore/lang/embeddedmontiarc/middleware/mqtt/TaggingTest.java
View file @
ffff063c
...
@@ -39,7 +39,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
...
@@ -39,7 +39,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
MqttConnectionSymbol
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
MqttConnectionSymbol
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
assertEquals
(
tag
.
getTopicName
().
get
(),
"/echoQ"
);
assertEquals
(
tag
.
getTopicName
().
get
(),
"/echoQ"
);
assertEquals
(
tag
.
getMsgField
().
get
(),
"dataQ"
);
//mqttInN
//mqttInN
EMAPortSymbol
mqttInN
=
component
.
getPortInstance
(
"mqttInN"
).
orElse
(
null
);
EMAPortSymbol
mqttInN
=
component
.
getPortInstance
(
"mqttInN"
).
orElse
(
null
);
...
@@ -50,7 +49,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
...
@@ -50,7 +49,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
assertEquals
(
tag
.
getTopicName
().
get
(),
"/echoN"
);
assertEquals
(
tag
.
getTopicName
().
get
(),
"/echoN"
);
assertEquals
(
tag
.
getMsgField
().
get
(),
"dataN"
);
//mqttInZ
//mqttInZ
EMAPortSymbol
mqttInZ
=
component
.
getPortInstance
(
"mqttInZ"
).
orElse
(
null
);
EMAPortSymbol
mqttInZ
=
component
.
getPortInstance
(
"mqttInZ"
).
orElse
(
null
);
...
@@ -61,7 +59,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
...
@@ -61,7 +59,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
assertEquals
(
tag
.
getTopicName
().
get
(),
"/echoZ"
);
assertEquals
(
tag
.
getTopicName
().
get
(),
"/echoZ"
);
assertEquals
(
tag
.
getMsgField
().
get
(),
"dataZ"
);
//mqttInB
//mqttInB
EMAPortSymbol
mqttInB
=
component
.
getPortInstance
(
"mqttInB"
).
orElse
(
null
);
EMAPortSymbol
mqttInB
=
component
.
getPortInstance
(
"mqttInB"
).
orElse
(
null
);
...
@@ -72,7 +69,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
...
@@ -72,7 +69,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
assertEquals
(
tag
.
getTopicName
().
get
(),
"/echoB"
);
assertEquals
(
tag
.
getTopicName
().
get
(),
"/echoB"
);
assertEquals
(
tag
.
getMsgField
().
get
(),
"true"
);
//mqttOutQ
//mqttOutQ
EMAPortSymbol
mqttOutQ
=
component
.
getPortInstance
(
"mqttOutQ"
).
orElse
(
null
);
EMAPortSymbol
mqttOutQ
=
component
.
getPortInstance
(
"mqttOutQ"
).
orElse
(
null
);
...
@@ -123,32 +119,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
...
@@ -123,32 +119,6 @@ public class TaggingTest extends AbstractTaggingResolverTest {
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
tag
=
(
MqttConnectionSymbol
)
tags
.
iterator
().
next
();
assertEquals
(
tag
.
getTopicName
(),
Optional
.
empty
());
assertEquals
(
tag
.
getTopicName
(),
Optional
.
empty
());
assertEquals
(
tag
.
getMsgField
(),
Optional
.
empty
());
}
@Test
public
void
testMqttConnectionParsingOptionalMsgField
()
{
TaggingResolver
symtab
=
createSymTabAndTaggingResolver
(
"src/test/resources"
);
EMAComponentInstanceSymbol
component
=
symtab
.<
EMAComponentInstanceSymbol
>
resolve
(
"middleware.mqtt.optionalMsgField"
,
EMAComponentInstanceSymbol
.
KIND
).
orElse
(
null
);
assertNotNull
(
component
);
EMAPortSymbol
in1
=
component
.
getPortInstance
(
"in1"
).
orElse
(
null
);
EMAPortSymbol
out1
=
component
.
getPortInstance
(
"out1"
).
orElse
(
null
);
assertNotNull
(
in1
);
assertNotNull
(
out1
);
MqttConnectionSymbol
tagIn1
=
(
MqttConnectionSymbol
)
symtab
.
getTags
(
in1
,
MqttConnectionSymbol
.
KIND
).
stream
().
findFirst
().
orElse
(
null
);
MqttConnectionSymbol
tagOut1
=
(
MqttConnectionSymbol
)
symtab
.
getTags
(
out1
,
MqttConnectionSymbol
.
KIND
).
stream
().
findFirst
().
orElse
(
null
);
assertNotNull
(
tagIn1
);
assertNotNull
(
tagOut1
);
assertFalse
(
tagIn1
.
getMsgField
().
isPresent
());
assertTrue
(
tagOut1
.
getMsgField
().
isPresent
());
assertTrue
(
tagOut1
.
getMsgField
().
get
().
equals
(
"msgField1"
));
}
}
}
}
src/test/resources/middleware/mqtt/BasicParsing.tag
View file @
ffff063c
...
@@ -2,13 +2,13 @@ package middleware.mqtt;
...
@@ -2,13 +2,13 @@ package middleware.mqtt;
conforms
to
middleware
.
mqtt
.
MqttToEmamTagSchema
;
conforms
to
middleware
.
mqtt
.
MqttToEmamTagSchema
;
tags
Echo
{
tags
Echo
{
tag
basicParsing
.
mqttInQ
with
MqttConnection
=
{
topic
=
/
echoQ
,
msgField
=
dataQ
};
tag
basicParsing
.
mqttInQ
with
MqttConnection
=
{
topic
=
/
echoQ
};
tag
basicParsing
.
mqttOutQ
with
MqttConnection
=
{
topic
=
/
echoQ
};
tag
basicParsing
.
mqttOutQ
with
MqttConnection
=
{
topic
=
/
echoQ
};
tag
basicParsing
.
mqttInN
with
MqttConnection
=
{
topic
=
/
echoN
,
msgField
=
dataN
};
tag
basicParsing
.
mqttInN
with
MqttConnection
=
{
topic
=
/
echoN
};
tag
basicParsing
.
mqttOutN
with
MqttConnection
=
{
topic
=
/
echoN
};
tag
basicParsing
.
mqttOutN
with
MqttConnection
=
{
topic
=
/
echoN
};
tag
basicParsing
.
mqttInZ
with
MqttConnection
=
{
topic
=
/
echoZ
,
msgField
=
dataZ
};
tag
basicParsing
.
mqttInZ
with
MqttConnection
=
{
topic
=
/
echoZ
};
tag
basicParsing
.
mqttOutZ
with
MqttConnection
=
{
topic
=
/
echoZ
};
tag
basicParsing
.
mqttOutZ
with
MqttConnection
=
{
topic
=
/
echoZ
};
tag
basicParsing
.
mqttInB
with
MqttConnection
=
{
topic
=
/
echoB
,
msgField
=
true
};
tag
basicParsing
.
mqttInB
with
MqttConnection
=
{
topic
=
/
echoB
};
tag
basicParsing
.
mqttOutB
with
MqttConnection
=
{
topic
=
/
echoB
};
tag
basicParsing
.
mqttOutB
with
MqttConnection
=
{
topic
=
/
echoB
};
tag
basicParsing
.
emptyTagIn
with
MqttConnection
;
tag
basicParsing
.
emptyTagIn
with
MqttConnection
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment