use of org.osate.aadl2.ModelUnit in project osate2 by osate.
the class TraverseWorkspace method getPackagesInWorkspace.
public final EList<Element> getPackagesInWorkspace() {
EList<Element> result = new BasicEList<Element>();
HashSet<IFile> files = TraverseWorkspace.getAadlFilesInWorkspace();
for (IFile file : files) {
ModelUnit target = (ModelUnit) AadlUtil.getElement(file);
if (target instanceof AadlPackage) {
result.add(target);
}
}
return result;
}
use of org.osate.aadl2.ModelUnit in project osate2 by osate.
the class TraverseWorkspace method getModelUnitsInWorkspace.
public final EList<Element> getModelUnitsInWorkspace() {
EList<Element> result = new BasicEList<Element>();
HashSet<IFile> files = TraverseWorkspace.getAadlFilesInWorkspace();
for (IFile file : files) {
ModelUnit target = (ModelUnit) AadlUtil.getElement(file);
result.add(target);
}
return result;
}
use of org.osate.aadl2.ModelUnit in project AMASE by loonwerks.
the class SafetyValidator method collectFaultsFromPackages.
/**
* Get packages defined in this component impl and collect all faults from
* all included packages.
* @param compImpl
* @return Map<String, List<String>> mapping from component instance name
* to a list of associated faults.
*/
private Map<String, List<String>> collectFaultsFromPackages(ComponentImplementation compImpl) {
Map<String, List<String>> mapCompNameToFaultNames = new HashMap<String, List<String>>();
List<AadlPackageImpl> packages = new ArrayList<AadlPackageImpl>();
AadlPackageImpl aadlPackage = getAadlPackageImpl(compImpl);
packages.add(aadlPackage);
PublicPackageSection pps = aadlPackage.getOwnedPublicSection();
// Collect all imported packages and iterate through
// annexes to find safety annexes with faults.
List<ModelUnit> imports = pps.getImportedUnits();
for (ModelUnit imp : imports) {
if (imp instanceof AadlPackageImpl) {
packages.add((AadlPackageImpl) imp);
}
}
for (AadlPackageImpl aadlPack : packages) {
PublicPackageSection pub = aadlPack.getPublicSection();
for (Classifier cl : pub.getOwnedClassifiers()) {
if (cl instanceof SystemType) {
for (AnnexSubclause sub : cl.getOwnedAnnexSubclauses()) {
if (sub.getName().contains("safety")) {
for (Element child : sub.getChildren()) {
List<String> faultNames = new ArrayList<String>();
if (child instanceof SafetyContractSubclause) {
SafetyContractSubclause safetyChild = (SafetyContractSubclause) child;
SafetyContract cont = (SafetyContract) safetyChild.getContract();
faultNames.addAll(getFaultNamesFromSpecs(cont.getSpecs()));
mapCompNameToFaultNames.put(cl.getName(), faultNames);
}
}
}
}
}
}
}
return mapCompNameToFaultNames;
}
use of org.osate.aadl2.ModelUnit in project osate2 by osate.
the class AadlUtil method isImportedPropertySet.
/**
* check whether property set is in the with clause of the containing top level name space (PackageSection or Property set) of the context.
* @param ps Property set
* @param context location at which property set reference is encountered
* @return aadl property set or null if not in import list
*/
public static boolean isImportedPropertySet(PropertySet ps, EObject context) {
EList<ModelUnit> importedPropertySets;
if (ps == null) {
return false;
}
if (isPredeclaredPropertySet(ps.getName())) {
return true;
}
context = AadlUtil.getContainingTopLevelNamespace(context);
if (context instanceof PropertySet) {
importedPropertySets = ((PropertySet) context).getImportedUnits();
} else {
importedPropertySets = ((PackageSection) context).getImportedUnits();
}
for (ModelUnit importedPropertySet : importedPropertySets) {
if (importedPropertySet instanceof PropertySet && !importedPropertySet.eIsProxy() && (importedPropertySet == ps || (ps.getQualifiedName().equalsIgnoreCase(importedPropertySet.getQualifiedName())))) {
return true;
}
}
return false;
}
use of org.osate.aadl2.ModelUnit in project osate2 by osate.
the class TraverseWorkspace method getPropertysetsInWorkspace.
public final EList<Element> getPropertysetsInWorkspace() {
EList<Element> result = new BasicEList<Element>();
HashSet<IFile> files = TraverseWorkspace.getAadlFilesInWorkspace();
for (IFile file : files) {
ModelUnit target = (ModelUnit) AadlUtil.getElement(file);
if (target instanceof PropertySet) {
result.add(target);
}
}
return result;
}
Aggregations