Package org.rhq.core.domain.search

Examples of org.rhq.core.domain.search.SavedSearch


    public void testCRUD() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                Subject subject = SessionTestHelper.createNewSubject(em, "fake subject");
                int entityId = savedSearchManager.createSavedSearch(subject, new SavedSearch(SearchSubsystem.GROUP,
                    "fake saved search", "pipo", subject));
                SavedSearch entity = savedSearchManager.getSavedSearchById(subject, entityId);
                assertNotNull(entity);
                SavedSearch modifiedEntity = new SavedSearch(SearchSubsystem.RESOURCE, "fake saved search modified",
                    "molo", subject);
                modifiedEntity.setId(entityId);
                boolean updateSuccess = savedSearchManager.updateSavedSearch(subject, modifiedEntity);
                assertTrue("Update save searched failed", updateSuccess);
                savedSearchManager.deleteSavedSearch(subject, entityId);
                assertNull(em.find(SavedSearch.class, entityId));
            }
View Full Code Here


    public void testgetSavedSearchByIdPermission() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                Subject subject1 = SessionTestHelper.createNewSubject(em, "fake subject 1");
                SavedSearch savedSearch = new SavedSearch(SearchSubsystem.GROUP, "fake saved search", "pipo", subject1);
                int entityId = savedSearchManager.createSavedSearch(subject1, savedSearch);
                Subject subject2 = SessionTestHelper.createNewSubject(em, "fake subject 2");
                try {
                    savedSearchManager.getSavedSearchById(subject2, entityId);
                    fail("Expected " + PermissionException.class.getSimpleName());
View Full Code Here

                final Subject subject1 = SessionTestHelper.createNewSubject(em, "fake subject 1");
                final Subject subject2 = SessionTestHelper.createNewSubject(em, "fake subject 2");
                assertManipulatePermissionExceptionThrown(new Runnable() {
                    @Override
                    public void run() {
                        savedSearchManager.createSavedSearch(subject2, new SavedSearch(SearchSubsystem.GROUP,
                            "fake saved search 2", "molo", subject1));
                    }
                });
            }
        });
View Full Code Here

    public void testDeleteSavedSearchPermission() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                final Subject subject1 = SessionTestHelper.createNewSubject(em, "fake subject 1");
                final int entityId = savedSearchManager.createSavedSearch(subject1, new SavedSearch(
                    SearchSubsystem.GROUP, "fake saved search", "pipo", subject1));
                final Subject subject2 = SessionTestHelper.createNewSubject(em, "fake subject 2");
                assertManipulatePermissionExceptionThrown(new Runnable() {
                    @Override
                    public void run() {
View Full Code Here

    public void testUpdateSavedSearchPermission() {
        executeInTransaction(new TransactionCallback() {
            @Override
            public void execute() throws Exception {
                final Subject subject1 = SessionTestHelper.createNewSubject(em, "fake subject 1");
                final int entityId = savedSearchManager.createSavedSearch(subject1, new SavedSearch(
                    SearchSubsystem.GROUP, "fake saved search", "pipo", subject1));
                final Subject subject2 = SessionTestHelper.createNewSubject(em, "fake subject 2");
                assertManipulatePermissionExceptionThrown(new Runnable() {
                    @Override
                    public void run() {
                        SavedSearch modifiedEntity = new SavedSearch(SearchSubsystem.GROUP, "fake saved search 2",
                            "molo", subject1);
                        modifiedEntity.setId(entityId);
                        savedSearchManager.updateSavedSearch(subject2, modifiedEntity);
                    }
                });
            }
        });
View Full Code Here

                Role inventoryManagerRole = SessionTestHelper.createNewRoleForSubject(em, subject2,
                    "inventory manager role", Permission.MANAGE_INVENTORY);

                for (int i = 0; i < 1000; i++) {
                    String iStr = String.valueOf(i);
                    savedSearchManager.createSavedSearch(subject1, new SavedSearch(SearchSubsystem.GROUP,
                        "fake saved search " + iStr, "pipo " + iStr, subject1));
                    savedSearchManager.createSavedSearch(subject2, new SavedSearch(SearchSubsystem.GROUP,
                        "fake saved search " + iStr, "molo " + iStr, subject2));
                }

                SavedSearchCriteria criteria = new SavedSearchCriteria();
                criteria.addFilterName("fake saved search");
View Full Code Here

        }
    }

    public boolean updateSavedSearchName(int savedSearchId, final String newName) throws RuntimeException {
        try {
            SavedSearch savedSearch = getSubjectSavedSearch(savedSearchId);
            savedSearch.setName(newName);
            return savedSearchManager.updateSavedSearch(getSessionSubject(), savedSearch);
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
    }
View Full Code Here

        }
    }

    public boolean updateSavedSearchPattern(int savedSearchId, final String newPattern) throws RuntimeException {
        try {
            SavedSearch savedSearch = getSubjectSavedSearch(savedSearchId);
            savedSearch.setPattern(newPattern);
            return savedSearchManager.updateSavedSearch(getSessionSubject(), savedSearch);
        } catch (Throwable t) {
            throw getExceptionToThrowToClient(t);
        }
    }
View Full Code Here

     * @see SavedSearchManagerRemote#updateSavedSearch(Subject, SavedSearch)
     */
    public boolean updateSavedSearch(Subject subject, SavedSearch savedSearch) {
        // this needs to prevent certain types of updates, be more sophisticated, etc
        validateManipulatePermission(subject, savedSearch);
        SavedSearch oldSavedSearch = entityManager.find(SavedSearch.class, savedSearch.getId());
        if (null == oldSavedSearch || oldSavedSearch.equals(savedSearch)) {
            return false;
        } else {
            entityManager.merge(savedSearch);
            return true;
        }
View Full Code Here

    /**
     * @see SavedSearchManagerRemote#deleteSavedSearch(Subject, int)
     */
    public void deleteSavedSearch(Subject subject, int savedSearchId) {
        SavedSearch savedSearch = entityManager.find(SavedSearch.class, savedSearchId);
        if (null != savedSearch) {
            validateManipulatePermission(subject, savedSearch);
            entityManager.remove(savedSearch);
        }
    }
View Full Code Here

TOP

Related Classes of org.rhq.core.domain.search.SavedSearch

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.