use of org.osate.aadl2.Subcomponent in project osate2 by osate.
the class AadlPropertyResolver method processContainedPropertyAssociationsInChildren.
private void processContainedPropertyAssociationsInChildren(final BusinessObjectContext q) {
// Process contained property associations contained in children
for (final BusinessObjectContext childQueryable : q.getChildren()) {
final Object childBo = childQueryable.getBusinessObject();
if (childBo instanceof InstanceObject) {
processPropertyAssociationsForInstanceObjectsNotInTree(childQueryable, (InstanceObject) childBo);
} else {
if (childBo instanceof Subcomponent || childBo instanceof FeatureGroup) {
final NamedElement childNamedElement = (NamedElement) childBo;
// Handle refinements
RefinableElement tmpRefinable = (RefinableElement) childNamedElement;
do {
processDeclarativeContainedPropertyAssociations(childQueryable, tmpRefinable.getOwnedPropertyAssociations());
tmpRefinable = tmpRefinable.getRefinedElement();
} while (tmpRefinable != null);
// Process contained property associations contained in the element's classifier
if (childBo instanceof FeatureGroup) {
final FeatureGroupType featureGroupType = AadlPrototypeUtil.getFeatureGroupType(AadlPrototypeUtil.getPrototypeBindingContext(childQueryable), (FeatureGroup) childBo);
if (featureGroupType != null) {
processDeclarativeContainedPropertyAssociations(childQueryable, featureGroupType);
}
} else if (childBo instanceof Subcomponent) {
final Classifier subcomponentClassifier = AadlPrototypeUtil.getComponentClassifier(AadlPrototypeUtil.getPrototypeBindingContext(childQueryable), (Subcomponent) childBo);
if (subcomponentClassifier != null) {
processDeclarativeContainedPropertyAssociations(childQueryable, subcomponentClassifier);
}
}
} else if (childBo instanceof Classifier) {
processDeclarativeContainedPropertyAssociations(childQueryable, ((Classifier) childBo));
} else if (childBo instanceof AadlPackage) {
processContainedPropertyAssociationsInChildren(childQueryable);
}
}
}
}
use of org.osate.aadl2.Subcomponent in project osate2 by osate.
the class AadlClassifierUtil method getComponentImplementation.
/**
* Returns a component implementation for a specified business object. Only component implementations and subcomponents are supported.
* @param bo
* @return
*/
public static Optional<ComponentImplementation> getComponentImplementation(final Object bo) {
final ComponentImplementation ci;
if (bo instanceof BusinessObjectContext) {
return getComponentImplementation(((BusinessObjectContext) bo).getBusinessObject());
} else if (bo instanceof ComponentImplementation) {
ci = (ComponentImplementation) bo;
} else if (bo instanceof Subcomponent) {
final Classifier scClassifier = ((Subcomponent) bo).getAllClassifier();
ci = scClassifier instanceof ComponentImplementation ? (ComponentImplementation) scClassifier : null;
} else {
ci = null;
}
return Optional.ofNullable(ci);
}
use of org.osate.aadl2.Subcomponent in project osate2 by osate.
the class AadlClassifierUtil method getComponentClassifier.
/**
* Returns a component classifier for a specified business object. Only component implementations and subcomponents are supported.
* @param bo
* @return
*/
public static Optional<ComponentClassifier> getComponentClassifier(final Object bo) {
final ComponentClassifier ci;
if (bo instanceof BusinessObjectContext) {
return getComponentClassifier(((BusinessObjectContext) bo).getBusinessObject());
} else if (bo instanceof ComponentImplementation) {
ci = (ComponentImplementation) bo;
} else if (bo instanceof Subcomponent) {
final ComponentClassifier scClassifier = ((Subcomponent) bo).getAllClassifier();
ci = scClassifier instanceof ComponentClassifier ? scClassifier : null;
} else {
ci = null;
}
return Optional.ofNullable(ci);
}
use of org.osate.aadl2.Subcomponent in project osate2 by osate.
the class SystemInstanceImpl method leadsOutof.
/**
* Does the connection instance lead out of the flow specific feature
* instance The connection may start in a subcomponent
*
* @param conni ConnectionInstance
* @param cfi FeatureInstance the source feature instance
* @param ffi The feature instance involved in the flow
* @return true if connection goes through the ffi
*/
private boolean leadsOutof(ConnectionInstance conni, FeatureInstance cfi, FeatureInstance ffi) {
if (cfi == ffi) {
return true;
}
ComponentInstance flowci = ffi.getContainingComponentInstance();
ComponentInstance connci = cfi.getContainingComponentInstance();
while (connci != null) {
if (flowci == connci) {
return true;
}
connci = connci.getContainingComponentInstance();
}
return false;
}
use of org.osate.aadl2.Subcomponent in project osate2 by osate.
the class EMV2Util method getLastComponentInstance.
/**
* get the last component instance in the epath relative to the component instance root
* Returns root if the path does not include subcomponents.
* Returns null if the component instance is not found, i.e., the path subcomponent references cannot be found in the
* component instance hierarchy.
* @param epath EMV2Path that includes EMV2PathElements pointing to subcomponents.
* @param root ComponentInstance that is the root of the subcomponent section of the path
* @return ComponentInstance
*/
public static ComponentInstance getLastComponentInstance(EMV2Path epath, ComponentInstance root) {
ComponentInstance result = root;
if (epath.getContainmentPath() != null) {
// handle paths that come from the EMV2PropertyAssociation with the new syntax for the core path
ContainmentPathElement ce = epath.getContainmentPath();
while (ce != null && result != null) {
if (ce.getNamedElement() instanceof Subcomponent) {
Subcomponent sub = (Subcomponent) ce.getNamedElement();
result = result.findSubcomponentInstance(sub);
}
ce = ce.getPath();
}
return result;
}
EMV2PathElement epe = epath.getEmv2Target();
while (epe != null && result != null) {
if (epe.getNamedElement() instanceof Subcomponent) {
Subcomponent sub = (Subcomponent) epe.getNamedElement();
result = result.findSubcomponentInstance(sub);
}
epe = epe.getPath();
}
return result;
}
Aggregations