Merge lp:~tapaal-contributor/tapaal/autodetect-lens-check into lp:tapaal

Proposed by Lena Ernstsen
Status: Rejected
Rejected by: Kenneth Yrke Jørgensen
Proposed branch: lp:~tapaal-contributor/tapaal/autodetect-lens-check
Merge into: lp:tapaal
Diff against target: 226 lines (+66/-16)
5 files modified
src/dk/aau/cs/gui/TabContent.java (+4/-2)
src/dk/aau/cs/io/LoadedModel.java (+20/-4)
src/dk/aau/cs/io/ModelLoader.java (+30/-7)
src/dk/aau/cs/io/TapnXmlLoader.java (+5/-1)
src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java (+7/-2)
To merge this branch: bzr merge lp:~tapaal-contributor/tapaal/autodetect-lens-check
Reviewer Review Type Date Requested Status
Kenneth Yrke Jørgensen Pending
TAPAAL Reviewers Pending
Review via email: mp+389463@code.launchpad.net

Commit message

Autodetect of lens info added when loading nets

Description of the change

Checks whether the registered lens information in the .tapn file is correct.

If no lens information is found in the file then auto detection checks which lens information is true.

To post a comment you must log in.
1101. By Lena Ernstsen

Merged with untimed-timed-gui

1102. By Lena Ernstsen

Merge with trunk

Unmerged revisions

1102. By Lena Ernstsen

Merge with trunk

1101. By Lena Ernstsen

Merged with untimed-timed-gui

1100. By Lena Ernstsen

