*/
private void initExtentMap(Object context) {
if (!getStatus().isOK() || context == null) {
return;
}
final Query queryToInit = getQuery();
final Object extentContext = context;
queryToInit.getExtentMap().clear();
if (queryToInit.queryText() != null
&& queryToInit.queryText().indexOf(
PredefinedType.ALL_INSTANCES_NAME) >= 0) {
AbstractVisitor visitior = new AbstractVisitor() {
private boolean usesAllInstances = false;
public Object visitOperationCallExp(OperationCallExp oc) {
if (!usesAllInstances) {
usesAllInstances = PredefinedType.ALL_INSTANCES == oc
.getOperationCode();
if (usesAllInstances) {
queryToInit
.getExtentMap()
.putAll(
oclInstance
.getEvaluationEnvironment()
.createExtentMap(
extentContext));
}
}
return super.visitOperationCallExp(oc);
}
};
queryToInit.getExpression().accept(visitior);
}
}