| package org.eclipse.papyrus.aiml.gen.keras |
| |
| import org.eclipse.papyrus.aiml.profile.AIML.Module.Model |
| import java.util.HashSet |
| import org.eclipse.jface.dialogs.MessageDialog |
| import org.eclipse.swt.widgets.Display |
| |
| class GenCheck { |
| /** |
| * return true if Null for each type |
| */ |
| static def isNull(Object value) { |
| return value === null |
| } |
| |
| /** |
| * return true if Null for each type |
| */ |
| static def isFalseBoolean(Boolean value) { |
| return value.booleanValue === Boolean.FALSE |
| } |
| /** |
| * return true if Null or string value is empty |
| */ |
| static def isNullOrEmptyForString(String value) { |
| return value === null || value.length == 0 || value === "null" |
| } |
| |
| static def isZeroForString(String value) { |
| return value === "0.0" || value ==="0" |
| } |
| |
| static def isZeroForStringL(String value) { |
| return value.equals("0.0") || value.equals("0") |
| } |
| /** |
| * return true if string value is equal to false |
| */ |
| static def isFalseForString(String value) { |
| return value !== null && value.equals("false") |
| } |
| |
| /** |
| * collect the number of layers in the model |
| */ |
| static def findNbrOfLayer(Model l) { |
| var nbr_lay = 0 |
| for (layer : l.base_Class.ownedAttributes) { |
| l.getClass().getSimpleName() |
| nbr_lay = nbr_lay + 1 |
| } |
| return nbr_lay |
| } |
| |
| static def findNbrOfInformationFLowPara(Model l) { |
| var nbrInformationFlowFinal = 0 |
| var nbrInformationFlowByLayer = 0 |
| |
| for (layer : l.base_Class.ownedAttributes) { |
| |
| nbrInformationFlowByLayer=layer.getTargetDirectedRelationships().length |
| |
| if (nbrInformationFlowByLayer>nbrInformationFlowFinal){ |
| nbrInformationFlowFinal=nbrInformationFlowByLayer |
| } |
| |
| } |
| |
| if (nbrInformationFlowFinal>1){ |
| MessageDialog.openWarning(Display.current.activeShell, "Warning Message : InformationFlow ", |
| "NOT SUPPORTED : InformationFLow parallelization (Double entry) "); |
| |
| return 0 |
| |
| } else { |
| return 1 |
| } |
| |
| } |
| |
| static def findNbrOfInformationFLowMissing(ModuleInfo mi) { |
| |
| System.err.println("module info list : " + mi.layersInput.toList) |
| |
| var HashSet hs = new HashSet<String>(); |
| hs.addAll(mi.layersInput.toList); |
| var int totalDuplicates = mi.layersInput.toList.size() - hs.size(); |
| |
| //MessageDialog.openWarning(Display.current.activeShell, "sdfsd", "warning ..."); |
| //Activator.log.info("sdfsd"); |
| |
| if (totalDuplicates !== 0) { |
| MessageDialog.openWarning(Display.current.activeShell, "Warning Message : InformationFlow ", |
| "NOT SUPPORTED : Missing InformationFlow Connection"); |
| return 0 |
| |
| } else { |
| return 1 |
| } |
| } |
| } |
| |