コード例 #1
0
 private void setReference(
     DelayedReference reference,
     Object singleForeachResult,
     IModelAdapter modelAdapter,
     ModelElementProxy foreachTargetElement,
     IModelInjector injector,
     int position)
     throws ModelElementCreationException, ModelAdapterException {
   // add the parsed part to the object first try to resolve if there is a model element that
   // already
   // exists and can be reused
   reference.setRealValue(injector.createOrResolve(foreachTargetElement, null, null));
   // by default use partition of reference.getModelElement
   if (reference.getModelElement() instanceof EObject
       && reference.getRealValue() instanceof EObject) {
     ((EObject) reference.getModelElement())
         .eResource()
         .getContents()
         .add((EObject) reference.getRealValue());
   }
   modelAdapter.set(
       reference.getModelElement(),
       reference.getPropertyName(),
       reference.getRealValue(),
       position);
 }
コード例 #2
0
 /**
  * If the <tt>reference</tt>'s {@link DelayedReference#getModelElement() model element} is a
  * proxy, resolve it first.
  */
 private void resolveModelElementProxy(DelayedReference reference, IModelAdapter modelAdapter)
     throws ModelAdapterException, ModelElementCreationException {
   if (reference.getModelElement() instanceof ModelElementProxy) {
     ModelElementProxy proxy = (ModelElementProxy) reference.getModelElement();
     if (proxy.getRealObject() == null) {
       Object result;
       result =
           modelAdapter.createOrResolveElement(
               proxy.getType(), proxy.getAttributeMap(), null, null, false, true);
       if (result instanceof EObject) {
         reference.setModelElement(result);
       }
     } else {
       reference.setModelElement(proxy.getRealObject());
     }
   }
 }
コード例 #3
0
 private PredicateSemantic getActivePredicateFromWhenAsClauses(
     DelayedReference reference,
     IModelAdapter modelAdapter,
     Object contextElement,
     Object currentForeachElement)
     throws ModelAdapterException {
   for (PredicateSemantic nextPred : reference.getPredicateActionList()) {
     if (nextPred.getWhen() != null) {
       Collection<?> resultBool =
           modelAdapter.evaluateOCLQuery(
               currentForeachElement, reference.getKeyValue(), nextPred.getWhen(), contextElement);
       if (resultBool.size() == 1) {
         Iterator<?> resIt = resultBool.iterator();
         Object nextBool = resIt.next();
         if (nextBool instanceof Boolean && (Boolean) nextBool) {
           return nextPred;
         }
       }
     } else {
       return nextPred; // no when-clause means "handle always"
     }
   }
   return null;
 }