Search in sources :

Example 11 with BehaviorVariable

use of org.osate.ba.aadlba.BehaviorVariable in project osate2 by osate.

the class AadlBaNameResolver method baVariableResolver.

private boolean baVariableResolver(Identifier id, boolean hasToReport) {
    String variableName = id.getId();
    BehaviorVariable v = AadlBaVisitors.findBehaviorVariable(_ba, variableName);
    if (v != null) {
        id.setBaRef(v);
        return true;
    } else {
        if (hasToReport) {
            reportNameError(id, variableName);
        }
        return false;
    }
}
Also used : BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable)

Example 12 with BehaviorVariable

use of org.osate.ba.aadlba.BehaviorVariable in project osate2 by osate.

the class AadlBaNameResolver method refResolver.

// Resolves Reference objects (arrayable identifiers)
// within parent component's features ones and ba's variables ones and
// for/forall's iterative variable scope handler.
private boolean refResolver(Classifier parentContainer, Reference ref) {
    boolean result = true;
    boolean currentIdResult = false;
    ListIterator<ArrayableIdentifier> it = ref.getIds().listIterator();
    // Checks ArrayableIdentifier objects.
    while (it.hasNext()) {
        ArrayableIdentifier id = it.next();
        // Can't resolve within a null parent classifier.
        if (parentContainer == null) {
            result = false;
            reportNameError(id, id.getId());
            break;
        }
        if (parentContainer == _baParentContainer) {
            currentIdResult = identifierBaResolver(id, false);
        }
        if (!currentIdResult) {
            currentIdResult = identifierComponentResolver(id, parentContainer, true);
        }
        if (id.isSetArrayIndexes()) {
            // Checks array indexes names.
            for (IntegerValue index : id.getArrayIndexes()) {
                // Recursive call.
                result &= integerValueResolver(index);
            }
        }
        // If the current id is found, fetch the container for the next id.
        if (currentIdResult && it.hasNext()) {
            Element el = AadlBaTypeChecker.getBindedElement(id);
            // not been type checked already.
            if (el instanceof BehaviorVariable) {
                QualifiedNamedElement qne = (QualifiedNamedElement) ((BehaviorVariable) el).getDataClassifier();
                parentContainer = (Classifier) qne.getOsateRef();
            } else if (el instanceof IterativeVariable) {
                IterativeVariable itv = (IterativeVariable) el;
                QualifiedNamedElement qne = (QualifiedNamedElement) itv.getDataClassifier();
                parentContainer = (Classifier) qne.getOsateRef();
            } else {
                parentContainer = AadlBaUtils.getClassifier(el, parentContainer);
            }
        }
        // Add the current id result to the global result.
        result &= currentIdResult;
        // Reset.
        currentIdResult = false;
        // Don't continue if the current id is not found.
        if (result == false) {
            break;
        }
    }
    // Binds with the last id reference.
    ArrayableIdentifier lastId = ref.getIds().get((ref.getIds().size() - 1));
    ref.setOsateRef(lastId.getOsateRef());
    ref.setBaRef(lastId.getBaRef());
    return result;
}
Also used : IterativeVariable(org.osate.ba.aadlba.IterativeVariable) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) IntegerValue(org.osate.ba.aadlba.IntegerValue) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) DeclarativeBehaviorElement(org.osate.ba.declarative.DeclarativeBehaviorElement) NamedElement(org.osate.aadl2.NamedElement) Element(org.osate.aadl2.Element) BehaviorElement(org.osate.ba.aadlba.BehaviorElement) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) DataClassifier(org.osate.aadl2.DataClassifier) ProcessorClassifier(org.osate.aadl2.ProcessorClassifier) ArrayableIdentifier(org.osate.ba.declarative.ArrayableIdentifier)

Example 13 with BehaviorVariable

use of org.osate.ba.aadlba.BehaviorVariable in project osate2 by osate.

the class BehaviorVariablePropertySection method getDataClassifierLabel.

private static String getDataClassifierLabel(final List<BehaviorVariable> behaviorVariables) {
    final Iterator<BehaviorVariable> it = behaviorVariables.iterator();
    BehaviorVariable bv = it.next();
    final DataClassifier dc = bv.getDataClassifier();
    while (it.hasNext()) {
        bv = it.next();
        // If variable data classifiers are not the same, set to multiple
        if (dc != bv.getDataClassifier()) {
            return "<Multiple>";
        }
    }
    if (dc instanceof QualifiedNamedElement) {
        final QualifiedNamedElement qualNamedElement = (QualifiedNamedElement) dc;
        final Identifier baNamespace = qualNamedElement.getBaNamespace();
        final Identifier baName = qualNamedElement.getBaName();
        return new StringBuilder(baNamespace == null ? "" : baNamespace.getId()).append("::").append(baName == null ? "" : baName.getId()).toString();
    }
    return dc.getQualifiedName();
}
Also used : QualifiedNamedElement(org.osate.ba.declarative.QualifiedNamedElement) Identifier(org.osate.ba.declarative.Identifier) BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) DataClassifier(org.osate.aadl2.DataClassifier)

Example 14 with BehaviorVariable

use of org.osate.ba.aadlba.BehaviorVariable in project osate2 by osate.

the class BehaviorVariableHandler method delete.

@Override
public void delete(final CustomDeleteContext ctx) {
    final BehaviorAnnex behaviorAnnex = ctx.getContainerBusinessObject(BehaviorAnnex.class).orElseThrow();
    // Find variable by URI.
    final BehaviorVariable behaviorVariable = (BehaviorVariable) behaviorAnnex.eResource().getResourceSet().getEObject(EcoreUtil.getURI(ctx.getReadonlyBoToDelete(BehaviorVariable.class).orElseThrow()), true);
    EcoreUtil.remove(behaviorVariable);
    if (behaviorAnnex.getVariables().isEmpty()) {
        behaviorAnnex.unsetVariables();
    }
}
Also used : BehaviorVariable(org.osate.ba.aadlba.BehaviorVariable) BehaviorAnnex(org.osate.ba.aadlba.BehaviorAnnex)

Aggregations

BehaviorVariable (org.osate.ba.aadlba.BehaviorVariable)14 DataClassifier (org.osate.aadl2.DataClassifier)7 QualifiedNamedElement (org.osate.ba.declarative.QualifiedNamedElement)6 NamedElement (org.osate.aadl2.NamedElement)5 Classifier (org.osate.aadl2.Classifier)4 ComponentClassifier (org.osate.aadl2.ComponentClassifier)4 Element (org.osate.aadl2.Element)4 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)4 BehaviorElement (org.osate.ba.aadlba.BehaviorElement)4 PropertyAssociation (org.osate.aadl2.PropertyAssociation)3 ArrayableIdentifier (org.osate.ba.declarative.ArrayableIdentifier)3 Identifier (org.osate.ba.declarative.Identifier)3 AbstractFeature (org.osate.aadl2.AbstractFeature)2 ArrayDimension (org.osate.aadl2.ArrayDimension)2 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)2 ClassifierFeature (org.osate.aadl2.ClassifierFeature)2 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)2 DataSubcomponent (org.osate.aadl2.DataSubcomponent)2 Feature (org.osate.aadl2.Feature)2 BehaviorAnnex (org.osate.ba.aadlba.BehaviorAnnex)2