use of org.osate.aadl2.BasicPropertyAssociation in project osate2 by osate.
the class ModelReference method toPropertyExpression.
@Override
public RecordValue toPropertyExpression(ResourceSet resourceSet) {
if (!modelType.isPresent() && !kind.isPresent() && !filename.isPresent() && !artifact.isPresent()) {
throw new IllegalStateException("Record must have at least one field set.");
}
RecordValue recordValue = Aadl2Factory.eINSTANCE.createRecordValue();
modelType.ifPresent(field -> {
BasicPropertyAssociation fieldAssociation = recordValue.createOwnedFieldValue();
fieldAssociation.setProperty(loadField(resourceSet, MODEL_TYPE__URI, MODEL_TYPE__NAME));
fieldAssociation.setOwnedValue(field.toPropertyExpression(resourceSet));
});
kind.ifPresent(field -> {
BasicPropertyAssociation fieldAssociation = recordValue.createOwnedFieldValue();
fieldAssociation.setProperty(loadField(resourceSet, KIND__URI, KIND__NAME));
fieldAssociation.setOwnedValue(field.toPropertyExpression(resourceSet));
});
filename.ifPresent(field -> {
BasicPropertyAssociation fieldAssociation = recordValue.createOwnedFieldValue();
fieldAssociation.setProperty(loadField(resourceSet, FILENAME__URI, FILENAME__NAME));
fieldAssociation.setOwnedValue(CodeGenUtil.toPropertyExpression(field));
});
artifact.ifPresent(field -> {
BasicPropertyAssociation fieldAssociation = recordValue.createOwnedFieldValue();
fieldAssociation.setProperty(loadField(resourceSet, ARTIFACT__URI, ARTIFACT__NAME));
fieldAssociation.setOwnedValue(CodeGenUtil.toPropertyExpression(field));
});
return recordValue;
}
use of org.osate.aadl2.BasicPropertyAssociation in project osate2 by osate.
the class FHAReport method reportStringProperty.
/**
* report String based property values. Can be list of string values (for handling Phases)
* @param fields
* @param fieldName
* @param report
*/
protected Boolean reportStringProperty(EList<BasicPropertyAssociation> fields, String fieldName, WriteToFile report) {
BasicPropertyAssociation xref = GetProperties.getRecordField(fields, fieldName);
String text = null;
if (xref != null) {
PropertyExpression val = xref.getOwnedValue();
if (val instanceof StringLiteral) {
text = ((StringLiteral) val).getValue();
}
if (val instanceof ListValue) {
ListValue lv = (ListValue) val;
text = "";
for (PropertyExpression pe : lv.getOwnedListElements()) {
if (text.length() > 0) {
text += " or ";
}
text += stripQuotes(((StringLiteral) pe).getValue());
}
}
}
if (text != null) {
text = makeCSVText(stripQuotes(text));
text = text.replaceAll(System.getProperty("line.separator"), " ");
report.addOutput("\"" + text + "\"");
return true;
}
return false;
}
use of org.osate.aadl2.BasicPropertyAssociation 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.BasicPropertyAssociation in project osate2 by osate.
the class GetProperties method getRecordField.
public static BasicPropertyAssociation getRecordField(EList<BasicPropertyAssociation> props, String fieldName) {
for (BasicPropertyAssociation propertyAssociation : props) {
BasicProperty prop = propertyAssociation.getProperty();
String name = prop.getName();
if (fieldName.equalsIgnoreCase(name)) {
return propertyAssociation;
}
}
return null;
}
use of org.osate.aadl2.BasicPropertyAssociation in project osate2 by osate.
the class GetProperties method getRateUnit.
public static EnumerationLiteral getRateUnit(final RecordValue ne) {
EList<BasicPropertyAssociation> fields = ne.getOwnedFieldValues();
BasicPropertyAssociation rateUnit = getRecordField(fields, "Rate_Unit");
PropertyExpression res = rateUnit.getValue();
if (res instanceof NamedValue) {
return (EnumerationLiteral) ((NamedValue) res).getNamedValue();
}
return null;
}
Aggregations