Search in sources :

Example 6 with ErrorPath

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath in project osate2 by osate.

the class ErrorFlowHandler method getGraphicalConfiguration.

@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
    final ErrorFlow bo = ctx.getBusinessObjectContext().getBusinessObject(ErrorFlow.class).get();
    final BusinessObjectContext classifierBoc = ctx.getBusinessObjectContext().getParent();
    if (classifierBoc == null) {
        return Optional.empty();
    }
    // Determine the type of graphic and the source and destination of the connection
    final ErrorFlowEnd src;
    final ErrorFlowEnd dst;
    final Graphic graphic;
    if (bo instanceof ErrorSource) {
        graphic = SOURCE_GRAPHIC;
        final ErrorSource es = (ErrorSource) bo;
        src = getErrorFlowEnd(ctx.getQueryService(), classifierBoc, es.isAll(), es.getSourceModelElement()).orElse(null);
        dst = null;
    } else if (bo instanceof ErrorSink) {
        graphic = SINK_GRAPHIC;
        final ErrorSink es = (ErrorSink) bo;
        src = getErrorFlowEnd(ctx.getQueryService(), classifierBoc, es.isAllIncoming(), es.getIncoming()).orElse(null);
        dst = null;
    } else if (bo instanceof ErrorPath) {
        graphic = PATH_GRAPHIC;
        final ErrorPath ep = (ErrorPath) bo;
        src = getErrorFlowEnd(ctx.getQueryService(), classifierBoc, ep.isAllIncoming(), ep.getIncoming()).orElse(null);
        dst = getErrorFlowEnd(ctx.getQueryService(), classifierBoc, ep.isAllOutgoing(), ep.getOutgoing()).orElse(null);
    } else {
        return Optional.empty();
    }
    // Determine style
    final StyleBuilder sb = StyleBuilder.create(GraphicalExtensionUtil.isInherited(ctx.getBusinessObjectContext()) ? GraphicalExtensionUtil.STYLE_INHERITED_ELEMENT : Style.EMPTY).lineWidth(4.0);
    final boolean partial = (src != null && src.partial) || (dst != null && dst.partial);
    if (partial) {
        sb.dotted();
    }
    return Optional.of(GraphicalConfigurationBuilder.create().graphic(graphic).style(sb.build()).defaultDockingPosition(DockingPosition.ANY).source(src == null ? null : src.boc).destination(dst == null ? null : dst.boc).build());
}
Also used : ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ErrorFlow(org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow) Graphic(org.osate.ge.graphics.Graphic) StyleBuilder(org.osate.ge.graphics.StyleBuilder) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) BusinessObjectContext(org.osate.ge.BusinessObjectContext) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)

Example 7 with ErrorPath

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath in project osate2 by osate.

the class ErrorPropagationHandler method canDelete.

@Override
public boolean canDelete(final CanDeleteContext ctx) {
    final ErrorPropagation bo = ctx.getBusinessObject(ErrorPropagation.class).get();
    // Don't allow deleting if there exists an error flow that references the error propagation
    final CombinedErrorModelSubclause combined = CombinedErrorModelSubclause.create(bo.getContainingClassifier());
    return !combined.getFlows().anyMatch(f -> {
        if (f instanceof ErrorSource) {
            final ErrorSource src = (ErrorSource) f;
            return src.getSourceModelElement() == bo;
        } else if (f instanceof ErrorSink) {
            final ErrorSink snk = (ErrorSink) f;
            return snk.getIncoming() == bo;
        } else if (f instanceof ErrorPath) {
            final ErrorPath path = (ErrorPath) f;
            return path.getIncoming() == bo || path.getOutgoing() == bo;
        }
        return false;
    });
}
Also used : GetNameForDiagramContext(org.osate.ge.businessobjecthandling.GetNameForDiagramContext) BusinessObjectHandler(org.osate.ge.businessobjecthandling.BusinessObjectHandler) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) CanDeleteContext(org.osate.ge.businessobjecthandling.CanDeleteContext) GraphicalConfiguration(org.osate.ge.GraphicalConfiguration) Style(org.osate.ge.graphics.Style) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink) Strings(com.google.common.base.Strings) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) Graphic(org.osate.ge.graphics.Graphic) GetGraphicalConfigurationContext(org.osate.ge.businessobjecthandling.GetGraphicalConfigurationContext) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) GetNameContext(org.osate.ge.businessobjecthandling.GetNameContext) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference) CanCopyContext(org.osate.ge.businessobjecthandling.CanCopyContext) LabelBuilder(org.osate.ge.graphics.LabelBuilder) GraphicalConfigurationBuilder(org.osate.ge.GraphicalConfigurationBuilder) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) GraphicalExtensionUtil(org.osate.ge.aadl2.GraphicalExtensionUtil) FeatureorPPReference(org.osate.xtext.aadl2.errormodel.errorModel.FeatureorPPReference) CanonicalBusinessObjectReference(org.osate.ge.CanonicalBusinessObjectReference) StyleBuilder(org.osate.ge.graphics.StyleBuilder) IsApplicableContext(org.osate.ge.businessobjecthandling.IsApplicableContext) ReferenceContext(org.osate.ge.businessobjecthandling.ReferenceContext) Optional(java.util.Optional) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) CombinedErrorModelSubclause(org.osate.ge.errormodel.combined.CombinedErrorModelSubclause) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)

