Package org.drools.core.factmodel.traits

Examples of org.drools.core.factmodel.traits.TraitableBean


                        // property reactivity may block trait proxies which have been asserted and then immediately updated because of another "don"
                        // however, PR must be disabled only once for each OTN: that is, a proxy will not pass an OTN if one of its ancestors can also pass it

                        // Example: given classes A <- B <-C, at OTN A, a proxy c can only pass if no proxy b exists

                        TraitableBean txBean = (TraitableBean) proxy.getObject();
                        TraitTypeMap tMap = (TraitTypeMap) txBean._getTraitMap();
                        Collection<Thing> x = tMap.immediateParents( this.typeMask );
                        Thing k = x.iterator().next();

                        long originalMask = context.getModificationMask();
                        if ( ! k.isTop() ) {
View Full Code Here



        Collection x = ksession2.getObjects();
        assertEquals( 4, x.size() );

        TraitableBean core = null;
        for ( Object o : x ) {
            if ( o instanceof TraitableBean ) {
                core = (TraitableBean) o;
                break;
            }
        }
        assertNotNull( core );
        assertEquals( 2, core._getDynamicProperties().size() );
        assertNotNull( core.getTrait( "org.drools.core.factmodel.traits.Thing" ) );
        assertNotNull( core.getTrait( "org.drools.trait.test.Mask" ) );
        assertNotNull( core.getTrait( "org.drools.trait.test.Cloak" ) );

    }
View Full Code Here


        Collection x = ksession2.getObjects();
        assertEquals( 4, x.size() );

        TraitableBean core = null;
        for ( Object o : x ) {
            if ( o instanceof TraitableBean ) {
                core = (TraitableBean) o;
                break;
            }
        }
        assertNotNull( core );
        assertEquals( 2, core._getDynamicProperties().size() );
        assertNotNull( core.getTrait( "org.drools.core.factmodel.traits.Thing" ) );
        assertNotNull( core.getTrait( "org.drools.trait.test.Mask2" ) );
        assertNotNull( core.getTrait( "org.drools.trait.test.Cloak2" ) );

    }
View Full Code Here

                list.size() );
        int id = ksession.getId();


        Collection yOld = ksession.getObjects();
        TraitableBean coreOld = null;
        for ( Object o : yOld ) {
            if ( o instanceof TraitableBean ) {
                coreOld = (TraitableBean) o;
                break;
            }
        }
        assertNotNull( coreOld );


        StatefulKnowledgeSession ksession2 = JPAKnowledgeService.loadStatefulKnowledgeSession( id, kbase, null, env );

        ksession2.fireAllRules();


        Collection y = ksession2.getObjects();
        assertEquals( 3, y.size() );

        TraitableBean core = null;
        for ( Object o : y ) {
            if ( o instanceof TraitableBean ) {
                core = (TraitableBean) o;
                break;
            }
        }
        assertNotNull( core );
        assertEquals( 1, core._getDynamicProperties().size() );
        assertNotNull( core.getTrait( "org.drools.core.factmodel.traits.Thing" ) );
        assertNotNull( core.getTrait( "org.drools.trait.test.Mask" ) );

    }
