use of org.geotoolkit.sml.xml.v100.Classifier in project AMASE by loonwerks.
the class FaultsVerifyAllHandler method isProbabilisticAnalysis.
private boolean isProbabilisticAnalysis() {
List<Classifier> classifiers = getClassifiers();
if (classifiers == null) {
return false;
}
// TODO: Finish addressing this issue.
for (Classifier cl : classifiers) {
// Get impl of this level
if (cl instanceof ComponentImplementationImpl) {
List<AnnexSubclause> asList = cl.getOwnedAnnexSubclauses();
for (AnnexSubclause as : asList) {
if (as.getName().equalsIgnoreCase("safety")) {
if (as instanceof DefaultAnnexSubclauseImpl) {
DefaultAnnexSubclauseImpl defaultAnnex = (DefaultAnnexSubclauseImpl) as;
SafetyContractSubclauseImpl safetyAnnex = (SafetyContractSubclauseImpl) defaultAnnex.getParsedAnnexSubclause();
// Get analysis stmt
List<SpecStatement> specs = ((SafetyContract) safetyAnnex.getContract()).getSpecs();
for (SpecStatement spec : specs) {
if (spec instanceof AnalysisStatement) {
if (!(((AnalysisStatement) spec).getBehavior() instanceof ProbabilityBehavior)) {
return false;
}
}
}
}
}
}
}
}
return true;
}
use of org.geotoolkit.sml.xml.v100.Classifier in project AMASE by loonwerks.
the class FaultDisableHandler method makeMap.
/**
* Checks classifiers in AadlPackage for any ComponentTypeImpl
* and then collects safety annex spec statements to gather
* fault names specific to that component.
*
* @param classifiers Classifiers in this AadlPackage
*/
private void makeMap(List<Classifier> classifiers) {
for (Classifier cl : classifiers) {
if (cl instanceof ComponentTypeImpl) {
String compName = cl.getName();
List<String> faultNameList = new ArrayList<String>();
List<AnnexSubclause> asList = cl.getOwnedAnnexSubclauses();
for (AnnexSubclause as : asList) {
if (as.getName().equalsIgnoreCase("safety")) {
if (as instanceof DefaultAnnexSubclauseImpl) {
DefaultAnnexSubclauseImpl defaultAnnex = (DefaultAnnexSubclauseImpl) as;
SafetyContractSubclauseImpl safetyAnnex = (SafetyContractSubclauseImpl) defaultAnnex.getParsedAnnexSubclause();
List<SpecStatement> specs = ((SafetyContract) safetyAnnex.getContract()).getSpecs();
for (SpecStatement spec : specs) {
if (spec instanceof FaultStatementImpl) {
FaultStatementImpl fs = (FaultStatementImpl) spec;
faultNameList.add(fs.getName());
}
}
}
}
}
// If list nonempty, add to map for this component
if (!faultNameList.isEmpty()) {
mapCompNameToFaults.put(compName, faultNameList);
}
}
}
}
use of org.geotoolkit.sml.xml.v100.Classifier 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.geotoolkit.sml.xml.v100.Classifier in project AMASE by loonwerks.
the class SafetyScopeProvider method scope_GetPropertyExpr_prop.
protected IScope scope_GetPropertyExpr_prop(GetPropertyExpr ctx, EReference ref) {
IScope prevScope = prevScope(ctx, ref);
ComponentRef cr = ctx.getComponentRef();
if (cr instanceof ThisRef) {
List<Property> ps = new ArrayList<>();
EObject container = ctx.getContainingClassifier();
while (container != null) {
if (container instanceof Classifier) {
List<PropertyAssociation> pas = ((Classifier) container).getAllPropertyAssociations();
for (PropertyAssociation pa : pas) {
ps.add(pa.getProperty());
}
container = ((Classifier) container).eContainer();
} else if (container instanceof AadlPackage) {
for (PropertySet propSet : EcoreUtil2.getAllContentsOfType(container, PropertySet.class)) {
for (Property p : propSet.getOwnedProperties()) {
ps.add(p);
}
// =======
// EList<EObject> refs = null;
//
// if (container instanceof NestedDotID) {
// NestedDotID parent = (NestedDotID) container;
// refs = parent.eCrossReferences();
//
// if (refs.size() != 1) {
// return new HashSet<>(); // this will throw a parsing error
// }
// container = refs.get(0); // figure out what this type this portion
//
// // of the nest id is so we can figure out
// // what we could possibly link to
//
// if (container instanceof ThreadSubcomponent) {
// container = ((ThreadSubcomponent) container).getComponentType();
// result.addAll(getAadlElements(container));
// } else if (container instanceof Subcomponent) {
// container = ((Subcomponent) container).getComponentImplementation();
// if (container == null) { // no implementation is provided
// container = refs.get(0);
// container = ((Subcomponent) container).getClassifier();
// }
// result.addAll(getAadlElements(container));
// } else if (container instanceof DataPort) {
// container = ((DataPort) container).getDataFeatureClassifier();
// result.addAll(getAadlElements(container));
// } else if (container instanceof EventDataPort) {
// container = ((EventDataPort) container).getDataFeatureClassifier();
// result.addAll(getAadlElements(container));
// } else if (container instanceof AadlPackage) {
// result.addAll(getAadlElements(container));
// } else if (container instanceof FeatureGroupImpl) {
// container = ((FeatureGroupImpl) container).getAllFeatureGroupType();
// result.addAll(getAadlElements(container));
// } else if (container instanceof Arg || container instanceof ConstStatement) {
// Type type;
//
// if (container instanceof Arg) {
// type = ((Arg) container).getType();
// } else {
// type = ((ConstStatement) container).getType();
// }
//
// if (type instanceof RecordType) {
// DoubleDotRef elID = ((RecordType) type).getRecord();
// NamedElement namedEl = elID.getElm();
//
// if (namedEl instanceof ComponentImplementation) {
// ComponentImplementation componentImplementation = (ComponentImplementation) namedEl;
// EList<Subcomponent> subs = componentImplementation.getAllSubcomponents();
// result.addAll(subs);
// } else if (namedEl instanceof RecordDefExpr) {
// result.addAll(((RecordDefExpr) namedEl).getArgs());
// >>>>>>> origin/develop
}
container = null;
} else {
container = container.eContainer();
}
}
return Scopes.scopeFor(ps, prevScope);
} else if (cr instanceof DoubleDotRef) {
NamedElement ne = ((DoubleDotRef) cr).getElm();
if (ne instanceof Subcomponent) {
List<PropertyAssociation> pas = ((Subcomponent) ne).getOwnedPropertyAssociations();
List<Property> ps = new ArrayList<>();
for (PropertyAssociation pa : pas) {
ps.add(pa.getProperty());
}
return Scopes.scopeFor(ps, prevScope);
}
}
return IScope.NULLSCOPE;
}
use of org.geotoolkit.sml.xml.v100.Classifier in project AMASE by loonwerks.
the class SafetyScopeProvider method getNamedElements.
private Set<NamedElement> getNamedElements(EObject ctx) {
Set<NamedElement> components = new HashSet<>();
if (ctx instanceof AadlPackage) {
PublicPackageSection pubSec = ((AadlPackage) ctx).getPublicSection();
for (Element el : pubSec.getOwnedElements()) {
if (el instanceof DataImplementation || el instanceof DataType) {
components.add((NamedElement) el);
}
}
for (AnnexLibrary annex : AnnexUtil.getAllActualAnnexLibraries(((AadlPackage) ctx), AgreePackage.eINSTANCE.getAgreeContractLibrary())) {
AgreeContract contract = (AgreeContract) ((AgreeContractLibrary) annex).getContract();
components.addAll(getNamedElementsFromSpecs(contract.getSpecs()));
}
components.add((AadlPackage) ctx);
} else {
components.addAll(getNamedElementsFromClassifier((Classifier) ctx, false));
}
return components;
}
Aggregations