diff --git a/src/main/java/tmltranslator/TMLChannel.java b/src/main/java/tmltranslator/TMLChannel.java index 08af99f2c23c0fe2128b7c3c93802cfe714dd41c..d7efba236154305c838610ce3795a3476ff4b0fe 100755 --- a/src/main/java/tmltranslator/TMLChannel.java +++ b/src/main/java/tmltranslator/TMLChannel.java @@ -627,6 +627,8 @@ public class TMLChannel extends TMLCommunicationElement { TMLChannel channel = (TMLChannel) o; TMLComparingMethod comp = new TMLComparingMethod(); + TraceManager.addDev("Comparing channel ports"); + if (originPort != null) { if (!originPort.equalSpec(channel.getOriginPort())) return false; @@ -636,6 +638,8 @@ public class TMLChannel extends TMLCommunicationElement { if (!destinationPort.equalSpec(channel.getDestinationPort())) return false; } + TraceManager.addDev("Comparing channel tasks"); + if (originTask != null) { if (!originTask.equalSpec(channel.getOriginTask())) return false; @@ -645,18 +649,28 @@ public class TMLChannel extends TMLCommunicationElement { if (!destinationTask.equalSpec(channel.getDestinationTask())) return false; } - return checkConf == channel.checkConf && + TraceManager.addDev("Comparing other attributes"); + + boolean ret = checkConf == channel.checkConf && checkAuth == channel.checkAuth && size == channel.size && type == channel.type && max == channel.max && vc == channel.vc && nbOfSamples == channel.getNumberOfSamples() && - priority == channel.priority && + priority == channel.priority; + + TraceManager.addDev("ret 1 = " + ret); + + ret = ret && comp.isTasksListEquals(originTasks, channel.getOriginTasks()) && comp.isTasksListEquals(destinationTasks, channel.getDestinationTasks()) && comp.isPortListEquals(originPorts, channel.getOriginPorts()) && comp.isPortListEquals(destinationPorts, channel.getDestinationPorts()); + + TraceManager.addDev("ret 2 = " + ret); + + return ret; } @@ -783,6 +797,7 @@ public class TMLChannel extends TMLCommunicationElement { newC.destinationPorts.add(port.deepClone(tmlm)); } + newC.setType(getType()); newC.setNumberOfSamples(getNumberOfSamples()); newC.setSize(getSize()); newC.setMax(getMax()); diff --git a/src/main/java/tmltranslator/TMLEvent.java b/src/main/java/tmltranslator/TMLEvent.java index 74e4afb4a6713363b1dd95daab7273d83a77faf2..4562cb6ff8f059e74b48521fc6557b1575e107d9 100755 --- a/src/main/java/tmltranslator/TMLEvent.java +++ b/src/main/java/tmltranslator/TMLEvent.java @@ -39,6 +39,8 @@ package tmltranslator; +import myutil.TraceManager; +import org.apache.batik.anim.timing.Trace; import translator.CheckingError; import java.util.ArrayList; @@ -362,25 +364,33 @@ public class TMLEvent extends TMLCommunicationElement { TMLComparingMethod comp = new TMLComparingMethod(); + TraceManager.addDev(("Event: testing origin port")); if (originPort != null) { if (!originPort.equalSpec(event.getOriginPort())) return false; } + TraceManager.addDev(("Event: testing destination port")); if (destinationPort != null) { if (!destinationPort.equalSpec(event.getDestinationPort())) return false; } + TraceManager.addDev(("Event: testing origin")); if (origin != null) { if (!origin.equalSpec(event.getOriginTask())) return false; } + TraceManager.addDev(("Event: testing destination")); if (destination != null) { if (!destination.equalSpec(event.getDestinationTask())) return false; } + + TraceManager.addDev(("Event: testing params")); if (!(new HashSet<>(params).equals(new HashSet<>(event.params)))) return false; + + TraceManager.addDev(("Event: testing others")); return maxEvt == event.maxEvt && isBlocking == event.isBlocking && checkAuth == event.checkAuth && diff --git a/src/main/java/tmltranslator/TMLModeling.java b/src/main/java/tmltranslator/TMLModeling.java index 1d441d1f6156fa40fbd24898ff3861f16986096e..7068895361cd03c1c9a4c39f2a51a2237894003e 100755 --- a/src/main/java/tmltranslator/TMLModeling.java +++ b/src/main/java/tmltranslator/TMLModeling.java @@ -3013,17 +3013,23 @@ public class TMLModeling<E> { if (!isRequestListEquals(requests, that.requests)) return false; - TraceManager.addDev("List of request: ok"); + TraceManager.addDev("List of requests: ok. Now testing events"); if (!isEventListEquals(events, that.events)) return false; + TraceManager.addDev("List of events: ok"); + if (!isChannelListEquals(channels, that.channels)) return false; + TraceManager.addDev("List of channels: ok"); + if (!isSecurityPatternListEquals(secPatterns, that.secPatterns)) return false; + TraceManager.addDev("List of Security Patterns: ok"); + return (new HashSet<>(securityPatterns).equals(new HashSet<>(that.securityPatterns))); } @@ -3052,7 +3058,10 @@ public class TMLModeling<E> { for (int i = 0; i < list1.size(); i++) { TraceManager.addDev("Comparing " + list1.get(i).getName() + " with " + list2.get(i).getName()); test = list1.get(i).equalSpec(list2.get(i)); - if (!test) return false; + if (!test) { + TraceManager.addDev("Returning false"); + return false; + } } return true; @@ -3235,6 +3244,51 @@ public class TMLModeling<E> { newTask.setActivity(task.getActivityDiagram().deepClone(tmlm)); } + // Others elements in class + for(TMLTask task: tasks) { + TMLTask newTask = tmlm.getTMLTaskByName(task.getName()); + if (newTask == null) { + throw new TMLCheckingError(CheckingError.STRUCTURE_ERROR, "No new task named " + task.getName() + " in new TMLModeling"); + } + for(TMLChannel ch: task.getChannelSet()) { + TMLChannel newCh = tmlm.getChannelByName(ch.getName()); + if (newCh == null) { + throw new TMLCheckingError(CheckingError.STRUCTURE_ERROR, "No new channel named " + ch.getName() + " in new TMLModeling"); + } + newTask.addTMLChannel(newCh); + } + for(TMLChannel ch: task.getReadTMLChannels()) { + TMLChannel newCh = tmlm.getChannelByName(ch.getName()); + if (newCh == null) { + throw new TMLCheckingError(CheckingError.STRUCTURE_ERROR, "No new channel named " + ch.getName() + " in new TMLModeling"); + } + newTask.addReadTMLChannel(newCh); + } + for(TMLChannel ch: task.getWriteTMLChannels()) { + TMLChannel newCh = tmlm.getChannelByName(ch.getName()); + if (newCh == null) { + throw new TMLCheckingError(CheckingError.STRUCTURE_ERROR, "No new channel named " + ch.getName() + " in new TMLModeling"); + } + newTask.addWriteTMLChannel(newCh); + } + for(TMLEvent evt: task.getTMLEvents()) { + TMLEvent newEvt = tmlm.getEventByName(evt.getName()); + if (newEvt == null) { + throw new TMLCheckingError(CheckingError.STRUCTURE_ERROR, "No new event named " + evt.getName() + " in new TMLModeling"); + } + newTask.addTMLEvent(newEvt); + } + TMLRequest req = task.getRequest(); + if (req != null) { + TMLRequest newReq = tmlm.getRequestByName(req.getName()); + if (newReq == null) { + throw new TMLCheckingError(CheckingError.STRUCTURE_ERROR, "No new request named " + req.getName() + " in new TMLModeling"); + } + newTask.setRequest(newReq); + } + + } + tmlm.optimized = optimized; // Security diff --git a/src/main/java/tmltranslator/TMLRequest.java b/src/main/java/tmltranslator/TMLRequest.java index 6fb95c895633e24aeb4cb16211a6636676893218..d3e2fc3a16bc21088a2f25723d5eb65ec5bf1e3f 100755 --- a/src/main/java/tmltranslator/TMLRequest.java +++ b/src/main/java/tmltranslator/TMLRequest.java @@ -187,7 +187,7 @@ public class TMLRequest extends TMLCommunicationElement { TMLComparingMethod comp = new TMLComparingMethod(); if (destinationTask != null) { - if (!destinationTask.equalSpec(request.getDestinationTask())) return false; + if (destinationTask.getName().compareTo(request.getDestinationTask().getName()) != 0) return false; } if (!(new HashSet<>(params).equals(new HashSet<>(request.params)))) diff --git a/src/main/java/tmltranslator/TMLTask.java b/src/main/java/tmltranslator/TMLTask.java index 7fe5789855b4e53c96f0580ff16f9b1929a89cf3..3085a74233c7a8d2b39a9e0dfa618e0f2086e904 100755 --- a/src/main/java/tmltranslator/TMLTask.java +++ b/src/main/java/tmltranslator/TMLTask.java @@ -539,25 +539,39 @@ public class TMLTask extends TMLElement { } public boolean equalSpec(Object o) { - if (!(o instanceof TMLTask)) return false; - if (!super.equalSpec(o)) return false; + if (!(o instanceof TMLTask)) { + //TraceManager.addDev("Returning false 1"); + return false; + } + if (!super.equalSpec(o)) { + //TraceManager.addDev("Returning false 2"); + return false; + } TMLTask tmlTask = (TMLTask) o; TMLComparingMethod comp = new TMLComparingMethod(); - TraceManager.addDev("Going to compare requests"); + //TraceManager.addDev("Going to compare requests of task " + getName() + " with task " + tmlTask.getName()); if (request != null) { - if (!request.equalSpec(tmlTask.getRequest())) return false; + if (!request.equalSpec(tmlTask.getRequest())) { + //TraceManager.addDev("Returning false 3"); + return false; + } } else { - if (tmlTask.getRequest() != null) return false; + if (tmlTask.getRequest() != null) { + //TraceManager.addDev("Returning false 4"); + return false; + } } + //TraceManager.addDev("Going to compare attributes"); + if (!(new HashSet<>(attributes).equals(new HashSet<>(tmlTask.attributes)))) return false; - TraceManager.addDev("HashSet of attributes ok"); + //TraceManager.addDev("HashSet of attributes ok"); - return operationType == tmlTask.operationType && + boolean ret = operationType == tmlTask.operationType && isDaemon == tmlTask.isDaemon && isPeriodic == tmlTask.isPeriodic && periodValue.compareTo(tmlTask.getPeriodValue()) == 0 && @@ -573,6 +587,10 @@ public class TMLTask extends TMLElement { comp.isTMLChannelSetEquals(readTMLChannelsList, tmlTask.getReadTMLChannelSet()) && comp.isTMLChannelSetEquals(writeTMLChannelsList, tmlTask.getWriteTMLChannelSet()) && comp.isTMLEventSetEquals(eventsList, tmlTask.getEventSet()); + + //TraceManager.addDev("Returning: " + ret); + + return ret; } public void nullifyDelayOperators(boolean execOp, boolean timeOp) { diff --git a/ttool/src/test/java/tmltranslator/TMLDeepCloneTests.java b/ttool/src/test/java/tmltranslator/TMLDeepCloneTests.java index 3a7c50fdd400040aa0e2a133d679649f31fc7d72..8e219264fb11479b83e15ba5bd0e51cc3aa0809a 100644 --- a/ttool/src/test/java/tmltranslator/TMLDeepCloneTests.java +++ b/ttool/src/test/java/tmltranslator/TMLDeepCloneTests.java @@ -76,8 +76,8 @@ public class TMLDeepCloneTests extends AbstractTest { assertTrue(syntax.hasErrors() == 0); // Comparing the two TML Modeling - //boolean equal = cloned.equalSpec(tmlts.getTMLModeling()); - //assertTrue(equal); + boolean equal = cloned.equalSpec(tmlts.getTMLModeling()); + assertTrue(equal); }