Example 8 with ErrorPath

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath 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);
}
Also used : ComponentImplementation(org.osate.aadl2.ComponentImplementation) PropagationPath(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPath) ComponentType(org.osate.aadl2.ComponentType) HashMap(java.util.HashMap) ErrorFlow(org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow) Classifier(org.osate.aadl2.Classifier) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink) ErrorSource(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource) PropagationPoint(org.osate.xtext.aadl2.errormodel.errorModel.PropagationPoint) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) KeywordPropagationPointType(org.osate.ge.errormodel.model.KeywordPropagationPointType) HashSet(java.util.HashSet)

Example 9 with ErrorPath

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath in project osate2 by osate.

the class EMV2Util method mapToken.

/**
 *  figure out the target typetoken based on the source and type mappings
 * Path can be a connection instance, a flow spec instance, or an error flow
 * If null or no mapping found, then use source type token
 * @param path connection instance, flow spec instance, error flow
 * @param path path of mapping
 * @return TypeToken
 */
public static TypeToken mapToken(TypeToken sourceToken, EObject path) {
    TypeToken result = sourceToken;
    if (path instanceof ConnectionInstance) {
        if (sourceToken != null) {
            // TODO lookup type transformations for connections and use them to determine target type
            ConnectionReference connref = Aadl2InstanceUtil.getTopConnectionReference((ConnectionInstance) path);
            ComponentInstance parentci = connref.getContext();
            TypeTransformationSet tts = getAllTypeTransformationSet(parentci);
            result = EMV2TypeSetUtil.mapTypeToken(sourceToken, tts);
        }
    } else if (path instanceof ErrorPath) {
        ErrorPath epath = (ErrorPath) path;
        // map the token
        TypeSet ttup = epath.getTargetToken();
        if (ttup == null) {
            // map token via tms
            TypeMappingSet tms = getUseMappings(epath);
            if (tms != null) {
                result = EMV2TypeSetUtil.mapTypeToken(sourceToken, tms);
            }
        } else {
            result = ttup.getTypeTokens().get(0);
        }
    } else if (path instanceof FlowSpecificationInstance) {
    // pass on source token
    }
    return result;
}
Also used : ConnectionInstance(org.osate.aadl2.instance.ConnectionInstance) TypeTransformationSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeTransformationSet) TypeToken(org.osate.xtext.aadl2.errormodel.errorModel.TypeToken) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) TypeSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeSet) ComponentInstance(org.osate.aadl2.instance.ComponentInstance) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) TypeMappingSet(org.osate.xtext.aadl2.errormodel.errorModel.TypeMappingSet) FlowSpecificationInstance(org.osate.aadl2.instance.FlowSpecificationInstance)

Example 10 with ErrorPath

use of org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath 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;
}
Also used : ErrorFlow(org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow) BasicEList(org.eclipse.emf.common.util.BasicEList) ErrorPath(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath) ErrorPropagation(org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation) ErrorSink(org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)

Aggregations

ErrorPath (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPath)11 ErrorPropagation (org.osate.xtext.aadl2.errormodel.errorModel.ErrorPropagation)10 ErrorFlow (org.osate.xtext.aadl2.errormodel.errorModel.ErrorFlow)8 ErrorSink (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSink)6 ErrorSource (org.osate.xtext.aadl2.errormodel.errorModel.ErrorSource)5 TypeSet (org.osate.xtext.aadl2.errormodel.errorModel.TypeSet)5 TypeToken (org.osate.xtext.aadl2.errormodel.errorModel.TypeToken)5 Collection (java.util.Collection)3 BasicEList (org.eclipse.emf.common.util.BasicEList)3 Classifier (org.osate.aadl2.Classifier)3 Optional (java.util.Optional)2 EObject (org.eclipse.emf.ecore.EObject)2 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)2 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)2 DirectionType (org.osate.aadl2.DirectionType)2 NamedElement (org.osate.aadl2.NamedElement)2 FeatureInstance (org.osate.aadl2.instance.FeatureInstance)2 Graphic (org.osate.ge.graphics.Graphic)2 StyleBuilder (org.osate.ge.graphics.StyleBuilder)2 EMV2PathElement (org.osate.xtext.aadl2.errormodel.errorModel.EMV2PathElement)2