public static Project makeProject() { Project project = FmpFactory.eINSTANCE.createProject(); project.setMetaMetaModel(MetaModel.makeMetaMetaModel(project)); project.setMetaModel(MetaModel.makeMetaModel(project)); project.setModel(MetaModel.makeModel(project)); return project; }
public static Feature makeModel(Project project) { Feature metaModel = project.getMetaModel(); Feature metaFeature = (Feature) metaModel.getChildren().get(0); // Feature metaFeatureGroup = (Feature)metaModel.getChildren().get(1); // Feature metaReference = (Feature) metaModel.getChildren().get(2); Feature model = FmpFactory.eINSTANCE.createFeature(); model.setProperties(ModelManipulation.INSTANCE.configure(metaFeature)); setFeatureAttributes( model, "My Feature Model", "My Feature Model", ConfigState.UNDECIDED_LITERAL, ValueType.NONE_LITERAL, null, null, 1, 1); return model; }
/** * @param resource * @return */ public static Feature getMetaMetaModel(EObject object) { Resource resource = object.eResource(); Project project = (Project) resource.getContents().get(0); return project.getMetaMetaModel(); }
public static Feature makeMetaModel(Project project) { Feature metaMetaModel = project.getMetaMetaModel(); // Root of the metamodel Feature metaModel = createFeatureWithProperties( "MetaModel", "MetaModel", ConfigState.UNDECIDED_LITERAL, ValueType.NONE_LITERAL, null, null, 1, 1, metaMetaModel); // this block creates "Feature" meta { Feature metaFeature = createFeatureWithProperties( "Feature", "Feature", ConfigState.UNDECIDED_LITERAL, ValueType.NONE_LITERAL, null, null, 1, 1, metaMetaModel); metaModel.getChildren().add(metaFeature); Feature nameOfFeature = createFeatureWithProperties( "Name", "Name", ConfigState.UNDECIDED_LITERAL, ValueType.STRING_LITERAL, null, null, 1, 1, metaMetaModel); metaFeature.getChildren().add(nameOfFeature); Feature idOfFeature = createFeatureWithProperties( "Id", "Id", ConfigState.UNDECIDED_LITERAL, ValueType.STRING_LITERAL, null, "featureVar", 1, 1, metaMetaModel); metaFeature.getChildren().add(idOfFeature); Feature descOfFeature = createFeatureWithProperties( "Description", "Description", ConfigState.UNDECIDED_LITERAL, ValueType.STRING_LITERAL, null, null, 0, 1, metaMetaModel); metaFeature.getChildren().add(descOfFeature); Feature attributeOfFeature = createFeatureWithProperties( "Attribute", "Attribute", ConfigState.UNDECIDED_LITERAL, ValueType.NONE_LITERAL, null, null, 0, 1, metaMetaModel); metaFeature.getChildren().add(attributeOfFeature); FeatureGroup typeGroup = createFeatureGroupWithProperties("TypeGroup", 0, 1, metaMetaModel); attributeOfFeature.getChildren().add(typeGroup); typeGroup .getChildren() .add(createTypeOfFeatureInMetaModel("Integer", ValueType.INTEGER_LITERAL, metaMetaModel)); typeGroup .getChildren() .add(createTypeOfFeatureInMetaModel("Float", ValueType.FLOAT_LITERAL, metaMetaModel)); typeGroup .getChildren() .add(createTypeOfFeatureInMetaModel("String", ValueType.STRING_LITERAL, metaMetaModel)); typeGroup .getChildren() .add(createTypeOfFeatureInMetaModel("Feature", ValueType.FEATURE_LITERAL, metaMetaModel)); Feature minOfFeature = createFeatureWithProperties( "Min", "Min", ConfigState.UNDECIDED_LITERAL, ValueType.INTEGER_LITERAL, null, new Integer(0), 1, 1, metaMetaModel); metaFeature.getChildren().add(minOfFeature); Feature maxOfFeature = createFeatureWithProperties( "Max", "Max", ConfigState.UNDECIDED_LITERAL, ValueType.INTEGER_LITERAL, null, new Integer(1), 1, 1, metaMetaModel); metaFeature.getChildren().add(maxOfFeature); } // this block creates "FeatureGroup" meta { Feature metaFeatureGroup = createFeatureWithProperties( "FeatureGroup", "FeatureGroup", ConfigState.UNDECIDED_LITERAL, ValueType.NONE_LITERAL, null, null, 1, 1, metaMetaModel); metaModel.getChildren().add(metaFeatureGroup); Feature idOfFeatureGroup = createFeatureWithProperties( "Id", "Id", ConfigState.UNDECIDED_LITERAL, ValueType.STRING_LITERAL, null, "group", 1, 1, metaMetaModel); metaFeatureGroup.getChildren().add(idOfFeatureGroup); Feature minOfFeatureGroup = createFeatureWithProperties( "Min", "Min", ConfigState.UNDECIDED_LITERAL, ValueType.INTEGER_LITERAL, null, new Integer(1), 1, 1, metaMetaModel); metaFeatureGroup.getChildren().add(minOfFeatureGroup); Feature maxOfFeatureGroup = createFeatureWithProperties( "Max", "Max", ConfigState.UNDECIDED_LITERAL, ValueType.INTEGER_LITERAL, null, new Integer(1), 1, 1, metaMetaModel); metaFeatureGroup.getChildren().add(maxOfFeatureGroup); } // this block creates "Reference" meta { Feature metaReference = createFeatureWithProperties( "Reference", "Reference", ConfigState.UNDECIDED_LITERAL, ValueType.NONE_LITERAL, null, null, 1, 1, metaMetaModel); metaModel.getChildren().add(metaReference); Reference referenceOfReference = createReferenceWithProperties( null, "Reference", ConfigState.UNDECIDED_LITERAL, 1, 1, metaMetaModel); metaReference.getChildren().add(referenceOfReference); Feature idOfReference = createFeatureWithProperties( "Id", "Id", ConfigState.UNDECIDED_LITERAL, ValueType.STRING_LITERAL, null, "reference", 1, 1, metaMetaModel); metaReference.getChildren().add(idOfReference); Feature minOfReference = createFeatureWithProperties( "Min", "Min", ConfigState.UNDECIDED_LITERAL, ValueType.INTEGER_LITERAL, null, new Integer(0), 1, 1, metaMetaModel); metaReference.getChildren().add(minOfReference); Feature maxOfReference = createFeatureWithProperties( "Max", "Max", ConfigState.UNDECIDED_LITERAL, ValueType.INTEGER_LITERAL, null, new Integer(1), 1, 1, metaMetaModel); metaReference.getChildren().add(maxOfReference); } return metaModel; }