Search in sources :

Example 1 with BEnumLiteral

use of org.obeonetwork.dsl.ecorebinding.BEnumLiteral in project InformationSystem by ObeoNetwork.

the class EcorebindingModelWizardSpec method explore.

/**
 * Expore the EPackage and init the BPackage.
 * @param ePackage The ecore Package input to read
 * @param bPackage The Binding Package to build
 */
private static void explore(EPackage ePackage, BPackage bPackage) {
    EList<EClassifier> eClassifiers = ePackage.getEClassifiers();
    for (EClassifier eClassifier : eClassifiers) {
        if (eClassifier instanceof EClass) {
            EClass eClass = (EClass) eClassifier;
            // Create BClass
            BClass bClass = EcorebindingFactory.eINSTANCE.createBClass();
            bClass.setEcoreClass(eClass);
            bPackage.getBClasses().add(bClass);
            bPackage.getBClassifiers().add(bClass);
            explore(eClass, bClass);
        } else if (eClassifier instanceof EEnum) {
            EEnum eEnum = (EEnum) eClassifier;
            // Create BEnum
            BEnum bEnum = EcorebindingFactory.eINSTANCE.createBEnum();
            bEnum.setEcoreEnum(eEnum);
            bEnum.setEcoreDataType(eEnum);
            bPackage.getBEnums().add(bEnum);
            bPackage.getBClassifiers().add(bEnum);
            List<EEnumLiteral> eLiterals = eEnum.getELiterals();
            for (EEnumLiteral eLiteral : eLiterals) {
                // Create BEnumLiteral
                BEnumLiteral bEnumLiteral = EcorebindingFactory.eINSTANCE.createBEnumLiteral();
                bEnumLiteral.setBEnum(bEnum);
                bEnumLiteral.setEcoreEnumLiteral(eLiteral);
            }
        } else if (eClassifier instanceof EDataType) {
            EDataType eDataType = (EDataType) eClassifier;
            // Create BDataType
            BDataType bDataType = EcorebindingFactory.eINSTANCE.createBDataType();
            bDataType.setEcoreDataType(eDataType);
            bPackage.getBDataTypes().add(bDataType);
            bPackage.getBClassifiers().add(bDataType);
        }
    }
    List<EPackage> eSubpackages = ePackage.getESubpackages();
    for (EPackage subEPackage : eSubpackages) {
        // Create BPackage
        BPackage subBPackage = EcorebindingFactory.eINSTANCE.createBPackage();
        subBPackage.setEcorePackage(subEPackage);
        bPackage.getNestedBPackages().add(subBPackage);
        explore(subEPackage, subBPackage);
    }
}
Also used : BEnum(org.obeonetwork.dsl.ecorebinding.BEnum) BDataType(org.obeonetwork.dsl.ecorebinding.BDataType) EDataType(org.eclipse.emf.ecore.EDataType) EClassifier(org.eclipse.emf.ecore.EClassifier) EEnum(org.eclipse.emf.ecore.EEnum) EPackage(org.eclipse.emf.ecore.EPackage) BPackage(org.obeonetwork.dsl.ecorebinding.BPackage) EClass(org.eclipse.emf.ecore.EClass) BEnumLiteral(org.obeonetwork.dsl.ecorebinding.BEnumLiteral) BClass(org.obeonetwork.dsl.ecorebinding.BClass) EList(org.eclipse.emf.common.util.EList) List(java.util.List) EEnumLiteral(org.eclipse.emf.ecore.EEnumLiteral)

Aggregations

List (java.util.List)1 EList (org.eclipse.emf.common.util.EList)1 EClass (org.eclipse.emf.ecore.EClass)1 EClassifier (org.eclipse.emf.ecore.EClassifier)1 EDataType (org.eclipse.emf.ecore.EDataType)1 EEnum (org.eclipse.emf.ecore.EEnum)1 EEnumLiteral (org.eclipse.emf.ecore.EEnumLiteral)1 EPackage (org.eclipse.emf.ecore.EPackage)1 BClass (org.obeonetwork.dsl.ecorebinding.BClass)1 BDataType (org.obeonetwork.dsl.ecorebinding.BDataType)1 BEnum (org.obeonetwork.dsl.ecorebinding.BEnum)1 BEnumLiteral (org.obeonetwork.dsl.ecorebinding.BEnumLiteral)1 BPackage (org.obeonetwork.dsl.ecorebinding.BPackage)1