Package com.volantis.mcs.devices.category

Examples of com.volantis.mcs.devices.category.CategoryDescriptor


    // javadoc inherited
    public CategoryDescriptor getCategoryDescriptor(
                String categoryName, Locale locale)
            throws DeviceRepositoryException {
        CategoryDescriptor descriptor = null;
        if (categoryName != null) {
            // get the right cache
            Map nameToDescriptor =
                (Map) cachedCategoryDescriptorRequests.get(locale);
            if (nameToDescriptor == null) {
View Full Code Here


                }

                for (Iterator iter = categoryDescriptors.iterator();
                     iter.hasNext();) {

                    final CategoryDescriptor categoryDescriptor =
                        (CategoryDescriptor) iter.next();
                    // Write the descriptors to the destination for this
                    // category.
                    try {
                        dstAccessor.addCategoryDescriptor(
View Full Code Here

                            DeviceRepositoryFactory.getDefaultInstance();
                URL deviceRepositoryUrl = file.toURL();
                DeviceRepository repository = factory.getDeviceRepository(
                        deviceRepositoryUrl, null);

                CategoryDescriptor descriptor =
                    repository.getCategoryDescriptor(null, Locale.getDefault());
                assertNull("Category descriptor should not be found", descriptor);

                // todo this code is commented cause the expected value should be null (currently a DeviceRepositoryException is thrown which is wrong).
//                descriptor = repository.getCategoryDescriptor(
View Full Code Here

        try {
            final InternalJDBCRepository repository = createRepository(defaultProject);
            final JDBCDeviceRepositoryAccessor accessor =
                new JDBCDeviceRepositoryAccessor(repository, location);
            final Locale locale = Locale.getDefault();
            CategoryDescriptor descriptor = accessor.
                retrieveCategoryDescriptor(connection, "unknown", locale);
            assertNull("Should find nothing", descriptor);

            // Populate with one value.
            Connection sqlConnection =
                    ((JDBCRepositoryConnection) connection).getConnection();

            Statement st = sqlConnection.createStatement();
            execute(st, "insert into VMPOLICY_CATEGORY values " +
                    "(" + "'" + defaultProject + "',0,'CategoryName', " +
                        "'<default>')");
            st.close();

            descriptor = accessor.retrieveCategoryDescriptor(connection,
                    "CategoryName", locale);
            assertNotNull("Should find descriptor", descriptor);
            assertEquals("CategoryName", descriptor.getCategoryDescriptiveName());


            st = sqlConnection.createStatement();
            execute(st, "insert into VMPOLICY_CATEGORY values " +
                "(" + "'" + defaultProject + "',0,'category name', 'en_GB_')");
            st.close();

            descriptor = accessor.retrieveCategoryDescriptor(connection,
                    "CategoryName", new Locale("en", "GB"));
            assertNotNull("Should find descriptor", descriptor);
            assertEquals("category name",
                descriptor.getCategoryDescriptiveName());
            assertEquals("en_GB_", descriptor.getLanguage());

            descriptor = accessor.retrieveCategoryDescriptor(connection,
                    "CategoryName", new Locale("en", "GB", "WIN"));
            assertNotNull("Should find descriptor", descriptor);
            assertEquals("category name",
                descriptor.getCategoryDescriptiveName());
            assertEquals("en_GB_", descriptor.getLanguage());

            descriptor = accessor.retrieveCategoryDescriptor(connection,
                    "CategoryName", new Locale("en"));
            assertNotNull("Should find descriptor", descriptor);
            assertEquals("CategoryName", descriptor.getCategoryDescriptiveName());
            assertNull(descriptor.getLanguage());

            descriptor = accessor.retrieveCategoryDescriptor(connection,
                    "CategoryName", new Locale("de"));
            assertNotNull("Should find descriptor", descriptor);
            assertEquals("CategoryName", descriptor.getCategoryDescriptiveName());
            assertNull(descriptor.getLanguage());
        } finally {
            removeRepository();
        }
    }
View Full Code Here

            // Retrieve the unknown value shouldn't find a match.
            enumeration = accessor.enumerateCategoryNames(connection);
            assertTrue("Should find category", enumeration.hasNext());
            assertEquals("CategoryName", enumeration.next());
            assertFalse(enumeration.hasNext());
            final CategoryDescriptor categoryDescriptor =
                accessor.retrieveCategoryDescriptor(
                    connection, "CategoryName", new Locale("en", "GB"));
            assertEquals("Category name",
                categoryDescriptor.getCategoryDescriptiveName());
            assertEquals("en_GB_", categoryDescriptor.getLanguage());
        } finally {
            removeRepository();
        }
    }
View Full Code Here

            String language = (String) entry.getKey();
            final Properties properties = (Properties) entry.getValue();
            if (properties.containsKey(nameProperty)) {
                final Locale locale =
                    convertPropertiesLanguageToLocale(language);
                final CategoryDescriptor categoryDescriptor =
                    retrieveCategoryDescriptor(connection, categoryName, locale);
                if (categoryDescriptor != null) {
                    result.add(categoryDescriptor);
                }
            }
View Full Code Here

                final Locale locale = Locale.getDefault();

                // Create a test connection
                final RepositoryConnection connection = createConnection();

                CategoryDescriptor descriptor =
                        accessor.retrieveCategoryDescriptor(
                                connection, "protocol", locale);
                // Ensure the name matches as expected
                assertEquals("Descriptive name should match (boolean)",
                        descriptor.getCategoryDescriptiveName(),
                        "Protocol");

                descriptor = accessor.retrieveCategoryDescriptor(
                                connection, "audio", new Locale("de"));
                // Ensure the name matches as expected
                assertEquals("Descriptive name should match",
                        descriptor.getCategoryDescriptiveName(),
                        "Audiodaten");

                descriptor = accessor.retrieveCategoryDescriptor(
                                connection, "audio", new Locale("de", "CH"));
                // Ensure the name matches as expected
                assertEquals("Descriptive name should match",
                        descriptor.getCategoryDescriptiveName(),
                        "Audiodaten");
            }
        });
    }
View Full Code Here

                final RepositoryConnection connection = createConnection();

                final List descriptors =
                    accessor.retrieveCategoryDescriptors(connection, "audio");
                assertEquals(2, descriptors.size());
                final CategoryDescriptor descriptor1 =
                    (CategoryDescriptor) descriptors.get(0);
                checkLanguage(descriptor1);
                final CategoryDescriptor descriptor2 =
                    (CategoryDescriptor) descriptors.get(1);
                checkLanguage(descriptor2);
                assertNotEquals(descriptor1.getLanguage(),
                    descriptor2.getLanguage());
            }

            private void checkLanguage(final CategoryDescriptor descriptor) {
                final String language = descriptor.getLanguage();
                if (language.equals("__")) {
View Full Code Here

TOP

Related Classes of com.volantis.mcs.devices.category.CategoryDescriptor

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.