use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.
the class E4ModelProcessor method initialize.
@Execute
protected void initialize() throws CoreException {
try {
ClasspathPersistenceProvider pp = new ClasspathPersistenceProvider("org/whole/product/e4/lw/WorkspaceConfiguration.xwl");
InterpreterOperation.interpret(XmlBuilderPersistenceKit.instance().readModel(pp));
MUIElement placeholderWindow = modelService.find(PLACEHOLDER_WINDOW_ID, application);
if (placeholderWindow == null || !placeholderWindow.getParent().getChildren().remove(placeholderWindow))
throw new IllegalStateException("Unable to remove placeholder window with id: '" + PLACEHOLDER_WINDOW_ID + "'");
MTrimmedWindow window = MBasicFactory.INSTANCE.createTrimmedWindow();
window.setLabel("Whole Language Workbench Window");
window.setX(500);
window.setY(20);
window.setWidth(800);
window.setHeight(1000);
MMenu mainMenu = MMenuFactory.INSTANCE.createMenu();
mainMenu.setElementId("menu:org.eclipse.ui.main.menu");
mainMenu.getChildren().add(createFileMenu());
mainMenu.getChildren().add(createEditMenu());
mainMenu.getChildren().add(createHelpMenu());
window.setMainMenu(mainMenu);
MTrimBar trimBar = MBasicFactory.INSTANCE.createTrimBar();
trimBar.setSide(SideValue.TOP);
trimBar.getChildren().add(createToolBar());
window.getTrimBars().add(trimBar);
MPerspectiveStack perspectiveStack = MAdvancedFactory.INSTANCE.createPerspectiveStack();
MPerspective perspective = MAdvancedFactory.INSTANCE.createPerspective();
perspective.setLabel("P1");
MPartSashContainer partSashContainer = MBasicFactory.INSTANCE.createPartSashContainer();
partSashContainer.setHorizontal(false);
MPartStack partStack = MBasicFactory.INSTANCE.createPartStack();
MPart part = MBasicFactory.INSTANCE.createPart();
part.setContributionURI("bundleclass://org.whole.lang.e4.ui/org.whole.lang.e4.ui.parts.E4GraphicalPart");
part.setLabel("Part1a");
part.setCloseable(true);
Map<String, String> persistedState = part.getPersistedState();
persistedState.put("basePersistenceKitId", "org.whole.lang.xml.codebase.XmlBuilderPersistenceKit");
persistedState.put("filePath", "/BaseProject/src/org/whole/lang/ExampleModel.xwl");
persistedState.put("overridePersistenceKitId", "org.whole.lang.xml.codebase.XmlBuilderPersistenceKit");
partStack.getChildren().add(part);
partSashContainer.getChildren().add(partStack);
perspective.getChildren().add(partSashContainer);
perspectiveStack.getChildren().add(perspective);
window.getChildren().add(perspectiveStack);
application.getChildren().add(window);
} catch (Exception e) {
System.out.println("Unable to configure the initial workspace");
e.printStackTrace();
}
}
use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.
the class PathExpressionsQueriesTest method testLanguageTest.
@Test
public void testLanguageTest() throws Exception {
IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/templates/codebase/TemplateManagerArtifactsTemplates.xwl"));
QueriesEntityFactory ef = QueriesEntityFactory.instance;
for (IEntity e : BehaviorUtils.compileAndLazyEvaluate(ef.createFilter(ef.createDescendantOrSelfStep(), ef.createLanguageTest("http://lang.whole.org/Java")), model)) Assert.assertEquals("http://lang.whole.org/Java", e.wGetLanguageKit().getURI());
}
use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.
the class DynamicModelDefinitionTest method testModelsInterpreter.
@Test
public void testModelsInterpreter() {
Model model;
try {
model = (Model) XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/queries/QueriesModel.xwl"));
} catch (Exception e) {
throw new IllegalStateException(e);
}
String URI = "http://my/uri/for/queries/lang";
model.getUri().setValue(URI);
ILanguageKit qlk = ReflectionFactory.getLanguageKit("http://lang.whole.org/Queries");
EntityDescriptorEnum qedenum = qlk.getEntityDescriptorEnum();
FeatureDescriptorEnum qfdenum = qlk.getFeatureDescriptorEnum();
InterpreterOperation.interpret(model);
ILanguageKit lk = ReflectionFactory.getLanguageKit(URI);
assertNotNull(lk);
assertNotSame(qlk, lk);
assertNotNull(lk.getMetaModelTemplate());
IEntity metaModel = lk.getMetaModel();
IEntity normalizedModel = NormalizerOperation.normalize(model);
assertTrue(Matcher.match(normalizedModel, metaModel));
metaModel = lk.getMetaModelTemplate().create();
assertTrue(Matcher.match(normalizedModel, metaModel));
EntityDescriptorEnum edenum = lk.getEntityDescriptorEnum();
FeatureDescriptorEnum fdenum = lk.getFeatureDescriptorEnum();
assertFalse(qfdenum.equals(fdenum));
assertEquals(qfdenum.size(), fdenum.size());
for (FeatureDescriptor qfd : qfdenum) {
assertEquals(qfd.getOrdinal(), fdenum.valueOf(qfd.getName()).getOrdinal());
}
assertFalse(qedenum.equals(edenum));
assertEquals(qedenum.size(), edenum.size());
for (EntityDescriptor<?> qed : qedenum) {
EntityDescriptor<?> ed = edenum.valueOf(qed.getName());
assertEquals(qed.getOrdinal(), ed.getOrdinal());
assertEquals(qed.getEntityKind(), ed.getEntityKind());
assertEquals(qed.isAbstract(), ed.isAbstract());
assertEquals(qed.isRelationship(), ed.isRelationship());
switch(qed.getEntityKind()) {
case SIMPLE:
assertEquals(qed.featureSize(), ed.featureSize());
for (int i = 0, size = qed.featureSize(); i < size; i++) {
FeatureDescriptor qfd = qed.getEntityFeatureDescriptor(i);
FeatureDescriptor fd = ed.getEntityFeatureDescriptor(i);
assertEquals(qfd.getName(), fd.getName());
assertEquals(qfd.getImplName(), fd.getImplName());
assertEquals(qfd.getOrdinal(), fd.getOrdinal());
assertEquals(qfd.isDerived(), fd.isDerived());
assertEquals(qfd.isId(), fd.isId());
assertEquals(qfd.isOptional(), fd.isOptional());
assertEquals(qfd.isReference(), fd.isReference());
assertEquals(qfd.isShared(), fd.isShared());
assertEquals(qfd.isToMany(), fd.isToMany());
if (qfd.getOppositeFeatureDescriptor() != null)
assertEquals(qfd.getOppositeFeatureDescriptor().getName(), fd.getOppositeFeatureDescriptor().getName());
}
break;
case COMPOSITE:
assertEquals(qed.getCompositeKind(), ed.getCompositeKind());
FeatureDescriptor qfd = qed.getEntityFeatureDescriptor(0);
FeatureDescriptor fd = ed.getEntityFeatureDescriptor(0);
assertEquals(qfd.isDerived(), fd.isDerived());
assertEquals(qfd.isReference(), fd.isReference());
assertEquals(qfd.isShared(), fd.isShared());
break;
case DATA:
assertEquals(qed.getDataKind(), ed.getDataKind());
if (qed.getDataKind().isEnumValue()) {
assertEquals(qed.getDataEnumType().size(), ed.getDataEnumType().size());
for (int i = 0; i < qed.getDataEnumType().size(); i++) assertEquals(qed.getDataEnumType().valueOf(i).getName(), ed.getDataEnumType().valueOf(i).getName());
} else
assertEquals(qed.getDataType(), ed.getDataType());
break;
}
}
}
use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.
the class XsdLanguageTest method testArtifactsMappedModel.
@Category(KnownFailingTests.class)
@Test
public void testArtifactsMappedModel() {
try {
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
PathExpression path = new ModelToXmlSchemaQuery().create();
IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/artifacts/ArtifactsModel.xwl"));
Assert.assertNotNull(BehaviorUtils.evaluateFirstResult(path, model, bm));
InterpreterOperation.interpret(bm.wGet("mapping"));
bm.wDefValue("folderLocation", new File("test/org/whole/lang/xsd/util").getAbsolutePath());
bm.wDefValue("packageName", "");
IEntity artifacts = XsiPersistenceKit.instance().readModel(new StreamPersistenceProvider(getInputStream("Artifacts.xml"), null, bm));
Assert.assertTrue(Matcher.match(new Artifacts().create(), artifacts));
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
use of org.whole.lang.codebase.ClasspathPersistenceProvider in project whole by wholeplatform.
the class XsdLanguageTest method testModelToXsdMapping.
@Test
public void testModelToXsdMapping() {
try {
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
PathExpression path = new ModelToXmlSchemaQuery().create();
IEntity model = XmlBuilderPersistenceKit.instance().readModel(new ClasspathPersistenceProvider("org/whole/lang/artifacts/ArtifactsModel.xwl"));
Assert.assertNotNull(BehaviorUtils.evaluateFirstResult(path, model, bm));
IEntity mappedXsd = bm.wGet("schema");
IEntity xsd = loadXsd("artifacts.xsd");
Assert.assertTrue(OrderedMatcher.match(xsd, mappedXsd, comparatorsMap));
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Aggregations