use of org.osate.ge.aadl2.internal.model.PropertyValueGroup in project osate2 by osate.
the class PropertyValueGroupHandler method getGraphicalConfiguration.
@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
final BusinessObjectContext boc = ctx.getBusinessObjectContext();
final PropertyValueGroup pvg = boc.getBusinessObject(PropertyValueGroup.class).orElseThrow();
if (pvg.getReferenceId() == null) {
return Optional.of(createTextGraphicalConfiguration());
} else {
// Try to get the referenced element
final DiagramElement referencedElement = ctx.getDiagram().findElementById(pvg.getReferenceId());
if (referencedElement == null) {
return Optional.empty();
}
// If the reference is from the child to an ancestor or from an ancestor to a child, show it as text if it is is based on a completely processed
// property association. Otherwise, don't show it at all.
final BusinessObjectContext parent = boc.getParent();
if (BusinessObjectContextUtil.isAncestor(parent, referencedElement) || BusinessObjectContextUtil.isAncestor(referencedElement, parent)) {
if (pvg.getFirstValueBasedOnCompletelyProcessedAssociation() == null) {
return Optional.empty();
} else {
return Optional.of(createTextGraphicalConfiguration());
}
}
return Optional.of(GraphicalConfigurationBuilder.create().graphic(graphic).style(pvg.isAbstract() ? abstractStyle : referenceStyle).source(boc.getParent()).destination(referencedElement).build());
}
}
use of org.osate.ge.aadl2.internal.model.PropertyValueGroup in project osate2 by osate.
the class PropertyValueFormatter method getUserString.
/**
* @param propertyValueQueryable
* @param prv
* @param expandComplexValues if true values inside of lists and groups will be contained in the result.
* @return
*/
public static String getUserString(final BusinessObjectContext pvgQueryable, final boolean singleLine, final boolean includeOnlyValuesBasedOnCompletelyProcessedAssociations, final boolean includeValues, final boolean includeAppliesTo, final boolean expandComplexValues) {
if (pvgQueryable == null || pvgQueryable.getParent() == null) {
return "";
}
if (!(pvgQueryable.getBusinessObject() instanceof PropertyValueGroup)) {
throw new RuntimeException("Queryable business object must be a PropertyValueGroup");
}
final PropertyValueGroup pvg = (PropertyValueGroup) pvgQueryable.getBusinessObject();
final StringBuilder sb = new StringBuilder();
Stream<AgePropertyValue> propertyValuesStream = pvg.getPropertyValues().stream();
if (includeOnlyValuesBasedOnCompletelyProcessedAssociations) {
propertyValuesStream = propertyValuesStream.filter(pv -> pv.isBasedOnCompletelyProcessedAssociation());
}
final List<AgePropertyValue> sortedPropertyValues = propertyValuesStream.sorted(propertyValueComparator).collect(Collectors.toList());
if (singleLine && sortedPropertyValues.size() > 1) {
sb.append(AadlUtil.getPropertySetElementName(pvg.getProperty()));
if (includeValues) {
sb.append(": <multiple>");
}
} else {
final BusinessObjectContext pvgParentQueryable = pvgQueryable.getParent();
for (final AgePropertyValue pv : sortedPropertyValues) {
if (sb.length() != 0) {
sb.append('\n');
}
sb.append(AadlUtil.getPropertySetElementName(pvg.getProperty()));
appendArrayIndices(sb, pv);
if (includeValues) {
sb.append(": ");
appendPropertyResultValue(sb, pv.getPropertyResult(), pv.getValue(), pvgParentQueryable, expandComplexValues);
}
// Add applies to
if (includeAppliesTo) {
if (pv.getAppliesToRef() != null) {
sb.append(" applies to ");
sb.append(pv.getAppliesToRef());
}
}
}
}
return sb.toString();
}
use of org.osate.ge.aadl2.internal.model.PropertyValueGroup in project osate2 by osate.
the class TimingPropertyValueHandler method isImmediateTimingProperty.
/**
* Returns whether the specified business object is an immediate timing property value group which will be handled by this handler
* @param bo is the business object to check
* @return whether the business object is an immediate timing property value.
*/
public static boolean isImmediateTimingProperty(final Object bo) {
if (!(bo instanceof PropertyValueGroup)) {
return false;
}
final PropertyValueGroup pvg = (PropertyValueGroup) bo;
final NamedValue namedValue = getNamedValue(pvg);
if (namedValue != null && namedValue.getNamedValue() instanceof NamedElement) {
final NamedElement ne = (NamedElement) namedValue.getNamedValue();
return CommunicationProperties.IMMEDIATE.equalsIgnoreCase(ne.getName());
}
return false;
}
use of org.osate.ge.aadl2.internal.model.PropertyValueGroup in project osate2 by osate.
the class TimingPropertyValueHandler method getGraphicalConfiguration.
@Override
public Optional<GraphicalConfiguration> getGraphicalConfiguration(final GetGraphicalConfigurationContext ctx) {
final BusinessObjectContext boc = ctx.getBusinessObjectContext();
final PropertyValueGroup pvg = boc.getBusinessObject(PropertyValueGroup.class).orElseThrow();
final Object parentBo = boc.getParent() == null ? null : boc.getParent().getBusinessObject();
// Use default property handler if the BO isn't a connection or connection reference.
if (!(parentBo instanceof Connection || parentBo instanceof ConnectionReference)) {
return pvgBoh.getGraphicalConfiguration(ctx);
}
final NamedValue namedValue = (NamedValue) pvg.getFirstValueBasedOnCompletelyProcessedAssociation().getValue();
Graphic graphic = null;
if (namedValue.getNamedValue() instanceof NamedElement) {
final NamedElement ne = (NamedElement) namedValue.getNamedValue();
if (CommunicationProperties.IMMEDIATE.equalsIgnoreCase(ne.getName())) {
graphic = IMMEDIATE_GRAPHIC;
} else if (CommunicationProperties.DELAYED.equalsIgnoreCase(ne.getName())) {
graphic = DELAYED_GRAPHIC;
}
}
if (graphic == null) {
return Optional.empty();
}
return Optional.of(GraphicalConfigurationBuilder.create().graphic(graphic).build());
}
use of org.osate.ge.aadl2.internal.model.PropertyValueGroup in project osate2 by osate.
the class PropertyValueGroupHandler method getRelativeReference.
@Override
public RelativeBusinessObjectReference getRelativeReference(final ReferenceContext ctx) {
final PropertyValueGroup pvg = ctx.getBusinessObject(PropertyValueGroup.class).orElseThrow();
final String propertyName = pvg.getProperty().getQualifiedName();
if (propertyName == null) {
throw new RuntimeException("Unable to build reference. Property name is null");
}
if (pvg.getReferenceId() == null) {
return new RelativeBusinessObjectReference(AadlReferenceUtil.PROPERTY_VALUE_GROUP_KEY, propertyName);
} else {
return new RelativeBusinessObjectReference(AadlReferenceUtil.PROPERTY_VALUE_GROUP_KEY, propertyName, pvg.getReferenceId().toString());
}
}
Aggregations