View Full Code Here

            if ( handle.isDisconnected() ) {
                handle = this.objectStore.reconnect( handle );
            }

            if ( handle.isTraitable() ) {
                TraitableBean traitableBean = (TraitableBean) handle.getObject();
                if( traitableBean.hasTraits() ){
                    PriorityQueue<TraitProxy> removedTypes =
                            new PriorityQueue<TraitProxy>( traitableBean._getTraitMap().values().size() );
                    removedTypes.addAll( traitableBean._getTraitMap().values() );

                    while ( ! removedTypes.isEmpty() ) {
                        TraitProxy proxy = removedTypes.poll();
                        if ( ! proxy.isVirtual() ) {
                            delete( getFactHandle( proxy ),
View Full Code Here

    protected <T, K> T applyManyTraits( K core, Collection<Class<? extends Thing>> traits, Object value, boolean logical) throws LogicalTypeInconsistencyException {
        // Precondition : traits is not empty, checked by don

        TraitFactory builder = TraitFactory.getTraitBuilderForKnowledgeBase( this.getKnowledgeRuntime().getKieBase() );

        TraitableBean inner = makeTraitable( core, builder, logical );

        Collection<Thing> mostSpecificTraits = inner.getMostSpecificTraits();
        boolean newTraitsAdded = false;
        T firstThing = null;
        Map<Thing, BitSet> things = new HashMap<Thing, BitSet>( traits.size() );

        for ( Class<?> trait : traits ) {
            boolean needsProxy = trait.isAssignableFrom( inner.getClass() );
            boolean hasTrait = inner.hasTrait( trait.getName() );
            boolean needsUpdate = needsProxy || core != inner;

            if ( ! hasTrait ) {
                BitSet boundary = inner.getCurrentTypeCode() != null ? (BitSet) inner.getCurrentTypeCode().clone() : null;

                T thing = (T) asTrait( core, inner, trait, needsProxy, hasTrait, needsUpdate, builder, logical );

                configureTrait( thing, value );
View Full Code Here


    protected <T, K> T applyTrait( K core, Class<T> trait, Object value, boolean logical ) throws LogicalTypeInconsistencyException {
        TraitFactory builder = TraitFactory.getTraitBuilderForKnowledgeBase( this.getKnowledgeRuntime().getKieBase() );

        TraitableBean inner = makeTraitable( core, builder, logical );

        boolean needsProxy = trait.isAssignableFrom( inner.getClass() );
        boolean hasTrait = inner.hasTrait( trait.getName() );
        boolean needsUpdate = needsProxy || core != inner;

        BitSet boundary = inner.getCurrentTypeCode() != null ? (BitSet) inner.getCurrentTypeCode().clone() : null;

        Collection<Thing> mostSpecificTraits = getTraitBoundary( inner, needsProxy, hasTrait, trait );

        T thing = asTrait( core, inner, trait, needsProxy, hasTrait, needsUpdate, builder, logical );

        configureTrait( thing, value );

        thing = doInsertTrait( thing, core, logical, boundary );

        refresh( thing, core, inner, trait, mostSpecificTraits, logical );

        if ( trait != Thing.class && inner._getFieldTMS() != null ) {
            inner._getFieldTMS().resetModificationMask();
        }
        return thing;
    }
View Full Code Here

            if ( handle.isDisconnected() ) {
                handle = this.objectStore.reconnect( handle );
            }

            if ( handle.isTraitable() ) {
                TraitableBean traitableBean = (TraitableBean) handle.getObject();
                if( traitableBean.hasTraits() ){
                    PriorityQueue<TraitProxy> removedTypes =
                            new PriorityQueue<TraitProxy>( traitableBean._getTraitMap().values().size() );
                    removedTypes.addAll( traitableBean._getTraitMap().values() );

                    while ( ! removedTypes.isEmpty() ) {
                        TraitProxy proxy = removedTypes.poll();
                        if ( ! proxy.isVirtual() ) {
                            delete( getFactHandle( proxy ),
View Full Code Here

            if ( handle.isDisconnected() ) {
                handle = this.objectStore.reconnect( handle );
            }

            if ( handle.isTraitable() ) {
                TraitableBean traitableBean = (TraitableBean) handle.getObject();
                if( traitableBean.hasTraits() ){
                    PriorityQueue<TraitProxy> removedTypes =
                            new PriorityQueue<TraitProxy>( traitableBean._getTraitMap().values().size() );
                    removedTypes.addAll( traitableBean._getTraitMap().values() );

                    while ( ! removedTypes.isEmpty() ) {
                        TraitProxy proxy = removedTypes.poll();
                        if ( ! proxy.isVirtual() ) {
                            delete( getFactHandle( proxy ),
View Full Code Here

                        // property reactivity may block trait proxies which have been asserted and then immediately updated because of another "don"
                        // however, PR must be disabled only once for each OTN: that is, a proxy will not pass an OTN if one of its ancestors can also pass it

                        // Example: given classes A <- B <-C, at OTN A, a proxy c can only pass if no proxy b exists

                        TraitableBean txBean = (TraitableBean) proxy.getObject();
                        TraitTypeMap tMap = (TraitTypeMap) txBean._getTraitMap();
                        Collection<Thing> x = tMap.immediateParents( this.typeMask );
                        Thing k = x.iterator().next();

                        BitMask originalMask = context.getModificationMask();
                        if ( ! k.isTop() ) {
View Full Code Here

TOP

Related Classes of org.drools.core.factmodel.traits.TraitableBean

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.