Package org.qi4j.spi.entity

Examples of org.qi4j.spi.entity.EntityState


        throws ConstraintViolationException, EntityStoreException
    {
        try
        {
            // New EntityState
            EntityState entityState = store.newEntityState( identity, this );

            // Set identity property
            PropertyDescriptor persistentPropertyDescriptor = state().getProperty( IDENTITY_METHOD );
            entityState.setProperty( persistentPropertyDescriptor.qualifiedName(), identity.identity() );

            return entityState;
        }
        catch( EntityAlreadyExistsException e )
        {
View Full Code Here


        EntityInstance entityInstance = instanceCache.get( identity );
        if( entityInstance == null )
        {   // Not yet in cache

            // Check if this is a root UoW, or if no parent UoW knows about this entity
            EntityState entityState = null;
            EntityModel model = null;
            ModuleInstance module = null;
            // Figure out what EntityStore to use
            for( ModelModule<EntityModel> potentialModule : potentialModels )
            {
                EntityStore store = potentialModule.module().entityStore();
                EntityStoreUnitOfWork storeUow = getEntityStoreUnitOfWork( store, potentialModule.module() );
                try
                {
                    entityState = storeUow.getEntityState( identity );
                }
                catch( EntityNotFoundException e )
                {
                    continue;
                }

                // Get the selected model
                model = (EntityModel) entityState.entityDescriptor();
                module = potentialModule.module();
            }

            // Check if model was found
            if( model == null )
View Full Code Here

        String identity;

        // Figure out whether to use given or generated identity
        identity = (String) entityState.getProperty( identityStateName );
        EntityState newEntityState = model.model().newEntityState( store, EntityReference.parseEntityReference( identity ) );

        prototypeInstance.invokeCreate();

        // Check constraints
        prototypeInstance.checkConstraints();
View Full Code Here

            identity = model.module().identityGenerator().generate( model.model().type() );
        }

        EntityStore entityStore = model.module().entityStore();

        EntityState entityState = model.model().newEntityState( uow.getEntityStoreUnitOfWork( entityStore, module() ),
                                                              parseEntityReference( identity ) );

        // Init state
        model.model().initState( model.module(), entityState );

        entityState.setProperty( IDENTITY_STATE_NAME, identity );

        EntityInstance instance = new EntityInstance( this, model.module(), model.model(), entityState );

        instance.invokeCreate();
View Full Code Here

        }
    }

    public synchronized EntityState getEntityState( EntityStoreUnitOfWork unitOfWork, EntityReference identity )
    {
        EntityState state = fetchCachedState( identity, (DefaultEntityStoreUnitOfWork) unitOfWork );
        if( state != null )
        {
            return state;
        }
        // Get state
View Full Code Here

                                    sender.sendTo( new Receiver<Reader, ReceiverThrowableType>()
                                    {
                                        public void receive( Reader item )
                                                throws ReceiverThrowableType
                                        {
                                            final EntityState entity = readEntityState( uow, item );
                                            if( entity.status() == EntityStatus.UPDATED )
                                            {
                                                migrated.add( entity );

                                                // Synch back 100 at a time
                                                if( migrated.size() > 100 )
View Full Code Here

        }

        public EntityState getEntityState( EntityReference anIdentity )
            throws EntityStoreException, EntityNotFoundException
        {
            EntityState entityState = uow.getEntityState( anIdentity );
            versions.rememberVersion( entityState.identity(), entityState.version() );
            loaded.add( entityState );
            return entityState;
        }
View Full Code Here

    // EntityStore

    public EntityState newEntityState( EntityReference anIdentity, EntityDescriptor descriptor )
        throws EntityStoreException
    {
        EntityState state = entityStoreSPI.newEntityState( this, anIdentity, descriptor );
        states.add( state );
        return state;
    }
View Full Code Here

    }

    public EntityState getEntityState( EntityReference anIdentity )
        throws EntityStoreException, EntityNotFoundException
    {
        EntityState entityState = entityStoreSPI.getEntityState( this, anIdentity );
        states.add( entityState );
        return entityState;
    }
View Full Code Here

                String storeVersion = versions.get( entityState.identity() );
                if( storeVersion == null )
                {
                    EntityStoreUnitOfWork unitOfWork = store.newUnitOfWork( Usecase.DEFAULT, module, currentTime );
                    EntityState state = unitOfWork.getEntityState( entityState.identity() );
                    storeVersion = state.version();
                    unitOfWork.discard();
                }

                if( !entityState.version().equals( storeVersion ) )
                {
View Full Code Here

TOP

Related Classes of org.qi4j.spi.entity.EntityState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.