use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class InstantiateModel method instantiateSubcomponent.
protected void instantiateSubcomponent(final ComponentInstance parent, final ModalElement mm, final Subcomponent sub, Stack<Long> indexStack, int index) throws InterruptedException {
final ComponentInstance newInstance = InstanceFactory.eINSTANCE.createComponentInstance();
final ComponentClassifier cc;
final InstantiatedClassifier ic;
newInstance.setSubcomponent(sub);
// Issue 961: Set the category for real later (below); set it here now in case something goes wrong
newInstance.setCategory(sub.getCategory());
newInstance.setName(sub.getName());
newInstance.getIndices().addAll(indexStack);
newInstance.getIndices().add(Long.valueOf(index));
parent.getComponentInstances().add(newInstance);
ic = getInstantiatedClassifier(newInstance);
if (ic == null) {
cc = null;
} else {
cc = (ComponentClassifier) ic.getClassifier();
}
if (cc == null) {
errManager.warning(newInstance, "Instantiated subcomponent doesn't have a component classifier");
} else {
// if (cc instanceof ComponentType) {
// if (sub instanceof SystemSubcomponent || sub instanceof ProcessSubcomponent
// || sub instanceof ThreadGroupSubcomponent) {
// errManager.warning(newInstance, "Instantiated subcomponent has a component type only");
// }
// }
newInstance.setClassifier(cc);
/*
* From Issue 961:
*
* I think the category can be determined as follows:
*
* If the classifier is not abstract then use its category (and maybe check that the subcomponent either has the same category or is abstract).
* If the classifier is abstract then use the category from the subcomponent.
*
* Only if both are abstract the component instance should be abstract.
* If both are not abstract then they must have the same category. If the categories are different, validation should already have reported an
* error, and we don't instantiate models with errors. It can't hurt if the instantiator checks again, though.
*/
final ComponentCategory classifierCategory = cc.getCategory();
final ComponentCategory subcomponentCategory = sub.getCategory();
if (classifierCategory != ComponentCategory.ABSTRACT) {
newInstance.setCategory(cc.getCategory());
if (subcomponentCategory != ComponentCategory.ABSTRACT && subcomponentCategory != classifierCategory) {
errManager.warning(newInstance, "Subcomponent's category and its classifier's category do not match");
}
} else {
newInstance.setCategory(subcomponentCategory);
}
}
for (Mode mode : mm.getAllInModes()) {
if (monitor.isCanceled()) {
throw new InterruptedException();
}
ModeInstance mi = parent.findModeInstance(mode);
if (mi != null) {
newInstance.getInModes().add(mi);
}
}
populateComponentInstance(newInstance, index);
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class ComponentInstanceImpl method setClassifier.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setClassifier(ComponentClassifier newClassifier) {
ComponentClassifier oldClassifier = classifier;
classifier = newClassifier;
if (eNotificationRequired()) {
eNotify(new ENotificationImpl(this, Notification.SET, InstancePackage.COMPONENT_INSTANCE__CLASSIFIER, oldClassifier, classifier));
}
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class ComponentInstanceImpl method acceptsProperty.
public boolean acceptsProperty(Property property) {
ComponentClassifier cc = getComponentClassifier();
Subcomponent sub = getSubcomponent();
if (getCategory().equals(ComponentCategory.ABSTRACT)) {
return true;
}
for (PropertyOwner propOwner : property.getAppliesTos()) {
if (propOwner instanceof MetaclassReference) {
MetaclassReference metaRef = (MetaclassReference) propOwner;
if (metaRef.getMetaclassNames().get(0).equals("all")) {
return true;
} else {
EClass appliesTo = metaRef.getMetaclass();
if (appliesTo == null) {
return false;
}
if (cc != null && appliesTo.isSuperTypeOf(cc.eClass()) || sub != null && appliesTo.isSuperTypeOf(sub.eClass())) {
return true;
}
}
}
}
return (cc == null) ? false : cc.checkAppliesToClassifier(property);
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class GetProperties method getProvidedVirtualBusClass.
public static List<ComponentClassifier> getProvidedVirtualBusClass(final NamedElement io) {
Property providedVirtualBusClass;
ArrayList<ComponentClassifier> components;
providedVirtualBusClass = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.PROVIDED_VIRTUAL_BUS_CLASS);
components = new ArrayList<>();
List<? extends PropertyExpression> propertyValues;
try {
propertyValues = io.getPropertyValueList(providedVirtualBusClass);
} catch (Exception e) {
return components;
}
for (PropertyExpression propertyExpression : propertyValues) {
components.add((ComponentClassifier) ((ClassifierValue) propertyExpression).getClassifier());
}
return components;
}
use of org.osate.aadl2.ComponentClassifier in project osate2 by osate.
the class GetProperties method getRequiredVirtualBusClass.
/**
* Get the virtual bus required for a connection, virtual bus, port, etc.
*
* @param io
* - the component which has the property
* @return - the list of virtual bus classifier
*/
public static List<ComponentClassifier> getRequiredVirtualBusClass(final NamedElement io) {
Property requiredVirtualBusClass;
ArrayList<ComponentClassifier> components;
requiredVirtualBusClass = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.REQUIRED_VIRTUAL_BUS_CLASS);
components = new ArrayList<ComponentClassifier>();
List<? extends PropertyExpression> propertyValues;
try {
propertyValues = io.getPropertyValueList(requiredVirtualBusClass);
} catch (Exception e) {
return components;
}
for (PropertyExpression propertyExpression : propertyValues) {
components.add((ComponentClassifier) ((ClassifierValue) propertyExpression).getClassifier());
}
return components;
}
Aggregations