Пример #1
0
 /**
  *
  * <!-- begin-user-doc -->
  * <!-- end-user-doc -->
  * <!-- begin-model-doc -->
  *
  * @param cr The receiving '<em><b>CR</b></em>' model object.
  * @param diagnostics The chain of diagnostics to which problems are to be appended.
  * @param context The cache of context-specific information.
  *     <!-- end-model-doc -->
  * @generated
  */
 public static boolean validateCR(
     CR cr, DiagnosticChain diagnostics, Map<Object, Object> context) {
   if (VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) {
     OCL.Helper helper = EOCL_ENV.createOCLHelper();
     helper.setContext(DatatypesPackage.Literals.CR);
     try {
       VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_INV =
           helper.createInvariant(VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP);
     } catch (ParserException pe) {
       throw new UnsupportedOperationException(pe.getLocalizedMessage());
     }
   }
   if (!EOCL_ENV.createQuery(VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(cr)) {
     if (diagnostics != null) {
       diagnostics.add(
           new BasicDiagnostic(
               Diagnostic.ERROR,
               DatatypesValidator.DIAGNOSTIC_SOURCE,
               DatatypesValidator.CR__CR,
               org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE.getString(
                   "_UI_GenericInvariant_diagnostic",
                   new Object[] {
                     "validateCR",
                     org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(cr, context)
                   }),
               new Object[] {cr}));
     }
     return false;
   }
   return true;
 }
Пример #2
0
 private EObjectCondition createMatcher(String expression) {
   OCL ocl = OCL.newInstance();
   try {
     return new BooleanOCLCondition<EClassifier, EClass, EObject>(
         ocl.getEnvironment(), expression, null);
   } catch (ParserException e) {
     throw new RuntimeException(e);
   }
 }
Пример #3
0
  public RowSourceHandler(ContainerHandler parent, RowSource rowSource) throws ParserException {
    this.parent = parent;
    OCL ocl = OCL.newInstance(parent.getEnvironment());
    Helper helper = ocl.createOCLHelper();
    OCLExpression expression = helper.createQuery(rowSource.getExpression());
    query = ocl.createQuery(expression);

    environment = parent.getEnvironment().getFactory().createEnvironment(parent.getEnvironment());
    Variable variable = EcoreFactory.eINSTANCE.createVariable();
    variable.setType(((CollectionType) expression.getType()).getElementType());
    varName = rowSource.getVar();
    environment.addElement(varName, variable, true);
  }
Пример #4
0
  private static OCLExpression parse(String expression) {
    if (expression == null) return null;

    OCLExpression oclExpression = null;
    Helper helper = OCL_ENV.createOCLHelper();
    helper.setContext(FragmentPackage.Literals.FRAGMENT);

    try {
      oclExpression = helper.createQuery(expression);
    } catch (ParserException e) {
      System.err.println(e.getLocalizedMessage());
    }
    return oclExpression;
  }
Пример #5
0
  private List<FacetValue> performDerivation(Fragment subject, FacetType facetType) {

    DerivationData derivationData = facetType.getDerivationData();
    String valueAsString = null;

    if (derivationData instanceof DirectDerivation) {
      DirectDerivation directDerivation = (DirectDerivation) derivationData;
      String rule = directDerivation.getRule();

      OCLExpression oclExpression = parse(rule);

      if (oclExpression == null) return Collections.emptyList();

      Query query = OCL_ENV.createQuery(oclExpression);
      Object result = null;

      try {
        result = query.evaluate(subject);
      } catch (Exception e) {
        e.printStackTrace();
        result = null;
      }

      valueAsString = result.toString();

      FacetValue derivedValue = null;
      for (FacetValue value : facetType.getValues()) {
        if (value.getName().equals(valueAsString)) {
          derivedValue = value;
          break;
        }
      }

      if (derivedValue == null) {
        derivedValue = FacetManager.buildFacetValue(valueAsString, null, null, null);
        facetType.getValues().add(derivedValue);
      }

      return Collections.singletonList(derivedValue);
    }

    return Collections.emptyList();
  }
Пример #6
0
  public void test_MessageExp_checkSignalArguments() {
    expectModified = true;
    MessagingFruitEnvironmentFactory envFactory =
        new MessagesTest.MessagingFruitEnvironmentFactory(this);
    ocl.dispose();
    ocl = OCL.newInstance(envFactory);
    helper = ocl.createOCLHelper();
    ((InitEnvironment) ocl.getEnvironment()).init();

    MessageExp m = factory.createMessageExp();

    SendSignalAction action = factory.createSendSignalAction();
    m.setSentSignal(action);

    EClass drop = (EClass) fruitPackage.getEClassifier("Drop");
    assertNotNull(drop);
    action.setSignal(drop);

    UnspecifiedValueExp arg = factory.createUnspecifiedValueExp();
    arg.setType(getOCLStandardLibrary().getInteger());
    m.getArgument().add(arg);

    arg = factory.createUnspecifiedValueExp();
    arg.setType(getOCLStandardLibrary().getBoolean());
    m.getArgument().add(arg);

    assertProblem(m, ExpressionsValidator.MESSAGE_EXP__SIGNAL_ARGUMENTS);

    arg.setType(stem);

    assertOK(m, ExpressionsValidator.MESSAGE_EXP__SIGNAL_ARGUMENTS);

    // wrong number of arguments
    m.getArgument().remove(arg);

    assertProblem(m, ExpressionsValidator.MESSAGE_EXP__SIGNAL_ARGUMENTS);
  }
/**
 *
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>IEpisode Observation</b></em>'.
 * <!-- end-user-doc -->
 *
 * <p>The following features are implemented:
 *
 * <ul>
 *   <li>{@link
 *       org.openhealthtools.mdht.uml.cda.apitest.domain.impl.IEpisodeObservationImpl#getCDAType
 *       <em>CDA Type</em>}
 * </ul>
 *
 * @generated
 */
public class IEpisodeObservationImpl extends EObjectImpl implements IEpisodeObservation {
  /**
   * The cached value of the '{@link #getCDAType() <em>CDA Type</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getCDAType()
   * @generated
   * @ordered
   */
  protected Observation cDAType;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  protected IEpisodeObservationImpl() {
    super();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  protected EClass eStaticClass() {
    return DomainPackage.Literals.IEPISODE_OBSERVATION;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Observation getCDAType() {
    if (cDAType != null && cDAType.eIsProxy()) {
      InternalEObject oldCDAType = (InternalEObject) cDAType;
      cDAType = (Observation) eResolveProxy(oldCDAType);
      if (cDAType != oldCDAType) {}
    }
    return cDAType;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Observation basicGetCDAType() {
    return cDAType;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void setCDAType(Observation newCDAType) {
    cDAType = newCDAType;
  }

  /**
   * The cached OCL expression body for the '{@link #getCode() <em>Get Code</em>}' operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getCode()
   * @generated
   * @ordered
   */
  protected static final String GET_CODE__EOCL_EXP = "self.code.oclAsType(datatypes::CD)";

  /**
   * The cached OCL query for the '{@link #getCode() <em>Get Code</em>}' query operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getCode()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_CODE__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public CD getCode() {
    if (GET_CODE__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IEPISODE_OBSERVATION,
          DomainPackage.Literals.IEPISODE_OBSERVATION.getEAllOperations().get(0));
      try {
        GET_CODE__EOCL_QRY = helper.createQuery(GET_CODE__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_CODE__EOCL_QRY);
    return (CD) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public CD withCode() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
    org.eclipse.emf.ecore.EFactory eFactory =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("CD");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    CD value = (CD) eObject;
    this.getCDAType().setCode(value);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IEpisodeObservation withCode(CD value) {
    this.getCDAType().setCode(value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getValue() <em>Get Value</em>}' operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getValue()
   * @generated
   * @ordered
   */
  protected static final String GET_VALUE__EOCL_EXP = "self.value.oclAsType(datatypes::CD)";

  /**
   * The cached OCL query for the '{@link #getValue() <em>Get Value</em>}' query operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getValue()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_VALUE__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public CD getValue() {
    if (GET_VALUE__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IEPISODE_OBSERVATION,
          DomainPackage.Literals.IEPISODE_OBSERVATION.getEAllOperations().get(3));
      try {
        GET_VALUE__EOCL_QRY = helper.createQuery(GET_VALUE__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_VALUE__EOCL_QRY);
    return (CD) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public CD withValue() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
    org.eclipse.emf.ecore.EFactory eFactory =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("CD");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    CD value = (CD) eObject;
    this.getCDAType().getValues().add(value);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IEpisodeObservation withValue(CD value) {
    this.getCDAType().getValues().add(value);
    return this;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID) {
      case DomainPackage.IEPISODE_OBSERVATION__CDA_TYPE:
        if (resolve) {
          return getCDAType();
        }
        return basicGetCDAType();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue) {
    switch (featureID) {
      case DomainPackage.IEPISODE_OBSERVATION__CDA_TYPE:
        setCDAType((Observation) newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public void eUnset(int featureID) {
    switch (featureID) {
      case DomainPackage.IEPISODE_OBSERVATION__CDA_TYPE:
        setCDAType((Observation) null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID) {
    switch (featureID) {
      case DomainPackage.IEPISODE_OBSERVATION__CDA_TYPE:
        return cDAType != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * The cached environment for evaluating OCL expressions.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   * @ordered
   */
  protected static final OCL EOCL_ENV = OCL.newInstance();

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IEpisodeObservation init() {
    CDAUtil.init(this);
    return this;
  }
} // IEpisodeObservationImpl
/**
 *
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Role Mixin</b></em>'.
 * <!-- end-user-doc -->
 *
 * <p>
 *
 * @generated
 */
public class RoleMixinImpl extends AntiRigidMixinClassImpl implements RoleMixin {
  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  protected RoleMixinImpl() {
    super();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  protected EClass eStaticClass() {
    return RefOntoUMLPackage.eINSTANCE.getRoleMixin();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Mediation mediation() {
    if (mediationBodyOCL == null) {
      EOperation eOperation = RefOntoUMLPackage.eINSTANCE.getRoleMixin().getEOperations().get(0);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getRoleMixin(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        mediationBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(mediationBodyOCL);

    return (Mediation) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Relator relator() {
    if (relatorBodyOCL == null) {
      EOperation eOperation = RefOntoUMLPackage.eINSTANCE.getRoleMixin().getEOperations().get(1);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getRoleMixin(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        relatorBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(relatorBodyOCL);

    return (Relator) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public EList<Role> roles() {
    if (rolesBodyOCL == null) {
      EOperation eOperation = RefOntoUMLPackage.eINSTANCE.getRoleMixin().getEOperations().get(2);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getRoleMixin(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        rolesBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(rolesBodyOCL);

    @SuppressWarnings("unchecked")
    Collection<Role> result = (Collection<Role>) query.evaluate(this);
    return new BasicEList.UnmodifiableEList<Role>(result.size(), result.toArray());
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public EList<RigidSortalClass> rigidSortals() {
    if (rigidSortalsBodyOCL == null) {
      EOperation eOperation = RefOntoUMLPackage.eINSTANCE.getRoleMixin().getEOperations().get(3);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getRoleMixin(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        rigidSortalsBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(rigidSortalsBodyOCL);

    @SuppressWarnings("unchecked")
    Collection<RigidSortalClass> result = (Collection<RigidSortalClass>) query.evaluate(this);
    return new BasicEList.UnmodifiableEList<RigidSortalClass>(result.size(), result.toArray());
  }

  /**
   * The parsed OCL expression for the body of the '{@link #mediation <em>Mediation</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #mediation
   * @generated
   */
  private static OCLExpression<EClassifier> mediationBodyOCL;

  /**
   * The parsed OCL expression for the body of the '{@link #relator <em>Relator</em>}' operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #relator
   * @generated
   */
  private static OCLExpression<EClassifier> relatorBodyOCL;

  /**
   * The parsed OCL expression for the body of the '{@link #roles <em>Roles</em>}' operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #roles
   * @generated
   */
  private static OCLExpression<EClassifier> rolesBodyOCL;

  /**
   * The parsed OCL expression for the body of the '{@link #rigidSortals <em>Rigid Sortals</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #rigidSortals
   * @generated
   */
  private static OCLExpression<EClassifier> rigidSortalsBodyOCL;

  private static final String OCL_ANNOTATION_SOURCE = "http://www.eclipse.org/ocl/examples/OCL";

  private static final OCL OCL_ENV = OCL.newInstance();
} // RoleMixinImpl
Пример #9
0
/**
 *
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>IProblem Entry</b></em>'.
 * <!-- end-user-doc -->
 *
 * <p>The following features are implemented:
 *
 * <ul>
 *   <li>{@link org.openhealthtools.mdht.uml.cda.apitest.domain.impl.IProblemEntryImpl#getCDAType
 *       <em>CDA Type</em>}
 * </ul>
 *
 * @generated
 */
public class IProblemEntryImpl extends EObjectImpl implements IProblemEntry {
  /**
   * The cached value of the '{@link #getCDAType() <em>CDA Type</em>}' reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getCDAType()
   * @generated
   * @ordered
   */
  protected Observation cDAType;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  protected IProblemEntryImpl() {
    super();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  protected EClass eStaticClass() {
    return DomainPackage.Literals.IPROBLEM_ENTRY;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Observation getCDAType() {
    if (cDAType != null && cDAType.eIsProxy()) {
      InternalEObject oldCDAType = (InternalEObject) cDAType;
      cDAType = (Observation) eResolveProxy(oldCDAType);
      if (cDAType != oldCDAType) {}
    }
    return cDAType;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public Observation basicGetCDAType() {
    return cDAType;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void setCDAType(Observation newCDAType) {
    cDAType = newCDAType;
  }

  /**
   * The cached OCL expression body for the '{@link #getIds() <em>Get Ids</em>}' operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getIds()
   * @generated
   * @ordered
   */
  protected static final String GET_IDS__EOCL_EXP = "self.id.oclAsType(datatypes::II)";

  /**
   * The cached OCL query for the '{@link #getIds() <em>Get Ids</em>}' query operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getIds()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_IDS__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public EList<II> getIds() {
    if (GET_IDS__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(0));
      try {
        GET_IDS__EOCL_QRY = helper.createQuery(GET_IDS__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_IDS__EOCL_QRY);
    @SuppressWarnings("unchecked")
    Collection<II> result = (Collection<II>) query.evaluate(this);
    return new BasicEList.UnmodifiableEList<II>(result.size(), result.toArray());
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public II addId() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
    org.eclipse.emf.ecore.EFactory eFactory =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("II");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    II value = (II) eObject;
    this.getCDAType().getIds().add(value);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry addId(II value) {
    // TODO: implement this method
    // Ensure that you remove @generated or mark it @generated NOT
    throw new UnsupportedOperationException();
  }

  /**
   * The cached OCL expression body for the '{@link #getProblemType() <em>Get Problem Type</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemType()
   * @generated
   * @ordered
   */
  protected static final String GET_PROBLEM_TYPE__EOCL_EXP = "self.code.oclAsType(datatypes::CD)";

  /**
   * The cached OCL query for the '{@link #getProblemType() <em>Get Problem Type</em>}' query
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemType()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_PROBLEM_TYPE__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public CD getProblemType() {
    if (GET_PROBLEM_TYPE__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(3));
      try {
        GET_PROBLEM_TYPE__EOCL_QRY = helper.createQuery(GET_PROBLEM_TYPE__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_TYPE__EOCL_QRY);
    return (CD) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public CD withProblemType() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
    org.eclipse.emf.ecore.EFactory eFactory =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("CD");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    CD value = (CD) eObject;
    this.getCDAType().setCode(value);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withProblemType(CD value) {
    this.getCDAType().setCode(value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getProblemName() <em>Get Problem Name</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemName()
   * @generated
   * @ordered
   */
  protected static final String GET_PROBLEM_NAME__EOCL_EXP = "self.text.oclAsType(datatypes::ED)";

  /**
   * The cached OCL query for the '{@link #getProblemName() <em>Get Problem Name</em>}' query
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemName()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_PROBLEM_NAME__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public ED getProblemName() {
    if (GET_PROBLEM_NAME__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(6));
      try {
        GET_PROBLEM_NAME__EOCL_QRY = helper.createQuery(GET_PROBLEM_NAME__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_NAME__EOCL_QRY);
    return (ED) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public ED withProblemName() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
    org.eclipse.emf.ecore.EFactory eFactory =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("ED");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    ED value = (ED) eObject;
    this.getCDAType().setText(value);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withProblemName(ED value) {
    this.getCDAType().setText(value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getProblemDate() <em>Get Problem Date</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemDate()
   * @generated
   * @ordered
   */
  protected static final String GET_PROBLEM_DATE__EOCL_EXP =
      "self.effectiveTime.oclAsType(datatypes::IVL_TS)";

  /**
   * The cached OCL query for the '{@link #getProblemDate() <em>Get Problem Date</em>}' query
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemDate()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_PROBLEM_DATE__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IVL_TS getProblemDate() {
    if (GET_PROBLEM_DATE__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(9));
      try {
        GET_PROBLEM_DATE__EOCL_QRY = helper.createQuery(GET_PROBLEM_DATE__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_DATE__EOCL_QRY);
    return (IVL_TS) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IVL_TS withProblemDate() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
    org.eclipse.emf.ecore.EFactory eFactory =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("IVL_TS");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    IVL_TS value = (IVL_TS) eObject;
    this.getCDAType().setEffectiveTime(value);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withProblemDate(IVL_TS value) {
    this.getCDAType().setEffectiveTime(value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getProblemCode() <em>Get Problem Code</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemCode()
   * @generated
   * @ordered
   */
  protected static final String GET_PROBLEM_CODE__EOCL_EXP = "self.value.oclAsType(datatypes::CD)";

  /**
   * The cached OCL query for the '{@link #getProblemCode() <em>Get Problem Code</em>}' query
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemCode()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_PROBLEM_CODE__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public CD getProblemCode() {
    if (GET_PROBLEM_CODE__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(12));
      try {
        GET_PROBLEM_CODE__EOCL_QRY = helper.createQuery(GET_PROBLEM_CODE__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_CODE__EOCL_QRY);
    return (CD) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public CD withProblemCode() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesPackage.eINSTANCE;
    org.eclipse.emf.ecore.EFactory eFactory =
        org.openhealthtools.mdht.uml.hl7.datatypes.DatatypesFactory.eINSTANCE;
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("CD");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    CD value = (CD) eObject;
    this.getCDAType().getValues().add(value);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withProblemCode(CD value) {
    this.getCDAType().getValues().add(value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getAgeAtOnset() <em>Get Age At Onset</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getAgeAtOnset()
   * @generated
   * @ordered
   */
  protected static final String GET_AGE_AT_ONSET__EOCL_EXP =
      "self.getObservations()->select(observation : cda::Observation | not observation.oclIsUndefined() and observation.oclIsKindOf(domain::IAgeObservation))->asSequence()->first().oclAsType(domain::IAgeObservation)";

  /**
   * The cached OCL query for the '{@link #getAgeAtOnset() <em>Get Age At Onset</em>}' query
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getAgeAtOnset()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_AGE_AT_ONSET__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IAgeObservation getAgeAtOnset() {
    if (GET_AGE_AT_ONSET__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(15));
      try {
        GET_AGE_AT_ONSET__EOCL_QRY = helper.createQuery(GET_AGE_AT_ONSET__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_AGE_AT_ONSET__EOCL_QRY);
    return (IAgeObservation) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IAgeObservation withAgeAtOnset() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEPackage(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EFactory eFactory =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEFactory(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("AgeObservation");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    try {
      java.lang.reflect.Method initMethod =
          eObject.getClass().getMethod("init", new java.lang.Class[0]);
      initMethod.invoke(eObject, new Object[0]);
    } catch (Exception e) {
      // no init() method
    }
    org.eclipse.emf.ecore.EPackage domainPackage = this.eClass().getEPackage();
    org.eclipse.emf.ecore.EFactory domainFactory = domainPackage.getEFactoryInstance();
    org.eclipse.emf.ecore.EClass domainEClass =
        (org.eclipse.emf.ecore.EClass) domainPackage.getEClassifier("IAgeObservation");
    IAgeObservation value = (IAgeObservation) domainFactory.create(domainEClass);
    value.setCDAType((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withAgeAtOnset(IAgeObservation value) {
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getSeverity() <em>Get Severity</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getSeverity()
   * @generated
   * @ordered
   */
  protected static final String GET_SEVERITY__EOCL_EXP =
      "self.getObservations()->select(observation : cda::Observation | not observation.oclIsUndefined() and observation.oclIsKindOf(domain::ISeverity))->asSequence()->first().oclAsType(domain::ISeverity)";

  /**
   * The cached OCL query for the '{@link #getSeverity() <em>Get Severity</em>}' query operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getSeverity()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_SEVERITY__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public ISeverity getSeverity() {
    if (GET_SEVERITY__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(18));
      try {
        GET_SEVERITY__EOCL_QRY = helper.createQuery(GET_SEVERITY__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_SEVERITY__EOCL_QRY);
    return (ISeverity) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public ISeverity withSeverity() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEPackage(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EFactory eFactory =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEFactory(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("Severity");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    try {
      java.lang.reflect.Method initMethod =
          eObject.getClass().getMethod("init", new java.lang.Class[0]);
      initMethod.invoke(eObject, new Object[0]);
    } catch (Exception e) {
      // no init() method
    }
    org.eclipse.emf.ecore.EPackage domainPackage = this.eClass().getEPackage();
    org.eclipse.emf.ecore.EFactory domainFactory = domainPackage.getEFactoryInstance();
    org.eclipse.emf.ecore.EClass domainEClass =
        (org.eclipse.emf.ecore.EClass) domainPackage.getEClassifier("ISeverity");
    ISeverity value = (ISeverity) domainFactory.create(domainEClass);
    value.setCDAType((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withSeverity(ISeverity value) {
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getProblemStatus() <em>Get Problem
   * Status</em>}' operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemStatus()
   * @generated
   * @ordered
   */
  protected static final String GET_PROBLEM_STATUS__EOCL_EXP =
      "self.getObservations()->select(observation : cda::Observation | not observation.oclIsUndefined() and observation.oclIsKindOf(domain::IProblemStatusObservation))->asSequence()->first().oclAsType(domain::IProblemStatusObservation)";

  /**
   * The cached OCL query for the '{@link #getProblemStatus() <em>Get Problem Status</em>}' query
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getProblemStatus()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_PROBLEM_STATUS__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemStatusObservation getProblemStatus() {
    if (GET_PROBLEM_STATUS__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(21));
      try {
        GET_PROBLEM_STATUS__EOCL_QRY = helper.createQuery(GET_PROBLEM_STATUS__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_STATUS__EOCL_QRY);
    return (IProblemStatusObservation) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemStatusObservation withProblemStatus() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEPackage(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EFactory eFactory =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEFactory(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("ProblemStatusObservation");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    try {
      java.lang.reflect.Method initMethod =
          eObject.getClass().getMethod("init", new java.lang.Class[0]);
      initMethod.invoke(eObject, new Object[0]);
    } catch (Exception e) {
      // no init() method
    }
    org.eclipse.emf.ecore.EPackage domainPackage = this.eClass().getEPackage();
    org.eclipse.emf.ecore.EFactory domainFactory = domainPackage.getEFactoryInstance();
    org.eclipse.emf.ecore.EClass domainEClass =
        (org.eclipse.emf.ecore.EClass) domainPackage.getEClassifier("IProblemStatusObservation");
    IProblemStatusObservation value =
        (IProblemStatusObservation) domainFactory.create(domainEClass);
    value.setCDAType((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withProblemStatus(IProblemStatusObservation value) {
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getHealthStatusObservation() <em>Get Health
   * Status Observation</em>}' operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getHealthStatusObservation()
   * @generated
   * @ordered
   */
  protected static final String GET_HEALTH_STATUS_OBSERVATION__EOCL_EXP =
      "self.getObservations()->select(observation : cda::Observation | not observation.oclIsUndefined() and observation.oclIsKindOf(domain::IHealthStatusObservation))->asSequence()->first().oclAsType(domain::IHealthStatusObservation)";

  /**
   * The cached OCL query for the '{@link #getHealthStatusObservation() <em>Get Health Status
   * Observation</em>}' query operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getHealthStatusObservation()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_HEALTH_STATUS_OBSERVATION__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IHealthStatusObservation getHealthStatusObservation() {
    if (GET_HEALTH_STATUS_OBSERVATION__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(24));
      try {
        GET_HEALTH_STATUS_OBSERVATION__EOCL_QRY =
            helper.createQuery(GET_HEALTH_STATUS_OBSERVATION__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_HEALTH_STATUS_OBSERVATION__EOCL_QRY);
    return (IHealthStatusObservation) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IHealthStatusObservation withHealthStatusObservation() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEPackage(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EFactory eFactory =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEFactory(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("HealthStatusObservation");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    try {
      java.lang.reflect.Method initMethod =
          eObject.getClass().getMethod("init", new java.lang.Class[0]);
      initMethod.invoke(eObject, new Object[0]);
    } catch (Exception e) {
      // no init() method
    }
    org.eclipse.emf.ecore.EPackage domainPackage = this.eClass().getEPackage();
    org.eclipse.emf.ecore.EFactory domainFactory = domainPackage.getEFactoryInstance();
    org.eclipse.emf.ecore.EClass domainEClass =
        (org.eclipse.emf.ecore.EClass) domainPackage.getEClassifier("IHealthStatusObservation");
    IHealthStatusObservation value = (IHealthStatusObservation) domainFactory.create(domainEClass);
    value.setCDAType((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withHealthStatusObservation(IHealthStatusObservation value) {
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) value);
    return this;
  }

  /**
   * The cached OCL expression body for the '{@link #getComments() <em>Get Comments</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getComments()
   * @generated
   * @ordered
   */
  protected static final String GET_COMMENTS__EOCL_EXP =
      "self.getActs()->select(act : cda::Act | not act.oclIsUndefined() and act.oclIsKindOf(domain::IComment)).oclAsType(domain::IComment)";

  /**
   * The cached OCL query for the '{@link #getComments() <em>Get Comments</em>}' query operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getComments()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_COMMENTS__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public EList<IComment> getComments() {
    if (GET_COMMENTS__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(27));
      try {
        GET_COMMENTS__EOCL_QRY = helper.createQuery(GET_COMMENTS__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_COMMENTS__EOCL_QRY);
    @SuppressWarnings("unchecked")
    Collection<IComment> result = (Collection<IComment>) query.evaluate(this);
    return new BasicEList.UnmodifiableEList<IComment>(result.size(), result.toArray());
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IComment addComment() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEPackage(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EFactory eFactory =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEFactory(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("Comment");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    try {
      java.lang.reflect.Method initMethod =
          eObject.getClass().getMethod("init", new java.lang.Class[0]);
      initMethod.invoke(eObject, new Object[0]);
    } catch (Exception e) {
      // no init() method
    }
    org.eclipse.emf.ecore.EPackage domainPackage = this.eClass().getEPackage();
    org.eclipse.emf.ecore.EFactory domainFactory = domainPackage.getEFactoryInstance();
    org.eclipse.emf.ecore.EClass domainEClass =
        (org.eclipse.emf.ecore.EClass) domainPackage.getEClassifier("IComment");
    IComment value = (IComment) domainFactory.create(domainEClass);
    value.setCDAType((org.openhealthtools.mdht.uml.cda.Act) eObject);
    this.getCDAType().addAct((org.openhealthtools.mdht.uml.cda.Act) eObject);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry addComment(IComment value) {
    // TODO: implement this method
    // Ensure that you remove @generated or mark it @generated NOT
    throw new UnsupportedOperationException();
  }

  /**
   * The cached OCL expression body for the '{@link #getCauseOfDeath() <em>Get Cause Of Death</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getCauseOfDeath()
   * @generated
   * @ordered
   */
  protected static final String GET_CAUSE_OF_DEATH__EOCL_EXP =
      "self.getObservations()->select(observation : cda::Observation | not observation.oclIsUndefined() and observation.oclIsKindOf(domain::ICauseOfDeathObservation))->asSequence()->first().oclAsType(domain::ICauseOfDeathObservation)";

  /**
   * The cached OCL query for the '{@link #getCauseOfDeath() <em>Get Cause Of Death</em>}' query
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getCauseOfDeath()
   * @generated
   * @ordered
   */
  protected static OCLExpression<EClassifier> GET_CAUSE_OF_DEATH__EOCL_QRY;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public ICauseOfDeathObservation getCauseOfDeath() {
    if (GET_CAUSE_OF_DEATH__EOCL_QRY == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setOperationContext(
          DomainPackage.Literals.IPROBLEM_ENTRY,
          DomainPackage.Literals.IPROBLEM_ENTRY.getEAllOperations().get(30));
      try {
        GET_CAUSE_OF_DEATH__EOCL_QRY = helper.createQuery(GET_CAUSE_OF_DEATH__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    OCL.Query query = EOCL_ENV.createQuery(GET_CAUSE_OF_DEATH__EOCL_QRY);
    return (ICauseOfDeathObservation) query.evaluate(this);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public ICauseOfDeathObservation withCauseOfDeath() {
    org.eclipse.emf.ecore.EPackage ePackage =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEPackage(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EFactory eFactory =
        org.eclipse.emf.ecore.EPackage.Registry.INSTANCE.getEFactory(
            "http://www.openhealthtools.org/mdht/uml/cda/apitest");
    org.eclipse.emf.ecore.EClass eClass =
        (org.eclipse.emf.ecore.EClass) ePackage.getEClassifier("CauseOfDeathObservation");
    org.eclipse.emf.ecore.EObject eObject = eFactory.create(eClass);
    try {
      java.lang.reflect.Method initMethod =
          eObject.getClass().getMethod("init", new java.lang.Class[0]);
      initMethod.invoke(eObject, new Object[0]);
    } catch (Exception e) {
      // no init() method
    }
    org.eclipse.emf.ecore.EPackage domainPackage = this.eClass().getEPackage();
    org.eclipse.emf.ecore.EFactory domainFactory = domainPackage.getEFactoryInstance();
    org.eclipse.emf.ecore.EClass domainEClass =
        (org.eclipse.emf.ecore.EClass) domainPackage.getEClassifier("ICauseOfDeathObservation");
    ICauseOfDeathObservation value = (ICauseOfDeathObservation) domainFactory.create(domainEClass);
    value.setCDAType((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) eObject);
    return value;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry withCauseOfDeath(ICauseOfDeathObservation value) {
    this.getCDAType().addObservation((org.openhealthtools.mdht.uml.cda.Observation) value);
    return this;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID) {
      case DomainPackage.IPROBLEM_ENTRY__CDA_TYPE:
        if (resolve) {
          return getCDAType();
        }
        return basicGetCDAType();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue) {
    switch (featureID) {
      case DomainPackage.IPROBLEM_ENTRY__CDA_TYPE:
        setCDAType((Observation) newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public void eUnset(int featureID) {
    switch (featureID) {
      case DomainPackage.IPROBLEM_ENTRY__CDA_TYPE:
        setCDAType((Observation) null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID) {
    switch (featureID) {
      case DomainPackage.IPROBLEM_ENTRY__CDA_TYPE:
        return cDAType != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   * The cached environment for evaluating OCL expressions.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   * @ordered
   */
  protected static final OCL EOCL_ENV = OCL.newInstance();

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public IProblemEntry init() {
    CDAUtil.init(this);
    return this;
  }
} // IProblemEntryImpl
/**
 *
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Measurement Dimension</b></em>'.
 * <!-- end-user-doc -->
 *
 * <p>The following features are implemented:
 *
 * <ul>
 *   <li>{@link RefOntoUML.impl.MeasurementDimensionImpl#getDomain <em>Domain</em>}
 *   <li>{@link RefOntoUML.impl.MeasurementDimensionImpl#getUnitOfMeasure <em>Unit Of Measure</em>}
 *   <li>{@link RefOntoUML.impl.MeasurementDimensionImpl#getLowerBound <em>Lower Bound</em>}
 *   <li>{@link RefOntoUML.impl.MeasurementDimensionImpl#getUpperBound <em>Upper Bound</em>}
 * </ul>
 *
 * @generated
 */
public abstract class MeasurementDimensionImpl extends MeasurementStructureImpl
    implements MeasurementDimension {
  /**
   * The default value of the '{@link #getUnitOfMeasure() <em>Unit Of Measure</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getUnitOfMeasure()
   * @generated
   * @ordered
   */
  protected static final String UNIT_OF_MEASURE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getUnitOfMeasure() <em>Unit Of Measure</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getUnitOfMeasure()
   * @generated
   * @ordered
   */
  protected String unitOfMeasure = UNIT_OF_MEASURE_EDEFAULT;

  /**
   * The cached value of the '{@link #getLowerBound() <em>Lower Bound</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getLowerBound()
   * @generated
   * @ordered
   */
  protected BasicMeasurementRegion lowerBound;

  /**
   * The cached value of the '{@link #getUpperBound() <em>Upper Bound</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #getUpperBound()
   * @generated
   * @ordered
   */
  protected BasicMeasurementRegion upperBound;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  protected MeasurementDimensionImpl() {
    super();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  protected EClass eStaticClass() {
    return RefOntoUMLPackage.eINSTANCE.getMeasurementDimension();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public MeasurementDomain getDomain() {
    if (eContainerFeatureID() != RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN) return null;
    return (MeasurementDomain) eContainer();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public NotificationChain basicSetDomain(MeasurementDomain newDomain, NotificationChain msgs) {
    msgs =
        eBasicSetContainer(
            (InternalEObject) newDomain, RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN, msgs);
    return msgs;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void setDomain(MeasurementDomain newDomain) {
    if (newDomain != eInternalContainer()
        || (eContainerFeatureID() != RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN
            && newDomain != null)) {
      if (EcoreUtil.isAncestor(this, newDomain))
        throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
      NotificationChain msgs = null;
      if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs);
      if (newDomain != null)
        msgs =
            ((InternalEObject) newDomain)
                .eInverseAdd(
                    this,
                    RefOntoUMLPackage.MEASUREMENT_DOMAIN__OWNED_DIMENSIONS,
                    MeasurementDomain.class,
                    msgs);
      msgs = basicSetDomain(newDomain, msgs);
      if (msgs != null) msgs.dispatch();
    } else if (eNotificationRequired())
      eNotify(
          new ENotificationImpl(
              this,
              Notification.SET,
              RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN,
              newDomain,
              newDomain));
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public String getUnitOfMeasure() {
    return unitOfMeasure;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void setUnitOfMeasure(String newUnitOfMeasure) {
    String oldUnitOfMeasure = unitOfMeasure;
    unitOfMeasure = newUnitOfMeasure;
    if (eNotificationRequired())
      eNotify(
          new ENotificationImpl(
              this,
              Notification.SET,
              RefOntoUMLPackage.MEASUREMENT_DIMENSION__UNIT_OF_MEASURE,
              oldUnitOfMeasure,
              unitOfMeasure));
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public BasicMeasurementRegion getLowerBound() {
    return lowerBound;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public NotificationChain basicSetLowerBound(
      BasicMeasurementRegion newLowerBound, NotificationChain msgs) {
    BasicMeasurementRegion oldLowerBound = lowerBound;
    lowerBound = newLowerBound;
    if (eNotificationRequired()) {
      ENotificationImpl notification =
          new ENotificationImpl(
              this,
              Notification.SET,
              RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND,
              oldLowerBound,
              newLowerBound);
      if (msgs == null) msgs = notification;
      else msgs.add(notification);
    }
    return msgs;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void setLowerBound(BasicMeasurementRegion newLowerBound) {
    if (newLowerBound != lowerBound) {
      NotificationChain msgs = null;
      if (lowerBound != null)
        msgs =
            ((InternalEObject) lowerBound)
                .eInverseRemove(
                    this,
                    EOPPOSITE_FEATURE_BASE - RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND,
                    null,
                    msgs);
      if (newLowerBound != null)
        msgs =
            ((InternalEObject) newLowerBound)
                .eInverseAdd(
                    this,
                    EOPPOSITE_FEATURE_BASE - RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND,
                    null,
                    msgs);
      msgs = basicSetLowerBound(newLowerBound, msgs);
      if (msgs != null) msgs.dispatch();
    } else if (eNotificationRequired())
      eNotify(
          new ENotificationImpl(
              this,
              Notification.SET,
              RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND,
              newLowerBound,
              newLowerBound));
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public BasicMeasurementRegion getUpperBound() {
    return upperBound;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public NotificationChain basicSetUpperBound(
      BasicMeasurementRegion newUpperBound, NotificationChain msgs) {
    BasicMeasurementRegion oldUpperBound = upperBound;
    upperBound = newUpperBound;
    if (eNotificationRequired()) {
      ENotificationImpl notification =
          new ENotificationImpl(
              this,
              Notification.SET,
              RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND,
              oldUpperBound,
              newUpperBound);
      if (msgs == null) msgs = notification;
      else msgs.add(notification);
    }
    return msgs;
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public void setUpperBound(BasicMeasurementRegion newUpperBound) {
    if (newUpperBound != upperBound) {
      NotificationChain msgs = null;
      if (upperBound != null)
        msgs =
            ((InternalEObject) upperBound)
                .eInverseRemove(
                    this,
                    EOPPOSITE_FEATURE_BASE - RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND,
                    null,
                    msgs);
      if (newUpperBound != null)
        msgs =
            ((InternalEObject) newUpperBound)
                .eInverseAdd(
                    this,
                    EOPPOSITE_FEATURE_BASE - RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND,
                    null,
                    msgs);
      msgs = basicSetUpperBound(newUpperBound, msgs);
      if (msgs != null) msgs.dispatch();
    } else if (eNotificationRequired())
      eNotify(
          new ENotificationImpl(
              this,
              Notification.SET,
              RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND,
              newUpperBound,
              newUpperBound));
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public boolean isNonBoundary() {
    if (isNonBoundaryBodyOCL == null) {
      EOperation eOperation =
          RefOntoUMLPackage.eINSTANCE.getMeasurementDimension().getEOperations().get(0);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getMeasurementDimension(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        isNonBoundaryBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(isNonBoundaryBodyOCL);

    return ((Boolean) query.evaluate(this)).booleanValue();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public boolean isOneBoundary() {
    if (isOneBoundaryBodyOCL == null) {
      EOperation eOperation =
          RefOntoUMLPackage.eINSTANCE.getMeasurementDimension().getEOperations().get(1);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getMeasurementDimension(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        isOneBoundaryBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(isOneBoundaryBodyOCL);

    return ((Boolean) query.evaluate(this)).booleanValue();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  public boolean isCircular() {
    if (isCircularBodyOCL == null) {
      EOperation eOperation =
          RefOntoUMLPackage.eINSTANCE.getMeasurementDimension().getEOperations().get(2);
      OCL.Helper helper = OCL_ENV.createOCLHelper();
      helper.setOperationContext(RefOntoUMLPackage.eINSTANCE.getMeasurementDimension(), eOperation);
      EAnnotation ocl = eOperation.getEAnnotation(OCL_ANNOTATION_SOURCE);
      String body = ocl.getDetails().get("body");

      try {
        isCircularBodyOCL = helper.createQuery(body);
      } catch (ParserException e) {
        throw new UnsupportedOperationException(e.getLocalizedMessage());
      }
    }

    Query<EClassifier, ?, ?> query = OCL_ENV.createQuery(isCircularBodyOCL);

    return ((Boolean) query.evaluate(this)).booleanValue();
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public NotificationChain eInverseAdd(
      InternalEObject otherEnd, int featureID, NotificationChain msgs) {
    switch (featureID) {
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN:
        if (eInternalContainer() != null) msgs = eBasicRemoveFromContainer(msgs);
        return basicSetDomain((MeasurementDomain) otherEnd, msgs);
    }
    return super.eInverseAdd(otherEnd, featureID, msgs);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(
      InternalEObject otherEnd, int featureID, NotificationChain msgs) {
    switch (featureID) {
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN:
        return basicSetDomain(null, msgs);
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND:
        return basicSetLowerBound(null, msgs);
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND:
        return basicSetUpperBound(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
    switch (eContainerFeatureID()) {
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN:
        return eInternalContainer()
            .eInverseRemove(
                this,
                RefOntoUMLPackage.MEASUREMENT_DOMAIN__OWNED_DIMENSIONS,
                MeasurementDomain.class,
                msgs);
    }
    return super.eBasicRemoveFromContainerFeature(msgs);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType) {
    switch (featureID) {
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN:
        return getDomain();
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UNIT_OF_MEASURE:
        return getUnitOfMeasure();
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND:
        return getLowerBound();
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND:
        return getUpperBound();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue) {
    switch (featureID) {
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN:
        setDomain((MeasurementDomain) newValue);
        return;
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UNIT_OF_MEASURE:
        setUnitOfMeasure((String) newValue);
        return;
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND:
        setLowerBound((BasicMeasurementRegion) newValue);
        return;
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND:
        setUpperBound((BasicMeasurementRegion) newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public void eUnset(int featureID) {
    switch (featureID) {
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN:
        setDomain((MeasurementDomain) null);
        return;
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UNIT_OF_MEASURE:
        setUnitOfMeasure(UNIT_OF_MEASURE_EDEFAULT);
        return;
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND:
        setLowerBound((BasicMeasurementRegion) null);
        return;
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND:
        setUpperBound((BasicMeasurementRegion) null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID) {
    switch (featureID) {
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__DOMAIN:
        return getDomain() != null;
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UNIT_OF_MEASURE:
        return UNIT_OF_MEASURE_EDEFAULT == null
            ? unitOfMeasure != null
            : !UNIT_OF_MEASURE_EDEFAULT.equals(unitOfMeasure);
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__LOWER_BOUND:
        return lowerBound != null;
      case RefOntoUMLPackage.MEASUREMENT_DIMENSION__UPPER_BOUND:
        return upperBound != null;
    }
    return super.eIsSet(featureID);
  }

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  @Override
  public String toString() {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (unitOfMeasure: ");
    result.append(unitOfMeasure);
    result.append(')');
    return result.toString();
  }

  /**
   * The parsed OCL expression for the body of the '{@link #isNonBoundary <em>Is Non Boundary</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #isNonBoundary
   * @generated
   */
  private static OCLExpression<EClassifier> isNonBoundaryBodyOCL;

  /**
   * The parsed OCL expression for the body of the '{@link #isOneBoundary <em>Is One Boundary</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #isOneBoundary
   * @generated
   */
  private static OCLExpression<EClassifier> isOneBoundaryBodyOCL;

  /**
   * The parsed OCL expression for the body of the '{@link #isCircular <em>Is Circular</em>}'
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #isCircular
   * @generated
   */
  private static OCLExpression<EClassifier> isCircularBodyOCL;

  private static final String OCL_ANNOTATION_SOURCE = "http://www.eclipse.org/ocl/examples/OCL";

  private static final OCL OCL_ENV = OCL.newInstance();
} // MeasurementDimensionImpl
Пример #11
0
/**
 *
 * <!-- begin-user-doc -->
 * A static utility class that provides operations related to '<em><b>CR</b></em>' model objects.
 * <!-- end-user-doc -->
 *
 * <p>The following operations are supported:
 *
 * <ul>
 *   <li>{@link
 *       org.openhealthtools.mdht.uml.hl7.datatypes.CR#validateCR(org.eclipse.emf.common.util.DiagnosticChain,
 *       java.util.Map) <em>Validate CR</em>}
 * </ul>
 *
 * @generated
 */
public class CROperations extends ANYOperations {
  /**
   * The cached environment for evaluating OCL expressions.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   * @ordered
   */
  protected static final OCL EOCL_ENV = OCL.newInstance();

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @generated
   */
  protected CROperations() {
    super();
  }

  /**
   * The cached OCL expression body for the '{@link #validateCR(CR,
   * org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Validate CR</em>}' operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #validateCR(CR, org.eclipse.emf.common.util.DiagnosticChain, java.util.Map)
   * @generated
   * @ordered
   */
  protected static final String VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP =
      "(self.isNullFlavorDefined() or self.isDefined('value')) and not(self.isNullFlavorDefined() and self.isDefined('value'))";

  /**
   * The cached OCL invariant for the '{@link #validateCR(CR,
   * org.eclipse.emf.common.util.DiagnosticChain, java.util.Map) <em>Validate CR</em>}' invariant
   * operation.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   *
   * @see #validateCR(CR, org.eclipse.emf.common.util.DiagnosticChain, java.util.Map)
   * @generated
   * @ordered
   */
  protected static Constraint VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_INV;

  /**
   *
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * <!-- begin-model-doc -->
   *
   * @param cr The receiving '<em><b>CR</b></em>' model object.
   * @param diagnostics The chain of diagnostics to which problems are to be appended.
   * @param context The cache of context-specific information.
   *     <!-- end-model-doc -->
   * @generated
   */
  public static boolean validateCR(
      CR cr, DiagnosticChain diagnostics, Map<Object, Object> context) {
    if (VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_INV == null) {
      OCL.Helper helper = EOCL_ENV.createOCLHelper();
      helper.setContext(DatatypesPackage.Literals.CR);
      try {
        VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_INV =
            helper.createInvariant(VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_EXP);
      } catch (ParserException pe) {
        throw new UnsupportedOperationException(pe.getLocalizedMessage());
      }
    }
    if (!EOCL_ENV.createQuery(VALIDATE_CR__DIAGNOSTIC_CHAIN_MAP__EOCL_INV).check(cr)) {
      if (diagnostics != null) {
        diagnostics.add(
            new BasicDiagnostic(
                Diagnostic.ERROR,
                DatatypesValidator.DIAGNOSTIC_SOURCE,
                DatatypesValidator.CR__CR,
                org.eclipse.emf.ecore.plugin.EcorePlugin.INSTANCE.getString(
                    "_UI_GenericInvariant_diagnostic",
                    new Object[] {
                      "validateCR",
                      org.eclipse.emf.ecore.util.EObjectValidator.getObjectLabel(cr, context)
                    }),
                new Object[] {cr}));
      }
      return false;
    }
    return true;
  }
} // CROperations
Пример #12
0
/** @author Matthias Schmidt */
public class DirectDerivator extends Derivator {

  private static final OCL OCL_ENV = OCL.newInstance(new EnhancedEcoreEnvironmentFactory());

  /*
   * (non-Javadoc)
   *
   * @see
   * org.reuseware.coconut.description.classify.derivate.Derivator#derive(
   * org.reuseware.coconut.fragment.Fragment)
   */
  @Override
  public Facet derive(Fragment subject, FacetType facetType) {
    if (!(facetType.getDerivationData() instanceof DirectDerivation)) return null;

    String rule = ((DirectDerivation) facetType.getDerivationData()).getRule();
    System.out.println("Rule: " + rule);

    List<FacetValue> values = performDerivation(subject, facetType);

    return buildFacet(facetType, values);
  }

  private List<FacetValue> performDerivation(Fragment subject, FacetType facetType) {

    DerivationData derivationData = facetType.getDerivationData();
    String valueAsString = null;

    if (derivationData instanceof DirectDerivation) {
      DirectDerivation directDerivation = (DirectDerivation) derivationData;
      String rule = directDerivation.getRule();

      OCLExpression oclExpression = parse(rule);

      if (oclExpression == null) return Collections.emptyList();

      Query query = OCL_ENV.createQuery(oclExpression);
      Object result = null;

      try {
        result = query.evaluate(subject);
      } catch (Exception e) {
        e.printStackTrace();
        result = null;
      }

      valueAsString = result.toString();

      FacetValue derivedValue = null;
      for (FacetValue value : facetType.getValues()) {
        if (value.getName().equals(valueAsString)) {
          derivedValue = value;
          break;
        }
      }

      if (derivedValue == null) {
        derivedValue = FacetManager.buildFacetValue(valueAsString, null, null, null);
        facetType.getValues().add(derivedValue);
      }

      return Collections.singletonList(derivedValue);
    }

    return Collections.emptyList();
  }

  private static OCLExpression parse(String expression) {
    if (expression == null) return null;

    OCLExpression oclExpression = null;
    Helper helper = OCL_ENV.createOCLHelper();
    helper.setContext(FragmentPackage.Literals.FRAGMENT);

    try {
      oclExpression = helper.createQuery(expression);
    } catch (ParserException e) {
      System.err.println(e.getLocalizedMessage());
    }
    return oclExpression;
  }

  /*
   * (non-Javadoc)
   *
   * @see
   * org.reuseware.coconut.description.classify.derivate.Derivator#getID()
   */
  @Override
  public String getID() {
    return DerivationManager.ID_DirectDerivator;
  }
}