Search in sources :

Example 26 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class IEntityIterator method evaluate.

public default E evaluate(IEntity self, IBindingManager bm) {
    IEntity oldSelfEntity = bm.wGet("self");
    bm.wDef("self", self);
    setBindings(bm);
    reset(self);
    E result = evaluateRemaining();
    if (oldSelfEntity == null && bm.wGet("self") == self)
        bm.wUnset("self");
    return result;
}
Also used : IEntity(org.whole.lang.model.IEntity)

Example 27 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class IEntityIterator method evaluateFirst.

public default E evaluateFirst(IEntity self, IBindingManager bm) {
    IEntity oldSelfEntity = bm.wGet("self");
    bm.wDef("self", self);
    setBindings(bm);
    reset(self);
    E result = evaluateNext();
    if (oldSelfEntity == null && bm.wGet("self") == self)
        bm.wUnset("self");
    return result;
}
Also used : IEntity(org.whole.lang.model.IEntity)

Example 28 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class AncestorReverseIterator method getCollectionIterable.

@Override
protected Iterable<?> getCollectionIterable(IEntity entity) {
    List<IEntity> ancestors = new ArrayList<IEntity>();
    IEntityIterator<IEntity> i = IteratorFactory.ancestorIterator();
    i.reset(entity);
    for (IEntity parent : i) ancestors.add(parent);
    Collections.reverse(ancestors);
    return ancestors;
}
Also used : IEntity(org.whole.lang.model.IEntity) ArrayList(java.util.ArrayList)

Example 29 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class AbstractEntityRegistryConfiguration method enforceMandatoryFeatures.

public static void enforceMandatoryFeatures(IEntityRegistry er, EntityDescriptor<?> ed, IEntity prototype, boolean[] isEnforced) {
    if (isEnforced[ed.getOrdinal()])
        return;
    isEnforced[ed.getOrdinal()] = true;
    if (ed.getEntityKind().isSimple()) {
        List<FeatureDescriptor> eds = ed.getEntityFeatureDescriptors();
        for (int i = 0, size = eds.size(); i < size; i++) {
            FeatureDescriptor efd = eds.get(i);
            EntityDescriptor<?> fed = efd.getEntityDescriptor();
            if (fed.isPolymorphic() || efd.isOptional() || efd.isReference())
                continue;
            IEntity child = prototype.wGet(i);
            if (!EntityUtils.isResolver(child))
                continue;
            if (fed.isAbstract())
                continue;
            child = er.get(fed);
            enforceMandatoryFeatures(er, fed, child, isEnforced);
            child = EntityUtils.clone(child);
            prototype.wSet(i, child);
        // if (fed.getEntityKind().isComposite() && !fed.getEntityFeatureDescriptor(0).isOptional())
        // try {
        // child.wAdd(CommonsEntityAdapterFactory.createResolver(fed.getEntityDescriptor(0)));
        // } catch (UnsupportedOperationException e) {
        // //FIXME workaround for Map entity
        // }
        }
    // } else if (ed.getEntityKind().isComposite() && !ed.getEntityFeatureDescriptor(0).isOptional()) {
    // try {
    // prototype.wAdd(CommonsEntityAdapterFactory.createResolver(ed.getEntityDescriptor(0)));
    // } catch (UnsupportedOperationException e) {
    // //FIXME workaround for Map entity
    // }
    }
}
Also used : FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor) IEntity(org.whole.lang.model.IEntity)

Example 30 with IEntity

use of org.whole.lang.model.IEntity in project whole by wholeplatform.

the class AbstractCollectIterator method next.

public IEntity next() {
    IEntity result = lookahead();
    if (result == null)
        throw new NoSuchElementException();
    nextEntity = null;
    return result;
}
Also used : IEntity(org.whole.lang.model.IEntity) NoSuchElementException(java.util.NoSuchElementException)

Aggregations

IEntity (org.whole.lang.model.IEntity)1407 ArrayList (java.util.ArrayList)604 Test (org.junit.Test)241 IBindingManager (org.whole.lang.bindings.IBindingManager)141 PathExpression (org.whole.lang.queries.model.PathExpression)68 ITemplateManager (org.whole.lang.templates.ITemplateManager)61 Grammar (org.whole.lang.grammars.model.Grammar)50 TestXmlGrammar (org.whole.lang.grammars.util.TestXmlGrammar)46 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)43 Model (org.whole.lang.models.model.Model)40 InternalIEntity (org.whole.lang.model.InternalIEntity)38 VisitException (org.whole.lang.visitors.VisitException)35 IEntityPartViewer (org.whole.lang.ui.viewers.IEntityPartViewer)30 ModelsModel (org.whole.lang.models.codebase.ModelsModel)27 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)26 StreamPersistenceProvider (org.whole.lang.codebase.StreamPersistenceProvider)24 ModelBuilderOperation (org.whole.lang.builders.ModelBuilderOperation)22 XmlModel (org.whole.lang.models.codebase.XmlModel)22 MissingVariableException (org.whole.lang.visitors.MissingVariableException)22 IEntityPart (org.whole.lang.ui.editparts.IEntityPart)21