use of org.osate.aadl2.ModalPropertyValue in project osate2 by osate.
the class PropertiesValidator method checkPropertyAssociation.
protected void checkPropertyAssociation(PropertyAssociation pa) {
// type check value against type
Property pdef = pa.getProperty();
checkPropertySetElementReferenceForPackageProperties(pdef, pa);
checkPropertySetElementReference(pdef, pa);
if (Aadl2Util.isNull(pdef)) {
return;
}
PropertyType pt = pdef.getPropertyType();
if (Aadl2Util.isNull(pt)) {
return;
}
EList<ModalPropertyValue> pvl = pa.getOwnedValues();
for (ModalPropertyValue modalPropertyValue : pvl) {
typeCheckPropertyValues(pt, modalPropertyValue.getOwnedValue(), modalPropertyValue.getOwnedValue(), pdef.getQualifiedName(), 0);
}
checkAssociationAppliesTo(pa);
checkInBinding(pa);
if (pa.getProperty() != null) {
if ("Byte_Count".equalsIgnoreCase(pa.getProperty().getName())) {
boolean offerQuickFix = true;
for (ModalPropertyValue modalPropertyValue : pvl) {
PropertyExpression pe = modalPropertyValue.getOwnedValue();
if (!(pe instanceof NumberValue)) {
offerQuickFix = false;
break;
}
}
if (offerQuickFix) {
warning("Byte_Count is deprecated. Please use Memory_Size.", pa, null, BYTE_COUNT_DEPRECATED);
} else {
warning(pa, "Byte_Count is deprecated. Please use Memory_Size.");
}
} else // } else
if ("Source_Code_Size".equalsIgnoreCase(pa.getProperty().getName())) {
warning("Source_Code_Size is deprecated. Please use Code_Size.", pa, null, SOURCE_CODE_SIZE_DEPRECATED);
} else if ("Source_Data_Size".equalsIgnoreCase(pa.getProperty().getName())) {
warning("Source_Data_Size is deprecated. Please use Data_Size.", pa, null, SOURCE_DATA_SIZE_DEPRECATED);
} else if ("Source_Heap_Size".equalsIgnoreCase(pa.getProperty().getName())) {
warning("Source_Heap_Size is deprecated. Please use Heap_Size.", pa, null, SOURCE_HEAP_SIZE_DEPRECATED);
} else if ("Source_Stack_Size".equalsIgnoreCase(pa.getProperty().getName())) {
warning("Source_Stack_Size is deprecated. Please use Stack_Size.", pa, null, SOURCE_STACK_SIZE_DEPRECATED);
} else if ("Data_Volume".equalsIgnoreCase(pa.getProperty().getName())) {
warning("Data_Volume is deprecated. Please use Data_Rate.", pa, null, DATA_VOLUME_DEPRECATED);
}
}
checkConstantProperty(pa);
}
use of org.osate.aadl2.ModalPropertyValue in project osate2 by osate.
the class SetBindingTool method createPropertyAssociations.
private void createPropertyAssociations(final AadlModificationService aadlModService) {
final BusinessObjectContext ciBoc = currentWindow.getComponentImplementationBoc();
final ComponentImplementation ci = (ComponentImplementation) ciBoc.getBusinessObject();
aadlModService.modify(Modification.create(ci, new SimpleModifier<ComponentClassifier>() {
@Override
public void modify(final ComponentClassifier ci) {
for (final BusinessObjectContext bocToBind : currentWindow.getBocsToBind()) {
final PropertyAssociation newPa = AgeAadlUtil.getAadl2Factory().createPropertyAssociation();
// Set property
newPa.setProperty(currentWindow.getSelectedProperty());
// Set applies to
if (ciBoc != bocToBind) {
setContainedNamedElementPath(newPa.createAppliesTo(), ciBoc, bocToBind);
}
// Create owned values
final ModalPropertyValue pv = newPa.createOwnedValue();
final ListValue lv = (ListValue) pv.createOwnedValue(Aadl2Package.eINSTANCE.getListValue());
for (final BusinessObjectContext targetBoc : currentWindow.getTargetBocs()) {
// Ignore diagram selections
final ReferenceValue rv = (ReferenceValue) lv.createOwnedListElement(Aadl2Package.eINSTANCE.getReferenceValue());
setContainedNamedElementPath(rv, ciBoc, targetBoc);
}
removeOldPropertyAssociation(ci, newPa);
// Add the property association
ci.setNoProperties(false);
ci.getOwnedPropertyAssociations().add(newPa);
}
}
// Deletes any existing property associations/removes the bound element from any property associations that matches the property association
// being created.
private void removeOldPropertyAssociation(final ComponentClassifier cc, final PropertyAssociation newPa) {
final List<PropertyAssociation> propertyAssociationsToDelete = new ArrayList<PropertyAssociation>();
for (final PropertyAssociation existingPa : cc.getOwnedPropertyAssociations()) {
// If Property matches
if (newPa.getProperty().getFullName().equals(existingPa.getProperty().getFullName())) {
if (existingPa.getAppliesTos().size() == 0 || newPa.getAppliesTos().size() == 0) {
if (existingPa.getAppliesTos().size() == 0 && newPa.getAppliesTos().size() == 0) {
propertyAssociationsToDelete.add(existingPa);
}
} else {
final List<ContainedNamedElement> containedElementsToDelete = new ArrayList<ContainedNamedElement>();
for (final ContainedNamedElement existingContainedElement : existingPa.getAppliesTos()) {
if (containmentPathsMatch(existingContainedElement.getPath(), newPa.getAppliesTos().get(0).getPath())) {
// Add the contained element to the list of objects to delete
containedElementsToDelete.add(existingContainedElement);
}
}
// Delete objects
for (final EObject ce : containedElementsToDelete) {
EcoreUtil.delete(ce);
}
// Delete the property association if it was the last element in the applies to clause
if (existingPa.getAppliesTos().size() == 0) {
propertyAssociationsToDelete.add(existingPa);
}
}
}
}
// Delete property association(s) that are being replaced
for (final PropertyAssociation pa : propertyAssociationsToDelete) {
EcoreUtil.delete(pa);
}
}
}));
}
use of org.osate.aadl2.ModalPropertyValue in project osate2 by osate.
the class PropertyAssociationImpl method createOwnedValue.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public ModalPropertyValue createOwnedValue() {
ModalPropertyValue newOwnedValue = (ModalPropertyValue) create(Aadl2Package.eINSTANCE.getModalPropertyValue());
getOwnedValues().add(newOwnedValue);
return newOwnedValue;
}
use of org.osate.aadl2.ModalPropertyValue in project osate2 by osate.
the class AbstractPropertiesSemanticSequencer method sequence.
@Override
public void sequence(ISerializationContext context, EObject semanticObject) {
EPackage epackage = semanticObject.eClass().getEPackage();
ParserRule rule = context.getParserRule();
Action action = context.getAssignedAction();
Set<Parameter> parameters = context.getEnabledBooleanParameters();
if (epackage == Aadl2Package.eINSTANCE)
switch(semanticObject.eClass().getClassifierID()) {
case Aadl2Package.ARRAY_RANGE:
sequence_ArrayRange(context, (ArrayRange) semanticObject);
return;
case Aadl2Package.BASIC_PROPERTY_ASSOCIATION:
sequence_FieldPropertyAssociation(context, (BasicPropertyAssociation) semanticObject);
return;
case Aadl2Package.BOOLEAN_LITERAL:
sequence_BooleanLiteral(context, (BooleanLiteral) semanticObject);
return;
case Aadl2Package.CLASSIFIER_VALUE:
sequence_ComponentClassifierTerm(context, (ClassifierValue) semanticObject);
return;
case Aadl2Package.COMPUTED_VALUE:
sequence_ComputedTerm(context, (ComputedValue) semanticObject);
return;
case Aadl2Package.CONTAINED_NAMED_ELEMENT:
sequence_ContainmentPath(context, (ContainedNamedElement) semanticObject);
return;
case Aadl2Package.CONTAINMENT_PATH_ELEMENT:
sequence_ContainmentPathElement(context, (ContainmentPathElement) semanticObject);
return;
case Aadl2Package.INTEGER_LITERAL:
sequence_IntegerTerm(context, (IntegerLiteral) semanticObject);
return;
case Aadl2Package.LIST_VALUE:
sequence_ListTerm(context, (ListValue) semanticObject);
return;
case Aadl2Package.MODAL_PROPERTY_VALUE:
if (rule == grammarAccess.getModalPropertyValueRule()) {
sequence_ModalPropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else if (rule == grammarAccess.getOptionalModalPropertyValueRule()) {
sequence_OptionalModalPropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyValueRule()) {
sequence_PropertyValue(context, (ModalPropertyValue) semanticObject);
return;
} else
break;
case Aadl2Package.NAMED_VALUE:
if (rule == grammarAccess.getConstantValueRule() || rule == grammarAccess.getNumAltRule()) {
sequence_ConstantValue(context, (NamedValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getLiteralorReferenceTermRule()) {
sequence_LiteralorReferenceTerm(context, (NamedValue) semanticObject);
return;
} else
break;
case Aadl2Package.OPERATION:
sequence_SignedConstant(context, (Operation) semanticObject);
return;
case Aadl2Package.PROPERTY_ASSOCIATION:
if (rule == grammarAccess.getBasicPropertyAssociationRule()) {
sequence_BasicPropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else if (rule == grammarAccess.getPModelRule() || rule == grammarAccess.getContainedPropertyAssociationRule()) {
sequence_ContainedPropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyAssociationRule()) {
sequence_PropertyAssociation(context, (PropertyAssociation) semanticObject);
return;
} else
break;
case Aadl2Package.RANGE_VALUE:
sequence_NumericRangeTerm(context, (RangeValue) semanticObject);
return;
case Aadl2Package.REAL_LITERAL:
sequence_RealTerm(context, (RealLiteral) semanticObject);
return;
case Aadl2Package.RECORD_VALUE:
if (rule == grammarAccess.getOldRecordTermRule()) {
sequence_OldRecordTerm(context, (RecordValue) semanticObject);
return;
} else if (rule == grammarAccess.getPropertyExpressionRule() || rule == grammarAccess.getRecordTermRule()) {
sequence_RecordTerm(context, (RecordValue) semanticObject);
return;
} else
break;
case Aadl2Package.REFERENCE_VALUE:
sequence_ReferenceTerm(context, (ReferenceValue) semanticObject);
return;
case Aadl2Package.STRING_LITERAL:
sequence_StringTerm(context, (StringLiteral) semanticObject);
return;
}
if (errorAcceptor != null)
errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
}
use of org.osate.aadl2.ModalPropertyValue in project osate2 by osate.
the class GetProperties method getSourceName.
public static String getSourceName(final NamedElement ne) {
try {
Property sn = lookupPropertyDefinition(ne, ProgrammingProperties._NAME, ProgrammingProperties.SOURCE_NAME);
PropertyAcc pacc = ne.getPropertyValue(sn);
if (pacc.getAssociations().size() > 0) {
ModalPropertyValue mdv = pacc.getAssociations().get(0).getOwnedValues().get(0);
PropertyExpression pe = mdv.getOwnedValue();
// System.out.println("pe=" + pe);
StringLiteral sl = (StringLiteral) pe;
return sl.getValue();
}
// System.out.println("pacc" + pacc.getAssociations().get(0).getOwnedValues().get(0));
return null;
} catch (PropertyLookupException e) {
return null;
}
}
Aggregations