use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class PropertyImpl method getPropertyValue.
private PropertyAcc getPropertyValue(EvaluationContext ctx) throws IllegalStateException, InvalidModelException, PropertyDoesNotApplyToHolderException, IllegalArgumentException {
// Error if the property is not acceptable
final PropertyAcc pas = new PropertyAcc(this);
getPropertyValueInternal(ctx, pas);
return pas;
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class PropertyImpl method getPropertyValueInternal.
public final void getPropertyValueInternal(EvaluationContext ctx, final PropertyAcc paa) throws InvalidModelException {
InstanceObject io = ctx.getInstanceObject();
/*
* Only relevant for connection instances
*/
if (ctx.getSCProp() != null) {
if (paa.add(ctx.getSCProp())) {
return;
}
}
/*
* First see if the property is defined locally in the instance. Such
* local property associations arise from component property
* associations in the declarative spec, from explicit programmatic
* setting of the property, or as cached results from earlier property
* lookups.
*/
if (paa.addLocal(io)) {
return;
}
getPropertyValueFromDeclarativeModel(ctx, paa);
/*
* If the property is "inherit", get it from the enclosing component
* instance. Don't short-circuit this step because the property caching
* during instantiation doesn't catch contained property values that may
* be attached to an ancestor instance and that might be inherited by
* this instance.
*/
if (isInherit()) {
io = (InstanceObject) io.eContainer();
if (io != null) {
getPropertyValueInternal(new EvaluationContext(io, ctx.getClassifierCache()), paa);
}
}
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class PropertyImpl method getPropertyValueFromDeclarativeModel.
protected void getPropertyValueFromDeclarativeModel(EvaluationContext ctx, PropertyAcc pas) throws InvalidModelException {
InstanceObject io = ctx.getInstanceObject();
List<? extends NamedElement> compDecls = io.getInstantiatedObjects();
if (compDecls == null) {
}
// Here we assume compDecls is empty or has only one element
if (!compDecls.isEmpty()) {
NamedElement compDecl = compDecls.get(0);
if (compDecl == null) {
return;
}
InstantiatedClassifier ic = ctx.getClassifierCache().get(io);
Classifier cl = (ic == null) ? null : ic.getClassifier();
if (compDecl instanceof Subcomponent) {
((SubcomponentImpl) compDecl).getPropertyValue(this, pas, cl, false);
} else if (compDecl instanceof FeatureGroup) {
((FeatureGroupImpl) compDecl).getPropertyValue(this, pas, cl, false);
} else if (compDecl instanceof Feature) {
((FeatureImpl) compDecl).getPropertyValue(this, pas, cl, false);
} else if (compDecl instanceof PortConnection) {
((PortConnectionImpl) compDecl).getPropertyValue(this, pas);
} else {
compDecl.getPropertyValueInternal(this, pas, true);
}
}
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class SubcomponentImpl method getPropertyValue.
public void getPropertyValue(Property prop, PropertyAcc pas, Classifier cl, final boolean all) {
final ComponentImplementation owner = (ComponentImplementation) getContainingClassifier();
if (pas.addLocalContained(this, owner)) {
return;
}
// get local value
if (pas.addLocal(this)) {
return;
}
// collect values from refined subcomponents
Subcomponent refined = getRefined();
while (refined != null) {
if (pas.addLocal(refined)) {
return;
}
refined = refined.getRefined();
}
// get values from classifier
if (cl != null) {
cl.getPropertyValueInternal(prop, pas, true, all);
} else {
final ComponentClassifier cc = getClassifier();
if (cc != null) {
cc.getPropertyValueInternal(prop, pas, true, all);
}
}
}
use of org.osate.aadl2.properties.PropertyAcc in project osate2 by osate.
the class GetProperties method getPlatform.
public static String getPlatform(final NamedElement ne) {
try {
Property sn = lookupPropertyDefinition(ne, SEI._NAME, SEI.PLATFORM);
PropertyAcc pacc = ne.getPropertyValue(sn);
if (pacc.getAssociations().size() > 0) {
ModalPropertyValue mdv = pacc.getAssociations().get(0).getOwnedValues().get(0);
PropertyExpression pe = mdv.getOwnedValue();
StringLiteral sl = (StringLiteral) pe;
return sl.getValue();
}
return null;
} catch (PropertyLookupException e) {
return null;
}
}
Aggregations