Package org.andromda.core.mapping

Examples of org.andromda.core.mapping.Mappings


                for (final Property mergeMappingsUri : mergeMappingsUris)
                {
                    String mergeMappingsUriValue = (mergeMappingsUri != null) ? mergeMappingsUri.getValue() : null;
                    if (StringUtils.isNotBlank(mergeMappingsUriValue))
                    {
                        Mappings mergeMappings = (Mappings)this.mergeMappingsCache.get(mergeMappingsUriValue);
                        if (mergeMappings == null)
                        {
                            try
                            {
                                mergeMappings = Mappings.getInstance(mergeMappingsUriValue);
View Full Code Here


    private static final String FROM_6 = "Class<? extends FromType>";

    public void testGetTo()
    {
        Mappings mappings1 = new Mappings();
        Mapping mapping1 = new Mapping();
        mapping1.setTo(TO_1);
        mapping1.addFrom(FROM_1);
        mapping1.addFrom(FROM_2);
        mapping1.addFrom(FROM_3);
        mapping1.addFrom(FROM_4);
        mappings1.addMapping(mapping1);
        TypeMappings typeMappings1 = TypeMappings.getInstance(mappings1);

        // make sure the to == from when passing in a mappings1 that don't exist
        assertNotNull(typeMappings1.getTo(NOT_MAPPED_1));
        assertEquals(NOT_MAPPED_1, typeMappings1.getTo(NOT_MAPPED_1));
        assertEquals(typeMappings1.getTo(NOT_MAPPED_2), typeMappings1.getTo(NOT_MAPPED_2));

        // make sure we can retrieve the to using a from array.
        assertNotNull(typeMappings1.getTo(FROM_1));
        assertEquals(TO_1, typeMappings1.getTo(FROM_1));

        // make sure we can retrieve the to using a from non array.
        assertEquals(TO_1, typeMappings1.getTo(FROM_4));

        Mappings mappings2 = new Mappings();
        Mapping mapping2 = new Mapping();
        mapping2.setTo(TO_2);
        mapping2.addFrom(FROM_5);
        mappings2.addMapping(mapping2);
        TypeMappings typeMappings2 = TypeMappings.getInstance(mappings2);
        typeMappings2.setArraySuffix(ARRAY_SUFFIX);

        assertEquals(TO_2, typeMappings2.getTo(FROM_5));
        assertEquals(TO_2 + ARRAY_SUFFIX, typeMappings2.getTo(FROM_5 + ARRAY_SUFFIX));

        Mappings mappings3 = new Mappings();
        Mapping mapping3 = new Mapping();
        mapping3.setTo(TO_3);
        mapping3.addFrom(FROM_6);
        mappings3.addMapping(mapping3);
        TypeMappings typeMappings3 = TypeMappings.getInstance(mappings3);
        // make sure whitespace isn't deleted, only trimmed (Java generics would fail compilation otherwise for example)
        assertEquals(
            TO_3,
            typeMappings3.getTo(FROM_6));
View Full Code Here

    private static final String TO_3 = "Class<? extends ToType>";
    private static final String FROM_6 = "Class<? extends FromType>";

    public void testGetTo()
    {
        Mappings mappings1 = new Mappings();
        Mapping mapping1 = new Mapping();
        mapping1.setTo(TO_1);
        mapping1.addFrom(FROM_1);
        mapping1.addFrom(FROM_2);
        mapping1.addFrom(FROM_3);
        mapping1.addFrom(FROM_4);
        mappings1.addMapping(mapping1);

        // make sure the to == from when passing in a mappings1 that don't exist
        assertNotNull(mappings1.getTo(NOT_MAPPED_1));
        assertEquals(
            NOT_MAPPED_1,
            mappings1.getTo(NOT_MAPPED_1));
        assertEquals(
            mappings1.getTo(NOT_MAPPED_2),
            mappings1.getTo(NOT_MAPPED_2));

        // make sure we can retrieve the to using a from array.
        assertNotNull(mappings1.getTo(FROM_1));
        assertEquals(
            TO_1,
            mappings1.getTo(FROM_1));

        // make sure we can retrieve the to using a from non array.
        assertEquals(
            TO_1,
            mappings1.getTo(FROM_4));

        Mappings mappings2 = new Mappings();
        Mapping mapping2 = new Mapping();
        mapping2.setTo(TO_2);
        mapping2.addFrom(FROM_5);
        mappings2.addMapping(mapping2);
        assertEquals(
            TO_2,
            mappings2.getTo(FROM_5));

        Mappings mappings3 = new Mappings();
        Mapping mapping3 = new Mapping();
        mapping3.setTo(TO_3);
        mapping3.addFrom(FROM_6);
        mappings3.addMapping(mapping3);
        // make sure whitespace isn't deleted, only trimmed (Java generics would fail compilation otherwise for example)
        assertEquals(
            TO_3,
            mappings3.getTo(FROM_6));
    }
View Full Code Here

    public void testMappingsInheritance()
    {
        final URL testMappingsParentUri = MappingsTest.class.getResource("TestMappingsParent.xml");
        assertNotNull(testMappingsParentUri);
        final Mappings testMappingsParent = Mappings.getInstance(testMappingsParentUri);
        assertNotNull(testMappingsParent);
        final Collection mappings1 = testMappingsParent.getMappings();
        assertEquals(
            3,
            mappings1.size());
        final Iterator mappings1Iterator = mappings1.iterator();
        Mapping mapping1 = (Mapping)mappings1Iterator.next();
        assertEquals(
            "datatype::typeOne",
            mapping1.getFroms().iterator().next());
        assertEquals(
            "Type_One",
            mapping1.getTo());
        Mapping mapping2 = (Mapping)mappings1Iterator.next();
        assertEquals(
            "datatype::typeTwo",
            mapping2.getFroms().iterator().next());
        assertEquals(
            "Type_Two",
            mapping2.getTo());
        Mapping mapping3 = (Mapping)mappings1Iterator.next();
        assertEquals(
            "datatype::typeThree",
            mapping3.getFroms().iterator().next());
        assertEquals(
            "Type_Three",
            mapping3.getTo());

        final URL testMappingsUri = MappingsTest.class.getResource("TestMappings.xml");
        assertNotNull(testMappingsUri);
        Mappings testMappings = Mappings.getInstance(testMappingsUri);
        assertNotNull(testMappings);
        final Collection mappings2 = testMappings.getMappings();
        assertEquals(
            4,
            mappings2.size());
        final Iterator mappings2Iterator = mappings2.iterator();
        mapping1 = (Mapping)mappings2Iterator.next();
View Full Code Here

    public void testEmptyMappings()
    {
        final URL testEmptyMappingsUri = MappingsTest.class.getResource("TestMappingsEmpty.xml");
        assertNotNull(testEmptyMappingsUri);

        final Mappings mappings = Mappings.getInstance(testEmptyMappingsUri);
        assertNotNull(mappings);

        final Collection mappingCollection = mappings.getMappings();
        assertEquals(0, mappingCollection.size());
    }
View Full Code Here

        Mappings.addLogicalMappings(MappingsTest.class.getResource("TestMappingsExtendsLevelC.xml"));
        Mappings.addLogicalMappings(MappingsTest.class.getResource("TestMappingsExtendsLevelB.xml"));

        Mappings.initializeLogicalMappings();

        final Mappings mappings = Mappings.getInstance("TestMappingsExtendsLevelD");
        assertNotNull(mappings);

        final Mapping aaa = mappings.getMapping("datatype::aaa");
        assertNotNull(aaa);
        assertEquals("AAA", aaa.getTo());

        final Mapping bbb = mappings.getMapping("datatype::bbb");
        assertNotNull(bbb);
        assertEquals("BBB", bbb.getTo());

        final Mapping ccc = mappings.getMapping("datatype::ccc");
        assertNotNull(ccc);
        assertEquals("CCC", ccc.getTo());

        final Mapping ddd = mappings.getMapping("datatype::ddd");
        assertNotNull(ddd);
        assertEquals("DDD", ddd.getTo());
    }
View Full Code Here

       
        if ( url != null )
        {
            String mappingFile = targetDir + "/" + sqlMappingUri.substring( sqlMappingUri.lastIndexOf( "/" ) + 1 );
            Mappings maps = getMappings( sqlMappingUri.substring( 0, sqlMappingUri.indexOf( "!" ) )
                    , sqlMappingUri.substring( sqlMappingUri.indexOf( "!" ) + 1 )
                    , mappingFile );
           
            if ( type != null && maps != null )
            {
                String name = type.getName();
                String pack = type.getPackage().getName();
               
                String datatype = pack+"::"+name;

                Mapping mapping = maps.getMapping( datatype );
               
                sqlType = mapping.getTo();
            }
        }
       
View Full Code Here

       
        if ( url != null )
        {
            String mappingFile = targetDir + "/" + jdbcMappingUri.substring( jdbcMappingUri.lastIndexOf( "/" ) + 1 );
            Mappings maps = getMappings( jdbcMappingUri.substring( 0, jdbcMappingUri.indexOf( "!" ) )
                    , jdbcMappingUri.substring( jdbcMappingUri.indexOf( "!" ) + 1 )
                    , mappingFile );
           
            if ( tempType != null && MAPPINGS != null )
            {
                String name = tempType.getName();
                String pack = tempType.getPackage().getName();
               
                String datatype = pack+"::"+name;

                Mapping mapping = maps.getMapping( datatype );
               
                jdbcType = mapping.getTo();
            }
        }
        return jdbcType;
View Full Code Here

    private static Mappings getMappings(String jarFileURL, String jarEntryName, String mappingsFile)
    {

        String mapsFile = mappingsFile.replace( '\\', '/' );
       
        Mappings maps = null;
       
        if ( MAPPINGS.containsKey( mapsFile ) )
        {
            maps = ( Mappings ) MAPPINGS.get( mapsFile );
        }
View Full Code Here

       
        if ( url != null )
        {
            String mappingFile = targetDir + "/" + sqlMappingUri.substring( sqlMappingUri.lastIndexOf( "/" ) + 1 );
            Mappings maps = getMappings( sqlMappingUri.substring( 0, sqlMappingUri.indexOf( "!" ) )
                    , sqlMappingUri.substring( sqlMappingUri.indexOf( "!" ) + 1 )
                    , mappingFile );
           
            if ( maps != null )
            {
                String datatype = "datatype::String";

                Mapping mapping = maps.getMapping( datatype );
               
                sqlType = mapping.getTo();
            }
        }
       
View Full Code Here

TOP

Related Classes of org.andromda.core.mapping.Mappings

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.