Added check for whether the lens is correct according to the net

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/dk/aau/cs/gui/TabContent.java'
--- src/dk/aau/cs/gui/TabContent.java 2020-08-17 08:18:13 +0000
+++ src/dk/aau/cs/gui/TabContent.java 2020-08-19 12:14:43 +0000
@@ -1988,7 +1988,8 @@
1988 allTemplates(),1988 allTemplates(),
1989 queriesOverwrite,1989 queriesOverwrite,
1990 network().constants(),1990 network().constants(),
1991 lens1991 lens,
1992 false
1992 );1993 );
19931994
1994 tapnWriter.savePNML(outFile);1995 tapnWriter.savePNML(outFile);
@@ -2072,7 +2073,8 @@
2072 allTemplates(),2073 allTemplates(),
2073 queries(),2074 queries(),
2074 network().constants(),2075 network().constants(),
2075 overwriteLens2076 overwriteLens,
2077 true
2076 );2078 );
20772079
2078 try {2080 try {
20792081
=== modified file 'src/dk/aau/cs/io/LoadedModel.java'
--- src/dk/aau/cs/io/LoadedModel.java 2020-08-11 11:11:59 +0000
+++ src/dk/aau/cs/io/LoadedModel.java 2020-08-19 12:14:43 +0000
@@ -15,21 +15,23 @@
15 private final Collection<TAPNQuery> queries;15 private final Collection<TAPNQuery> queries;
16 private final TimedArcPetriNetNetwork network;16 private final TimedArcPetriNetNetwork network;
17 private final Collection<String> messages;17 private final Collection<String> messages;
18 private final TabContent.TAPNLens lens;18 private final boolean isFeatureChanged;
19 private TabContent.TAPNLens lens;
1920
20 public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages){21 public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages){
21 this(network, templates, queries, messages, TabContent.TAPNLens.Default);22 this(network, templates, queries, messages, TabContent.TAPNLens.Default, false);
22 }23 }
23 public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries){24 public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries){
24 this(network, templates, queries, List.of(), TabContent.TAPNLens.Default);25 this(network, templates, queries, List.of(), TabContent.TAPNLens.Default, false);
25 }26 }
2627
27 public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages, TabContent.TAPNLens lens){28 public LoadedModel(TimedArcPetriNetNetwork network, Collection<Template> templates, Collection<TAPNQuery> queries, Collection<String> messages, TabContent.TAPNLens lens, boolean isFeatureChanged){
28 this.templates = templates;29 this.templates = templates;
29 this.network = network;30 this.network = network;
30 this.queries = queries;31 this.queries = queries;
31 this.lens = lens;32 this.lens = lens;
32 this.messages = messages;33 this.messages = messages;
34 this.isFeatureChanged = isFeatureChanged;
33 }35 }
3436
35 public Collection<Template> templates(){ return templates; }37 public Collection<Template> templates(){ return templates; }
@@ -48,4 +50,18 @@
48 return lens.isGame();50 return lens.isGame();
49 }51 }
5052
53 public void setLens(boolean isTimed, boolean isGame) {
54 if (lens == null || !isFeatureChanged) {
55 lens = new TabContent.TAPNLens(isTimed, isGame);
56 }
57 }
58
59 public void addMessage(String message) {
60 messages.add(message);
61 }
62
63 public boolean isFeatureChanged() {
64 return isFeatureChanged;
65 }
66
51}67}
52\ No newline at end of file68\ No newline at end of file
5369
=== modified file 'src/dk/aau/cs/io/ModelLoader.java'
--- src/dk/aau/cs/io/ModelLoader.java 2020-07-14 10:47:03 +0000
+++ src/dk/aau/cs/io/ModelLoader.java 2020-08-19 12:14:43 +0000
@@ -7,7 +7,11 @@
7import java.io.InputStream;7import java.io.InputStream;
88
9import dk.aau.cs.TCTL.Parsing.ParseException;9import dk.aau.cs.TCTL.Parsing.ParseException;
10import dk.aau.cs.debug.Logger;
10import dk.aau.cs.io.batchProcessing.LoadedBatchProcessingModel;11import dk.aau.cs.io.batchProcessing.LoadedBatchProcessingModel;
12import pipe.gui.CreateGui;
13
14import javax.swing.*;
1115
12public class ModelLoader {16public class ModelLoader {
1317
@@ -17,11 +21,13 @@
17 public LoadedModel load(File file) throws Exception{ 21 public LoadedModel load(File file) throws Exception{
18 TapnXmlLoader newFormatLoader = new TapnXmlLoader();22 TapnXmlLoader newFormatLoader = new TapnXmlLoader();
19 try{23 try{
20 return newFormatLoader.load(file);24 LoadedModel model = newFormatLoader.load(file);
25 return checkLens(model);
21 }catch(Throwable e1){26 }catch(Throwable e1){
22 try {27 try {
23 TapnLegacyXmlLoader oldFormatLoader = new TapnLegacyXmlLoader();28 TapnLegacyXmlLoader oldFormatLoader = new TapnLegacyXmlLoader();
24 return oldFormatLoader.load(file);29 LoadedModel model = oldFormatLoader.load(file);
30 return checkLens(model);
25 } catch(Throwable e2) {31 } catch(Throwable e2) {
26 throw new ParseException(e1.getMessage());32 throw new ParseException(e1.getMessage());
27 }33 }
@@ -42,19 +48,36 @@
42 System.out.println(e.getMessage());48 System.out.println(e.getMessage());
43 }49 }
44 try{50 try{
4551 LoadedModel model = newFormatLoader.load(new ByteArrayInputStream(baos.toByteArray()));
46 return newFormatLoader.load(new ByteArrayInputStream(baos.toByteArray()));52 return checkLens(model);
47
48 }catch(Throwable e1){53 }catch(Throwable e1){
49 try {54 try {
50 TapnLegacyXmlLoader oldFormatLoader = new TapnLegacyXmlLoader();55 TapnLegacyXmlLoader oldFormatLoader = new TapnLegacyXmlLoader();
5156
52 return oldFormatLoader.load(new ByteArrayInputStream(baos.toByteArray()));57 LoadedModel model = oldFormatLoader.load(new ByteArrayInputStream(baos.toByteArray()));
5358 return checkLens(model);
54 } catch(Throwable e2) {59 } catch(Throwable e2) {
55 throw new ParseException(e1.getMessage());60 throw new ParseException(e1.getMessage());
56 }61 }
57 }62 }
58 }63 }
64
65 private LoadedModel checkLens(LoadedModel model) {
66 boolean isNetTimed = !model.network().isUntimed();
67 boolean isNetGame = model.network().hasUncontrollableTransitions();
68 String timeMessage = "The net contains time features. The entire net will be changed to include time features.";
69 String gameMessage = "The net contains game features. The entire net will be changed to include game features.";
70
71 if (model.getLens() != null && !model.isFeatureChanged()) {
72 if (!model.isGame() && isNetGame) {
73 model.addMessage(gameMessage);
74 }
75 if (!model.isTimed() && isNetTimed) {
76 model.addMessage(timeMessage);
77 }
78 }
79 model.setLens(isNetTimed, isNetGame);
80 return model;
81 }
59 82
60}83}
6184
=== modified file 'src/dk/aau/cs/io/TapnXmlLoader.java'
--- src/dk/aau/cs/io/TapnXmlLoader.java 2020-08-11 12:18:11 +0000
+++ src/dk/aau/cs/io/TapnXmlLoader.java 2020-08-19 12:14:43 +0000
@@ -71,6 +71,7 @@
71 private final IdResolver idResolver = new IdResolver();71 private final IdResolver idResolver = new IdResolver();
72 private final Collection<String> messages = new ArrayList<>(10);72 private final Collection<String> messages = new ArrayList<>(10);
7373
74 private boolean isFeatureChanged = false;
74 private TabContent.TAPNLens lens;75 private TabContent.TAPNLens lens;
7576
76 public TapnXmlLoader() {77 public TapnXmlLoader() {
@@ -133,7 +134,7 @@
133134
134135
135136
136 return new LoadedModel(network, templates, queries,messages, lens);137 return new LoadedModel(network, templates, queries,messages, lens, isFeatureChanged);
137 }138 }
138139
139 private void parseBound(Document doc, TimedArcPetriNetNetwork network){140 private void parseBound(Document doc, TimedArcPetriNetNetwork network){
@@ -149,6 +150,9 @@
149150
150 var isTimed = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isTimed").getNodeValue());151 var isTimed = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isTimed").getNodeValue());
151 var isGame = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isGame").getNodeValue());152 var isGame = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isGame").getNodeValue());
153 if (nodeList.item(0).getAttributes().getNamedItem("isChanged") != null) {
154 isFeatureChanged = Boolean.parseBoolean(nodeList.item(0).getAttributes().getNamedItem("isChanged").getNodeValue());
155 }
152156
153 lens = new TabContent.TAPNLens(isTimed, isGame);157 lens = new TabContent.TAPNLens(isTimed, isGame);
154 } else {158 } else {
155159
=== modified file 'src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java'
--- src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2020-08-11 13:25:25 +0000
+++ src/dk/aau/cs/io/TimedArcPetriNetNetworkWriter.java 2020-08-19 12:14:43 +0000
@@ -57,6 +57,7 @@
57 private final Iterable<Constant> constants;57 private final Iterable<Constant> constants;
58 private final TimedArcPetriNetNetwork network;58 private final TimedArcPetriNetNetwork network;
59 private final TabContent.TAPNLens lens;59 private final TabContent.TAPNLens lens;
60 private final String isFeatureChanged;
6061
61 public TimedArcPetriNetNetworkWriter(62 public TimedArcPetriNetNetworkWriter(
62 TimedArcPetriNetNetwork network, 63 TimedArcPetriNetNetwork network,
@@ -69,20 +70,23 @@
69 this.queries = queries;70 this.queries = queries;
70 this.constants = constants;71 this.constants = constants;
71 this.lens = TabContent.TAPNLens.Default;72 this.lens = TabContent.TAPNLens.Default;
72 }73 this.isFeatureChanged = "false";
74 }
7375
74 public TimedArcPetriNetNetworkWriter(76 public TimedArcPetriNetNetworkWriter(
75 TimedArcPetriNetNetwork network,77 TimedArcPetriNetNetwork network,
76 Iterable<Template> templates,78 Iterable<Template> templates,
77 Iterable<TAPNQuery> queries,79 Iterable<TAPNQuery> queries,
78 Iterable<Constant> constants,80 Iterable<Constant> constants,
79 TabContent.TAPNLens lens81 TabContent.TAPNLens lens,
82 boolean isFeatureChanged
80 ) {83 ) {
81 this.network = network;84 this.network = network;
82 this.templates = templates;85 this.templates = templates;
83 this.queries = queries;86 this.queries = queries;
84 this.constants = constants;87 this.constants = constants;
85 this.lens = lens;88 this.lens = lens;
89 this.isFeatureChanged = String.valueOf(isFeatureChanged);
86 }90 }
87 91
88 public ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException {92 public ByteArrayOutputStream savePNML() throws IOException, ParserConfigurationException, DOMException, TransformerConfigurationException, TransformerException {
@@ -178,6 +182,7 @@
178182
179 feature.setAttribute("isTimed", isTimed);183 feature.setAttribute("isTimed", isTimed);
180 feature.setAttribute("isGame", isGame);184 feature.setAttribute("isGame", isGame);
185 feature.setAttribute("isChanged", isFeatureChanged);
181186
182 return feature;187 return feature;
183 }188 }

Subscribers

People subscribed via source and target branches