Package org.qi4j.api.value

Examples of org.qi4j.api.value.ValueDescriptor


         // Value as parameter
         final ValueComposite valueObject = (ValueComposite) requestObject;
         if (request.getMethod().equals(Method.GET))
         {
            StateHolder holder = spi.stateOf( valueObject );
            final ValueDescriptor descriptor = spi.valueDescriptorFor( valueObject );

            final Reference ref = request.getResourceRef();
            ref.setQuery( null );

             try
             {
                 for( PropertyDescriptor propertyDescriptor : descriptor.state().properties() )
                 {
                     Object value = holder.propertyFor( propertyDescriptor.accessor() ).get();
                     String param;
                     if( value == null )
                     {
View Full Code Here


    {
        QName qname = getSchemaType();
        final String className = ( qname.getNamespaceURI() + "." + qname.getLocalPart() ).substring( 20 );

        // Read attributes
        ValueDescriptor descriptor = module.valueDescriptor( className );
        StateDescriptor stateDescriptor = descriptor.state();
        final Map<QualifiedName, Object> values = new HashMap<>();
        while( reader.hasMoreElementReaders() )
        {
            MessageReader childReader = reader.getNextElementReader();
            QName childName = childReader.getName();
            QualifiedName childQualifiedName = QualifiedName.fromClass( (Class) typeClass,
                                                                        childName.getLocalPart() );
            PropertyDescriptor propertyDescriptor = stateDescriptor.findPropertyModelByQualifiedName(
                childQualifiedName );
            Type propertyType = propertyDescriptor.type();
            AegisType type = getTypeMapping().getType( propertyType );
            Object value = type.readObject( childReader, context );
            values.put( childQualifiedName, value );
        }

        ValueBuilder<?> builder = module.newValueBuilderWithState(
            (Class<?>) typeClass,
            new Function<PropertyDescriptor, Object>()
        {
            @Override
            public Object map( PropertyDescriptor descriptor1 )
            {
                return values.get( descriptor1.qualifiedName() );
            }
            },
            new Function<AssociationDescriptor, EntityReference>()
            {
                @Override
                public EntityReference map( AssociationDescriptor descriptor )
                {
                    Object value = values.get( descriptor.qualifiedName() );
                    if( value == null )
                    {
                        return null;
                    }
                    return EntityReference.parseEntityReference( value.toString() );
                }
            },
            new Function<AssociationDescriptor, Iterable<EntityReference>>()
            {
                @Override
                public Iterable<EntityReference> map( AssociationDescriptor descriptor )
                {
                    Object value = values.get( descriptor.qualifiedName() );
                    if( value == null )
                    {
                        return Iterables.empty();
                    }
                    String[] ids = value.toString().split( "," );
                    List<EntityReference> references = new ArrayList<>( ids.length );
                    for( String id : ids )
                    {
                        references.add( EntityReference.parseEntityReference( id ) );
                    }
                    return references;
                }
            },
            new Function<AssociationDescriptor, Map<String, EntityReference>>()
            {
                @Override
                public Map<String, EntityReference> map( AssociationDescriptor descriptor )
                {
                    Object value = values.get( descriptor.qualifiedName() );
                    if( value == null )
                    {
                        return Collections.emptyMap();
                    }
                    String[] namedRefs = value.toString().split( "," );
View Full Code Here

        root.getItems().add( complex );

        XmlSchemaSequence sequence = new XmlSchemaSequence(); // No clue why this?
        complex.setParticle( sequence )// No idea what this is for

        ValueDescriptor descriptor = module.valueDescriptor( getTypeClass().getName() );

        for( PropertyDescriptor p : descriptor.state().properties() )
        {
            if( isValueComposite( p.type() ) )
            {
                XmlSchemaElement element = new XmlSchemaElement( root, false );
                element.setName( p.qualifiedName().name() );
View Full Code Here

        }

        Class<?> valueType = interactionMethod.getParameterTypes()[ 0 ];
        if( ValueComposite.class.isAssignableFrom( valueType ) )
        {
            ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() );

            for( PropertyDescriptor propertyDescriptor : valueDescriptor.state().properties() )
            {
                String value = getValue( propertyDescriptor.qualifiedName().name(), queryAsForm, entityAsForm );

                if( value == null )
                {
View Full Code Here

        {
            MediaType type = getVariant( response.getRequest(), ENGLISH, supportedMediaTypes ).getMediaType();
            if( MediaType.APPLICATION_JSON.equals( type ) )
            {
                JSONObject json = new JSONObject();
                ValueDescriptor vd = (ValueDescriptor) result;
                try
                {
                    for( PropertyDescriptor propertyDescriptor : vd.state().properties() )
                    {
                        Object o = propertyDescriptor.initialValue( module );
                        if( o == null )
                        {
                            json.put( propertyDescriptor.qualifiedName().name(), JSONObject.NULL );
View Full Code Here

                }, entities );
        }

        private <T> ValueBuilder<?> doConversion( final Class<T> valueType, Object entity )
        {
            ValueDescriptor valueDescriptor = module.valueDescriptor( valueType.getName() );
            if( valueDescriptor == null )
            {
                throw new NoSuchValueException( valueType.getName(), module.name() );
            }
            Unqualified unqualified = valueDescriptor.metaInfo( Unqualified.class );
//            Iterable<? extends PropertyDescriptor> properties = valueDescriptor.state().properties();
            final EntityComposite composite = (EntityComposite) entity;
            final EntityDescriptor entityDescriptor = spi.entityDescriptorFor( composite );
            final AssociationStateHolder associationState = spi.stateOf( composite );
            ValueBuilder<?> builder;
View Full Code Here

TOP

Related Classes of org.qi4j.api.value.ValueDescriptor

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.