Search in sources :

Example 11 with InternalIEntity

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

the class BindingCommandTest method testBindingCommand.

@Test
public void testBindingCommand() {
    IEntity program = new ExampleTest().create();
    IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
    i.reset(program);
    for (IEntity e : i) if (((InternalIEntity) e).wGetBindingCommand() != NullCommand.instance)
        Assert.fail();
    program = EntityUtils.clone(program);
    i = IteratorFactory.<IEntity>descendantOrSelfIterator();
    i.reset(program);
    for (IEntity e : i) if (((InternalIEntity) e).wGetBindingCommand() != NullCommand.instance)
        Assert.fail();
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) Test(org.junit.Test)

Example 12 with InternalIEntity

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

the class CloneOperation method applyClone.

protected IEntity applyClone(IEntity entity) {
    IEntity entityClone = ((InternalIEntity) entity).wShallowClone();
    setCopy(entity, entityClone);
    setChildrenAndAspects(entity, entityClone);
    return entityClone;
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 13 with InternalIEntity

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

the class IntensionalEntityContext method wGetPrevVersion.

protected final IEntity wGetPrevVersion(IEntity e) {
    ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
    if (cmd.getKind().isComposite()) {
        IEntity source = cmd.getSource();
        List<IEntity> children = wIndexedFeatures(source, ((InternalIEntity) source).wGetLastCommand().getPrevCommand().getExecutionTime());
        return children.get(cmd.getSourceIndex());
    } else
        return cmd.getPrevCommand().getNewEntity();
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) ICommand(org.whole.lang.commands.ICommand) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 14 with InternalIEntity

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

the class IntensionalEntityContext method wIndexedFeatures.

@Deprecated
public final List<IEntity> wIndexedFeatures(IEntity e, int contextTime) {
    List<IEntity> result = childrenCache.get(e);
    if (result != null && this.contextTime == contextTime)
        return result;
    result = new ArrayList<IEntity>(e.wFeatures());
    ICommand cmd = ((InternalIEntity) e).wGetLastCommand();
    while (contextTime < cmd.getExecutionTime()) {
        switch(cmd.getKind()) {
            case ADD:
                result.remove(cmd.getSourceIndex());
                break;
            case REMOVE:
                result.add(cmd.getSourceIndex(), cmd.getOldEntity());
                break;
            case CHANGE:
                result.set(cmd.getSourceIndex(), cmd.getOldEntity());
                break;
        }
        cmd = cmd.getPrevCommand();
    }
    if (this.contextTime == contextTime)
        childrenCache.put(e, result);
    return result;
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) ICommand(org.whole.lang.commands.ICommand) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 15 with InternalIEntity

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

the class CloneOperationOld method cloneDescendantTree.

protected IEntity cloneDescendantTree(IEntity entity) {
    IEntity entityClone = entityCloneMap.get(entity);
    if (entityClone == null) {
        entityClone = ((InternalIEntity) entity).wShallowClone();
        entityCloneMap.put(entity, entityClone);
        for (// TODO test was int i=entityClone.wSize()-1; i>=0; i--)
        int i = 0; // TODO test was int i=entityClone.wSize()-1; i>=0; i--)
        i < entityClone.wSize(); // TODO test was int i=entityClone.wSize()-1; i>=0; i--)
        i++) cloneAndUpdate(entityClone, i);
        for (FeatureDescriptor fd : entity.wGetAspectualFeatureDescriptors()) if (!fd.isReference())
            cloneAndUpdate(entityClone, fd);
    }
    return entityClone;
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) FeatureDescriptor(org.whole.lang.reflect.FeatureDescriptor)

Aggregations

InternalIEntity (org.whole.lang.model.InternalIEntity)25 IEntity (org.whole.lang.model.IEntity)19 Test (org.junit.Test)13 ICommand (org.whole.lang.commands.ICommand)6 IFragmentModel (org.whole.lang.model.IFragmentModel)2 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)2 Serializable (java.io.Serializable)1 Category (org.junit.experimental.categories.Category)1 ITransactionScope (org.whole.lang.bindings.ITransactionScope)1 QuantifierEnum (org.whole.lang.commons.model.QuantifierEnum)1 Variable (org.whole.lang.commons.model.Variable)1 SubstituteException (org.whole.lang.matchers.SubstituteException)1