use of org.osate.aadl2.PropertyType in project osate2 by osate.
the class NamedElementImpl method checkPropertyAssociation.
/**
* Check that the proposed association is legal.
*/
public void checkPropertyAssociation(final Property pd, final Collection<? extends PropertyExpression> vals) {
// Check that the property applies to this element
if (!acceptsProperty(pd)) {
throw new IllegalArgumentException("Property " + pd.getName() + " does not apply to " + getName());
}
final boolean isList = pd.isList();
if (!isList) {
if (vals.size() == 0) {
throw new IllegalArgumentException("Cannot assign an empty list to the non-list property " + pd.getName());
} else if (vals.size() > 1) {
throw new IllegalArgumentException("Cannot assign a list of values to the non-list property " + pd.getName());
}
}
final PropertyType pt = (PropertyType) pd.getType();
if (pt == null) {
return;
// for (final Iterator<? extends PropertyExpression> i =
// vals.iterator(); i.hasNext();) {
// final PropertyExpression pv = i.next();
// final String msg = pt.containsValue(isList, pv);
// if (msg != PropertyType.VALUE_OKAY) {
// throw new IllegalArgumentException("Type mismatch: " + msg);
// }
// }
}
}
use of org.osate.aadl2.PropertyType in project geo-platform by geosdi.
the class AbstractTranctionUpdate method getPropertyToUpdate.
/**
* @param attributes
* @return {@link List<PropertyType>}
* @throws Exception
*/
final List<PropertyType> getPropertyToUpdate(@Nonnull(when = NEVER) List<AttributeDTO> attributes) throws Exception {
checkArgument((attributes != null) && !(attributes.isEmpty()), "The Parameter attributes must not be null or empty.");
List<PropertyType> properties = Lists.newArrayListWithCapacity(attributes.size());
for (AttributeDTO attribute : attributes) {
if (!attribute.isNillable() && attribute.getValue() == null) {
throw new IllegalParameterFault("Property '" + attribute.getName() + "' cannot be null.");
}
PropertyType property = new PropertyType();
QName qName = new QName(attribute.getName());
property.setName(qName);
property.setValue(((attribute instanceof GeometryAttributeDTO) ? createGeometry((GeometryAttributeDTO) attribute) : attribute.getValue()));
properties.add(property);
}
return properties;
}
use of org.osate.aadl2.PropertyType in project osate2 by osate.
the class ReqValDeclarationImpl method basicSetProperty.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public NotificationChain basicSetProperty(PropertyType newProperty, NotificationChain msgs) {
PropertyType oldProperty = property;
property = newProperty;
if (eNotificationRequired()) {
ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, ReqSpecPackage.REQ_VAL_DECLARATION__PROPERTY, oldProperty, newProperty);
if (msgs == null)
msgs = notification;
else
msgs.add(notification);
}
return msgs;
}
use of org.osate.aadl2.PropertyType in project osate2 by osate.
the class AadlBaUtils method getDataRepresentation.
/**
* Returns the data representation associated to the given PropertyReference
* object <BR><BR>
* Note : {@link #getDataRepresentation(PropertyType)} and
* {@link #getDataRepresentation(PropertyExpression)} to see restrictions.
* <BR><BR>
* @param pv the given PropertyReference object
* @return the data representation associated to the given
* PropertyReference object
* @exception UnsupportedOperationException for the unsupported types
*/
public static DataRepresentation getDataRepresentation(PropertyReference pr) {
EList<PropertyNameHolder> holders = pr.getProperties();
PropertyNameHolder last = holders.get(holders.size() - 1);
Element el = last.getProperty().getElement();
if (el instanceof PropertyType || el instanceof BasicProperty) {
return getDataRepresentation(((BasicProperty) el).getPropertyType());
} else if (el instanceof PropertyAssociation) {
return getDataRepresentation((PropertyAssociation) el);
} else if (el instanceof PropertyExpression) {
return getDataRepresentation((PropertyExpression) el);
} else if (el instanceof EnumerationLiteral) {
return DataRepresentation.ENUM_LITERAL;
} else {
String errorMsg = "getDataRepresentation: " + el.getClass().getSimpleName() + " is not supported yet.";
System.err.println(errorMsg);
throw new UnsupportedOperationException(errorMsg);
}
}
use of org.osate.aadl2.PropertyType in project osate2 by osate.
the class AadlBaUtils method getPropertyType.
/**
* Returns the PropertyType object associated to the given PropertyElementHolder
* given object.
* @param holder the PropertyElementHolder given object
* @return the associated PropertyType object
*/
public static PropertyType getPropertyType(PropertyElementHolder holder) {
PropertyType result = null;
Element el = holder.getElement();
if (el instanceof PropertyType) {
result = (PropertyType) el;
} else if (el instanceof BasicProperty) {
result = ((BasicProperty) el).getPropertyType();
} else if (el instanceof PropertyAssociation) {
result = ((PropertyAssociation) el).getProperty().getPropertyType();
} else if (el instanceof PropertyExpression) {
result = PropertyUtils.getContainingProperty((PropertyExpression) el).getPropertyType();
} else if (el instanceof EnumerationLiteral) {
result = (EnumerationType) el.eContainer();
}
return result;
}
Aggregations