public static boolean check(EObject eObject, String body) throws Exception { OCL.Helper helper = ocl.createOCLHelper(); helper.setContext(eObject.eClass()); Constraint constraint = helper.createInvariant(body); OCL.Query query = ocl.createQuery(constraint); return query.check(eObject); }
/** * Creates a new <code>OCL</code> using the shared Ecore environment * factory instance. * * @return the new <code>OCL</code> */ public static OCL newInstance() { return new OCL(EcoreEnvironmentFactory.INSTANCE); }
public void dispose() { if (ocl != null) { ocl.dispose(); } }
OCL.Query oclQuery = ocl.createQuery(query); Environment<EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> env = ocl.getEnvironment(); EClassifier contextType = evalEnv.getType(target); if (!TypeUtil.compatibleTypeMatch(env, contextType, context)) {
protected OCLExpression createQuery(String expression) { OCL ocl = delegateDomain.getOCL(); Helper helper = ocl.createOCLHelper(); helper.setContext(eClassifier); try { return helper.createQuery(/*(String)*/expression); } catch (ParserException e) { throw new org.eclipse.ocl.ecore.delegate.OCLDelegateException(e.getLocalizedMessage(), e); } }
protected boolean check(Object object, String constraint, OCLExpression query) { OCL ocl = delegateDomain.getOCL(); OCLStandardLibrary<EClassifier> stdlib = ocl.getEnvironment().getOCLStandardLibrary(); if (query.getType() != stdlib.getBoolean()) { String message = NLS.bind(OCLMessages.ValidationConstraintIsNotBoolean_ERROR_, constraint); throw new org.eclipse.ocl.ecore.delegate.OCLDelegateException(message); } Object result = ocl.evaluate(object, query); if (ocl.isInvalid(result)) { String message = NLS.bind(OCLMessages.ValidationResultIsInvalid_ERROR_, constraint); throw new org.eclipse.ocl.ecore.delegate.OCLDelegateException(message); } if ((result == null) /* || ocl.isInvalid(result) */) { String message = NLS.bind(OCLMessages.ValidationResultIsNull_ERROR_, constraint); throw new org.eclipse.ocl.ecore.delegate.OCLDelegateException(message); } if (!(result instanceof Boolean)) { String message = NLS.bind(OCLMessages.ValidationResultIsNotBoolean_ERROR_, constraint); throw new org.eclipse.ocl.ecore.delegate.OCLDelegateException(message); } return Boolean.TRUE.equals(result); }
@Override protected OCLExpression<EClassifier> getPropertyBody( EStructuralFeature property) { OCLExpression<EClassifier> result = SettingBehavior.INSTANCE .getCachedOCLExpression(property); if (result == SettingBehavior.NO_OCL_DEFINITION) { result = null; } else if (result == null) { if (SettingBehavior.INSTANCE.hasCompileableFeatureBody(property)) { OCL ocl = OCL.newInstance(getEnvironment().getFactory()); result = SettingBehavior.INSTANCE.getFeatureBody(ocl, property); ocl.dispose(); } if (result == null) { result = super.getPropertyBody(property); } } return result; }
/** * Tries to fetch an operation body from where the * {@link OCLInvocationDelegate OCL invocation delegate} stores it. If nothing * is found, this method delegates to the base class implementation which then * performs the usual search in the OCL_NAMESPACE_URI annotation and the * environment's body condition cache. */ @Override protected OCLExpression<EClassifier> getOperationBody(EOperation operation) { OCLExpression<EClassifier> result = InvocationBehavior.INSTANCE .getCachedOCLExpression(operation); if (result == InvocationBehavior.NO_OCL_DEFINITION) { result = null; } else if (result == null) { if (InvocationBehavior.INSTANCE.hasCompileableOperationBody(operation)) { OCL ocl = OCL.newInstance(getEnvironment().getFactory()); result = InvocationBehavior.INSTANCE.getOperationBody(ocl, operation); ocl.dispose(); } if (result == null) { result = super.getOperationBody(operation); } } return result; }
public static Object query(EObject eObject, String body) throws Exception { OCL.Helper helper = ocl.createOCLHelper(); helper.setContext(eObject.eClass()); OCLExpression expression = helper.createQuery(body); OCL.Query query = ocl.createQuery(expression); return query.evaluate(eObject); }
/** * Creates a new <code>OCL</code> using the specified Ecore environment * factory. * * @param envFactory an environment factory for Ecore * @return the new <code>OCL</code> */ public static OCL newInstance(EnvironmentFactory< EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> envFactory) { return new OCL(envFactory); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static ProblemEntry getProblemEntry(AbdomenSection abdomenSection) { if (GET_PROBLEM_ENTRY__EOCL_QRY == null) { OCL.Helper helper = EOCL_ENV.createOCLHelper(); helper.setOperationContext( IHEPackage.Literals.ABDOMEN_SECTION, IHEPackage.Literals.ABDOMEN_SECTION.getEAllOperations().get(58)); try { GET_PROBLEM_ENTRY__EOCL_QRY = helper.createQuery(GET_PROBLEM_ENTRY__EOCL_EXP); } catch (ParserException pe) { throw new UnsupportedOperationException(pe.getLocalizedMessage()); } } OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_ENTRY__EOCL_QRY); return (ProblemEntry) query.evaluate(abdomenSection); }
/** * Creates a new <code>OCL</code> using the specified initial Ecore * environment. * * @param env an environment for Ecore * @return the new <code>OCL</code> */ public static OCL newInstance(Environment< EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> env) { return new OCL(env); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static PhysicalExamSection getPhysicalExamSection(ProgressNote progressNote) { if (GET_PHYSICAL_EXAM_SECTION__EOCL_QRY == null) { OCL.Helper helper = EOCL_ENV.createOCLHelper(); helper.setOperationContext( ConsolPackage.Literals.PROGRESS_NOTE, ConsolPackage.Literals.PROGRESS_NOTE.getEAllOperations().get(332)); try { GET_PHYSICAL_EXAM_SECTION__EOCL_QRY = helper.createQuery(GET_PHYSICAL_EXAM_SECTION__EOCL_EXP); } catch (ParserException pe) { throw new UnsupportedOperationException(pe.getLocalizedMessage()); } } OCL.Query query = EOCL_ENV.createQuery(GET_PHYSICAL_EXAM_SECTION__EOCL_QRY); return (PhysicalExamSection) query.evaluate(progressNote); }
/** * Creates a new <code>OCL</code> using the specified Ecore environment * factory and a resource from which to load the initial environment. * * @param envFactory an environment factory for Ecore * @param resource the resource containing a persistent environment * (which may be empty for an initially empty environment) * @return the new <code>OCL</code> */ public static OCL newInstance(EnvironmentFactory< EPackage, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, EObject, CallOperationAction, SendSignalAction, Constraint, EClass, EObject> envFactory, Resource resource) { return new OCL(envFactory, resource); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static VitalSignsSectionEntriesOptional getVitalSignsSectionEntriesOptional(ProgressNote progressNote) { if (GET_VITAL_SIGNS_SECTION_ENTRIES_OPTIONAL__EOCL_QRY == null) { OCL.Helper helper = EOCL_ENV.createOCLHelper(); helper.setOperationContext( ConsolPackage.Literals.PROGRESS_NOTE, ConsolPackage.Literals.PROGRESS_NOTE.getEAllOperations().get(337)); try { GET_VITAL_SIGNS_SECTION_ENTRIES_OPTIONAL__EOCL_QRY = helper.createQuery(GET_VITAL_SIGNS_SECTION_ENTRIES_OPTIONAL__EOCL_EXP); } catch (ParserException pe) { throw new UnsupportedOperationException(pe.getLocalizedMessage()); } } OCL.Query query = EOCL_ENV.createQuery(GET_VITAL_SIGNS_SECTION_ENTRIES_OPTIONAL__EOCL_QRY); return (VitalSignsSectionEntriesOptional) query.evaluate(progressNote); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static ProblemEntry getProblemEntry(HeadSection headSection) { if (GET_PROBLEM_ENTRY__EOCL_QRY == null) { OCL.Helper helper = EOCL_ENV.createOCLHelper(); helper.setOperationContext( IHEPackage.Literals.HEAD_SECTION, IHEPackage.Literals.HEAD_SECTION.getEAllOperations().get(58)); try { GET_PROBLEM_ENTRY__EOCL_QRY = helper.createQuery(GET_PROBLEM_ENTRY__EOCL_EXP); } catch (ParserException pe) { throw new UnsupportedOperationException(pe.getLocalizedMessage()); } } OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_ENTRY__EOCL_QRY); return (ProblemEntry) query.evaluate(headSection); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static ProblemEntry getProblemEntry(RectumSection rectumSection) { if (GET_PROBLEM_ENTRY__EOCL_QRY == null) { OCL.Helper helper = EOCL_ENV.createOCLHelper(); helper.setOperationContext( IHEPackage.Literals.RECTUM_SECTION, IHEPackage.Literals.RECTUM_SECTION.getEAllOperations().get(58)); try { GET_PROBLEM_ENTRY__EOCL_QRY = helper.createQuery(GET_PROBLEM_ENTRY__EOCL_EXP); } catch (ParserException pe) { throw new UnsupportedOperationException(pe.getLocalizedMessage()); } } OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_ENTRY__EOCL_QRY); return (ProblemEntry) query.evaluate(rectumSection); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static AssessmentAndPlanSectionProcNote getAssessmentAndPlanSection(ProgressNote progressNote) { if (GET_ASSESSMENT_AND_PLAN_SECTION__EOCL_QRY == null) { OCL.Helper helper = EOCL_ENV.createOCLHelper(); helper.setOperationContext( CDTPackage.Literals.PROGRESS_NOTE, CDTPackage.Literals.PROGRESS_NOTE.getEAllOperations().get(89)); try { GET_ASSESSMENT_AND_PLAN_SECTION__EOCL_QRY = helper.createQuery(GET_ASSESSMENT_AND_PLAN_SECTION__EOCL_EXP); } catch (ParserException pe) { throw new UnsupportedOperationException(pe.getLocalizedMessage()); } } OCL.Query query = EOCL_ENV.createQuery(GET_ASSESSMENT_AND_PLAN_SECTION__EOCL_QRY); return (AssessmentAndPlanSectionProcNote) query.evaluate(progressNote); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static ReviewOfSystemsSectionIHE getReviewOfSystemsSection(ProgressNote progressNote) { if (GET_REVIEW_OF_SYSTEMS_SECTION__EOCL_QRY == null) { OCL.Helper helper = EOCL_ENV.createOCLHelper(); helper.setOperationContext( CDTPackage.Literals.PROGRESS_NOTE, CDTPackage.Literals.PROGRESS_NOTE.getEAllOperations().get(100)); try { GET_REVIEW_OF_SYSTEMS_SECTION__EOCL_QRY = helper.createQuery(GET_REVIEW_OF_SYSTEMS_SECTION__EOCL_EXP); } catch (ParserException pe) { throw new UnsupportedOperationException(pe.getLocalizedMessage()); } } OCL.Query query = EOCL_ENV.createQuery(GET_REVIEW_OF_SYSTEMS_SECTION__EOCL_QRY); return (ReviewOfSystemsSectionIHE) query.evaluate(progressNote); }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * @generated */ public static ProblemEntry getProblemEntry(NeckSection neckSection) { if (GET_PROBLEM_ENTRY__EOCL_QRY == null) { OCL.Helper helper = EOCL_ENV.createOCLHelper(); helper.setOperationContext( IHEPackage.Literals.NECK_SECTION, IHEPackage.Literals.NECK_SECTION.getEAllOperations().get(58)); try { GET_PROBLEM_ENTRY__EOCL_QRY = helper.createQuery(GET_PROBLEM_ENTRY__EOCL_EXP); } catch (ParserException pe) { throw new UnsupportedOperationException(pe.getLocalizedMessage()); } } OCL.Query query = EOCL_ENV.createQuery(GET_PROBLEM_ENTRY__EOCL_QRY); return (ProblemEntry) query.evaluate(neckSection); }