blob: fb5408069abd224106da9d903b6781ceeed63a65 [file] [log] [blame]
@GenModel(fileExtensions="type", modelDirectory="/org.eclipse.osbp.dsl.common.xtext/emf-gen", editDirectory="/org.eclipse.osbp.dsl.common.xtext.edit/src", extensibleProviderFactory="true")
@GenModel(modelName="Types")
@GenModel(prefix="OSBPTypes")
@GenModel(suppressEMFModelTags="true")
@GenModel(loadInitialization="false")
@GenModel(literalsInterface="true")
@GenModel(copyrightText="Copyright (c) 2011, 2016 - Lunifera GmbH (Wien), Loetz GmbH&Co.KG (Heidelberg)
All rights reserved. This program and the accompanying materials
are made available under the terms of the Eclipse Public License 2.0
which accompanies this distribution, and is available at
https://www.eclipse.org/legal/epl-2.0/
SPDX-License-Identifier: EPL-2.0
Based on ideas from Xtext, Xtend, Xcore
Contributors:
Florian Pirchner - Initial implementation
")
@Ecore(nsURI="http://osbp.eclipse.org/dsl/common/types/v1")
@Ecore(nsPrefix="types")
@Ecore(rootPackage="types")
package org.eclipse.osbp.dsl.semantic.common.types
import org.eclipse.emf.common.util.EList
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.InternalEObject
import org.eclipse.osbp.dsl.semantic.common.helper.Bounds
import org.eclipse.osbp.xtext.oxtype.resource.EcoreUtil3
import org.eclipse.xtext.common.types.JvmFormalParameter
import org.eclipse.xtext.common.types.JvmTypeReference
import org.eclipse.xtext.xbase.XExpression
import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation
import org.eclipse.xtext.xtype.XImportSection
class LCommonModel extends LLazyResolver {
contains XImportSection importSection
contains LTypedPackage[] packages
}
class LLazyResolver {
op EObject eResolveProxy(InternalEObject proxy) {
return EcoreUtil3.resolve(proxy, this.eResource()?.resourceSet);
}
}
class LPackage extends LLazyResolver {
String name
}
class LTypedPackage extends LPackage {
contains LType[] types
op String getResourceSimpleName() {
val resource = eResource
if (resource === null) {
return ""
}
return resource.URI.lastSegment + " - " + name
}
}
class LImport {
String importedNamespace
}
class LType extends LAnnotationTarget {
String name
contains LAnnotationTarget annotationInfo
/**
* Delegates the annotation request to the target element.
*/
op AnnotationList getResolvedAnnotations() {
if (annotationInfo !== null) {
annotationInfo.annotations
} else {
annotations
}
}
}
class LAnnotationDef extends LLazyResolver {
boolean exclude
contains XAnnotation ^annotation
}
class LAnnotationTarget extends LLazyResolver {
contains LAnnotationDef[] annotations
}
class LScalarType extends LType {
}
class LDataType extends LScalarType {
contains JvmTypeReference jvmTypeReference
boolean asPrimitive
boolean date
boolean asBlob
int length
LDateType dateType
/**
* Attention: synthetic must only be used inside the same resource
*/
// is used to prepare datatypes during linking
boolean syntheticFlag
// defines what target type should be prepared by the synthetic datatype. May be any string.
String syntheticSelector
// is used to target a feature in the current entity
refers LFeature syntheticTypeReference
// used to target a feature in the current entity, but avoids resolving cross refernces too early.
// for instance if the feature is contained in a superclass
refers LType syntheticType
// key value pairs
contains LKeyAndValue[*] properties
// constraints for the datatype
contains LDatatypeConstraint[*] constraints
}
enum LDateType {
DATE
, TIME
, TIMESTAMP
}
class LEnum extends LScalarType {
contains LEnumLiteral[] literals
}
class LEnumLiteral extends LLazyResolver {
String name
boolean ^default
boolean ^null
int value
}
class LClass extends LType {
boolean ^abstract
boolean serializable
String shortName
}
interface LFeaturesHolder {
/**
* Returns the features of the holder
*/
op FeaturesList getFeatures()
/**
* Returns all features of the holder and from super types
*/
op FeaturesList getAllFeatures()
}
interface LFeature extends LAnnotationTarget {
String name
contains LMultiplicity multiplicity
contains LAnnotationTarget annotationInfo
/**
* Delegates the annotation request to the target element.
*/
op AnnotationList getResolvedAnnotations() {
if (annotationInfo !== null) {
annotationInfo.annotations
} else {
annotations
}
}
}
interface LReference extends LFeature {
boolean lazy
boolean cascading
contains LKeyAndValue[*] properties
// constraints for the datatype
contains LDatatypeConstraint[*] constraints
// could be grouped for ui
boolean isGrouped
String groupName
// ui should use a grid
boolean asGrid
// ui should use a table
boolean asTable
}
interface LAttribute extends LFeature {
boolean ^id
boolean uuid
boolean version
boolean lazy
boolean cascading
boolean ^transient
boolean ^derived
boolean dirty
/**
* The domainKey is a human readable value for a dto or entity
*/
boolean domainKey
/**
* The domainKey is the human readable description for a dto or entity
*/
boolean domainDescription
/**
* This keyword allows for generic filter dialogs in the UI based on eq, gt, lt,..
*/
boolean filtering
/**
* This keyword allows for generic filter dialogs in the UI based on eq, gt, lt,..
*/
boolean rangeFiltering
/**
* Attributes marked with uniqueEntry must be checked against the database,
* whether they already exist in the database with a different id
*/
boolean uniqueEntry
contains XExpression derivedGetterExpression
refers LScalarType ^type
contains LKeyAndValue[*] properties
// constraints for the datatype
contains LDatatypeConstraint[*] constraints
// could be grouped for ui
boolean isGrouped
String groupName
}
class LKeyAndValue {
String key
String value
}
class LOperation extends LAnnotationTarget {
contains LModifier modifier
contains JvmTypeReference ^type
contains JvmFormalParameter[] params
contains XExpression body
/**
* Method to generalize naming conventions for annotation access
*/
op AnnotationList getResolvedAnnotations() {
annotations
}
}
class LModifier extends LLazyResolver {
boolean final
boolean ^static
LVisibility visibility
}
enum LVisibility {
PACKAGE = 0
PRIVATE = 1
PROTECTED = 2
PUBLIC = 3
}
class LMultiplicity {
LLowerBound lower
LUpperBound upper
derived String toMultiplicityString get {
return Bounds.createFor(this).toBoundsString
}
}
enum LLowerBound {
NULL = 0
MANY = 1
OPTIONAL = 2
ATLEASTONE = 3
ZERO = 4
ONE = 5
}
enum LUpperBound {
NULL = 0
MANY = 1
ONE = 2
}
interface LConstraint extends LLazyResolver{
}
/**
* ResultFilters are used to filter the possible results for a reference.
* May be used by UI to filter unwanted entries.
*/
class LResultFilters extends LLazyResolver {
contains LResultFilter[*] resultFilters
}
interface LResultFilter extends LConstraint {
}
class LAttributeMatchingConstraint extends LResultFilter {
refers LAttribute attribute
LComparatorType comparatorType
String matchingValue
refers LEnumLiteral matchingLiteral
}
enum LComparatorType {
EQUALS as '=='
GREATER as '>'
LOWER as '<'
GREATER_EQ as '>='
LOWER_EQ as '<='
NOT_EQ as '<>'
}
/**
* DatatypeConstraints are used to create javax.validation constraint annotations.
*/
interface LDatatypeConstraint extends LConstraint {
String msgCode
String msgI18nKey
LConstraintSeverity severity
/**
* Returns true, if the constraint can be used for primitive datatypes.
*/
op boolean isForPrimitives()
}
enum LConstraintSeverity {
INFO
, WARNING
, ERROR
}
interface LStringConstraint extends LDatatypeConstraint {
}
interface LNumericConstraint extends LDatatypeConstraint {
}
interface LDecimalConstraint extends LDatatypeConstraint {
}
interface LDateConstraint extends LDatatypeConstraint {
}
interface LBooleanConstraint extends LDatatypeConstraint {
}
interface LBlobConstraint extends LDatatypeConstraint {
}
class LDtCAssertFalse extends LBooleanConstraint {
op boolean isForPrimitives() {
return true
}
}
class LDtCAssertTrue extends LBooleanConstraint {
op boolean isForPrimitives() {
return true
}
}
class LDtCDecimalMax extends LDecimalConstraint {
float max
op boolean isForPrimitives() {
return true
}
}
class LDtCDecimalMin extends LDecimalConstraint {
float min
op boolean isForPrimitives() {
return true
}
}
class LDtCDigits extends LDecimalConstraint {
int intDigits
int fractionDigits
op boolean isForPrimitives() {
return true
}
}
class LDtCFuture extends LDateConstraint {
op boolean isForPrimitives() {
return false
}
}
class LDtCPast extends LDateConstraint {
op boolean isForPrimitives() {
return false
}
}
class LDtCNumericMax extends LNumericConstraint {
int max
op boolean isForPrimitives() {
return true
}
}
class LDtCNumericMin extends LNumericConstraint {
int min
op boolean isForPrimitives() {
return true
}
}
class LDtCNotNull extends LBlobConstraint, LDateConstraint, LStringConstraint,
LBooleanConstraint, LDecimalConstraint, LNumericConstraint {
op boolean isForPrimitives() {
return false
}
}
class LDtCNull extends LBlobConstraint, LDateConstraint, LStringConstraint,
LBooleanConstraint, LDecimalConstraint, LNumericConstraint {
op boolean isForPrimitives() {
return false
}
}
class LDtCRegEx extends LStringConstraint {
String pattern
op boolean isForPrimitives() {
return true
}
}
class LDtCSize extends LStringConstraint {
int min
int max
op boolean isForPrimitives() {
return true
}
}
type OperationsList wraps java.util.List<LOperation>
type FeaturesList wraps java.util.List<? extends LFeature>
type AnnotationList wraps EList<LAnnotationDef>
type InternalEObject wraps InternalEObject