use of org.osate.aadl2.GroupExtension in project osate2 by osate.
the class FeatureGroupTypeImpl method basicSetOwnedExtension.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetOwnedExtension(GroupExtension newOwnedExtension, NotificationChain msgs) {
GroupExtension oldOwnedExtension = ownedExtension;
ownedExtension = newOwnedExtension;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, Aadl2Package.FEATURE_GROUP_TYPE__OWNED_EXTENSION, oldOwnedExtension, newOwnedExtension);
if (msgs == null) {
msgs = notification;
} else {
msgs.add(notification);
}
}
return msgs;
}
use of org.osate.aadl2.GroupExtension in project osate2 by osate.
the class ClassifierOperationExecutor method addStep.
/**
* @param operation
* @param part
* @param basePart
* @param pkgBoc if non-null then the operation result will indicate that the object should be added to the diagram.
* @return
*/
private OperationBuilder<Classifier> addStep(final OperationBuilder<?> operation, final ClassifierOperationPart part, final ClassifierOperationPart basePart, final BusinessObjectContext pkgBoc) {
Objects.requireNonNull(part, "part must not be null");
Objects.requireNonNull(part.getType(), "operation part type must not be null");
switch(part.getType()) {
case EXISTING:
return operation.supply(() -> StepResultBuilder.create(classifierCreationHelper.getResolvedClassifier(part.getSelectedClassifier())).build());
case NEW_COMPONENT_IMPLEMENTATION:
case NEW_COMPONENT_TYPE:
case NEW_FEATURE_GROUP_TYPE:
final EClass creationEClass = getCreationEClass(part);
final PackageSection unmodifiableSection = classifierCreationHelper.getResolvedPublicSection(part.getSelectedPackage());
return operation.modifyModel(unmodifiableSection, (tag, prevResult) -> tag, (tag, section, prevResult) -> {
// Create the new classifier
final Classifier newClassifier = section.createOwnedClassifier(creationEClass);
// Set name
newClassifier.setName(classifierCreationHelper.getName(part, basePart));
final Classifier baseOperationResult = resolveWithLiveResourceSetOrThrowIfProxy((Classifier) prevResult);
// Handle component implementations
if (newClassifier instanceof ComponentImplementation) {
final ComponentImplementation newImpl = (ComponentImplementation) newClassifier;
final ComponentType baseComponentType;
if (baseOperationResult instanceof ComponentType) {
final Realization realization = newImpl.createOwnedRealization();
baseComponentType = (ComponentType) baseOperationResult;
realization.setImplemented(baseComponentType);
} else if (baseOperationResult instanceof ComponentImplementation) {
final ComponentImplementation baseImpl = (ComponentImplementation) baseOperationResult;
final ImplementationExtension extension = newImpl.createOwnedExtension();
extension.setExtended(baseImpl);
final Realization realization = newImpl.createOwnedRealization();
realization.setImplemented(baseImpl.getType());
baseComponentType = baseImpl.getType();
// Import the base implementation's package
final AadlPackage baseImplPkg = (AadlPackage) baseImpl.getNamespace().getOwner();
AadlImportsUtil.addImportIfNeeded(section, baseImplPkg);
} else {
throw new RuntimeException("Invalid base classifier: " + baseOperationResult);
}
// Get the base component type
if (baseComponentType == null) {
throw new RuntimeException("Unable to determine base component type");
}
if (!AadlNameUtil.namesAreEqual(section, baseComponentType.getNamespace())) {
// Import the package if necessary
final AadlPackage baseComponentTypePkg = (AadlPackage) baseComponentType.getNamespace().getOwner();
AadlImportsUtil.addImportIfNeeded(section, baseComponentTypePkg);
// Create an alias for the component type
final ClassifierCreationHelper.RenamedTypeDetails aliasDetails = classifierCreationHelper.getRenamedType(section, baseComponentTypePkg, baseComponentType.getName());
if (!aliasDetails.exists) {
final ComponentTypeRename ctr = section.createOwnedComponentTypeRename();
ctr.setName(aliasDetails.aliasName);
ctr.setCategory(baseComponentType.getCategory());
ctr.setRenamedComponentType(baseComponentType);
}
}
} else if (newClassifier instanceof ComponentType && baseOperationResult instanceof ComponentType) {
final ComponentType newType = (ComponentType) newClassifier;
final TypeExtension extension = newType.createOwnedExtension();
extension.setExtended((ComponentType) baseOperationResult);
} else if (newClassifier instanceof FeatureGroupType && baseOperationResult instanceof FeatureGroupType) {
final FeatureGroupType newFgt = (FeatureGroupType) newClassifier;
final GroupExtension extension = newFgt.createOwnedExtension();
extension.setExtended((FeatureGroupType) baseOperationResult);
}
final StepResultBuilder<Classifier> resultBuilder = StepResultBuilder.create(newClassifier);
// Hint for adding to diagram
if (pkgBoc != null && newClassifier != null) {
resultBuilder.showNewBusinessObject(pkgBoc, newClassifier);
}
return resultBuilder.build();
});
case NONE:
return operation.map(prevResult -> StepResultBuilder.create((Classifier) null).build());
default:
throw new RuntimeException("Unexpected operation: " + part.getType());
}
}
use of org.osate.aadl2.GroupExtension in project osate2 by osate.
the class AadlBusinessObjectProvider method getChildren.
private static Stream<?> getChildren(final Classifier classifier, final boolean includeGeneralizations, final ExtensionRegistryService extRegistryService) {
Stream<?> children = Stream.empty();
// Shapes
children = Stream.concat(children, AadlFeatureUtil.getAllDeclaredFeatures(classifier).stream());
if (classifier instanceof ComponentImplementation) {
final ComponentImplementation ci = (ComponentImplementation) classifier;
children = Stream.concat(children, AgeAadlUtil.getAllInternalFeatures(ci).stream());
children = Stream.concat(children, AgeAadlUtil.getAllProcessorFeatures(ci).stream());
children = Stream.concat(children, ci.getAllSubcomponents().stream());
}
if (classifier instanceof BehavioredImplementation) {
children = Stream.concat(children, AgeAadlUtil.getAllSubprogramCallSequences((BehavioredImplementation) classifier).stream());
}
if (classifier instanceof ComponentClassifier) {
children = Stream.concat(children, ((ComponentClassifier) classifier).getAllModes().stream());
}
// Annex Subclauses
final Stream.Builder<AnnexSubclause> subclauseStreamBuilder = Stream.builder();
for (final AnnexSubclause annexSubclause : getAllDefaultAnnexSubclauses(classifier)) {
final AnnexSubclause parsedAnnexSubclause = getParsedAnnexSubclause(annexSubclause);
final boolean specializedHandling = parsedAnnexSubclause != null && extRegistryService.getApplicableBusinessObjectHandler(parsedAnnexSubclause) != null;
// Only contribute the annex object if a BOH for the annex does not exist. The annex plugin is expected to contribute the object as needed.
if (!specializedHandling) {
subclauseStreamBuilder.add(annexSubclause);
}
}
children = Stream.concat(children, subclauseStreamBuilder.build());
// Connections
if (classifier instanceof ComponentClassifier) {
children = Stream.concat(children, ((ComponentClassifier) classifier).getAllModeTransitions().stream());
}
if (classifier instanceof ComponentImplementation) {
children = Stream.concat(children, ((ComponentImplementation) classifier).getAllConnections().stream());
}
final ComponentType componentType;
if (classifier instanceof ComponentType) {
componentType = (ComponentType) classifier;
} else if (classifier instanceof ComponentImplementation) {
componentType = ((ComponentImplementation) classifier).getType();
} else {
componentType = null;
}
if (componentType != null) {
children = Stream.concat(children, componentType.getAllFlowSpecifications().stream());
}
// Add generalizations
if (includeGeneralizations) {
if (classifier instanceof ComponentType) {
final ComponentType ct = ((ComponentType) classifier);
final TypeExtension te = ct.getOwnedExtension();
if (te != null) {
children = Stream.concat(children, Stream.of(te));
}
} else if (classifier instanceof ComponentImplementation) {
final ComponentImplementation componentImplementation = ((ComponentImplementation) classifier);
// Implementation Extension
final ImplementationExtension ie = componentImplementation.getOwnedExtension();
if (ie != null) {
children = Stream.concat(children, Stream.of(ie));
} else {
// Realization
final Realization realization = componentImplementation.getOwnedRealization();
if (realization != null) {
children = Stream.concat(children, Stream.of(realization));
}
}
} else if (classifier instanceof FeatureGroupType) {
final FeatureGroupType featureGroupType = ((FeatureGroupType) classifier);
final GroupExtension ge = featureGroupType.getOwnedExtension();
if (ge != null) {
children = Stream.concat(children, Stream.of(ge));
}
}
}
return children;
}
Aggregations