use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class Issue2288Test method testModeResolution.
@Test
public void testModeResolution() {
final IPreferenceStore store = OsateCorePlugin.getDefault().getPreferenceStore();
store.setDefault("behavior_specification", true);
// annex is turned off
store.setValue("behavior_specification", false);
AadlPackage pkg = testHelper.parseFile(PATH + "Issue2288.aadl");
for (Classifier cl : pkg.getPublicSection().getOwnedClassifiers()) {
for (AnnexSubclause ac : cl.getOwnedAnnexSubclauses()) {
if (ac.getName().equalsIgnoreCase("behavior_specification")) {
if (!ac.getClass().getTypeName().contains("DefaultAnnexSubclause")) {
Assert.fail("behavior_specification annex is still being used to parse the file. Expected behavior_specification annex to be turned off per preference test");
}
}
}
}
validationHelper.assertNoIssues(pkg);
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class GetProperties method getAllowedMemoryBindingClass.
public static List<Classifier> getAllowedMemoryBindingClass(final InstanceObject io) {
Property allowedMemoryBindingClass = lookupPropertyDefinition(io, DeploymentProperties._NAME, DeploymentProperties.ALLOWED_MEMORY_BINDING_CLASS);
ArrayList<Classifier> components = new ArrayList<>();
List<? extends PropertyExpression> propertyValues;
try {
propertyValues = io.getPropertyValueList(allowedMemoryBindingClass);
} catch (Exception e) {
return components;
}
for (PropertyExpression propertyExpression : propertyValues) {
components.add(((ClassifierValue) propertyExpression).getClassifier());
}
return components;
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class GetProperties method sumElementsDataSize.
private static double sumElementsDataSize(final NamedElement ne, UnitLiteral unit, Property DataSize, Property SourceDataSize, int nesting) {
double res = 0.0;
Classifier cl = null;
if (ne instanceof Classifier) {
cl = (Classifier) ne;
} else if (ne instanceof FeatureInstance) {
cl = ((FeatureInstance) ne).getFeature().getAllClassifier();
} else if (ne instanceof Feature) {
cl = ((Feature) ne).getClassifier();
} else if (ne instanceof DataSubcomponent) {
cl = ((DataSubcomponent) ne).getClassifier();
}
if (cl != null) {
if (cl instanceof FeatureGroupType) {
EList<Feature> fl = ((FeatureGroupType) cl).getAllFeatures();
for (Feature f : fl) {
res = res + getDataSize(f, unit, DataSize, SourceDataSize, nesting);
}
} else if (cl instanceof DataImplementation) {
for (Subcomponent ds : ((DataImplementation) cl).getAllSubcomponents()) {
if (!AadlUtil.isSameOrExtends(cl, ds.getAllClassifier())) {
res = res + getDataSize(ds, unit, DataSize, SourceDataSize, nesting);
}
}
}
}
return res;
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class PropertyUtils method getContainedSimplePropertyValue.
/**
* get a property association from the properties section of the containing classifier if the context.
* This method has been designed to work with end points of connections, i.e., consisting of a target and a context.
* The context must be a NamedElement in its containing classifier, i.e., a feature, feature group, subcomponent.
* The property holder is assumed to be contained in the context object, e.g., a feature in afeature group or a data subcomponent in a port, or feature in a subcomponent.
* The association must match the property definition.
* if the context is null then the containing classifier of the target is used and the path must be one or no path.
* The applies to clause of the property association must be of size 2 if the context is set and point to the context and then the property holder.
* The property value of the property association is assumed not to be modal.
* @param context NamedElement whose containing classifier's properties section is searched for the desired property
* @param target NamedElement the model element to which the property is applied to via the applies to clause
* @param pd Property the property definition
* @return
*/
public static PropertyExpression getContainedSimplePropertyValue(final NamedElement context, final NamedElement target, final Property pd) {
if (context == null) {
return target.getNonModalPropertyValue(pd);
}
Classifier cl = AadlUtil.getContainingClassifier(context);
EList<PropertyAssociation> props = cl.getAllPropertyAssociations();
for (PropertyAssociation propertyAssociation : props) {
if (propertyAssociation.getProperty().equals(pd)) {
// we found a property with the corect type
// now we need to check whether the applies to points to the holder
EList<ContainedNamedElement> appliestos = propertyAssociation.getAppliesTos();
for (ContainedNamedElement containedNamedElement : appliestos) {
EList<ContainmentPathElement> cpes = containedNamedElement.getContainmentPathElements();
if (cpes.size() == 2) {
NamedElement pathcxt = cpes.get(0).getNamedElement();
NamedElement pathelement = cpes.get(1).getNamedElement();
if (context.equals(pathcxt) && target.equals(pathelement)) {
EList<ModalPropertyValue> vallist = propertyAssociation.getOwnedValues();
if (!vallist.isEmpty()) {
ModalPropertyValue elem = vallist.get(0);
PropertyExpression res = elem.getOwnedValue();
if (res instanceof NamedValue) {
AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
if (nv instanceof Property) {
res = target.getNonModalPropertyValue((Property) nv);
} else if (nv instanceof PropertyConstant) {
res = ((PropertyConstant) nv).getConstantValue();
}
}
return res;
}
}
}
}
}
}
return null;
}
use of org.geotoolkit.sml.xml.v100.Classifier in project osate2 by osate.
the class PropertiesLinkingService method findClassifier.
/**
* find the classifier taking into account rename aliases
* We do not check whether the referenced package is in the with clause. This is checked separately
* This is a helper method for findFeatureGroupType and findComponentClassifier
* @param context classifier reference context
* @param reference identifying attribute of reference
* @param name name to be resolved
* @return Classifier or null
*/
public Classifier findClassifier(EObject context, EReference reference, String name) {
Namespace scope = AadlUtil.getContainingTopLevelNamespace(context);
EObject e = getIndexedObject(context, reference, name);
if (e != null && e instanceof Classifier && reference.getEReferenceType().isSuperTypeOf(e.eClass())) {
// the result satisfied the expected class
Namespace ns = AadlUtil.getContainingTopLevelNamespace(e);
if (ns instanceof PrivatePackageSection && scope != ns) {
return null;
}
return (Classifier) e;
}
// need to do a local lookup as it was not found in the index.
String packname = null;
String cname = name;
final int idx = name.lastIndexOf("::");
if (idx != -1) {
packname = name.substring(0, idx);
cname = name.substring(idx + 2);
// if rename is not a package rename, but component type rename then all is treated as component ID
if (cname.equalsIgnoreCase("all")) {
return null;
}
}
// NOTE: checking whether the referenced package is imported is done by the validator.
if (context instanceof NamedElement) {
// then stop. Otherwise we have a cycle.
if (((NamedElement) context).getName() == null) {
if (packname == null || scope.getName().equalsIgnoreCase(packname)) {
return null;
}
}
}
if (e == null && scope instanceof PackageSection) {
// the reference is from inside a package section. Lookup by identifier with or without qualification
e = findNamedElementInAadlPackage(packname, cname, scope);
if (e != null && e instanceof Classifier && reference.getEReferenceType().isSuperTypeOf(e.eClass())) {
// the result satisfied the expected class
return (Classifier) e;
}
}
return null;
}
Aggregations