use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class AadlBusinessObjectProvider method getChildBusinessObjects.
@Override
public Stream<?> getChildBusinessObjects(final BusinessObjectProviderContext ctx) {
final Object bo = ctx.getBusinessObjectContext().getBusinessObject();
// An IProject is specified as the business object for contextless diagrams.
if (bo instanceof IProject) {
// Special handling for project
final IProject project = (IProject) bo;
// Perform an incremental project build to ensure new packages are included.
try {
project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, new NullProgressMonitor());
} catch (CoreException e) {
throw new RuntimeException(e);
}
Stream<Object> packages = getPackages(project);
// If no packages were found, assume that the project needs to be built. This can happen if the Eclipse process is forcefully terminated.
if (packages == null) {
try {
project.build(IncrementalProjectBuilder.FULL_BUILD, new NullProgressMonitor());
} catch (CoreException e) {
throw new RuntimeException(e);
}
packages = getPackages(project);
}
return packages;
} else if (bo instanceof AadlPackage) {
return getChildren((AadlPackage) bo, ctx.getExtensionRegistry());
} else if (bo instanceof Classifier) {
return getChildren((Classifier) bo, true, ctx.getExtensionRegistry());
} else if (bo instanceof FeatureGroup) {
final FeatureGroupType fgt = AadlFeatureUtil.getFeatureGroupType(ctx.getBusinessObjectContext(), (FeatureGroup) bo);
return fgt == null ? Stream.empty() : AadlFeatureUtil.getAllFeatures(fgt).stream();
} else if (bo instanceof Subcomponent) {
return getChildren((Subcomponent) bo, ctx.getBusinessObjectContext(), ctx.getExtensionRegistry());
} else if (bo instanceof SubprogramCall) {
return getChildren((SubprogramCall) bo);
} else if (bo instanceof SubprogramCallSequence) {
return getChildren((SubprogramCallSequence) bo);
} else if (bo instanceof ModeTransition) {
final ModeTransition mt = ((ModeTransition) bo);
final String modeTransitionTriggersDesc = mt.getOwnedTriggers().stream().map(mtt -> mttHandler.getName(mtt)).collect(Collectors.joining(","));
return Stream.concat(mt.getOwnedTriggers().stream(), Stream.of(new Tag(Tag.KEY_MODE_TRANSITION_TRIGGERS, modeTransitionTriggersDesc)));
} else if (bo instanceof ComponentInstance) {
return getChildren((ComponentInstance) bo);
} else if (bo instanceof FeatureInstance) {
return ((FeatureInstance) bo).getFeatureInstances().stream();
} else if (bo instanceof Connection) {
if (!((Connection) bo).isAllBidirectional()) {
return Stream.of(new Tag(Tag.KEY_UNIDIRECTIONAL, null));
}
} else if (bo instanceof ConnectionInstance) {
if (!((ConnectionInstance) bo).isBidirectional()) {
return Stream.of(new Tag(Tag.KEY_UNIDIRECTIONAL, null));
}
}
return Stream.empty();
}
use of org.osate.aadl2.FeatureGroup 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.FeatureGroup in project osate2 by osate.
the class EMV2Util method getErrorPropagationFeatureDirection.
/**
* returns the feature instance in the component instance that is referenced by the Error Propagation (or Containment)
* @param ep
* @param ci
* @return
*/
public static DirectionType getErrorPropagationFeatureDirection(ErrorPropagation ep) {
FeatureorPPReference fref = ep.getFeatureorPPRef();
boolean inverse = false;
NamedElement f = null;
DirectionType featuredir = DirectionType.IN_OUT;
while (fref != null) {
f = fref.getFeatureorPP();
fref = fref.getNext();
if (f instanceof FeatureGroup && fref != null) {
FeatureGroup fg = (FeatureGroup) f;
FeatureGroupType fgt = fg.getAllFeatureGroupType();
if (fg.isInverse()) {
inverse = !inverse;
}
if (fgt != null && fgt.getInverse() != null && !fgt.getOwnedFeatures().contains(fref.getFeatureorPP())) {
inverse = !inverse;
}
}
}
if (f instanceof DirectedFeature) {
featuredir = ((DirectedFeature) f).getDirection();
if (inverse) {
return featuredir.getInverseDirection();
} else {
return featuredir;
}
}
return featuredir;
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class FeatureInstanceImpl method findInverseFeatureGroup.
/**
* find the matching inverse feature group instance in this feature group instance
* the contained feature group instance must have the inverse feature group type
* @param targetpgt feature group instance with feature group type to be found
* @return feature instance with the specified feature, or null
*/
// XXX: [AADL 1 -> AADL 2] Added to make instantiation work.
public FeatureInstance findInverseFeatureGroup(FeatureGroupType targetpgt) {
if (!(getFeature() instanceof FeatureGroup)) {
return null;
}
EList<FeatureInstance> subcil = getFeatureInstances();
for (Iterator<FeatureInstance> it = subcil.iterator(); it.hasNext(); ) {
FeatureInstance fi = it.next();
if (fi.getFeature() instanceof FeatureGroup) {
FeatureGroupType srcpgt = ((FeatureGroup) fi.getFeature()).getFeatureGroupType();
if (srcpgt != null && srcpgt.isInverseOf(targetpgt)) {
return fi;
}
fi.findInverseFeatureGroup(targetpgt);
}
}
return null;
}
use of org.osate.aadl2.FeatureGroup in project osate2 by osate.
the class Aadl2Validator method checkIncomingFeatureDirection.
private boolean checkIncomingFeatureDirection(Feature inFeature, FlowImplementation flow, boolean inverseOf, boolean report) {
// Test for L2
if (inFeature instanceof Port || inFeature instanceof Parameter || inFeature instanceof AbstractFeature) {
DirectionType fDirection = ((DirectedFeature) inFeature).getDirection();
if (inverseOf) {
fDirection = fDirection.getInverseDirection();
}
if (!fDirection.incoming()) {
if (report) {
error(flow.getInEnd(), '\'' + (flow.getInEnd().getContext() != null ? flow.getInEnd().getContext().getName() + '.' : "") + inFeature.getName() + "' must be an in or in out feature.");
}
return false;
} else {
return true;
}
} else // Test for L4
if (inFeature instanceof DataAccess) {
AccessRights accessRight = org.osate.aadl2.contrib.memory.MemoryProperties.getAccessRight(inFeature).orElse(AccessRights.READ_WRITE);
if (inverseOf) {
accessRight = AadlContribUtils.getInverseDirection(accessRight);
}
if (accessRight != AccessRights.READ_ONLY && accessRight != AccessRights.READ_WRITE) {
if (report) {
error(flow.getInEnd(), '\'' + (flow.getInEnd().getContext() != null ? flow.getInEnd().getContext().getName() + '.' : "") + inFeature.getName() + "' must have an access right of Read_Only or Read_Write.");
}
return false;
} else {
return true;
}
} else // Test for L6
if (inFeature instanceof FeatureGroup) {
FeatureGroupType fgt = ((FeatureGroup) inFeature).getAllFeatureGroupType();
boolean inInverseof = ((FeatureGroup) inFeature).isInverse();
if (!Aadl2Util.isNull(fgt)) {
if (!Aadl2Util.isNull(fgt.getInverse()) && fgt.getOwnedFeatures().isEmpty()) {
inInverseof = !inInverseof;
}
if (fgt.getAllFeatures().isEmpty()) {
return true;
}
for (Feature f : fgt.getAllFeatures()) {
// the feature group
if (checkIncomingFeatureDirection(f, flow, inInverseof ? !inverseOf : inverseOf, false)) {
return true;
}
}
if (report) {
error(flow.getInEnd(), '\'' + (flow.getInEnd().getContext() != null ? flow.getInEnd().getContext().getName() + '.' : "") + inFeature.getName() + "' must contain at least one in or in out port or parameter, at least data access with an access right of Read_Only or Read_Write, or be empty.");
return false;
}
}
return true;
}
return false;
}
Aggregations