def setBusinessObjectsAsSerializable(package): for jclass in [ jclass for jclass in package.getOwnedElement(Class) if hasStereotype(jclass, 'Entity')]: stereoImplements = [it for it in getTagValues(jclass, 'JavaImplements') if 'Serializable' in it] modelImplements = [ ir for ir in jclass.getRealized() if ir.getImplemented().getName() == 'Serializable' ] if not stereoImplements and not modelImplements: addTagValue(jclass, "JavaImport", "java.io.Serializable") addTagValue(jclass, "JavaImplements", "Serializable") for subPackage in package.getOwnedElement(Package): setBusinessObjectsAsSerializable(subPackage)
# you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # from modelling import hasStereotype program = selectedElements.get(0) model = program.getOwner().getOwner() hwPlat = [p for p in model.getOwnedElement(Package) if hasStereotype(p, "HardwarePlatformModel")][0] def create_node(hwPlat): node = modelingSession.getModel().createInstance("node", hwPlat) node.addStereotype("MARTEDesigner", "HwComputingResource_Instance") node.addStereotype("JuniperIDE", "CloudNode") cpu = modelingSession.getModel().createBindableInstance() cpu.setName("CPU") node.getPart().add(cpu) cpu.addStereotype("MARTEDesigner", "HwProcessor_Instance") cpu.addStereotype("JuniperIDE", "CloudNodeCPU") return node
if not program.getRepresenting(): msg = MessageBox(Display.getCurrent().getActiveShell(), SWT.ICON_WARNING|SWT.OK) msg.setText("Update or generate code") msg.setMessage("Warn : generate hardware model please.") msg.open() return False return True def getNodeIP(node): return getTagValues(node, 'ip') def getFullJavaName(el): return getJavaClassName(el) def getFullClassName(jclass): return getJavaClassName(jclass) def getFullInterfaceName(iface): return getJavaClassName(iface) model = selectedElements.get(0) swPlat = [p for p in model.getOwnedElement(Package) if hasStereotype(p, 'SoftwareArchitectureModel')][0] hwPlat = [p for p in model.getOwnedElement(Package) if hasStereotype(p, 'HardwarePlatformModel')][0] programs = [ el for el in swPlat.getOwnedElement(Class) if hasStereotype(el, 'JUNIPERProgram') ] if not hardwareModelIsMissingMessageBox(programs) : class InvalidHardwareModelException(Exception): pass raise InvalidHardwareModelException() projectName = hwPlat.getOwner().getName() defaultLibFolder = getTagValue(swPlat, 'libfolder') if not defaultLibFolder: defaultLibFolder = 'lib' cmdLineOptionsValues = swPlat.getTagValues('JuniperIDE','javacmdline') if cmdLineOptionsValues: