use of org.whole.lang.models.factories.ModelsEntityFactory in project whole by wholeplatform.
the class WorkflowsInterpreterVisitorTest method testCreateEntity.
@Test
public void testCreateEntity() {
IEntity createEntityTest = WorkflowsTestTemplateManager.instance().create("createEntityTest");
IBindingManager args = BindingManagerFactory.instance.createArguments();
InterpreterOperation.interpret(createEntityTest, args);
ModelsEntityFactory mef = ModelsEntityFactory.instance(RegistryConfigurations.RESOLVER);
Assert.assertTrue(args.wIsSet("entity"));
Assert.assertTrue(Matcher.match(mef.buildSimpleEntity().set(ModelsFeatureDescriptorEnum.modifiers, mef.createEntityModifiers(0)).set(ModelsFeatureDescriptorEnum.name, mef.createSimpleName("EntityName")).set(ModelsFeatureDescriptorEnum.types, mef.createTypes(mef.createSimpleName("Type"))).set(ModelsFeatureDescriptorEnum.features, mef.createFeatures(mef.buildFeature().set(ModelsFeatureDescriptorEnum.type, mef.createSimpleName("FType")).set(ModelsFeatureDescriptorEnum.name, mef.createSimpleName("fname")).getResult())).getResult(), args.wGet("entity")));
}
use of org.whole.lang.models.factories.ModelsEntityFactory in project whole by wholeplatform.
the class Grammars2ModelsVisitor method createFeature.
protected Feature createFeature(IEntityIterator<Rule> ruleIterator, String featureName) {
ModelsEntityFactory mf = ModelsEntityFactory.instance;
IEntityBuilder<Feature> fb = mf.buildFeature();
fb.set(ModelsFeatureDescriptorEnum.name, featureName);
while (ruleIterator.hasNext()) {
Rule rule = ruleIterator.next();
switch(rule.wGetEntityOrd()) {
// break;
case GrammarsEntityDescriptorEnum.When_ord:
When when = (When) rule;
((AbstractPatternFilterIterator<Rule>) ruleIterator).skipTo(when.getRule());
break;
case GrammarsEntityDescriptorEnum.NonTerminal_ord:
if (isLexicalNonTerminal((NonTerminal) rule) && EntityUtils.hasParent(rule) && Matcher.match(GrammarsEntityDescriptorEnum.Concatenate, rule.wGetParent()))
break;
fb.set(ModelsFeatureDescriptorEnum.type, mf.createSimpleName(getMappedEntityName((NonTerminal) rule)));
IEntity ancestor = null;
IEntityIterator<IEntity> iterator = IteratorFactory.ancestorIterator();
iterator.reset(Matcher.findAncestor(GrammarsEntityDescriptorEnum.As, rule));
while (iterator.hasNext() && !Matcher.match(GrammarsEntityDescriptorEnum.Production, ancestor = iterator.next())) if (Matcher.match(GrammarsEntityDescriptorEnum.Optional, ancestor))
fb.set(ModelsFeatureDescriptorEnum.modifiers, mf.createFeatureModifiers(mf.createFeatureModifier(FeatureModifierEnum.optional)));
return fb.getResult();
}
}
throw new IllegalArgumentException("Missing NonTerminal");
}
use of org.whole.lang.models.factories.ModelsEntityFactory in project whole by wholeplatform.
the class Grammars2ModelsVisitor method visit.
@Override
public void visit(Grammar entity) {
entity = normalize(entity);
IEntityIterator<Production> lexiconIiterator = IteratorFactory.<Production>childIterator();
lexiconIiterator.reset(entity.getLexicalStructure());
for (Production p : lexiconIiterator) lexiconMap.put(p.getName().getValue(), p);
LanguageDescriptor ld = (LanguageDescriptor) entity.getTargetLanguage();
ModelsEntityFactory mf = ModelsEntityFactory.instance;
Model model = mf.createModel(mf.createSimpleName(ld.getName().getValue()), mf.createTypeRelations(), modelDeclarations = mf.createModelDeclarations(), mf.createNamespace(ld.getNamespace().getValue()), EntityUtils.isResolver(ld.getVersion()) ? CommonsEntityAdapterFactory.createResolver(ModelsEntityDescriptorEnum.Version) : mf.createVersion(ld.getVersion().getValue()), mf.createURI(ld.getUri().getValue()));
entity.getPhraseStructure().accept(this);
setResult(model);
}
use of org.whole.lang.models.factories.ModelsEntityFactory in project whole by wholeplatform.
the class ControlQueriesTest method testQueryDecl8.
@Test
public void testQueryDecl8() {
ModelsEntityFactory mef = ModelsEntityFactory.instance;
FeatureModifiers modifiers = mef.createFeatureModifiers(mef.createFeatureModifier(FeatureModifierEnum.optional), mef.createFeatureModifier(FeatureModifierEnum.derived), mef.createFeatureModifier(FeatureModifierEnum.id));
ITemplateManager tm = ControlQueriesTemplateManager.instance();
PathExpression query = (PathExpression) tm.create("queryDecl8");
int count = 0;
for (IEntity p : BehaviorUtils.compileAndLazyEvaluate(query, modifiers)) {
IEntity modifier = modifiers.wGet(count++);
assertTrue(Matcher.match(modifier, p));
}
assertEquals(modifiers.wSize(), count);
}
use of org.whole.lang.models.factories.ModelsEntityFactory in project whole by wholeplatform.
the class ByChildAPITest method testAbstractListEntity.
@Test
public void testAbstractListEntity() {
ModelsEntityFactory mf = ModelsEntityFactory.instance;
ComponentModifier o = mf.createComponentModifier(ComponentModifierEnum.ordered);
ComponentModifier r1 = mf.createComponentModifier(ComponentModifierEnum.reference);
ComponentModifier r2 = mf.createComponentModifier(ComponentModifierEnum.reference);
ComponentModifier s = mf.createComponentModifier(ComponentModifierEnum.derived);
ComponentModifier[] modifiersArray = new ComponentModifier[] { o, r1, r2, s };
int[] businessEquivalence = new int[] { 0, 1, 1, 3 };
ComponentModifiers modifiers = mf.createComponentModifiers(modifiersArray);
orderedCompositeOperationsEntityTest(modifiersArray, businessEquivalence, modifiers);
commonOperationsEntityTest(modifiersArray, modifiersArray, modifiers);
propertyChangeEntityTest(modifiersArray, modifiers, mf.createComponentModifier(ComponentModifierEnum.reference));
}
Aggregations