Search in sources :

Example 16 with InternalIEntity

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

the class ReflectionFactory method makeRootEntity.

public static <E extends IEntity> E makeRootEntity(E entity, IFragmentModel parentFragmentModel) {
    IFragmentModel fragmentModel = getLanguageKit(entity).createFragmentModel();
    if (parentFragmentModel != NullFragmentModel.instance)
        fragmentModel.setCompoundModel(parentFragmentModel.getCompoundModel());
    ((InternalIEntity) entity).wSetModel(fragmentModel);
    return entity;
}
Also used : IFragmentModel(org.whole.lang.model.IFragmentModel) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 17 with InternalIEntity

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

the class GenericCloneVisitor method applyClone.

public void applyClone(IEntity entity) {
    IEntity entityClone = ((InternalIEntity) entity).wShallowClone();
    setClone(entity, entityClone);
    setChildrenAndAspects(entity, entityClone);
    setResult(entityClone);
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 18 with InternalIEntity

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

the class ReflectionServer method getPid.

public Serializable getPid(IEntity entity) {
    Serializable pid = entity.wGetPid();
    if (pid == null) {
        pid = getFreshPid();
        ((InternalIEntity) entity).wSetPid(pid);
        pidEntityMap.put(pid, entity);
        if (!EntityUtils.hasParent(entity))
            rootEntities.add(entity);
    }
    return pid;
}
Also used : Serializable(java.io.Serializable) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 19 with InternalIEntity

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

the class ReflectionServer method replaceEntity.

public IEntity replaceEntity(IEntity targetEntity, IEntity sourceEntity) {
    // FIXME move pid from old to newChild ?
    ((InternalIEntity) sourceEntity).wSetPid(targetEntity.wGetPid());
    // TODO replace opposite references
    // add as arguments
    IEntity parentEntity = targetEntity.wGetParent();
    int index = parentEntity.wIndexOf(targetEntity);
    parentEntity.wSet(index, sourceEntity);
    return sourceEntity;
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) InternalIEntity(org.whole.lang.model.InternalIEntity)

Example 20 with InternalIEntity

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

the class HistoryInvariantsTest method testModelCloneHistory.

@Category(SlowTests.class)
@Test
public void testModelCloneHistory() {
    performChanges(model);
    IEntity model2 = EntityUtils.clone(model);
    IEntityIterator<IEntity> i = IteratorFactory.descendantOrSelfIterator();
    i.reset(model2);
    for (IEntity e : i) {
        ICommand cmd = ((InternalIEntity) e).wGetBindingCommand();
        Assert.assertTrue(cmd.getKind() == CommandKind.NULL);
        cmd = ((InternalIEntity) e).wGetLastCommand();
        if (cmd.getKind() != CommandKind.NULL)
            Assert.assertTrue(cmd.getKind() == CommandKind.NULL);
    }
    Assert.assertTrue(Matcher.match(model2, model));
}
Also used : IEntity(org.whole.lang.model.IEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) InternalIEntity(org.whole.lang.model.InternalIEntity) Category(org.junit.experimental.categories.Category) Test(org.junit.Test)

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