Package org.qi4j.api.entity

Examples of org.qi4j.api.entity.EntityReference


    {
        Usecase usecase = UsecaseBuilder.newUsecase( "Remove entity" );
        EntityStoreUnitOfWork uow = entityStore.newUnitOfWork( usecase, module, System.currentTimeMillis() );
        try
        {
            EntityReference identityRef = EntityReference.parseEntityReference( identity );
            uow.entityStateOf( identityRef ).remove();
            uow.applyChanges().commit();
            getResponse().setStatus( Status.SUCCESS_NO_CONTENT );
        }
        catch( EntityNotFoundException e )
View Full Code Here


        throws ResourceException
    {
        EntityState entityState;
        try
        {
            EntityReference entityReference = EntityReference.parseEntityReference( identity );
            entityState = unitOfWork.entityStateOf( entityReference );
        }
        catch( EntityNotFoundException e )
        {
            throw new ResourceException( Status.CLIENT_ERROR_NOT_FOUND );
View Full Code Here

                {
                    // Synchronize old and new association
                    int index = 0;
                    while( ( identity = bufferedReader.readLine() ) != null )
                    {
                        EntityReference reference = new EntityReference( identity );

                        if( manyAssociation.count() < index && manyAssociation.get( index ).equals( reference ) )
                        {
                            continue;
                        }

                        try
                        {
                            unitOfWork.entityStateOf( reference );

                            manyAssociation.remove( reference );
                            manyAssociation.add( index++, reference );
                        }
                        catch( EntityNotFoundException e )
                        {
                            // Ignore this entity - doesn't exist
                        }
                    }

                    // Remove "left-overs"
                    while( manyAssociation.count() > index )
                    {
                        manyAssociation.remove( manyAssociation.get( index ) );
                    }
                }
                catch( IOException e )
                {
                    // Ignore
                }
            }
            for( AssociationDescriptor associationType : descriptor.state().namedAssociations() )
            {
                String newStringAssociation = form.getFirstValue( associationType.qualifiedName().name() );
                NamedAssociationState namedAssociation = entity.namedAssociationValueOf( associationType.qualifiedName() );
                if( newStringAssociation == null )
                {
                    // Remove "left-overs"
                    for( String name : namedAssociation )
                    {
                        namedAssociation.remove( name );
                    }
                    continue;
                }
                Set<String> names = new HashSet<>();
                BufferedReader bufferedReader = new BufferedReader( new StringReader( newStringAssociation ) );
                String line;
                try
                {
                    while( ( line = bufferedReader.readLine() ) != null )
                    {
                        String name = line;
                        line = bufferedReader.readLine();
                        if( line == null )
                        {
                            break;
                        }
                        String identity = line;
                        EntityReference reference = new EntityReference( identity );
                        try
                        {
                            unitOfWork.entityStateOf( reference );

                            namedAssociation.remove( name );
View Full Code Here

    }

    @Test
    public void testEntitySerializer() throws RDFHandlerException
    {
        EntityReference entityReference = new EntityReference( "test2" );
        EntityState entityState = entityStore.newUnitOfWork( UsecaseBuilder.newUsecase( "Test" ), module, System.currentTimeMillis() ).entityStateOf( entityReference );

        Iterable<Statement> graph = serializer.serialize( entityState );

        String[] prefixes = new String[]{ "rdf", "dc", " vc" };
View Full Code Here

TOP

Related Classes of org.qi4j.api.entity.EntityReference

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.