use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow in project osate2 by osate.
the class CombinedErrorModelSubclause method create.
/**
* Creates an instance for the specified classifier. Processes error model subclauses owned or inherited by the classifier.
* @param classifier the classifier for which to create the instance.
* @return the new instance
*/
public static CombinedErrorModelSubclause create(final Classifier classifier) {
final Map<String, PropagationPoint> points = new HashMap<>();
final Map<String, PropagationPath> paths = new HashMap<>();
final Map<String, ErrorFlow> flows = new HashMap<>();
final PropagationNode propagations = new PropagationNode();
final Set<KeywordPropagationPointType> usedKeywordPointTypes = new HashSet<>();
final EList<Classifier> classifiers = classifier.getSelfPlusAllExtended();
if (classifier instanceof ComponentImplementation) {
final ComponentType ct = ((ComponentImplementation) classifier).getType();
if (ct != null) {
classifiers.addAll(ct.getSelfPlusAllExtended());
}
}
final boolean[] subclauseFound = { false };
for (final Classifier tmpClassifier : Lists.reverse(classifiers)) {
ErrorModelGeUtil.getAllErrorModelSubclauses(tmpClassifier).forEachOrdered(subclause -> {
subclauseFound[0] = true;
addAllToMap(subclause.getPoints(), points);
addAllToMap(subclause.getPaths(), paths);
addAllToMap(subclause.getFlows(), flows);
// Create a tree for error propagations
for (final ErrorPropagation propagation : subclause.getPropagations()) {
propagations.put(propagation);
}
//
for (final ErrorPropagation propagation : subclause.getPropagations()) {
if (propagation.getKind() != null) {
usedKeywordPointTypes.add(KeywordPropagationPointType.getByKind(propagation.getKind()));
}
}
for (final ErrorFlow errorFlow : subclause.getFlows()) {
if (errorFlow instanceof ErrorPath) {
final ErrorPath errorPath = (ErrorPath) errorFlow;
if (errorPath.isAllIncoming() || errorPath.isAllOutgoing()) {
usedKeywordPointTypes.add(KeywordPropagationPointType.ALL);
}
if (errorPath.getIncoming() != null) {
usedKeywordPointTypes.add(KeywordPropagationPointType.getByKind(errorPath.getIncoming().getKind()));
}
if (errorPath.getOutgoing() != null) {
usedKeywordPointTypes.add(KeywordPropagationPointType.getByKind(errorPath.getOutgoing().getKind()));
}
} else if (errorFlow instanceof ErrorSink) {
final ErrorSink errorSink = (ErrorSink) errorFlow;
if (errorSink.isAllIncoming()) {
usedKeywordPointTypes.add(KeywordPropagationPointType.ALL);
} else if (errorSink.getIncoming() != null) {
usedKeywordPointTypes.add(KeywordPropagationPointType.getByKind(errorSink.getIncoming().getKind()));
}
} else if (errorFlow instanceof ErrorSource) {
final ErrorSource errorSrc = (ErrorSource) errorFlow;
if (errorSrc.isAll()) {
usedKeywordPointTypes.add(KeywordPropagationPointType.ALL);
} else if (errorSrc.getSourceModelElement() instanceof ErrorPropagation) {
usedKeywordPointTypes.add(KeywordPropagationPointType.getByKind(((ErrorPropagation) errorSrc.getSourceModelElement()).getKind()));
}
}
}
});
}
return new CombinedErrorModelSubclause(subclauseFound[0], points, paths, flows, usedKeywordPointTypes, propagations);
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow in project osate2 by osate.
the class EMV2Util method findErrorFlowFrom.
/**
* find the error flow whose incoming error propagation point is flowSource
* @param eps List of error propagations
* @param flowSource ErrorPropagation
* @return ErrorFlow list
*/
public static EList<ErrorFlow> findErrorFlowFrom(Collection<ErrorFlow> efs, ErrorPropagation flowSource) {
EList<ErrorFlow> result = new BasicEList<ErrorFlow>();
for (ErrorFlow ef : efs) {
ErrorPropagation eprop = null;
if (ef instanceof ErrorPath) {
ErrorPath ep = (ErrorPath) ef;
eprop = ep.getIncoming();
} else if (ef instanceof ErrorSink) {
ErrorSink es = (ErrorSink) ef;
eprop = es.getIncoming();
}
if (eprop != null && eprop == flowSource) {
result.add(ef);
}
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow in project osate2 by osate.
the class EMV2Util method findReverseErrorFlowFrom.
/**
* find the error flow whose outgoing error propagation point is flowSource
* @param eps List of error propagations
* @param flowSource ErrorPropagation
* @return ErrorFlow list
*/
public static EList<ErrorFlow> findReverseErrorFlowFrom(Collection<ErrorFlow> efs, ErrorPropagation flowSource) {
EList<ErrorFlow> result = new BasicEList<ErrorFlow>();
for (ErrorFlow ef : efs) {
ErrorPropagation eprop = null;
boolean isall = false;
if (ef instanceof ErrorPath) {
ErrorPath ep = (ErrorPath) ef;
eprop = ep.getOutgoing();
isall = ep.isAllOutgoing();
} else if (ef instanceof ErrorSource && ((ErrorSource) ef).getSourceModelElement() instanceof ErrorPropagation) {
ErrorSource es = (ErrorSource) ef;
eprop = (ErrorPropagation) es.getSourceModelElement();
isall = es.isAll();
}
if ((eprop != null && eprop == flowSource) || isall) {
result.add(ef);
}
}
return result;
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow in project osate2 by osate.
the class EMV2Util method getAllErrorFlows.
/**
* return list of error flow including those inherited from classifiers being extended
* @param cl Classifier
* @return Collection<ErrorFlow> list of error flow
*/
public static Collection<ErrorFlow> getAllErrorFlows(Classifier cl) {
HashMap<String, ErrorFlow> result = new LinkedHashMap<>();
EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
for (ErrorModelSubclause errorModelSubclause : emslist) {
EList<ErrorFlow> eflist = errorModelSubclause.getFlows();
for (ErrorFlow errorFlow : eflist) {
if (!result.containsKey(errorFlow.getName())) {
result.put(errorFlow.getName(), errorFlow);
}
}
}
return result.values();
}
use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow in project osate2 by osate.
the class EMV2Util method getAllErrorSources.
/**
* return list of error sources including those inherited from classifiers being extended
* @param cl Classifier
* @return Collection<ErrorSource> list of error flow
*/
public static Collection<ErrorSource> getAllErrorSources(Classifier cl) {
HashMap<String, ErrorSource> result = new LinkedHashMap<>();
EList<ErrorModelSubclause> emslist = getAllContainingClassifierEMV2Subclauses(cl);
for (ErrorModelSubclause errorModelSubclause : emslist) {
EList<ErrorFlow> eflist = errorModelSubclause.getFlows();
for (ErrorFlow errorFlow : eflist) {
if (errorFlow instanceof ErrorSource) {
if (!result.containsKey(errorFlow.getName())) {
result.put(errorFlow.getName(), (ErrorSource) errorFlow);
}
}
}
}
return result.values();
}
Aggregations