use of org.obeonetwork.dsl.ecorebinding.BClass 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);
}
}
Aggregations