use of org.osate.ba.aadlba.BehaviorVariable in project osate2 by osate.
the class AadlBaNameResolver method baVariableResolver.
private boolean baVariableResolver(Identifier id, boolean hasToReport) {
String variableName = id.getId();
BehaviorVariable v = AadlBaVisitors.findBehaviorVariable(_ba, variableName);
if (v != null) {
id.setBaRef(v);
return true;
} else {
if (hasToReport) {
reportNameError(id, variableName);
}
return false;
}
}
use of org.osate.ba.aadlba.BehaviorVariable in project osate2 by osate.
the class AadlBaNameResolver method refResolver.
// Resolves Reference objects (arrayable identifiers)
// within parent component's features ones and ba's variables ones and
// for/forall's iterative variable scope handler.
private boolean refResolver(Classifier parentContainer, Reference ref) {
boolean result = true;
boolean currentIdResult = false;
ListIterator<ArrayableIdentifier> it = ref.getIds().listIterator();
// Checks ArrayableIdentifier objects.
while (it.hasNext()) {
ArrayableIdentifier id = it.next();
// Can't resolve within a null parent classifier.
if (parentContainer == null) {
result = false;
reportNameError(id, id.getId());
break;
}
if (parentContainer == _baParentContainer) {
currentIdResult = identifierBaResolver(id, false);
}
if (!currentIdResult) {
currentIdResult = identifierComponentResolver(id, parentContainer, true);
}
if (id.isSetArrayIndexes()) {
// Checks array indexes names.
for (IntegerValue index : id.getArrayIndexes()) {
// Recursive call.
result &= integerValueResolver(index);
}
}
// If the current id is found, fetch the container for the next id.
if (currentIdResult && it.hasNext()) {
Element el = AadlBaTypeChecker.getBindedElement(id);
// not been type checked already.
if (el instanceof BehaviorVariable) {
QualifiedNamedElement qne = (QualifiedNamedElement) ((BehaviorVariable) el).getDataClassifier();
parentContainer = (Classifier) qne.getOsateRef();
} else if (el instanceof IterativeVariable) {
IterativeVariable itv = (IterativeVariable) el;
QualifiedNamedElement qne = (QualifiedNamedElement) itv.getDataClassifier();
parentContainer = (Classifier) qne.getOsateRef();
} else {
parentContainer = AadlBaUtils.getClassifier(el, parentContainer);
}
}
// Add the current id result to the global result.
result &= currentIdResult;
// Reset.
currentIdResult = false;
// Don't continue if the current id is not found.
if (result == false) {
break;
}
}
// Binds with the last id reference.
ArrayableIdentifier lastId = ref.getIds().get((ref.getIds().size() - 1));
ref.setOsateRef(lastId.getOsateRef());
ref.setBaRef(lastId.getBaRef());
return result;
}
use of org.osate.ba.aadlba.BehaviorVariable in project osate2 by osate.
the class BehaviorVariablePropertySection method getDataClassifierLabel.
private static String getDataClassifierLabel(final List<BehaviorVariable> behaviorVariables) {
final Iterator<BehaviorVariable> it = behaviorVariables.iterator();
BehaviorVariable bv = it.next();
final DataClassifier dc = bv.getDataClassifier();
while (it.hasNext()) {
bv = it.next();
// If variable data classifiers are not the same, set to multiple
if (dc != bv.getDataClassifier()) {
return "<Multiple>";
}
}
if (dc instanceof QualifiedNamedElement) {
final QualifiedNamedElement qualNamedElement = (QualifiedNamedElement) dc;
final Identifier baNamespace = qualNamedElement.getBaNamespace();
final Identifier baName = qualNamedElement.getBaName();
return new StringBuilder(baNamespace == null ? "" : baNamespace.getId()).append("::").append(baName == null ? "" : baName.getId()).toString();
}
return dc.getQualifiedName();
}
use of org.osate.ba.aadlba.BehaviorVariable in project osate2 by osate.
the class BehaviorVariableHandler method delete.
@Override
public void delete(final CustomDeleteContext ctx) {
final BehaviorAnnex behaviorAnnex = ctx.getContainerBusinessObject(BehaviorAnnex.class).orElseThrow();
// Find variable by URI.
final BehaviorVariable behaviorVariable = (BehaviorVariable) behaviorAnnex.eResource().getResourceSet().getEObject(EcoreUtil.getURI(ctx.getReadonlyBoToDelete(BehaviorVariable.class).orElseThrow()), true);
EcoreUtil.remove(behaviorVariable);
if (behaviorAnnex.getVariables().isEmpty()) {
behaviorAnnex.unsetVariables();
}
}
Aggregations