Search in sources :

Example 11 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class GetProperties method getSourceLanguage.

public static List<String> getSourceLanguage(final NamedElement ne) {
    try {
        List<String> res = new ArrayList<String>();
        Property sourceLanguage = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_LANGUAGE);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(sourceLanguage);
        for (PropertyExpression propertyExpression : propertyValues) {
            String v = ((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue()).getName();
            res.add(v);
        }
        return res;
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 12 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class GetProperties method getProvidedConnectionQualityOfService.

public static List<EnumerationLiteral> getProvidedConnectionQualityOfService(NamedElement ne) {
    try {
        List<EnumerationLiteral> res = new ArrayList<>();
        Property providedConnQos = lookupPropertyDefinition(ne, DeploymentProperties._NAME, DeploymentProperties.PROVIDED_CONNECTION_QUALITY_OF_SERVICE);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(providedConnQos);
        for (PropertyExpression propertyExpression : propertyValues) {
            res.add((EnumerationLiteral) ((NamedValue) propertyExpression).getNamedValue());
        }
        return res;
    } catch (PropertyLookupException e) {
        return Collections.emptyList();
    }
}
Also used : ArrayList(java.util.ArrayList) PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 13 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class GetProperties method getRateUnit.

public static EnumerationLiteral getRateUnit(final RecordValue ne) {
    EList<BasicPropertyAssociation> fields = ne.getOwnedFieldValues();
    BasicPropertyAssociation rateUnit = getRecordField(fields, "Rate_Unit");
    PropertyExpression res = rateUnit.getValue();
    if (res instanceof NamedValue) {
        return (EnumerationLiteral) ((NamedValue) res).getNamedValue();
    }
    return null;
}
Also used : PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral)

Example 14 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class GetProperties method getConcurrencyControlProtocol.

public static String getConcurrencyControlProtocol(final NamedElement ne) {
    try {
        Property concurrencyControlProtocol = lookupPropertyDefinition(ne, ThreadProperties._NAME, DeploymentProperties.CONCURRENCY_CONTROL_PROTOCOL);
        List<? extends PropertyExpression> propertyValues = ne.getPropertyValueList(concurrencyControlProtocol);
        if (!propertyValues.isEmpty()) {
            return ((EnumerationLiteral) ((NamedValue) propertyValues.iterator().next()).getNamedValue()).getName();
        } else {
            return null;
        }
    } catch (PropertyLookupException e) {
        return null;
    }
}
Also used : BasicProperty(org.osate.aadl2.BasicProperty) Property(org.osate.aadl2.Property) EnumerationLiteral(org.osate.aadl2.EnumerationLiteral) PropertyLookupException(org.osate.aadl2.properties.PropertyLookupException)

Example 15 with NamedValue

use of org.osate.aadl2.NamedValue in project osate2 by osate.

the class PropertyUtils method getSimplePropertyListValue.

/**
 * get non-model proeprty list value
 */
public static PropertyExpression getSimplePropertyListValue(final NamedElement ph, final Property pd) throws InvalidModelException, PropertyNotPresentException, PropertyIsModalException, IllegalStateException, IllegalArgumentException, PropertyDoesNotApplyToHolderException, PropertyIsListException {
    PropertyExpression res;
    if (ph == null) {
        throw new IllegalArgumentException("NamedElement ph cannot be null.");
    }
    res = ph.getSimplePropertyValue(pd);
    if (res instanceof NamedValue) {
        AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
        if (nv instanceof Property) {
            res = ph.getSimplePropertyValue((Property) nv);
        } else if (nv instanceof PropertyConstant) {
            res = ((PropertyConstant) nv).getConstantValue();
        }
    }
    return res;
}
Also used : AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) PropertyExpression(org.osate.aadl2.PropertyExpression) NamedValue(org.osate.aadl2.NamedValue) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) Property(org.osate.aadl2.Property) PropertyConstant(org.osate.aadl2.PropertyConstant)

Aggregations

NamedValue (org.osate.aadl2.NamedValue)41 EnumerationLiteral (org.osate.aadl2.EnumerationLiteral)29 Property (org.osate.aadl2.Property)27 PropertyExpression (org.osate.aadl2.PropertyExpression)24 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)20 PropertyAssociation (org.osate.aadl2.PropertyAssociation)18 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)15 ContainmentPathElement (org.osate.aadl2.ContainmentPathElement)15 ListValue (org.osate.aadl2.ListValue)15 StringLiteral (org.osate.aadl2.StringLiteral)15 BasicProperty (org.osate.aadl2.BasicProperty)13 ContainedNamedElement (org.osate.aadl2.ContainedNamedElement)13 IntegerLiteral (org.osate.aadl2.IntegerLiteral)12 BooleanLiteral (org.osate.aadl2.BooleanLiteral)11 ClassifierValue (org.osate.aadl2.ClassifierValue)11 ModalPropertyValue (org.osate.aadl2.ModalPropertyValue)11 NamedElement (org.osate.aadl2.NamedElement)11 RangeValue (org.osate.aadl2.RangeValue)11 RealLiteral (org.osate.aadl2.RealLiteral)11 RecordValue (org.osate.aadl2.RecordValue)11