Search in sources :

Example 1 with PropertyValueGroup

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());
    }
}
Also used : PropertyValueGroup(org.osate.ge.aadl2.internal.model.PropertyValueGroup) DiagramElement(org.osate.ge.internal.diagram.runtime.DiagramElement) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 2 with PropertyValueGroup

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();
}
Also used : PropertyValueGroup(org.osate.ge.aadl2.internal.model.PropertyValueGroup) ContainmentPathElement(org.osate.aadl2.ContainmentPathElement) StringLiteral(org.osate.aadl2.StringLiteral) NamedValue(org.osate.aadl2.NamedValue) RangeValue(org.osate.aadl2.RangeValue) NodeModelUtils(org.eclipse.xtext.nodemodel.util.NodeModelUtils) ArrayRange(org.osate.aadl2.ArrayRange) AgePropertyValue(org.osate.ge.aadl2.internal.model.AgePropertyValue) BusinessObjectContext(org.osate.ge.BusinessObjectContext) Classifier(org.osate.aadl2.Classifier) RecordValue(org.osate.aadl2.RecordValue) ComputedValue(org.osate.aadl2.ComputedValue) INode(org.eclipse.xtext.nodemodel.INode) BasicPropertyAssociation(org.osate.aadl2.BasicPropertyAssociation) ClassifierValue(org.osate.aadl2.ClassifierValue) AadlUtil(org.osate.aadl2.modelsupport.util.AadlUtil) IntegerLiteral(org.osate.aadl2.IntegerLiteral) InstanceReferenceValue(org.osate.aadl2.instance.InstanceReferenceValue) EObject(org.eclipse.emf.ecore.EObject) Collectors(java.util.stream.Collectors) AbstractNamedValue(org.osate.aadl2.AbstractNamedValue) PropertyValueGroup(org.osate.ge.aadl2.internal.model.PropertyValueGroup) List(java.util.List) Stream(java.util.stream.Stream) Ordering(com.google.common.collect.Ordering) BooleanLiteral(org.osate.aadl2.BooleanLiteral) NamedElement(org.osate.aadl2.NamedElement) Comparator(java.util.Comparator) RealLiteral(org.osate.aadl2.RealLiteral) AgePropertyValue(org.osate.ge.aadl2.internal.model.AgePropertyValue) BusinessObjectContext(org.osate.ge.BusinessObjectContext)

Example 3 with PropertyValueGroup

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;
}
Also used : PropertyValueGroup(org.osate.ge.aadl2.internal.model.PropertyValueGroup) NamedValue(org.osate.aadl2.NamedValue) NamedElement(org.osate.aadl2.NamedElement)

Example 4 with PropertyValueGroup

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());
}
Also used : PropertyValueGroup(org.osate.ge.aadl2.internal.model.PropertyValueGroup) Graphic(org.osate.ge.graphics.Graphic) ConnectionReference(org.osate.aadl2.instance.ConnectionReference) Connection(org.osate.aadl2.Connection) NamedValue(org.osate.aadl2.NamedValue) BusinessObjectContext(org.osate.ge.BusinessObjectContext) NamedElement(org.osate.aadl2.NamedElement)

Example 5 with PropertyValueGroup

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());
    }
}
Also used : PropertyValueGroup(org.osate.ge.aadl2.internal.model.PropertyValueGroup) RelativeBusinessObjectReference(org.osate.ge.RelativeBusinessObjectReference)

Aggregations

PropertyValueGroup (org.osate.ge.aadl2.internal.model.PropertyValueGroup)6 NamedElement (org.osate.aadl2.NamedElement)3 NamedValue (org.osate.aadl2.NamedValue)3 BusinessObjectContext (org.osate.ge.BusinessObjectContext)3 RelativeBusinessObjectReference (org.osate.ge.RelativeBusinessObjectReference)2 AgePropertyValue (org.osate.ge.aadl2.internal.model.AgePropertyValue)2 Ordering (com.google.common.collect.Ordering)1 Comparator (java.util.Comparator)1 List (java.util.List)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 EObject (org.eclipse.emf.ecore.EObject)1 INode (org.eclipse.xtext.nodemodel.INode)1 NodeModelUtils (org.eclipse.xtext.nodemodel.util.NodeModelUtils)1 AbstractNamedValue (org.osate.aadl2.AbstractNamedValue)1 ArrayRange (org.osate.aadl2.ArrayRange)1 BasicPropertyAssociation (org.osate.aadl2.BasicPropertyAssociation)1 BooleanLiteral (org.osate.aadl2.BooleanLiteral)1 Classifier (org.osate.aadl2.Classifier)1