diff --git a/plugins/org.polarsys.chess.codegen.ada/META-INF/MANIFEST.MF b/plugins/org.polarsys.chess.codegen.ada/META-INF/MANIFEST.MF index db0e749b60e539adb2a0774610fa63615be0ab9d..f03ffdf7eb68cf420fbf94821fe4fe6426d0894b 100644 --- a/plugins/org.polarsys.chess.codegen.ada/META-INF/MANIFEST.MF +++ b/plugins/org.polarsys.chess.codegen.ada/META-INF/MANIFEST.MF @@ -36,6 +36,8 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Eclipse-LazyStart: true Export-Package: org.polarsys.chess.codegen.ada, + org.polarsys.chess.codegen.ada.handlers, org.polarsys.chess.codegen.ada.main, - org.polarsys.chess.codegen.ada.service + org.polarsys.chess.codegen.ada.transformations, + org.polarsys.chess.codegen.ada.util diff --git a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/handlers/AdaGenUIHandler.java b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/handlers/AdaGenUIHandler.java index 667c82c9ecd885a0bf6faa960b43097207fed522..0dc6779a30672557547f5dcabab6fdb1bd0789bc 100644 --- a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/handlers/AdaGenUIHandler.java +++ b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/handlers/AdaGenUIHandler.java @@ -18,6 +18,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import org.polarsys.chess.codegen.ada.transformations.Transformations; +import org.polarsys.chess.codegen.ada.util.AdaGenUtil; import org.polarsys.chess.core.util.CHESSProjectSupport; import org.polarsys.chess.core.util.uml.ResourceUtils; import org.polarsys.chess.m2m.Activator; @@ -40,15 +41,20 @@ import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.handlers.HandlerUtil; +/** + * The Class AdaGenUIHandler is the handler of the Ada code generation command (org.polarsys.chess.codegen.ada.ada.id) + * registered through the org.eclipse.ui.commands extension point + */ public class AdaGenUIHandler extends AbstractHandler { - - private IProject getActiveProject(IEditorPart editor) { - IFileEditorInput input = (IFileEditorInput) editor.getEditorInput(); - IFile file = input.getFile(); - return file.getProject(); - } - + /** + * implementation of the Ada code generation command as an Eclipse Job. + * Calls the internal implementation, refreshes the active project and prints messages to the CHESS console + * + * @param event the execution event + * @return the object (always null) + * @throws ExecutionException the execution exception + */ public Object execute(final ExecutionEvent event) throws ExecutionException { final IEditorPart editor = HandlerUtil.getActiveEditor(event); @@ -62,7 +68,7 @@ public class AdaGenUIHandler extends AbstractHandler { } catch (Exception e) { throw e; } finally { - getActiveProject(editor).refreshLocal(IResource.DEPTH_INFINITE, monitor); + AdaGenUtil.getActiveProject(editor).refreshLocal(IResource.DEPTH_INFINITE, monitor); } } catch (Exception e) { e.printStackTrace(); @@ -94,10 +100,18 @@ public class AdaGenUIHandler extends AbstractHandler { return null; } - public Object execute_(IEditorPart editor, IProgressMonitor monitor) throws Exception { + /** + * Internal implementation of the Ada code generation command. + * Loads the UML model and calls the code generation + * + * @param editor the active editor + * @param monitor the progress monitor + * @throws Exception if unable to load the UML model + */ + private void execute_(IEditorPart editor, IProgressMonitor monitor) throws Exception { monitor.beginTask("Transforming", 4); if (!(editor instanceof PapyrusMultiDiagramEditor)) - return null; + return; PapyrusMultiDiagramEditor cEditor = (PapyrusMultiDiagramEditor) editor; Resource inResource = null; try { @@ -111,6 +125,6 @@ public class AdaGenUIHandler extends AbstractHandler { Transformations.performCodeGeneration((PapyrusMultiDiagramEditor)editor, inputFile, monitor); //CHESSProjectSupport.fileReplace(newFile, inputFile); - return null; + return; } } diff --git a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/main/GenerateInfrastructure.java b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/main/GenerateInfrastructure.java index 9f890ca4d14df01d52f5ae0f29a84ecbb5535bcd..99f41df974b0702637bb62a9b8ac20f8f78a9520 100644 --- a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/main/GenerateInfrastructure.java +++ b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/main/GenerateInfrastructure.java @@ -310,11 +310,10 @@ public class GenerateInfrastructure extends AbstractAcceleoGenerator { /** * Adds a properties file in the list of properties files. - * - * @param propertiesFile - * The properties file to add. - * @generated + * + * @param propertiesFile The properties file to add. * @since 3.1 + * @generated */ @Override public void addPropertiesFile(String propertiesFile) { diff --git a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/service/UML2Service.java b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/service/UML2Service.java index 8b232481fea6b299f192e273332b60cb594b5c3b..10f8fc7e1dc1c9522a4b07ddda4b6dc8ca14bac2 100644 --- a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/service/UML2Service.java +++ b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/service/UML2Service.java @@ -13,7 +13,7 @@ -- v1.0 which accompanies this distribution, and is available at -- -- http://www.eclipse.org/legal/epl-v10.html -- ----------------------------------------------------------------------- -*/ + */ /** * 2015/04/03 NP: fixed problem regarding ordering of slots in instances of connectors @@ -63,854 +63,1104 @@ import org.polarsys.chess.chessmlprofile.Dependability.MitigationMeans.Transmiss import org.polarsys.chess.chessmlprofile.Predictability.RTComponentModel.CHRtPortSlot; import org.polarsys.chess.chessmlprofile.Predictability.RTComponentModel.CHRtSpecification; -public class UML2Service { +// TODO: Auto-generated Javadoc +/** + * The Class UML2Service contains utility methods that are meant to be called from the Acceleo Transformation + */ +public class UML2Service { + + /** The Constant DOCSTEREO. */ + private static final String DOCSTEREO = "Papyrus::Documentation::Documentation"; + // private static final String REQUIREMENT_EXTENSION = "requirement"; + // private static final Object LINK = "#Link_to"; + + /** + * Gets the provided interface from a Port (must be stereotyped as ClientServerPort) + * + * @param port the port + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return the provided interface + */ + public Interface getProvidedInterface(Port port, String stName) { + Stereotype clSvPortSt = port.getAppliedStereotype(stName); + ClientServerPort clSvPort = (ClientServerPort) port.getStereotypeApplication(clSvPortSt); + // Assumption : 1 PI per Port + return clSvPort.getProvInterface().get(0); + } + + /** + * Gets the required interface from a Port (must be stereotyped as ClientServerPort) + * + * @param port the port + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return the required interface + */ + public Interface getRequiredInterface(Port port, String stName) { + Stereotype clSvPortSt = port.getAppliedStereotype(stName); + ClientServerPort clSvPort = (ClientServerPort) port.getStereotypeApplication(clSvPortSt); + // Assumption : 1 RI per Port + return clSvPort.getReqInterface().get(0); + } + + /** + * Checks if a specific port is a ClientServerPort which can provide interfaces. + * + * @param pt the port + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return true if the port is a ClientServerPort of kind PROVIDED, false otherwise + */ + public Boolean isProvidedPort(Port pt, String stName) { + Stereotype st = pt.getAppliedStereotype(stName); + ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); + if (csp != null) + return csp.getKind().equals(ClientServerKind.PROVIDED); + else + return false; + + } + + /** + * Checks if a specific port is a ClientServerPort which can require interfaces. + * + * @param pt the port + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return true if the port is a ClientServerPort of kind REQUIRED, false otherwise + */ + public Boolean isRequiredPort(Port pt, String stName) { + Stereotype st = pt.getAppliedStereotype(stName); + ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); + if (csp != null) + return csp.getKind().equals(ClientServerKind.REQUIRED); + else + return false; + } + + /** + * Gets the list of the provided interfaces from a list of ClientServerPorts. + * + * @param portList the list of ports. + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return a list containing the provided interfaces. + */ + public List<Interface> getProvidedInterfaceList(List<Port> portList, String stName) { + + ArrayList<Interface> intList = new ArrayList<Interface>(); + Port pt = null; + Stereotype st = null; + ClientServerPort csp = null; + + for (int i=0; i <portList.size(); i++) { + pt = portList.get(i); + st = pt.getAppliedStereotype(stName); + csp = (ClientServerPort) pt.getStereotypeApplication(st); + + if (csp!= null && csp.getKind().equals(ClientServerKind.PROVIDED)) { + // Assumption: only 1 providedInterface x Port + intList.add(csp.getProvInterface().get(0)); + } + } + + return intList; + } + + /** + * Returns a String representing the names of the provided interfaces from a list of ClientServerPorts. + * + * @param portList the list of ports. + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return the String representing the names of the provided interfaces + */ + public String getProvidedInterfaceListAsQualifiedString(List<Port> portList, String stName) { + + Port pt = null; + Stereotype st = null; + ClientServerPort csp = null; + String piNameList = new String(); + String interfaceName = null; + boolean firstWritten = false; + + for (int i=0; i <portList.size(); i++) { + pt = portList.get(i); + st = pt.getAppliedStereotype(stName); + csp = (ClientServerPort) pt.getStereotypeApplication(st); + + if (csp != null && csp.getKind().equals(ClientServerKind.PROVIDED)) { + // Assumption: only 1 providedInterface x Port + interfaceName = csp.getProvInterface().get(0).getName(); + if (! firstWritten) { + piNameList += interfaceName + "." + interfaceName; + firstWritten = true; + } else { + piNameList += " and " + interfaceName + "." + interfaceName; + } + } + } + + return piNameList; + } + + /** + * Checks if among the elements of a List of ClientServerPort, at least one can require ports. + * + * @param portList the list of ports. + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return true if a ClientServerPort of kind REQUIRED is found in the list, false otherwise. + */ + public Boolean hasRequiredInterface(List<Port> portList, String stName) { + Port pt = null; + Stereotype st = null; + ClientServerPort csp = null; + + for (int i=0; i <portList.size(); i++) { + pt = portList.get(i); + st = pt.getAppliedStereotype(stName); + csp = (ClientServerPort) pt.getStereotypeApplication(st); + + if (csp!= null && csp.getKind().equals(ClientServerKind.REQUIRED)) { + return true; + } + } + + return false; + } + + + /** + * Gets the list of the required interfaces from a list of ClientServerPorts. + * + * @param portList the list of ports. + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return a list containing the required interfaces. + */ + public List<Interface> getRequiredInterfaceList(List<Port> portList, String stName) { + + ArrayList<Interface> intList = new ArrayList<Interface>(); + Port pt = null; + Stereotype st = null; + ClientServerPort csp = null; + + for (int i=0; i <portList.size(); i++) { + pt = portList.get(i); + st = pt.getAppliedStereotype(stName); + csp = (ClientServerPort) pt.getStereotypeApplication(st); + + if (csp != null && csp.getKind().equals(ClientServerKind.REQUIRED)) { + // Assumption: only 1 requiredInterface x Port + intList.add(csp.getReqInterface().get(0)); + } + } + + return intList; + } + + /** + * Gets a String representing the operation signature. + * + * @param c the component containing the operation + * @param op the operation + * @return the operation signature as a String + */ + public String getOperationSignature(Component c, Operation op) { + String opName = new String(c.getName() + "." + op.getName()); + //MODIFIED MP WAS ELIST + List<Parameter> lParam = op.getOwnedParameters(); + if (lParam.size() > 0) { + opName += "("; + opName += lParam.get(0).getType().getName(); + + if (lParam.size() > 1) { + + for (int i=1; i < lParam.size(); i++) { + opName += ", " + lParam.get(i).getType().getName(); + } + } + opName += ")"; + } + return opName; + } + + /** + * This is a method very specific to the Acceleo transformation (Ada code generation) + * + * @param slotList the slot list + * @param stName the st name + * @param st2Name the st2 name + * @return the package to with spec + */ + public List<String> getPackageToWithSpec(List<Object> slotList, String stName, String st2Name) { + + boolean cyclicRequired = false; + boolean sporadicRequired = false; + + boolean pkgSystemAdded = false; + boolean pkgRealTimeAdded = false; + boolean pkgDataStructureAdded = false; + boolean pkgContainerProtectionAdded = false; + boolean pkgCyclicTaskAdded = false; + + Slot slot = null; + CHRtPortSlot chrtPs = null; + CHRtSpecification chrtSpec = null; + List<CHRtSpecification> chRtSpecList = null; + ArrayList<String> withPackageList = new ArrayList<String>(); + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + chRtSpecList = chrtPs.getCH_RtSpecification(); + + for (int j=0; j < chRtSpecList.size(); j++) { + chrtSpec = chRtSpecList.get(j); + String occKind = chrtSpec.getOccKind(); + + if (occKind != null && ! occKind.equals("")) { + + if (occKind.startsWith("periodic") && ! cyclicRequired) { + + if (! pkgRealTimeAdded) { + withPackageList.add("with Ada.Real_Time; use Ada.Real_Time;"); + pkgRealTimeAdded = true; + } + + if (! pkgDataStructureAdded) { + withPackageList.add("with Data_Structure;"); + pkgDataStructureAdded = true; + } + + if (! pkgContainerProtectionAdded) { + withPackageList.add("with Container_Protection; use Container_Protection;"); + pkgContainerProtectionAdded = true; + } + + if (! pkgCyclicTaskAdded) { + withPackageList.add("with Cyclic_Task;"); + pkgCyclicTaskAdded = true; + } + + cyclicRequired = true; + } else if (occKind.startsWith("sporadic") && ! sporadicRequired) { + + if (! pkgSystemAdded) { + withPackageList.add("with System;"); + pkgSystemAdded = true; + } + + if (! pkgRealTimeAdded) { + withPackageList.add("with Ada.Real_Time; use Ada.Real_Time;"); + pkgRealTimeAdded = true; + } + + if (! pkgDataStructureAdded) { + withPackageList.add("with Data_Structure;"); + pkgDataStructureAdded = true; + } + + sporadicRequired = true; + } + + } else if (chrtSpec.getProtection().equals(CallConcurrencyKind.GUARDED)) {// occKind is null or "" + + if (! pkgSystemAdded) { + withPackageList.add("with System;"); + pkgSystemAdded = true; + } + + } + } + + if (cyclicRequired && sporadicRequired) { + break; + } + } + } + return withPackageList; + } + + /** + * Gets the "value" substring of a given VSL string. + * For example, from the VSL String (value=45.0,unit=ms) this method returns 45.0 + * + * @param inputVSL the input VSL string + * @return the "value" substring + */ + public String getValue(String inputVSL) { + int endOfValueIndex = inputVSL.indexOf(",unit"); + int startOfValueIndex = inputVSL.indexOf("value=") + 6; + return inputVSL.substring(startOfValueIndex, endOfValueIndex); + } + + /** + * Gets the "unit" substring of a given VSL string. + * For example, from the VSL String (value=45.0,unit=ms) this method returns ms + * + * @param inputVSL the input VSL string + * @return the "unit" substring + */ + public String getUnit(String inputVSL) { + int startOfUnitIndex = inputVSL.indexOf("unit=") + 5; + int endOfUnitIndex = inputVSL.indexOf("))"); + return inputVSL.substring(startOfUnitIndex, endOfUnitIndex); + } + + /** + * Gets the Priority of an operation. + * Pre-condition : op is an operation marked as "cyclic" in some CHRtSpecification + * + * @param slotList the list of Slots in the model + * @param op the Operation + * @param stName unused + * @return the priority as String, or a message error + */ + public String getPriority(List<Object> slotList, Operation op, String stName) { + Slot slot = null; + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + CHRtPortSlot chrtPs = null; + + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + if (CHRtSpecList.get(j).getContext().equals(op)) { + return CHRtSpecList.get(j).getRelativePriority(); + } + } + } + + } + // + return "ERROR_PRIORITY_NOT_FOUND"; + } + + /** + * Gets the Period or minimum interarrival time (MIAT) of an operation. + * Pre-condition : op is an operation marked as "cyclic" or "sporadic" in some CHRtSpecification + * + * @param slotList the list of Slots in the model + * @param op the Operation + * @param stName unused + * @return the period (for a "cyclic" operation) or the MIAT (for a "sporadic" operation) + */ + public String getPeriodOrMIAT(List<Object> slotList, Operation op, String stName) { + Slot slot = null; + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + CHRtPortSlot chrtPs = null; + + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + if (CHRtSpecList.get(j).getContext().equals(op)) { + + String occKind = chrtPs.getCH_RtSpecification().get(0).getOccKind(); + String periodOrMIAT = getValue(occKind); + if (periodOrMIAT.length() <= 5) { + return periodOrMIAT.substring(0, periodOrMIAT.length()-2); + } else { + return periodOrMIAT.substring(0, periodOrMIAT.length()-5).concat("_"). + concat(periodOrMIAT.substring(periodOrMIAT.length()-5, periodOrMIAT.length()-2)); + } + } + } + } + } + return "ERROR_PERIOD_OR_MIAT_NOT_FOUND"; + } + + /** + * Gets the Ceiling of an operation. + * Pre-condition : op is an operation marked as "cyclic", "sporadic" or "protected" in some CHRtSpecification + * + * @param slotList the list of Slots in the model + * @param op the Operation + * @param stName unused + * @return the Ceiling as String, or a message error + */ + public String getCeiling(List<Object> slotList, Operation op, String stName) { + Slot slot = null; + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + CHRtPortSlot chrtPs = null; + + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + if (CHRtSpecList.get(j).getContext().equals(op)) { + + return chrtPs.getCH_RtSpecification().get(j).getCeiling(); + } + } + } + } + return "ERROR_CEILING_NOT_FOUND"; + } + + /** + * Gets a list of cyclic operations from a list of slots. + * + * @param slotList the list of Slots in the model + * @param stName unused + * @return a list containing the cyclic operations + */ + public List<Operation> getCyclicOperationList(List<Slot> slotList, String stName) { + + ArrayList<Operation> cyclicOpList = new ArrayList<Operation>(); + CHRtPortSlot chrtPs = null; + Slot slot = null; + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); + + if (occKind != null) { + if (occKind.startsWith("periodic")) { + cyclicOpList.add((Operation) CHRtSpecList.get(j).getContext()); + } + } + } + } + } + return cyclicOpList; + } + + /** + * Gets a list of sporadic operations from a list of slots. + * + * @param slotList the list of Slots in the model + * @param stName unused + * @return a list containing the sporadic operations + */ + public List<Operation> getSporadicOperationList(List<Slot> slotList, String stName) { + + ArrayList<Operation> sporadicOpList = new ArrayList<Operation>(); + CHRtPortSlot chrtPs = null; + Slot slot = null; + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); + + if (occKind != null) { + if (occKind.startsWith("sporadic")) { + sporadicOpList.add((Operation) CHRtSpecList.get(j).getContext()); + } + } + } + } + } + return sporadicOpList; + } + + /** + * Gets a list of protected operations from a list of slots. + * + * @param slotList the list of Slots in the model + * @param stName unused + * @return a list containing the protected operations + */ + public List<Operation> getProtectedOperationList(List<Slot> slotList, String stName) { + + ArrayList<Operation> protectedOpList = new ArrayList<Operation>(); + CHRtPortSlot chrtPs = null; + Slot slot = null; + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); + + // Sporadic kind is GUARDED and occKind => sporadic(...) + if (CHRtSpecList.get(j).getProtection().equals(CallConcurrencyKind.GUARDED) && + (occKind == null || occKind.isEmpty())) { + protectedOpList.add((Operation) CHRtSpecList.get(j).getContext()); + } + } + } + } + return protectedOpList; + } + + + /** + * Gets the Protected Operation from the given Slot + * + * @param sl the Slot + * @param stName unused + * @return the Protected Operation + */ + public List<Operation> getSlotProtectedOperation(Slot sl, String stName) { + + ArrayList<Operation> protectedOpList = new ArrayList<Operation>(); + CHRtPortSlot chrtPs = null; + + List<Stereotype> stList = sl.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) sl.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); + + // Sporadic kind is GUARDED and occKind => sporadic(...) + if (CHRtSpecList.get(j).getProtection().equals(CallConcurrencyKind.GUARDED) && + (occKind == null || occKind.isEmpty())) { + protectedOpList.add((Operation) CHRtSpecList.get(j).getContext()); + } + } + } + return protectedOpList; + } + + + /** + * Gets a list of unprotected operations from a list of slots. + * + * @param slotList the list of Slots in the model + * @param stName unused + * @return a list containing the unprotected operations + */ + public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String stName) { + + ArrayList<Operation> unprotectedOpList = new ArrayList<Operation>(); + CHRtPortSlot chrtPs = null; + Slot slot = null; + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); + if (CHRtSpecList.get(j).getProtection().equals(CallConcurrencyKind.CONCURRENT) && + (occKind == null || occKind.isEmpty())) { + unprotectedOpList.add((Operation) CHRtSpecList.get(j).getContext()); + } + } + } + } + return unprotectedOpList; + } + + /** + * Gets the list of component instances from the list of the instances with multiplicity. (i.e package "_full" in the model) + * + * @param instList the list of the instances with multiplicity + * @param stName the name of the stereotype. Must be "CHESS::ComponentModel::ComponentImplementation" + * @return the list of the component instances + */ + public List<InstanceSpecification> getComponentInstanceList(List<InstanceSpecification> instList, String stName) { + ArrayList<InstanceSpecification> componentInstanceList = new ArrayList<InstanceSpecification>(); + + for (int i=0; i<instList.size(); i++) { + List<Classifier> clList = instList.get(i).getClassifiers(); + + if (clList.size() > 0) { + Stereotype st = clList.get(0).getAppliedStereotype(stName); + + if (st != null && !instList.get(i).getNearestPackage().getName().endsWith("_full")) { + componentInstanceList.add(instList.get(i)); + } + } + } + + return componentInstanceList; + } + + /** + * Gets the list of slots that require an interface from a list of instances + * + * @param instList the list of instances + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return the list of slots that require an interface + */ + public List<Slot> getRequiredInterfaceSlotList(List<InstanceSpecification> instList, String stName) { + ArrayList<Slot> reqInterfaceSlotList = new ArrayList<Slot>(); + + for (int i=0; i<instList.size(); i++) { + List<Slot> slList = instList.get(i).getSlots(); + for (int j=0; j<slList.size(); j++) { + + if (slList.get(j).getDefiningFeature() instanceof Port) { + Port pt = (Port) slList.get(j).getDefiningFeature(); + Stereotype st = pt.getAppliedStereotype(stName); + if (st != null) { + ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); + if (csp.getKind() == ClientServerKind.REQUIRED) { + reqInterfaceSlotList.add(slList.get(j)); + } + } + } + } + } + + // the list of all RI + return reqInterfaceSlotList; + } + + + /** + * Gets the list of slots that require an interface from a single instance + * + * @param instList the InstanceSpecfication + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return the list of slots that require an interface + */ + public List<Slot> getInstanceRequiredInterfaceSlotList(InstanceSpecification inst, String stName) { + ArrayList<Slot> reqInterfaceSlotList = new ArrayList<Slot>(); + + + List<Slot> slList = inst.getSlots(); + for (int j=0; j<slList.size(); j++) { + + if (slList.get(j).getDefiningFeature() instanceof Port) { + Port pt = (Port) slList.get(j).getDefiningFeature(); + Stereotype st = pt.getAppliedStereotype(stName); + if (st != null) { + ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); + if (csp.getKind() == ClientServerKind.REQUIRED) { + reqInterfaceSlotList.add(slList.get(j)); + } + } + } + } + + // the list of all RI slots of the instance specification + return reqInterfaceSlotList; + } + + /** + * Gets the list of slots that provide an interface from a list of instances + * + * @param instList the list of instances + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return the list of slots that provide an interface + */ + public List<Slot> getProvidedInterfaceSlotList(List<InstanceSpecification> instList, String stName) { + ArrayList<Slot> provInterfaceSlotList = new ArrayList<Slot>(); + + for (int i=0; i<instList.size(); i++) { + List<Slot> slList = instList.get(i).getSlots(); + for (int j=0; j<slList.size(); j++) { + + if (slList.get(j).getDefiningFeature() instanceof Port) { + Port pt = (Port) slList.get(j).getDefiningFeature(); + Stereotype st = pt.getAppliedStereotype(stName); + if (st != null) { + ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); + if (csp.getKind() == ClientServerKind.PROVIDED) { + provInterfaceSlotList.add(slList.get(j)); + } + } + } + } + } + + // the list of all RI + return provInterfaceSlotList; + } + + + /** + * Gets the list of slots that provide an interface from a single instance + * + * @param instList the InstanceSpecfication + * @param stName the stereotype name. Must be "MARTE::MARTE_DesignModel::GCM::ClientServerPort" + * @return the list of slots that provide an interface + */ + public List<Slot> getInstanceProvidedInterfaceSlotList(InstanceSpecification inst, String stName) { + ArrayList<Slot> provInterfaceSlotList = new ArrayList<Slot>(); + + + List<Slot> slList = inst.getSlots(); + for (int j=0; j<slList.size(); j++) { + + if (slList.get(j).getDefiningFeature() instanceof Port) { + Port pt = (Port) slList.get(j).getDefiningFeature(); + Stereotype st = pt.getAppliedStereotype(stName); + if (st != null) { + ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); + if (csp.getKind() == ClientServerKind.PROVIDED) { + provInterfaceSlotList.add(slList.get(j)); + } + } + } + } + + // the list of all RI slots of the instance specification + return provInterfaceSlotList; + } + + + + /** + * Gets the connector inst list. + * + * @param instList the inst list + * @param stName the st name + * @return the connector inst list + */ + public List<InstanceSpecification> getConnectorInstList(List<InstanceSpecification> instList, String stName) { + ArrayList<InstanceSpecification> connectorInstList = new ArrayList<InstanceSpecification>(); + + for (int i=0; i<instList.size(); i++) { + if (instList.get(i).getClassifiers().size()==0) { + List<Slot> slList = instList.get(i).getSlots(); + if (slList.size() > 0) { + Port pt = (Port) slList.get(0).getDefiningFeature(); + Stereotype st = pt.getAppliedStereotype(stName); + // check if the defining feature is a <<ClientServerPort>> + if (st != null) { + connectorInstList.add(instList.get(i)); + } + } + } + } + return connectorInstList; + } + + + + /** + * Gets the component impl list. + * + * @param compList the comp list + * @param stName the st name + * @return the component impl list + */ + public List<Component> getComponentImplList(List<Component> compList, String stName) { + ArrayList<Component> compImplList = new ArrayList<Component>(); + + for (int i=0; i<compList.size(); i++) { + Stereotype st = compList.get(i).getAppliedStereotype(stName); + // check if it is a <<ComponentImplementation>> + if (st != null) { + compImplList.add(compList.get(i)); + } + } + return compImplList; + } + + /** + * Gets the provided slot bounded to the given slot + * + * @param sl the given slot + * @param connectorInstList the list of connector instances + * @return the bounded provided slot + */ + public Slot getBoundPIslot(Slot sl, List<InstanceSpecification> connectorInstList) { + + // All methods based on equality between slot fail (indexOf, contains, etc..) + // Check that definingFeature and owningInstance of the slot are matching + + for (int i=0; i<connectorInstList.size(); i++) { + List<Slot> slotList = connectorInstList.get(i).getSlots(); + List<Slot> targetInstanceSlotList = null; + Slot targetSlot = null; + + // 2 slots are included in the instance of the connecto. + Slot slot0 = slotList.get(0); + Slot slot1 = slotList.get(1); + + if (slot0.getDefiningFeature().equals(sl.getDefiningFeature())) { + List<ValueSpecification> vsList = slot0.getValues(); + InstanceValue iv = (InstanceValue) vsList.get(0); + if (sl.getOwningInstance().equals(iv.getInstance())) { + //slot1 is the slot in the instance of the connector + //we must return the slot in the instance of the component instance! + vsList = slot1.getValues(); + iv = (InstanceValue) vsList.get(0); + InstanceSpecification targetIs = iv.getInstance(); + targetInstanceSlotList = targetIs.getSlots(); + for (int j = 0; j < targetInstanceSlotList.size(); j++) { + targetSlot = targetInstanceSlotList.get(j); + if (targetSlot.getDefiningFeature().equals(slot1.getDefiningFeature())) { + return targetSlot; + } + } + + } + } else if (slot1.getDefiningFeature().equals(sl.getDefiningFeature())) { + List<ValueSpecification> vsList = slot1.getValues(); + InstanceValue iv = (InstanceValue) vsList.get(0); + if (sl.getOwningInstance().equals(iv.getInstance())) { + //slot0 is the slot in the instance of the connector + //we must return the slot in the instance of the component instance! + vsList = slot0.getValues(); + iv = (InstanceValue) vsList.get(0); + InstanceSpecification targetIs = iv.getInstance(); + targetInstanceSlotList = targetIs.getSlots(); + for (int j = 0; j < targetInstanceSlotList.size(); j++) { + targetSlot = targetInstanceSlotList.get(j); + if (targetSlot.getDefiningFeature().equals(slot0.getDefiningFeature())) { + return targetSlot; + } + } + + } + } + } + return sl; + } + + /** + * Gets the required slots bounded to the given slot + * + * @param sl the given slot + * @param connectorInstList the list of connector instances + * @return the bounded required slots list + */ + public List<Slot> getBoundRIslotList(Slot sl, List<InstanceSpecification> connectorInstList) { + List<Slot> boundRIslotList = new ArrayList<Slot>(); + + // Check that definingFeature and owningInstance of the slot are matching + + for (int i=0; i<connectorInstList.size(); i++) { + List<Slot> slotList = connectorInstList.get(i).getSlots(); + List<Slot> targetInstanceSlotList = null; + Slot targetSlot = null; + + // 2 slots are included in the instance of the connector. + Slot slot0 = slotList.get(0); + Slot slot1 = slotList.get(1); + + if (slot0.getDefiningFeature().equals(sl.getDefiningFeature())) { + List<ValueSpecification> vsList = slot0.getValues(); + InstanceValue iv = (InstanceValue) vsList.get(0); + if (sl.getOwningInstance().equals(iv.getInstance())) { + //slot1 is the slot in the instance of the connector + //we must return the corresponding slot in the instance of the component instance! + vsList = slot1.getValues(); + iv = (InstanceValue) vsList.get(0); + InstanceSpecification targetIs = iv.getInstance(); + targetInstanceSlotList = targetIs.getSlots(); + for (int j = 0; j < targetInstanceSlotList.size(); j++) { + targetSlot = targetInstanceSlotList.get(j); + if (targetSlot.getDefiningFeature().equals(slot1.getDefiningFeature())) { + boundRIslotList.add(targetSlot); + } + } + + } + } else if (slot1.getDefiningFeature().equals(sl.getDefiningFeature())) { + List<ValueSpecification> vsList = slot1.getValues(); + InstanceValue iv = (InstanceValue) vsList.get(0); + if (sl.getOwningInstance().equals(iv.getInstance())) { + //slot0 is the slot in the instance of the connector + //we must return the corresponding slot in the instance of the component instance! + vsList = slot0.getValues(); + iv = (InstanceValue) vsList.get(0); + InstanceSpecification targetIs = iv.getInstance(); + targetInstanceSlotList = targetIs.getSlots(); + for (int j = 0; j < targetInstanceSlotList.size(); j++) { + targetSlot = targetInstanceSlotList.get(j); + if (targetSlot.getDefiningFeature().equals(slot0.getDefiningFeature())) { + boundRIslotList.add(targetSlot); + } + } + + } + } + } + return boundRIslotList; + } + + /** + * Checks if the given operation is cyclic + * + * @param slotList the list of slots in the model + * @param op the operation + * @param stName unused + * @return true, if the operation cyclic + */ + public boolean isCyclicOperation(List<Slot> slotList, Operation op, String stName) { + + CHRtPortSlot chrtPs = null; + Slot slot = null; + + for (int i=0; i < slotList.size(); i++) { + slot = (Slot) slotList.get(i); + List<Stereotype> stList = slot.getAppliedStereotypes(); + if (! stList.isEmpty()) { + chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); + List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); + for (int j=0; j < CHRtSpecList.size(); j++) { + Operation myOp = (Operation) CHRtSpecList.get(j).getContext(); + + if (myOp.equals(op)) { + String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); + + if (occKind != null) { + if (occKind.startsWith("periodic")) { + return true; + } + } + } + } + } + } + return false; + } + - private static final String DOCSTEREO = "Papyrus::Documentation::Documentation"; -// private static final String REQUIREMENT_EXTENSION = "requirement"; -// private static final Object LINK = "#Link_to"; + /** + * Gets the list of operations called by the given operation. + * + * @param op the given operation + * @return the list of called operations + */ + public List<CallOperationAction> getCalledOperation(Operation op) { + ArrayList<CallOperationAction> coaList = new ArrayList<CallOperationAction>(); + List<Behavior> bhList = op.getMethods(); - public Interface getProvidedInterface(Port port, String stName) { - Stereotype clSvPortSt = port.getAppliedStereotype(stName); - ClientServerPort clSvPort = (ClientServerPort) port.getStereotypeApplication(clSvPortSt); - // Assumption : 1 PI per Port - return clSvPort.getProvInterface().get(0); + if (bhList.size() > 0) { + for (int i=0; i < bhList.size(); i++) { + if (bhList.get(i) instanceof Activity) { + + List<ActivityNode> actNodeList = ((Activity) bhList.get(i)).getNodes(); + for (int j=0; j < actNodeList.size(); j++) { + if (actNodeList.get(j) instanceof CallOperationAction) { + coaList.add((CallOperationAction) actNodeList.get(j)); + } + } + } + } + } + return coaList; } - - public Interface getRequiredInterface(Port port, String stName) { - Stereotype clSvPortSt = port.getAppliedStereotype(stName); - ClientServerPort clSvPort = (ClientServerPort) port.getStereotypeApplication(clSvPortSt); - // Assumption : 1 RI per Port - return clSvPort.getReqInterface().get(0); + /** + * Checks if two operation are equal to each other according to the following criteria: + * name, visibility, size of parameter list + * type of parameters, name of parameters + * isAbstract is purposely not considered + * + * @param op1 the first operation + * @param op2 the second operation + * @return true, two operation are equal to each other + */ + public boolean isSameOperation(Operation op1, Operation op2) { + if (! op1.getName().equals(op2.getName())) { + return false; + } + + if (! op1.getVisibility().equals(op2.getVisibility())) { + return false; + } + + + List<Parameter> paramList1 = op1.getOwnedParameters(); + List<Parameter> paramList2 = op2.getOwnedParameters(); + + if (paramList1.size() != paramList2.size()) { + return false; + } + + for (int i = 0; i < paramList1.size(); i++) { + Parameter par1 = paramList1.get(i); + Parameter par2 = paramList2.get(i); + + //par1.getType().equals(par2.getType()) unexpectedly fails + //replacing it with a very reliable check on names + if (! par1.getType().getName().equals(par2.getType().getName())) { + return false; + } + + if (! par1.getName().equals(par2.getName())) { + return false; + } + + if (! par1.getDirection().equals(par2.getDirection())) { + return false; + } + } + return true; + } + + + /** + * Gets the interface containing the given operation searching in the list of provided interfaces + * + * @param op the given operation + * @param ptList the list of ports. Used to get the list of provided interfaces + * @param stName the stereotype name + * @return the interface containing the given operation + */ + public Interface getInterface(Operation op, List<Port> ptList, String stName) { + + List<Interface> interfaceList = getProvidedInterfaceList(ptList, stName); + + for (int i=0; i < interfaceList.size(); i++) { + Interface myIf = interfaceList.get(i); + List<Operation> opList = myIf.getOperations(); + + for (int j=0; j < opList.size(); j++) { + if ( isSameOperation(op, opList.get(j))) { + return myIf; + } + } + } + + return null; } - public Boolean isProvidedPort(Port pt, String stName) { - Stereotype st = pt.getAppliedStereotype(stName); - ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); - if (csp != null) - return csp.getKind().equals(ClientServerKind.PROVIDED); - else - return false; - - } - - public Boolean isRequiredPort(Port pt, String stName) { - Stereotype st = pt.getAppliedStereotype(stName); - ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); - if (csp != null) - return csp.getKind().equals(ClientServerKind.REQUIRED); - else - return false; - } - - public List<Interface> getProvidedInterfaceList(List<Port> portList, String stName) { - - ArrayList<Interface> intList = new ArrayList<Interface>(); - Port pt = null; - Stereotype st = null; - ClientServerPort csp = null; - - for (int i=0; i <portList.size(); i++) { - pt = portList.get(i); - st = pt.getAppliedStereotype(stName); - csp = (ClientServerPort) pt.getStereotypeApplication(st); - - if (csp!= null && csp.getKind().equals(ClientServerKind.PROVIDED)) { - // Assumption: only 1 providedInterface x Port - intList.add(csp.getProvInterface().get(0)); - } - } - - return intList; - } - - public String getProvidedInterfaceListAsQualifiedString(List<Port> portList, String stName) { - - Port pt = null; - Stereotype st = null; - ClientServerPort csp = null; - String piNameList = new String(); - String interfaceName = null; - boolean firstWritten = false; - - for (int i=0; i <portList.size(); i++) { - pt = portList.get(i); - st = pt.getAppliedStereotype(stName); - csp = (ClientServerPort) pt.getStereotypeApplication(st); - - if (csp != null && csp.getKind().equals(ClientServerKind.PROVIDED)) { - // Assumption: only 1 providedInterface x Port - interfaceName = csp.getProvInterface().get(0).getName(); - if (! firstWritten) { - piNameList += interfaceName + "." + interfaceName; - firstWritten = true; - } else { - piNameList += " and " + interfaceName + "." + interfaceName; - } - } - } - - return piNameList; - } - - public Boolean hasRequiredInterface(List<Port> portList, String stName) { - Port pt = null; - Stereotype st = null; - ClientServerPort csp = null; - - for (int i=0; i <portList.size(); i++) { - pt = portList.get(i); - st = pt.getAppliedStereotype(stName); - csp = (ClientServerPort) pt.getStereotypeApplication(st); - - if (csp!= null && csp.getKind().equals(ClientServerKind.REQUIRED)) { - return true; - } - } - - return false; - } - - - public List<Interface> getRequiredInterfaceList(List<Port> portList, String stName) { - - ArrayList<Interface> intList = new ArrayList<Interface>(); - Port pt = null; - Stereotype st = null; - ClientServerPort csp = null; - - for (int i=0; i <portList.size(); i++) { - pt = portList.get(i); - st = pt.getAppliedStereotype(stName); - csp = (ClientServerPort) pt.getStereotypeApplication(st); - - if (csp != null && csp.getKind().equals(ClientServerKind.REQUIRED)) { - // Assumption: only 1 requiredInterface x Port - intList.add(csp.getReqInterface().get(0)); - } - } - - return intList; - } - - public String getOperationSignature(Component c, Operation op) { - String opName = new String(c.getName() + "." + op.getName()); - //MODIFIED MP WAS ELIST - List<Parameter> lParam = op.getOwnedParameters(); - if (lParam.size() > 0) { - opName += "("; - opName += lParam.get(0).getType().getName(); - - if (lParam.size() > 1) { - - for (int i=1; i < lParam.size(); i++) { - opName += ", " + lParam.get(i).getType().getName(); - } - } - opName += ")"; - } - return opName; - } - - public List<String> getPackageToWithSpec(List<Object> slotList, String stName, String st2Name) { - - boolean cyclicRequired = false; - boolean sporadicRequired = false; - - boolean pkgSystemAdded = false; - boolean pkgRealTimeAdded = false; - boolean pkgDataStructureAdded = false; - boolean pkgContainerProtectionAdded = false; - boolean pkgCyclicTaskAdded = false; - - Slot slot = null; - CHRtPortSlot chrtPs = null; - CHRtSpecification chrtSpec = null; - List<CHRtSpecification> chRtSpecList = null; - ArrayList<String> withPackageList = new ArrayList<String>(); - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - chRtSpecList = chrtPs.getCH_RtSpecification(); - - for (int j=0; j < chRtSpecList.size(); j++) { - chrtSpec = chRtSpecList.get(j); - String occKind = chrtSpec.getOccKind(); - - if (occKind != null && ! occKind.equals("")) { - - if (occKind.startsWith("periodic") && ! cyclicRequired) { - - if (! pkgRealTimeAdded) { - withPackageList.add("with Ada.Real_Time; use Ada.Real_Time;"); - pkgRealTimeAdded = true; - } - - if (! pkgDataStructureAdded) { - withPackageList.add("with Data_Structure;"); - pkgDataStructureAdded = true; - } - - if (! pkgContainerProtectionAdded) { - withPackageList.add("with Container_Protection; use Container_Protection;"); - pkgContainerProtectionAdded = true; - } - - if (! pkgCyclicTaskAdded) { - withPackageList.add("with Cyclic_Task;"); - pkgCyclicTaskAdded = true; - } - - cyclicRequired = true; - } else if (occKind.startsWith("sporadic") && ! sporadicRequired) { - - if (! pkgSystemAdded) { - withPackageList.add("with System;"); - pkgSystemAdded = true; - } - - if (! pkgRealTimeAdded) { - withPackageList.add("with Ada.Real_Time; use Ada.Real_Time;"); - pkgRealTimeAdded = true; - } - - if (! pkgDataStructureAdded) { - withPackageList.add("with Data_Structure;"); - pkgDataStructureAdded = true; - } - - sporadicRequired = true; - } - - } else if (chrtSpec.getProtection().equals(CallConcurrencyKind.GUARDED)) {// occKind is null or "" - - if (! pkgSystemAdded) { - withPackageList.add("with System;"); - pkgSystemAdded = true; - } - - } - } - - if (cyclicRequired && sporadicRequired) { - break; - } - } - } - return withPackageList; - } - - public String getValue(String inputVSL) { - int endOfValueIndex = inputVSL.indexOf(",unit"); - int startOfValueIndex = inputVSL.indexOf("value=") + 6; - return inputVSL.substring(startOfValueIndex, endOfValueIndex); + /** + * Checks if is data type with required. + * Checks if the generated code requires a "with DataTypes;" clause + * + * @param aInt the Interface + * @return true, if "with DataTypes;" clause is required + */ + public boolean isDataTypeWithRequired(Interface aInt) { + List<Operation> opList = aInt.getOwnedOperations(); + for (int i=0; i < opList.size(); i++) { + List<Parameter> parList = opList.get(i).getOwnedParameters(); + + for (int j=0; j < parList.size(); j++) { + Parameter par = parList.get(j); + if (! (par.getName().equals("Integer") || par.getName().equals("Float") || + par.getName().equals("Natural") )) { + return true; + } + } + } + + return false; } - - public String getUnit(String inputVSL) { - int startOfUnitIndex = inputVSL.indexOf("unit=") + 5; - int endOfUnitIndex = inputVSL.indexOf("))"); - return inputVSL.substring(startOfUnitIndex, endOfUnitIndex); - } - - public String getPriority(List<Object> slotList, Operation op, String stName) { - //Pre-condition : op is an operation marked as "cyclic" in some CHRtSpecification - Slot slot = null; - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - CHRtPortSlot chrtPs = null; - - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - if (CHRtSpecList.get(j).getContext().equals(op)) { - return CHRtSpecList.get(j).getRelativePriority(); - } - } - } - - } - // - return "ERROR_PRIORITY_NOT_FOUND"; - } - - public String getPeriodOrMIAT(List<Object> slotList, Operation op, String stName) { - //Pre-condition : op is an operation marked as "cyclic" or "sporadic" in some CHRtSpecification - Slot slot = null; - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - CHRtPortSlot chrtPs = null; - - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - if (CHRtSpecList.get(j).getContext().equals(op)) { - - String occKind = chrtPs.getCH_RtSpecification().get(0).getOccKind(); - String periodOrMIAT = getValue(occKind); - if (periodOrMIAT.length() <= 5) { - return periodOrMIAT.substring(0, periodOrMIAT.length()-2); - } else { - return periodOrMIAT.substring(0, periodOrMIAT.length()-5).concat("_"). - concat(periodOrMIAT.substring(periodOrMIAT.length()-5, periodOrMIAT.length()-2)); - } - } - } - } - } - return "ERROR_PERIOD_OR_MIAT_NOT_FOUND"; - } - - public String getCeiling(List<Object> slotList, Operation op, String stName) { - //Pre-condition : op is an operation marked as "cyclic", "sporadic" - // or "protected" in some CHRtSpecification - Slot slot = null; - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - CHRtPortSlot chrtPs = null; - - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - if (CHRtSpecList.get(j).getContext().equals(op)) { - - return chrtPs.getCH_RtSpecification().get(j).getCeiling(); - } - } - } - } - return "ERROR_CEILING_NOT_FOUND"; - } - - public List<Operation> getCyclicOperationList(List<Slot> slotList, String stName) { - - ArrayList<Operation> cyclicOpList = new ArrayList<Operation>(); - CHRtPortSlot chrtPs = null; - Slot slot = null; - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); - - if (occKind != null) { - if (occKind.startsWith("periodic")) { - cyclicOpList.add((Operation) CHRtSpecList.get(j).getContext()); - } - } - } - } - } - return cyclicOpList; - } - - public List<Operation> getSporadicOperationList(List<Slot> slotList, String stName) { - - ArrayList<Operation> sporadicOpList = new ArrayList<Operation>(); - CHRtPortSlot chrtPs = null; - Slot slot = null; - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); - - if (occKind != null) { - if (occKind.startsWith("sporadic")) { - sporadicOpList.add((Operation) CHRtSpecList.get(j).getContext()); - } - } - } - } - } - return sporadicOpList; - } - -public List<Operation> getProtectedOperationList(List<Slot> slotList, String stName) { - - ArrayList<Operation> protectedOpList = new ArrayList<Operation>(); - CHRtPortSlot chrtPs = null; - Slot slot = null; - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); - - // Sporadic kind is GUARDED and occKind => sporadic(...) - if (CHRtSpecList.get(j).getProtection().equals(CallConcurrencyKind.GUARDED) && - (occKind == null || occKind.isEmpty())) { - protectedOpList.add((Operation) CHRtSpecList.get(j).getContext()); - } - } - } - } - return protectedOpList; - } - - - public List<Operation> getSlotProtectedOperation(Slot sl, String stName) { - - ArrayList<Operation> protectedOpList = new ArrayList<Operation>(); - CHRtPortSlot chrtPs = null; - - List<Stereotype> stList = sl.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) sl.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); - - // Sporadic kind is GUARDED and occKind => sporadic(...) - if (CHRtSpecList.get(j).getProtection().equals(CallConcurrencyKind.GUARDED) && - (occKind == null || occKind.isEmpty())) { - protectedOpList.add((Operation) CHRtSpecList.get(j).getContext()); - } - } - } - return protectedOpList; - } - - -public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String stName) { - - ArrayList<Operation> unprotectedOpList = new ArrayList<Operation>(); - CHRtPortSlot chrtPs = null; - Slot slot = null; - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); - if (CHRtSpecList.get(j).getProtection().equals(CallConcurrencyKind.CONCURRENT) && - (occKind == null || occKind.isEmpty())) { - unprotectedOpList.add((Operation) CHRtSpecList.get(j).getContext()); - } - } - } - } - return unprotectedOpList; - } - - public List<InstanceSpecification> getComponentInstanceList(List<InstanceSpecification> instList, String stName) { - ArrayList<InstanceSpecification> componentInstanceList = new ArrayList<InstanceSpecification>(); - - for (int i=0; i<instList.size(); i++) { - List<Classifier> clList = instList.get(i).getClassifiers(); - - if (clList.size() > 0) { - Stereotype st = clList.get(0).getAppliedStereotype(stName); - - if (st != null && !instList.get(i).getNearestPackage().getName().endsWith("_full")) { - componentInstanceList.add(instList.get(i)); - } - } - } - - return componentInstanceList; - } - - public List<Slot> getRequiredInterfaceSlotList(List<InstanceSpecification> instList, String stName) { - ArrayList<Slot> reqInterfaceSlotList = new ArrayList<Slot>(); - - for (int i=0; i<instList.size(); i++) { - List<Slot> slList = instList.get(i).getSlots(); - for (int j=0; j<slList.size(); j++) { - - if (slList.get(j).getDefiningFeature() instanceof Port) { - Port pt = (Port) slList.get(j).getDefiningFeature(); - Stereotype st = pt.getAppliedStereotype(stName); - if (st != null) { - ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); - if (csp.getKind() == ClientServerKind.REQUIRED) { - reqInterfaceSlotList.add(slList.get(j)); - } - } - } - } - } - - // the list of all RI - return reqInterfaceSlotList; - } - - - public List<Slot> getInstanceRequiredInterfaceSlotList(InstanceSpecification inst, String stName) { - ArrayList<Slot> reqInterfaceSlotList = new ArrayList<Slot>(); - - - List<Slot> slList = inst.getSlots(); - for (int j=0; j<slList.size(); j++) { - - if (slList.get(j).getDefiningFeature() instanceof Port) { - Port pt = (Port) slList.get(j).getDefiningFeature(); - Stereotype st = pt.getAppliedStereotype(stName); - if (st != null) { - ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); - if (csp.getKind() == ClientServerKind.REQUIRED) { - reqInterfaceSlotList.add(slList.get(j)); - } - } - } - } - - // the list of all RI slots of the instance specification - return reqInterfaceSlotList; - } - - public List<Slot> getProvidedInterfaceSlotList(List<InstanceSpecification> instList, String stName) { - ArrayList<Slot> provInterfaceSlotList = new ArrayList<Slot>(); - - for (int i=0; i<instList.size(); i++) { - List<Slot> slList = instList.get(i).getSlots(); - for (int j=0; j<slList.size(); j++) { - - if (slList.get(j).getDefiningFeature() instanceof Port) { - Port pt = (Port) slList.get(j).getDefiningFeature(); - Stereotype st = pt.getAppliedStereotype(stName); - if (st != null) { - ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); - if (csp.getKind() == ClientServerKind.PROVIDED) { - provInterfaceSlotList.add(slList.get(j)); - } - } - } - } - } - - // the list of all RI - return provInterfaceSlotList; - } - - - public List<Slot> getInstanceProvidedInterfaceSlotList(InstanceSpecification inst, String stName) { - ArrayList<Slot> provInterfaceSlotList = new ArrayList<Slot>(); - - - List<Slot> slList = inst.getSlots(); - for (int j=0; j<slList.size(); j++) { - - if (slList.get(j).getDefiningFeature() instanceof Port) { - Port pt = (Port) slList.get(j).getDefiningFeature(); - Stereotype st = pt.getAppliedStereotype(stName); - if (st != null) { - ClientServerPort csp = (ClientServerPort) pt.getStereotypeApplication(st); - if (csp.getKind() == ClientServerKind.PROVIDED) { - provInterfaceSlotList.add(slList.get(j)); - } - } - } - } - - // the list of all RI slots of the instance specification - return provInterfaceSlotList; - } - - - - public List<InstanceSpecification> getConnectorInstList(List<InstanceSpecification> instList, String stName) { - ArrayList<InstanceSpecification> connectorInstList = new ArrayList<InstanceSpecification>(); - - for (int i=0; i<instList.size(); i++) { - if (instList.get(i).getClassifiers().size()==0) { - List<Slot> slList = instList.get(i).getSlots(); - if (slList.size() > 0) { - Port pt = (Port) slList.get(0).getDefiningFeature(); - Stereotype st = pt.getAppliedStereotype(stName); - // check if the defining feature is a <<ClientServerPort>> - if (st != null) { - connectorInstList.add(instList.get(i)); - } - } - } - } - return connectorInstList; - } - - - - public List<Component> getComponentImplList(List<Component> compList, String stName) { - ArrayList<Component> compImplList = new ArrayList<Component>(); - - for (int i=0; i<compList.size(); i++) { - Stereotype st = compList.get(i).getAppliedStereotype(stName); - // check if it is a <<ComponentImplementation>> - if (st != null) { - compImplList.add(compList.get(i)); - } - } - return compImplList; - } - - public Slot getBoundPIslot(Slot sl, List<InstanceSpecification> connectorInstList) { - - // All methods based on equality between slot fail (indexOf, contains, etc..) - // Check that definingFeature and owningInstance of the slot are matching - - for (int i=0; i<connectorInstList.size(); i++) { - List<Slot> slotList = connectorInstList.get(i).getSlots(); - List<Slot> targetInstanceSlotList = null; - Slot targetSlot = null; - - // 2 slots are included in the instance of the connecto. - Slot slot0 = slotList.get(0); - Slot slot1 = slotList.get(1); - - if (slot0.getDefiningFeature().equals(sl.getDefiningFeature())) { - List<ValueSpecification> vsList = slot0.getValues(); - InstanceValue iv = (InstanceValue) vsList.get(0); - if (sl.getOwningInstance().equals(iv.getInstance())) { - //slot1 is the slot in the instance of the connector - //we must return the slot in the instance of the component instance! - vsList = slot1.getValues(); - iv = (InstanceValue) vsList.get(0); - InstanceSpecification targetIs = iv.getInstance(); - targetInstanceSlotList = targetIs.getSlots(); - for (int j = 0; j < targetInstanceSlotList.size(); j++) { - targetSlot = targetInstanceSlotList.get(j); - if (targetSlot.getDefiningFeature().equals(slot1.getDefiningFeature())) { - return targetSlot; - } - } - - } - } else if (slot1.getDefiningFeature().equals(sl.getDefiningFeature())) { - List<ValueSpecification> vsList = slot1.getValues(); - InstanceValue iv = (InstanceValue) vsList.get(0); - if (sl.getOwningInstance().equals(iv.getInstance())) { - //slot0 is the slot in the instance of the connector - //we must return the slot in the instance of the component instance! - vsList = slot0.getValues(); - iv = (InstanceValue) vsList.get(0); - InstanceSpecification targetIs = iv.getInstance(); - targetInstanceSlotList = targetIs.getSlots(); - for (int j = 0; j < targetInstanceSlotList.size(); j++) { - targetSlot = targetInstanceSlotList.get(j); - if (targetSlot.getDefiningFeature().equals(slot0.getDefiningFeature())) { - return targetSlot; - } - } - - } - } - } - return sl; - } - - public List<Slot> getBoundRIslotList(Slot sl, List<InstanceSpecification> connectorInstList) { - List<Slot> boundRIslotList = new ArrayList<Slot>(); - - // Check that definingFeature and owningInstance of the slot are matching - - for (int i=0; i<connectorInstList.size(); i++) { - List<Slot> slotList = connectorInstList.get(i).getSlots(); - List<Slot> targetInstanceSlotList = null; - Slot targetSlot = null; - - // 2 slots are included in the instance of the connector. - Slot slot0 = slotList.get(0); - Slot slot1 = slotList.get(1); - - if (slot0.getDefiningFeature().equals(sl.getDefiningFeature())) { - List<ValueSpecification> vsList = slot0.getValues(); - InstanceValue iv = (InstanceValue) vsList.get(0); - if (sl.getOwningInstance().equals(iv.getInstance())) { - //slot1 is the slot in the instance of the connector - //we must return the corresponding slot in the instance of the component instance! - vsList = slot1.getValues(); - iv = (InstanceValue) vsList.get(0); - InstanceSpecification targetIs = iv.getInstance(); - targetInstanceSlotList = targetIs.getSlots(); - for (int j = 0; j < targetInstanceSlotList.size(); j++) { - targetSlot = targetInstanceSlotList.get(j); - if (targetSlot.getDefiningFeature().equals(slot1.getDefiningFeature())) { - boundRIslotList.add(targetSlot); - } - } - - } - } else if (slot1.getDefiningFeature().equals(sl.getDefiningFeature())) { - List<ValueSpecification> vsList = slot1.getValues(); - InstanceValue iv = (InstanceValue) vsList.get(0); - if (sl.getOwningInstance().equals(iv.getInstance())) { - //slot0 is the slot in the instance of the connector - //we must return the corresponding slot in the instance of the component instance! - vsList = slot0.getValues(); - iv = (InstanceValue) vsList.get(0); - InstanceSpecification targetIs = iv.getInstance(); - targetInstanceSlotList = targetIs.getSlots(); - for (int j = 0; j < targetInstanceSlotList.size(); j++) { - targetSlot = targetInstanceSlotList.get(j); - if (targetSlot.getDefiningFeature().equals(slot0.getDefiningFeature())) { - boundRIslotList.add(targetSlot); - } - } - - } - } - } - return boundRIslotList; - } - - public boolean isCyclicOperation(List<Slot> slotList, Operation op, String stName) { - - CHRtPortSlot chrtPs = null; - Slot slot = null; - - for (int i=0; i < slotList.size(); i++) { - slot = (Slot) slotList.get(i); - List<Stereotype> stList = slot.getAppliedStereotypes(); - if (! stList.isEmpty()) { - chrtPs = (CHRtPortSlot) slot.getStereotypeApplication(stList.get(0)); - List<CHRtSpecification> CHRtSpecList = chrtPs.getCH_RtSpecification(); - for (int j=0; j < CHRtSpecList.size(); j++) { - Operation myOp = (Operation) CHRtSpecList.get(j).getContext(); - - if (myOp.equals(op)) { - String occKind = chrtPs.getCH_RtSpecification().get(j).getOccKind(); - - if (occKind != null) { - if (occKind.startsWith("periodic")) { - return true; - } - } - } - } - } - } - return false; - } - - - public List<CallOperationAction> getCalledOperation(Operation op) { - ArrayList<CallOperationAction> coaList = new ArrayList<CallOperationAction>(); - List<Behavior> bhList = op.getMethods(); - - if (bhList.size() > 0) { - for (int i=0; i < bhList.size(); i++) { - if (bhList.get(i) instanceof Activity) { - - List<ActivityNode> actNodeList = ((Activity) bhList.get(i)).getNodes(); - for (int j=0; j < actNodeList.size(); j++) { - if (actNodeList.get(j) instanceof CallOperationAction) { - coaList.add((CallOperationAction) actNodeList.get(j)); - } - } - } - } - } - return coaList; - } - - /* Equality criteria between operation: - * - name, visibility, size of parameter list - * type of parameters, name of parameters - * - * isAbstract is purposedly not considered - */ - public boolean isSameOperation(Operation op1, Operation op2) { - if (! op1.getName().equals(op2.getName())) { - return false; - } - - if (! op1.getVisibility().equals(op2.getVisibility())) { - return false; - } - - - List<Parameter> paramList1 = op1.getOwnedParameters(); - List<Parameter> paramList2 = op2.getOwnedParameters(); - - if (paramList1.size() != paramList2.size()) { - return false; - } - - for (int i = 0; i < paramList1.size(); i++) { - Parameter par1 = paramList1.get(i); - Parameter par2 = paramList2.get(i); - - //par1.getType().equals(par2.getType()) unexpectedly fails - //replacing it with a very reliable check on names - if (! par1.getType().getName().equals(par2.getType().getName())) { - return false; - } - - if (! par1.getName().equals(par2.getName())) { - return false; - } - - if (! par1.getDirection().equals(par2.getDirection())) { - return false; - } - } - return true; - } - - - public Interface getInterface(Operation op, List<Port> ptList, String stName) { - - List<Interface> interfaceList = getProvidedInterfaceList(ptList, stName); - - for (int i=0; i < interfaceList.size(); i++) { - Interface myIf = interfaceList.get(i); - List<Operation> opList = myIf.getOperations(); - - for (int j=0; j < opList.size(); j++) { - if ( isSameOperation(op, opList.get(j))) { - return myIf; - } - } - } - - return null; - } - - public boolean isDataTypeWithRequired(Interface aInt) { - List<Operation> opList = aInt.getOwnedOperations(); - for (int i=0; i < opList.size(); i++) { - List<Parameter> parList = opList.get(i).getOwnedParameters(); - - for (int j=0; j < parList.size(); j++) { - Parameter par = parList.get(j); - if (! (par.getName().equals("Integer") || par.getName().equals("Float") || - par.getName().equals("Natural") )) { - return true; - } - } - } - - return false; - } - - public String getImplementationLanguage(Component c, String stName) { + + /** + * Gets the implementation language from a given ComponentImplementation. + * + * @param c the given ComponentImplementation + * @param stName the stereotype name + * @return the implementation language String + */ + public String getImplementationLanguage(Component c, String stName) { Stereotype cImplSt = c.getAppliedStereotype(stName); ComponentImplementation cImpl = (ComponentImplementation) c.getStereotypeApplication(cImplSt); @@ -920,23 +1170,36 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s } else { return lang; } - } - - public String adaTypeToCtype(Type type) { - if (type instanceof PrimitiveType && type.getName().equals("Integer")) { - return "int"; - } else if (type instanceof PrimitiveType && type.getName().equals("Float")) { - return "float"; - } else if (type instanceof PrimitiveType && type.getName().equals("Boolean")) { - return "bool"; - } //else if (type instanceof Enumeration) { + } + + /** + * Converts, if possible, an Ada data type to a C data type. + * + * @param type the Ada type + * @return the C type as String + */ + public String adaTypeToCtype(Type type) { + if (type instanceof PrimitiveType && type.getName().equals("Integer")) { + return "int"; + } else if (type instanceof PrimitiveType && type.getName().equals("Float")) { + return "float"; + } else if (type instanceof PrimitiveType && type.getName().equals("Boolean")) { + return "bool"; + } //else if (type instanceof Enumeration) { // return "int"; - //} + //} + + // assumes that the datatype have been defined in the datatype package + return type.getName(); + } - // assumes that the datatype have been defined in the datatype package - return type.getName(); - } - + /** + * Checks if there is at least one ComponentImplementation with language equals to C or C++ + * + * @param lComp the list of ComponentImplementation + * @param stName the stereotype name + * @return true if there is at least one ComponentImplementation with language equals to C or C++ + */ public Boolean hasCimplementation(List<Component> lComp, String stName) { for (int i=0; i < lComp.size(); i++) { Stereotype compImplSt = lComp.get(i).getAppliedStereotype(stName); @@ -950,7 +1213,13 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s // all component implementations are realized in Ada return false; } - + + /** + * Gets the list of called operation (CalledOperationAction) from the given Activity. + * + * @param act the Activity + * @return the list of called operations + */ public List<CallOperationAction> getCalledOperationList(Activity act) { ArrayList<CallOperationAction> coaList = new ArrayList<CallOperationAction>(); @@ -958,7 +1227,7 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s ActivityNode actNode = null; ControlFlow cf = null; boolean finalNodeFound = false; - + for (int j=0; j < actNodeList.size(); j++) { if (actNodeList.get(j) instanceof InitialNode) { actNode = (InitialNode) actNodeList.get(j); @@ -977,10 +1246,16 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s return null; } } - + return coaList; } - + + /** + * Gets the the Intra-Component Binding (ICB) Activity of the given Operation + * + * @param op the operation + * @return the ICB Activity + */ public Activity getICB(Operation op) { List<Behavior> bhList = op.getMethods(); for (int i=0; i<bhList.size(); i++) { @@ -988,33 +1263,46 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s return (Activity) bhList.get(i); } } - + return null; } - + + /** + * Gets the component instance list. + * + * @param cImpl the c impl + * @param allIsList the all is list + * @return the component instance list + */ public List<InstanceSpecification> getComponentInstanceList(Component cImpl, List<InstanceSpecification> allIsList) { ArrayList<InstanceSpecification> isList = new ArrayList<InstanceSpecification>(); - + for (int i=0; i<allIsList.size(); i++) { if (allIsList.get(i).getClassifiers().get(0).equals(cImpl)) { isList.add(allIsList.get(i)); } } - + return isList; } - + // Deployment related services - // Added on Apr 5th with a lot of rush - - + + + /** + * Checks if the system is single node. + * + * @param allIsList the list of all the instances + * @param stName the stereotype name + * @return true if the system is single node, false if it is multi node (distributed) + */ public Boolean isSingleNodeSystem(List<InstanceSpecification> allIsList, String stName) { InstanceSpecification processingNode = null; Stereotype st = null; - + for (int i=0; i < allIsList.size(); i++) { - st = allIsList.get(i).getAppliedStereotype(stName); - + st = allIsList.get(i).getAppliedStereotype(stName); + if (st != null) { if (processingNode == null) { processingNode = allIsList.get(i); @@ -1025,38 +1313,53 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s } } } - + return true; } - - + + + /** + * Gets the list of processing nodes. + * + * @param allIsList the list of all the instances + * @param stName the the stereotype name + * @return the list of processing nodes. + */ public List<InstanceSpecification> getProcessingNodeList(List<InstanceSpecification> allIsList, String stName) { ArrayList<InstanceSpecification> pnList = new ArrayList<InstanceSpecification>(); Stereotype st = null; - + for (int i=0; i < allIsList.size(); i++) { - st = allIsList.get(i).getAppliedStereotype(stName); - + st = allIsList.get(i).getAppliedStereotype(stName); + if (st != null) { pnList.add(allIsList.get(i)); } } - + return pnList; } - + + /** + * Gets the instance specification deployed to the given instance specification hw node. + * + * @param node the given hw node + * @param commList the list of comments (assigns) + * @param stName the stereotype name + * @return list of instance specification deployed + */ public List<InstanceSpecification> getNodeInstanceSpecification(InstanceSpecification node, List<Comment> commList, String stName) { - + ArrayList<InstanceSpecification> isList = new ArrayList<InstanceSpecification>(); Stereotype st = null; Assign ass = null; - + for (int i=0; i < commList.size(); i++) { st = commList.get(i).getAppliedStereotype(stName); - + if (st != null) { ass = (Assign) commList.get(i).getStereotypeApplication(st); - + if (ass.getTo().get(0).equals(node)) { InstanceSpecification fromInst = (InstanceSpecification) ass.getFrom().get(0); if(!isList.contains(fromInst)){ @@ -1065,30 +1368,45 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s } } } - + return isList; } - + + /** + * Gets the list of component implementations from the given list of instance specifications. + * (it should be the list of deployed instances @see UML2Service.getNodeInstanceSpecification) + * + * @param isList the the list of instance specifications + * @param stName the stereotype name + * @return the list of component implementations + */ public List<Component> getNodeComponentImplementationList(List<InstanceSpecification> isList, String stName) { - + ArrayList<Component> cImplList = new ArrayList<Component>(); Component cImpl = null; - + for (int i=0; i < isList.size(); i++) { - + if (isList.get(i).getClassifiers().get(0) instanceof Component) { cImpl = (Component) isList.get(i).getClassifiers().get(0); if (cImpl.getAppliedStereotype(stName) != null) { cImplList.add(cImpl); } - - + + } } - + return cImplList; } - + + /** + * Gets the list of component types from the given list of component implementations + * + * @param cImplList the list of component implementations + * @param stName the stereotype name + * @return the list of component types + */ public List<Component> getNodeComponentTypeList(List<Component> cImplList, String stName) { ArrayList<Component> cTypeList = new ArrayList<Component>(); @@ -1106,7 +1424,14 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s return cTypeList; } - + + /** + * Gets the list of component types from the given list of component implementations + * + * @param cImplList the list of component implementations + * @param stName the stereotype name + * @return the list of component types + */ public List<Component> getAllComponentTypeList(List<Component> allComponentList, String stName) { ArrayList<Component> cTypeList = new ArrayList<Component>(); @@ -1120,7 +1445,14 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s return cTypeList; } - + + /** + * Gets the list of interfaces from the given list of component types + * + * @param cImplList the list of component types + * @param stName the stereotype name + * @return the list of interfaces + */ public List<Interface> getNodeInterfaceList(List<Component> cTypeList, String stName) { ArrayList<Interface> ifList = new ArrayList<Interface>(); @@ -1129,7 +1461,7 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s for (int i=0; i < cTypeList.size(); i++) { List<Property> pList = cTypeList.get(i).getOwnedAttributes(); ClientServerPort csp = null; - + if (pList != null) { for (int j=0; j < pList.size(); j++) { @@ -1156,24 +1488,32 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s return ifList; } - + + /** + * Gets the deployment processing node. + * + * @param sl the given slot + * @param commList the list of comments (Assigns) + * @param stName the stereotype name + * @return the deployment processing node + */ public InstanceSpecification getDeploymentProcessingNode(Slot sl, List<Comment> commList, String stName) { - + Stereotype st = null; - Assign ass = null; + Assign assign = null; for (int i=0; i < commList.size(); i++) { st = commList.get(i).getAppliedStereotype(stName); if (st != null) { - ass = (Assign) commList.get(i).getStereotypeApplication(st); + assign = (Assign) commList.get(i).getStereotypeApplication(st); - if (ass.getFrom() != null && ass.getTo() != null) { + if (assign.getFrom() != null && assign.getTo() != null) { - if (ass.getTo().get(0) instanceof InstanceSpecification && - ass.getFrom().get(0) instanceof InstanceSpecification) { - if (ass.getFrom().get(0).equals(sl.getOwningInstance())) { - return (InstanceSpecification) ass.getTo().get(0); + if (assign.getTo().get(0) instanceof InstanceSpecification && + assign.getFrom().get(0) instanceof InstanceSpecification) { + if (assign.getFrom().get(0).equals(sl.getOwningInstance())) { + return (InstanceSpecification) assign.getTo().get(0); } } } @@ -1181,28 +1521,44 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s } return null; } - + + /** + * Checks if the remote communication is necessary. + * + * @param slList the list of slots + * @param procNode the processing node (@see UML2Service.getDeploymentProcessingNode) + * @param commList the list of comments + * @param stName the stereotype name + * @return true if remote communication is necessary, false otherwise + */ public Boolean isRemoteCommNecessary (List<Slot> slList, InstanceSpecification procNode, List<Comment> commList, String stName) { - + for (int i=0; i < slList.size(); i++) { if (! this.getDeploymentProcessingNode(slList.get(i), commList, stName).equals(procNode)){ return true; } } - + return false; } - + + /** + * Gets the provided operation list. + * + * @param cTypeList the list of component types + * @param stName the stereotype name + * @return the list of provided operations + */ public List<Operation> getProvidedOperationList (List<Component> cTypeList, String stName) { ArrayList<Operation> opList = new ArrayList<Operation>(); Stereotype st = null; Port pt = null; Interface myIf = null; - + for (int i=0; i < cTypeList.size(); i++) { List<Property> pList = cTypeList.get(i).getOwnedAttributes(); - + for (int j=0; j < pList.size(); j++) { if (pList.get(j) instanceof Port) { pt = (Port) pList.get(j); @@ -1220,33 +1576,53 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s } } } - + return opList; } - + + /** + * Gets the remote required slot list. + * + * @param riSlotList the required slot list + * @param procNode the processing node + * @param connectorInstList the connector instance list + * @param commList the list of comments + * @param assignStName the assign stereotype name + * @return the remote required slot list + */ public List<Slot> getRemoteRIslotList(List<Slot> riSlotList, InstanceSpecification procNode, List<InstanceSpecification> connectorInstList, List<Comment> commList, String assignStName) { - + ArrayList<Slot> remoteRIslotList = new ArrayList<Slot>(); Slot boundSlot = null; - + for (int i=0; i<riSlotList.size(); i++) { boundSlot = getBoundPIslot(riSlotList.get(i), connectorInstList); if (! getDeploymentProcessingNode(boundSlot, commList, assignStName).equals(procNode)) { - + if (! remoteRIslotList.contains(boundSlot)) { remoteRIslotList.add(boundSlot); } } } - + return remoteRIslotList; } - + + /** + * Checks if remote msg client is necessary. + * + * @param riSlotList the required slot list + * @param procNode the processing node + * @param connectorInstList the connector instance list + * @param commList the list of comments + * @param assignStName the assign stereotype name + * @return true if remote msg client is necessary, false otherwise + */ public Boolean isRemoteMsgClientNecessary(List<Slot> riSlotList, InstanceSpecification procNode, List<InstanceSpecification> connectorInstList, List<Comment> commList, String assignStName) { - + Slot boundSlot = null; for (int i = 0; i < riSlotList.size(); i++) { boundSlot = getBoundPIslot(riSlotList.get(i), connectorInstList); @@ -1255,87 +1631,124 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s } } // all RI slots are connected to PI of instances deployed on the same processor node - + return false; } - - + + + /** + * Checks if remote msg server is necessary. + * + * @param slList the slot list + * @param procNode the processing node + * @param connectorInstList the connector instance list + * @param commList the list of comments + * @param stName the stereotype name + * @return true if remote msg server is necessary, false otherwise + */ public Boolean isRemoteMsgServerNecessary (List<Slot> slList, InstanceSpecification procNode, List<InstanceSpecification> connectorInstList, List<Comment> commList, String stName) { - + List<Slot> boundSlotList = null; - + for (int i=0; i < slList.size(); i++) { - + boundSlotList = getBoundRIslotList(slList.get(i), connectorInstList); - + for (int j=0; j < boundSlotList.size(); j++) { if (! this.getDeploymentProcessingNode(boundSlotList.get(j), commList, stName).equals(procNode)){ return true; } } } - + return false; } - - + + + /** + * Check whether to use sequence id. + * + * @param sl the slot + * @param connectorInstList the list of connector instances + * @param connectorList the list of connectors + * @param stName the stereotype name + * @return true if sequence id is used, false otherwise + */ public Boolean useSequenceID(Slot sl, List<InstanceSpecification> connectorInstList, - List<Connector> connectorList, String stName) { - - // Check that definingFeature and owningInstance of the slot are matching - - for (int i=0; i<connectorInstList.size(); i++) { - List<Slot> slotList = connectorInstList.get(i).getSlots(); - - // 2 slots are included in the instance of the connector. - Slot slot0 = slotList.get(0); - Slot slot1 = slotList.get(1); - - if (slot0.getDefiningFeature().equals(sl.getDefiningFeature())) { - List<ValueSpecification> vsList = slot0.getValues(); - InstanceValue iv = (InstanceValue) vsList.get(0); - if (sl.getOwningInstance().equals(iv.getInstance())) { - return isTransmissionWithSequenceID(slot0, slot1, connectorList, stName); - - } - } else if (slot1.getDefiningFeature().equals(sl.getDefiningFeature())) { - List<ValueSpecification> vsList = slot1.getValues(); - InstanceValue iv = (InstanceValue) vsList.get(0); - if (sl.getOwningInstance().equals(iv.getInstance())) { - return isTransmissionWithSequenceID(slot0, slot1, connectorList, stName); - } - } - } - return false; + List<Connector> connectorList, String stName) { + + // Check that definingFeature and owningInstance of the slot are matching + + for (int i=0; i<connectorInstList.size(); i++) { + List<Slot> slotList = connectorInstList.get(i).getSlots(); + + // 2 slots are included in the instance of the connector. + Slot slot0 = slotList.get(0); + Slot slot1 = slotList.get(1); + + if (slot0.getDefiningFeature().equals(sl.getDefiningFeature())) { + List<ValueSpecification> vsList = slot0.getValues(); + InstanceValue iv = (InstanceValue) vsList.get(0); + if (sl.getOwningInstance().equals(iv.getInstance())) { + return isTransmissionWithSequenceID(slot0, slot1, connectorList, stName); + + } + } else if (slot1.getDefiningFeature().equals(sl.getDefiningFeature())) { + List<ValueSpecification> vsList = slot1.getValues(); + InstanceValue iv = (InstanceValue) vsList.get(0); + if (sl.getOwningInstance().equals(iv.getInstance())) { + return isTransmissionWithSequenceID(slot0, slot1, connectorList, stName); + } + } + } + return false; } - + + /** + * Checks if the connector has transmission with sequence id. + * + * @param slot0 the first slot + * @param slot1 the second slot + * @param connectorList the list of connectors + * @param stName the stereotype name + * @return true if the connector has transmission with sequence id, false otherwise + */ public Boolean isTransmissionWithSequenceID(Slot slot0, Slot slot1, List<Connector> connectorList, String stName) { // assessing whether the connector has a "TransmissionWithProtocol" stereotype on it - + List<ConnectorEnd> ctEndList = null; - + for (int i=0; i < connectorList.size(); i++) { ctEndList = connectorList.get(i).getEnds(); ConnectorEnd ce0 = ctEndList.get(0); ConnectorEnd ce1 = ctEndList.get(1); - + if ((ce0.getRole().equals(slot0.getDefiningFeature()) || ce1.getRole().equals(slot0.getDefiningFeature())) - && - (ce0.getRole().equals(slot1.getDefiningFeature()) || ce1.getRole().equals(slot1.getDefiningFeature()))) { - + && + (ce0.getRole().equals(slot1.getDefiningFeature()) || ce1.getRole().equals(slot1.getDefiningFeature()))) { + Stereotype st = connectorList.get(i).getAppliedStereotype(stName); - if (st == null) { - return false; - } else { - TransmissionWithProtocol twp = (TransmissionWithProtocol) connectorList.get(i).getStereotypeApplication(st); - return twp.isUseSeqID(); - } + if (st == null) { + return false; + } else { + TransmissionWithProtocol twp = (TransmissionWithProtocol) connectorList.get(i).getStereotypeApplication(st); + return twp.isUseSeqID(); + } } } return false; } - + + /** + * Gets the CRC library. + * + * @param sl the slot + * @param connectorInstList the list of connector instances + * @param connectorList the list of connectors + * @param stName the stereotype name + * @return the CRC library + */ public String getCRClib(Slot sl, List<InstanceSpecification> connectorInstList, List<Connector> connectorList, String stName) { @@ -1366,32 +1779,47 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s return ""; } + /** + * Gets the transmission with CRC. + * + * @param slot0 the first slot + * @param slot1 the second slot + * @param connectorList the list of connectors + * @param stName the stereotype name + * @return the transmission with CRC + */ public String getTransmissionWithCRC(Slot slot0, Slot slot1, List<Connector> connectorList, String stName) { // assessing whether the connector has a "TransmissionWithProtocol" stereotype on it - + List<ConnectorEnd> ctEndList = null; - + for (int i=0; i < connectorList.size(); i++) { ctEndList = connectorList.get(i).getEnds(); ConnectorEnd ce0 = ctEndList.get(0); ConnectorEnd ce1 = ctEndList.get(1); - + if ((ce0.getRole().equals(slot0.getDefiningFeature()) || ce1.getRole().equals(slot0.getDefiningFeature())) - && - (ce0.getRole().equals(slot1.getDefiningFeature()) || ce1.getRole().equals(slot1.getDefiningFeature()))) { - + && + (ce0.getRole().equals(slot1.getDefiningFeature()) || ce1.getRole().equals(slot1.getDefiningFeature()))) { + Stereotype st = connectorList.get(i).getAppliedStereotype(stName); - if (st == null) { - return ""; - } else { - TransmissionWithProtocol twp = (TransmissionWithProtocol) connectorList.get(i).getStereotypeApplication(st); - return twp.getCRC(); - } + if (st == null) { + return ""; + } else { + TransmissionWithProtocol twp = (TransmissionWithProtocol) connectorList.get(i).getStereotypeApplication(st); + return twp.getCRC(); + } } } return ""; } - + + /** + * Gets the Papyrus documentation of an element + * + * @param elem the Element + * @return the documentation as a String + */ public String getDocumentation(NamedElement elem){ String docString = ""; EList<Comment> comments = elem.getOwnedComments(); @@ -1410,16 +1838,25 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s scanner.close(); return commented; } - + + /** + * Gets the tuple attributes of a MARTE's TupleType stereotype. + * + * @param dt the data type + * @param stereo the stereotype (TupleType) + * @return the list of proerties that are the tuple attributes + */ public List<Property> getTupleAttributes(DataType dt, Stereotype stereo){ TupleType tuple = (TupleType) dt.getStereotypeApplication(stereo); return tuple.getTupleAttrib() ; } - + /** - * checks if the op will generate a function in Ada. - * @param op - * @return true if there's one and only one parameter with direction "return" + * checks if the operation generates a function in Ada. + * it's a function if there's one and only one parameter with direction "return" + * + * @param op the operation + * @return true if it's a function, false otherwise (it is a procedure) */ public Boolean isFunction(Operation op){ Boolean res = false; @@ -1434,11 +1871,13 @@ public List<Operation> getUnprotectedOperationList(List<Slot> slotList, String s } return res; } - + /** - * op must be a function (see previous method) - * @param op - * @return the return parameter + * Gets the return parameter of a given operation. + * The given operation must be a function (@see UML2Service.isFunction). + * + * @param op the given Operation + * @return the return parameter of the operation */ public Parameter getReturnParam(Operation op){ Parameter param = null; diff --git a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/transformations/AcceleoCodeGen.java b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/transformations/AcceleoCodeGen.java index 11bbf21c5be7f9fc08a0220510a64982c7d12b8c..264e0a001376dfc270bfaaca882df0aadb221c5f 100644 --- a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/transformations/AcceleoCodeGen.java +++ b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/transformations/AcceleoCodeGen.java @@ -55,16 +55,11 @@ public class AcceleoCodeGen { /** * Constructor. - * - * @param modelURI - * is the URI of the model. - * @param targetFolder - * is the output folder - * @param arguments - * are the other arguments - * @throws IOException - * Thrown when the output cannot be saved. - * @generated + * + * @param modelURI is the URI of the model. + * @param targetFolder is the output folder + * @param arguments are the other arguments + * @generated */ public AcceleoCodeGen(URI modelURI, IContainer targetFolder, List<? extends Object> arguments) { this.modelURI = modelURI; @@ -96,14 +91,12 @@ public class AcceleoCodeGen { /** * Finds the template in the plug-in. Returns the template plug-in URI. - * - * @param bundleID - * is the plug-in ID - * @param relativePath - * is the relative path of the template in the plug-in + * + * @param bundleID is the plug-in ID + * @param relativePath is the relative path of the template in the plug-in * @return the template URI - * @throws IOException - * @generated + * @throws IOException Signals that an I/O exception has occurred. + * @generated */ @SuppressWarnings("unused") private URI getTemplateURI(final String bundleID, final IPath relativePath) throws IOException { @@ -143,6 +136,14 @@ public class AcceleoCodeGen { return result; } + /** + * Run codegen. + * + * @param model the model + * @param target the target folder + * @param monitor the monitor used to display progress information to the user + * @throws Exception the exception + */ public static void runCodegen(IFile model, IContainer target, IProgressMonitor monitor) throws Exception { URI modelURI = URI.createPlatformResourceURI(model.getFullPath().toString(), true); AcceleoCodeGen generator = new AcceleoCodeGen(modelURI, target, new ArrayList<String>()); diff --git a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/transformations/Transformations.java b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/transformations/Transformations.java index cc20c143011054e666797b5abd692dc5611adf9c..4678745f9b6f2a300d45ccc0c8ea5ab9f953f540 100644 --- a/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/transformations/Transformations.java +++ b/plugins/org.polarsys.chess.codegen.ada/src/org/polarsys/chess/codegen/ada/transformations/Transformations.java @@ -14,60 +14,45 @@ package org.polarsys.chess.codegen.ada.transformations; -import org.polarsys.chess.codegen.ada.Activator; -import org.polarsys.chess.core.util.CHESSProjectSupport; -import org.polarsys.chess.m2m.TransUtil; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.m2m.internal.qvt.oml.emf.util.ModelContent; import org.eclipse.papyrus.editor.PapyrusMultiDiagramEditor; import org.eclipse.uml2.uml.Model; +import org.polarsys.chess.core.util.CHESSProjectSupport; +import org.polarsys.chess.m2m.TransUtil; +/** + * The Class Transformations. + */ @SuppressWarnings("restriction") public class Transformations { + /** + * Load the model, sets up the environment and performs the Ada code generation. + * + * @param editor the editor + * @param model the model + * @param monitor the monitor + * @throws Exception the exception + */ public static void performCodeGeneration(final PapyrusMultiDiagramEditor editor, IFile model, IProgressMonitor monitor) throws Exception { ModelContent mc = TransUtil.loadModel(model); final Model mi = (Model) mc.getContent().get(0); -// TransactionalEditingDomain editingDomain = editor.getServicesRegistry().getService(ModelSet.class).getTransactionalEditingDomain(); -// final InternalValidator v = new InternalValidator(mi, editingDomain); -// int res = InternalValidator.GUI.validate(editor, v, mi); -// if (res != 0) -// return; - String codeGenDir = TransUtil.CODEGEN_DIR + "_" + mi.getName(); -// IFolder transDir = model.getProject().getFolder(TransUtil.PIM_PSM_DIR); + IFolder srcDir = model.getProject().getFolder(codeGenDir); CHESSProjectSupport.bundleToProjectCopy(org.polarsys.chess.codegen.ada.Activator.PLUGIN_ID, org.polarsys.chess.codegen.ada.Activator.getDefault(), "src-lib", model.getProject(), codeGenDir, false); - // Delete the working dir if it exists -// CHESSProjectSupport.deleteFolder(transDir); - -// CHESSProjectSupport.createFolder(transDir); CHESSProjectSupport.createFolder(model.getProject().getFolder(codeGenDir + "/obj")); - // Work on a copy of the model -// IFile modelCopy = CHESSProjectSupport.copyFile(model, TransUtil.PIM_PSM_DIR, model.getName()); - - // Remove the content of the RtAnalysisPackage -// TransUtil.purgeModel(modelCopy); - - //TODO enable the transformation when it works - // Execute the various steps of the transformations - //QVToTransformation.launchPIM2PSM(modelCopy, monitor); - -// QVToTransformation.launchCeilingAssignment(modelCopy, monitor); - - // Replace the input model file with the transformed model - //CHESSProjectSupport.fileReplace(modelCopy, model); - + AcceleoCodeGen.runCodegen(model/*Copy*/, srcDir, monitor); - // Finally delete the working dir -// CHESSProjectSupport.deleteFolder(transDir); + } } \ No newline at end of file diff --git a/plugins/org.polarsys.chess.codegen.ada/tasks/generateInfrastructure.xml b/plugins/org.polarsys.chess.codegen.ada/tasks/generateInfrastructure.xml index 982a8d7ec5ec99cc0656112056daabfc2871256d..afefa3701ec195ae3adc6b79b52591f475386796 100644 --- a/plugins/org.polarsys.chess.codegen.ada/tasks/generateInfrastructure.xml +++ b/plugins/org.polarsys.chess.codegen.ada/tasks/generateInfrastructure.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <project default="generateInfrastructure" name="org.polarsys.chess.codegen.ada"> - <property name="ECLIPSE_HOME" value="../../../../../Programs/CHESS_Luna/eclipse"/> - <property name="ECLIPSE_WORKSPACE" value="../.."/> + <property name="ECLIPSE_HOME" value="../../../../../../../../Programs/CHESS_Luna/eclipse"/> + <property name="ECLIPSE_WORKSPACE" value="../../../../../0.9.0_Workspace"/> <!-- The classpath with only the dependencies used by the project --> <path id="org.polarsys.chess.codegen.ada.libraryclasspath"> @@ -36,13 +36,13 @@ <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.acceleo.engine_3.5.1.201409021433.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.emf.codegen.ecore_2.10.2.v20150123-0452.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.emf.codegen_2.10.0.v20150123-0452.jar"/> - <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.marte.static.profile_1.0.2.v201502181446.jar"/> + <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.marte.static.profile_1.0.2.v201504031223.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.core.commands_3.6.100.v20140528-1422.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.core.resources_3.9.1.v20140825-1431.jar"/> - <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core_1.0.2.v201502181349.jar"/> - <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core.sasheditor_1.0.2.v201502181349.jar"/> - <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core.sasheditor.di_1.0.2.v201502181349.jar"/> - <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.editor_1.0.2.v201502181349.jar"/> + <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core_1.0.2.v201504030953.jar"/> + <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core.sasheditor_1.0.2.v201504030953.jar"/> + <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.infra.core.sasheditor.di_1.0.2.v201504030953.jar"/> + <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.editor_1.0.2.v201504030953.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.m2m.qvt.oml.common_3.4.0.v20140306-0649.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.m2m.qvt.oml.emf.util_3.4.0.v20140306-0718.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui_3.106.1.v20141002-1150.jar"/> @@ -52,7 +52,7 @@ <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui.workbench_3.106.2.v20150204-1030.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.e4.ui.workbench3_0.12.0.v20140227-2118.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui.ide_3.10.2.v20141118-1227.jar"/> - <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.sysml_1.0.2.v201502181349.jar"/> + <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.papyrus.sysml_1.0.2.v201504030953.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.uml2.uml.profile.standard_1.0.0.v20150202-0947.jar"/> <pathelement location="${ECLIPSE_HOME}/plugins/org.eclipse.ui.views_3.7.0.v20140408-0703.jar"/> </path>