Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
pnml-relast
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
JastAdd
pnml
pnml-relast
Commits
7da5a7ae
Commit
7da5a7ae
authored
2 years ago
by
Johannes Mey
Browse files
Options
Downloads
Patches
Plain Diff
throw exceptions instead of exiting on errors
parent
3921e9d2
No related branches found
No related tags found
No related merge requests found
Pipeline
#14700
passed
2 years ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/de/tudresden/inf/st/pnml/PnmlParser.java
+7
-17
7 additions, 17 deletions
src/main/java/de/tudresden/inf/st/pnml/PnmlParser.java
src/test/java/de/tudresden/inf/st/pnml/PnmlTest.java
+2
-1
2 additions, 1 deletion
src/test/java/de/tudresden/inf/st/pnml/PnmlTest.java
with
9 additions
and
18 deletions
src/main/java/de/tudresden/inf/st/pnml/PnmlParser.java
+
7
−
17
View file @
7da5a7ae
...
@@ -37,22 +37,18 @@ public class PnmlParser {
...
@@ -37,22 +37,18 @@ public class PnmlParser {
* @param fileName the file name of a *.pnml file
* @param fileName the file name of a *.pnml file
* @return a list of Petri nets
* @return a list of Petri nets
*/
*/
public
static
List
<
PetriNet
>
parsePnml
(
String
fileName
)
{
public
static
List
<
PetriNet
>
parsePnml
(
String
fileName
)
throws
PnmlParseException
{
Path
file
=
Paths
.
get
(
fileName
);
Path
file
=
Paths
.
get
(
fileName
);
HLAPIRootClass
document
=
null
;
HLAPIRootClass
document
=
null
;
try
{
try
{
document
=
PNMLUtils
.
importPnmlDocument
(
file
.
toFile
(),
false
);
document
=
PNMLUtils
.
importPnmlDocument
(
file
.
toFile
(),
false
);
logger
.
debug
(
document
.
toPNML
());
logger
.
info
(
document
.
toPNML
());
}
catch
(
ImportException
|
InvalidIDException
e
)
{
}
catch
(
ImportException
|
InvalidIDException
e
)
{
logger
.
error
(
"Unable to import PNML document from file '{}'"
,
fileName
);
throw
new
PnmlParseException
(
"Unable to import PNML document from file '"
+
fileName
+
"'"
,
e
);
logger
.
error
(
"Exception was thrown!"
,
e
);
System
.
exit
(-
1
);
}
}
logger
.
info
(
"Imported document workspace ID: {}"
,
ModelRepository
.
getInstance
().
getCurrentDocWSId
());
logger
.
info
(
"Imported document workspace ID: {}"
,
ModelRepository
.
getInstance
().
getCurrentDocWSId
());
List
<
PetriNet
>
petriNets
=
new
ArrayList
<>();
List
<
PetriNet
>
petriNets
=
new
ArrayList
<>();
...
@@ -60,18 +56,12 @@ public class PnmlParser {
...
@@ -60,18 +56,12 @@ public class PnmlParser {
fr
.
lip6
.
move
.
pnml
.
framework
.
general
.
PNType
type
=
PNMLUtils
.
determinePNType
(
document
);
fr
.
lip6
.
move
.
pnml
.
framework
.
general
.
PNType
type
=
PNMLUtils
.
determinePNType
(
document
);
switch
(
type
)
{
switch
(
type
)
{
case
PTNET:
case
PTNET:
PetriNetDocHLAPI
ptDoc
=
PetriNetDocHLAPI
ptDoc
=
(
PetriNetDocHLAPI
)
document
;
(
PetriNetDocHLAPI
)
document
;
for
(
fr
.
lip6
.
move
.
pnml
.
ptnet
.
PetriNet
pmnlNet
:
ptDoc
.
getNets
())
{
for
(
fr
.
lip6
.
move
.
pnml
.
ptnet
.
PetriNet
pmnlNet
:
ptDoc
.
getNets
())
{
PnmlParser
parser
;
PnmlParser
parser
;
try
{
parser
=
new
PnmlParser
(
pmnlNet
);
parser
=
new
PnmlParser
(
pmnlNet
);
petriNets
.
add
(
parser
.
getPetriNet
());
petriNets
.
add
(
parser
.
getPetriNet
());
}
catch
(
PnmlParseException
e
)
{
logger
.
error
(
"Parsing the Petri net using the PNML framework failed."
,
e
);
}
}
}
break
;
break
;
...
@@ -80,7 +70,7 @@ public class PnmlParser {
...
@@ -80,7 +70,7 @@ public class PnmlParser {
case
HLPN:
case
HLPN:
case
PTHLPN:
case
PTHLPN:
default
:
default
:
logger
.
error
(
"Petri net is of unsupported type
{}."
,
type
.
getLiteral
());
throw
new
PnmlParseException
(
"Petri net is of unsupported type
"
+
type
.
getLiteral
()
+
"."
);
}
}
return
petriNets
;
return
petriNets
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/test/java/de/tudresden/inf/st/pnml/PnmlTest.java
+
2
−
1
View file @
7da5a7ae
...
@@ -2,6 +2,7 @@ package de.tudresden.inf.st.pnml;
...
@@ -2,6 +2,7 @@ package de.tudresden.inf.st.pnml;
import
de.tudresden.inf.st.pnml.jastadd.model.PNType
;
import
de.tudresden.inf.st.pnml.jastadd.model.PNType
;
import
de.tudresden.inf.st.pnml.jastadd.model.PetriNet
;
import
de.tudresden.inf.st.pnml.jastadd.model.PetriNet
;
import
de.tudresden.inf.st.pnml.jastadd.model.PnmlParseException
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.ParameterizedTest
;
import
org.junit.jupiter.params.provider.ValueSource
;
import
org.junit.jupiter.params.provider.ValueSource
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -17,7 +18,7 @@ class PnmlTest {
...
@@ -17,7 +18,7 @@ class PnmlTest {
@ParameterizedTest
@ParameterizedTest
@ValueSource
(
strings
=
{
"src/test/resources/minimal.pnml"
,
"src/test/resources/philo.pnml"
,
"src/test/resources/haddadin_automaton_flat.pnml"
})
@ValueSource
(
strings
=
{
"src/test/resources/minimal.pnml"
,
"src/test/resources/philo.pnml"
,
"src/test/resources/haddadin_automaton_flat.pnml"
})
void
parsePnml
(
String
fileName
)
{
void
parsePnml
(
String
fileName
)
throws
PnmlParseException
{
List
<
PetriNet
>
result
=
PnmlParser
.
parsePnml
(
fileName
);
List
<
PetriNet
>
result
=
PnmlParser
.
parsePnml
(
fileName
);
assertThat
(
result
).
asList
()
assertThat
(
result
).
asList
()
.
isNotEmpty
()
.
isNotEmpty
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment