Search in sources :

Example 46 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class Issue2288Test method testModeResolution.

@Test
public void testModeResolution() {
    final IPreferenceStore store = OsateCorePlugin.getDefault().getPreferenceStore();
    store.setDefault("behavior_specification", true);
    // annex is turned off
    store.setValue("behavior_specification", false);
    AadlPackage pkg = testHelper.parseFile(PATH + "Issue2288.aadl");
    for (Classifier cl : pkg.getPublicSection().getOwnedClassifiers()) {
        for (AnnexSubclause ac : cl.getOwnedAnnexSubclauses()) {
            if (ac.getName().equalsIgnoreCase("behavior_specification")) {
                if (!ac.getClass().getTypeName().contains("DefaultAnnexSubclause")) {
                    Assert.fail("behavior_specification annex is still being used to parse the file. Expected behavior_specification annex to be turned off per preference test");
                }
            }
        }
    }
    validationHelper.assertNoIssues(pkg);
}
Also used : AadlPackage(org.osate.aadl2.AadlPackage) Classifier(org.osate.aadl2.Classifier) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) AnnexSubclause(org.osate.aadl2.AnnexSubclause) Test(org.junit.Test)

Example 47 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class GetProperties method getAllowedMemoryBindingClass.

public static List<Classifier> getAllowedMemoryBindingClass(final InstanceObject io) {
    Property allowedMemoryBindingClass = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_MEMORY_BINDING_CLASS);
    ArrayList<Classifier> components = new ArrayList<>();
    List<? extends PropertyExpression> propertyValues;
    try {
        propertyValues = io.getPropertyValueList(allowedMemoryBindingClass);
    } catch (Exception e) {
        return components;
    }
    for (PropertyExpression propertyExpression : propertyValues) {
        components.add(((ClassifierValue) propertyExpression).getClassifier());
    }
    return components;
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException) PropertyNotPresentException(org.osate.aadl2.properties.PropertyNotPresentException)

Example 48 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class GetProperties method sumElementsDataSize.

private static double sumElementsDataSize(final NamedElement ne, UnitLiteral unit, Property DataSize, Property SourceDataSize, int nesting) {
    double res = 0.0;
    Classifier cl = null;
    if (ne instanceof Classifier) {
        cl = (Classifier) ne;
    } else if (ne instanceof FeatureInstance) {
        cl = ((FeatureInstance) ne).getFeature().getAllClassifier();
    } else if (ne instanceof Feature) {
        cl = ((Feature) ne).getClassifier();
    } else if (ne instanceof DataSubcomponent) {
        cl = ((DataSubcomponent) ne).getClassifier();
    }
    if (cl != null) {
        if (cl instanceof FeatureGroupType) {
            EList<Feature> fl = ((FeatureGroupType) cl).getAllFeatures();
            for (Feature f : fl) {
                res = res + getDataSize(f, unit, DataSize, SourceDataSize, nesting);
            }
        } else if (cl instanceof DataImplementation) {
            for (Subcomponent ds : ((DataImplementation) cl).getAllSubcomponents()) {
                if (!AadlUtil.isSameOrExtends(cl, ds.getAllClassifier())) {
                    res = res + getDataSize(ds, unit, DataSize, SourceDataSize, nesting);
                }
            }
        }
    }
    return res;
}
Also used : FeatureInstance(org.osate.aadl2.instance.FeatureInstance) DataSubcomponent(org.osate.aadl2.DataSubcomponent) DataSubcomponent(org.osate.aadl2.DataSubcomponent) Subcomponent(org.osate.aadl2.Subcomponent) FeatureGroupType(org.osate.aadl2.FeatureGroupType) DataImplementation(org.osate.aadl2.DataImplementation) ComponentClassifier(org.osate.aadl2.ComponentClassifier) Classifier(org.osate.aadl2.Classifier) Feature(org.osate.aadl2.Feature)

Example 49 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class PropertyUtils method getContainedSimplePropertyValue.

/**
 * get a property association from the properties section of the containing classifier if the context.
 * This method has been designed to work with end points of connections, i.e., consisting of a target and a context.
 * The context must be a NamedElement in its containing classifier, i.e., a feature, feature group, subcomponent.
 * The property holder is assumed to be contained in the context object, e.g., a feature in afeature group or a data subcomponent in a port, or feature in a subcomponent.
 * The association must match the property definition.
 * if the context is null then the containing classifier of the target is used and the path must be one or no path.
 * The applies to clause of the property association must be of size 2 if the context is set and point to the context and then the property holder.
 * The property value of the property association is assumed not to be modal.
 * @param context NamedElement whose containing classifier's properties section is searched for the desired property
 * @param target NamedElement the model element to which the property is applied to via the applies to clause
 * @param pd Property the property definition
 * @return
 */
public static PropertyExpression getContainedSimplePropertyValue(final NamedElement context, final NamedElement target, final Property pd) {
    if (context == null) {
        return target.getNonModalPropertyValue(pd);
    }
    Classifier cl = AadlUtil.getContainingClassifier(context);
    EList<PropertyAssociation> props = cl.getAllPropertyAssociations();
    for (PropertyAssociation propertyAssociation : props) {
        if (propertyAssociation.getProperty().equals(pd)) {
            // we found a property with the corect type
            // now we need to check whether the applies to points to the holder
            EList<ContainedNamedElement> appliestos = propertyAssociation.getAppliesTos();
            for (ContainedNamedElement containedNamedElement : appliestos) {
                EList<ContainmentPathElement> cpes = containedNamedElement.getContainmentPathElements();
                if (cpes.size() == 2) {
                    NamedElement pathcxt = cpes.get(0).getNamedElement();
                    NamedElement pathelement = cpes.get(1).getNamedElement();
                    if (context.equals(pathcxt) && target.equals(pathelement)) {
                        EList<ModalPropertyValue> vallist = propertyAssociation.getOwnedValues();
                        if (!vallist.isEmpty()) {
                            ModalPropertyValue elem = vallist.get(0);
                            PropertyExpression res = elem.getOwnedValue();
                            if (res instanceof NamedValue) {
                                AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
                                if (nv instanceof Property) {
                                    res = target.getNonModalPropertyValue((Property) nv);
                                } else if (nv instanceof PropertyConstant) {
                                    res = ((PropertyConstant) nv).getConstantValue();
                                }
                            }
                            return res;
                        }
                    }
                }
            }
        }
    }
    return null;
}
Also used : ModalPropertyValue(org.osate.aadl2.ModalPropertyValue) PropertyAssociation(org.osate.aadl2.PropertyAssociation) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) NamedValue(org.osate.aadl2.NamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) Classifier(org.osate.aadl2.Classifier) PropertyConstant(org.osate.aadl2.PropertyConstant) PropertyExpression(org.osate.aadl2.PropertyExpression) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Property(org.osate.aadl2.Property)

Example 50 with Classifier

use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.

the class PropertiesLinkingService method findClassifier.

/**
 * find the classifier taking into account rename aliases
 * We do not check whether the referenced package is in the with clause. This is checked separately
 * This is a helper method for findFeatureGroupType and findComponentClassifier
 * @param context classifier reference context
 * @param reference identifying attribute of reference
 * @param name name to be resolved
 * @return Classifier or null
 */
public Classifier findClassifier(EObject context, EReference reference, String name) {
    Namespace scope = AadlUtil.getContainingTopLevelNamespace(context);
    EObject e = getIndexedObject(context, reference, name);
    if (e != null && e instanceof Classifier && reference.getEReferenceType().isSuperTypeOf(e.eClass())) {
        // the result satisfied the expected class
        Namespace ns = AadlUtil.getContainingTopLevelNamespace(e);
        if (ns instanceof PrivatePackageSection && scope != ns) {
            return null;
        }
        return (Classifier) e;
    }
    // need to do a local lookup as it was not found in the index.
    String packname = null;
    String cname = name;
    final int idx = name.lastIndexOf("::");
    if (idx != -1) {
        packname = name.substring(0, idx);
        cname = name.substring(idx + 2);
        // if rename is not a package rename, but component type rename then all is treated as component ID
        if (cname.equalsIgnoreCase("all")) {
            return null;
        }
    }
    // NOTE: checking whether the referenced package is imported is done by the validator.
    if (context instanceof NamedElement) {
        // then stop. Otherwise we have a cycle.
        if (((NamedElement) context).getName() == null) {
            if (packname == null || scope.getName().equalsIgnoreCase(packname)) {
                return null;
            }
        }
    }
    if (e == null && scope instanceof PackageSection) {
        // the reference is from inside a package section. Lookup by identifier with or without qualification
        e = findNamedElementInAadlPackage(packname, cname, scope);
        if (e != null && e instanceof Classifier && reference.getEReferenceType().isSuperTypeOf(e.eClass())) {
            // the result satisfied the expected class
            return (Classifier) e;
        }
    }
    return null;
}
Also used : PackageSection(org.osate.aadl2.PackageSection) PrivatePackageSection(org.osate.aadl2.PrivatePackageSection) PublicPackageSection(org.osate.aadl2.PublicPackageSection) EObject(org.eclipse.emf.ecore.EObject) Classifier(org.osate.aadl2.Classifier) ComponentClassifier(org.osate.aadl2.ComponentClassifier) PrivatePackageSection(org.osate.aadl2.PrivatePackageSection) ContainedNamedElement(org.osate.aadl2.ContainedNamedElement) NamedElement(org.osate.aadl2.NamedElement) Namespace(org.osate.aadl2.Namespace)

Aggregations

Classifier (org.osate.aadl2.Classifier)203 ComponentClassifier (org.osate.aadl2.ComponentClassifier)90 ComponentImplementation (org.osate.aadl2.ComponentImplementation)49 NamedElement (org.osate.aadl2.NamedElement)40 AadlPackage (org.osate.aadl2.AadlPackage)38 Subcomponent (org.osate.aadl2.Subcomponent)37 ComponentType (org.osate.aadl2.ComponentType)34 EObject (org.eclipse.emf.ecore.EObject)31 ArrayList (java.util.ArrayList)29 BasicEList (org.eclipse.emf.common.util.BasicEList)28 Feature (org.osate.aadl2.Feature)26 DataClassifier (org.osate.aadl2.DataClassifier)22 FeatureGroupType (org.osate.aadl2.FeatureGroupType)21 ProcessorClassifier (org.osate.aadl2.ProcessorClassifier)21 AnnexSubclause (org.osate.aadl2.AnnexSubclause)17 Element (org.osate.aadl2.Element)17 EList (org.eclipse.emf.common.util.EList)15 ComponentInstance (org.osate.aadl2.instance.ComponentInstance)15 FeatureGroup (org.osate.aadl2.FeatureGroup)14 PropertyExpression (org.osate.aadl2.PropertyExpression)14