/** * Constructor that takes care of {@link #setStorageType(Class)}. * * @see #setStorageType(Class) */ public NamedObjectRegistry(Class<T> type) { this(); setStorageType(type); }
/** * Registers the instance */ public void afterPropertiesSet() throws Exception { PropertyCheck.mandatory(this, "name", name); PropertyCheck.mandatory(this, "registry", registry); registry.register(name, this); }
@Override public PagingResults<Pair<TopicInfo, Integer>> listHotTopics( NodeRef nodeRef, Date since, PagingRequest paging) { // Do the query GetDiscussionTopcisWithPostsCannedQueryFactory getCQFactory = (GetDiscussionTopcisWithPostsCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_TOPICS_WITH_POSTS); GetDiscussionTopcisWithPostsCannedQuery cq = (GetDiscussionTopcisWithPostsCannedQuery)getCQFactory.getCannedQuery( nodeRef, null, since, true, null, paging); // Execute the canned query CannedQueryResults<NodeWithChildrenEntity> results = cq.execute(); // Wrap and return return wrapWithCount(results, nodeRef); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void setUp() throws Exception { // Create the registry namedQueryFactoryRegistry = new NamedObjectRegistry<CannedQueryFactory>(); namedQueryFactoryRegistry.setStorageType(CannedQueryFactory.class); namedQueryFactoryRegistry.setNamePattern("test\\.query\\..*"); // Registry the query factories // ONE TestCannedQueryFactory<String> namedQueryFactoryOne = new TestCannedQueryFactory(RESULTS_ONE); namedQueryFactoryOne.setBeanName(QUERY_TEST_ONE); namedQueryFactoryOne.setRegistry(namedQueryFactoryRegistry); namedQueryFactoryOne.afterPropertiesSet(); // TWO TestCannedQueryFactory<Long> namedQueryFactoryTwo = new TestCannedQueryFactory(RESULTS_TWO); namedQueryFactoryTwo.setBeanName(QUERY_TEST_TWO); namedQueryFactoryTwo.setRegistry(namedQueryFactoryRegistry); namedQueryFactoryTwo.afterPropertiesSet(); }
@Override public PagingResults<Pair<TopicInfo, Integer>> listHotTopics( NodeRef nodeRef, Date since, PagingRequest paging) { // Do the query GetDiscussionTopcisWithPostsCannedQueryFactory getCQFactory = (GetDiscussionTopcisWithPostsCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_TOPICS_WITH_POSTS); GetDiscussionTopcisWithPostsCannedQuery cq = (GetDiscussionTopcisWithPostsCannedQuery)getCQFactory.getCannedQuery( nodeRef, null, since, true, null, paging); // Execute the canned query CannedQueryResults<NodeWithChildrenEntity> results = cq.execute(); // Wrap and return return wrapWithCount(results, nodeRef); }
/** * Registers the instance */ public void afterPropertiesSet() throws Exception { PropertyCheck.mandatory(this, "name", name); PropertyCheck.mandatory(this, "registry", registry); registry.register(name, this); }
/** * Constructor that takes care of {@link #setStorageType(Class)}. * * @see #setStorageType(Class) */ public NamedObjectRegistry(Class<T> type) { this(); setStorageType(type); }
@Override public PagingResults<CopyInfo> getCopies(NodeRef originalNodeRef, PagingRequest pagingRequest) { CannedQueryFactory<CopyInfo> queryFactory = cannedQueryRegistry.getNamedObject(QUERY_FACTORY_GET_COPIES); CannedQueryParameters params = new CannedQueryParameters( new AbstractCopyCannedQueryFactory.CopyCannedQueryDetail(originalNodeRef), null, pagingRequest); CannedQuery<CopyInfo> query = queryFactory.getCannedQuery(params); return query.execute(); }
/** * Registers the instance */ public void afterPropertiesSet() throws Exception { PropertyCheck.mandatory(this, "name", name); PropertyCheck.mandatory(this, "registry", registry); registry.register(name, this); }
@Override public PagingResults<CopyInfo> getCopies(NodeRef originalNodeRef, PagingRequest pagingRequest) { CannedQueryFactory<CopyInfo> queryFactory = cannedQueryRegistry.getNamedObject(QUERY_FACTORY_GET_COPIES); CannedQueryParameters params = new CannedQueryParameters( new AbstractCopyCannedQueryFactory.CopyCannedQueryDetail(originalNodeRef), null, pagingRequest); CannedQuery<CopyInfo> query = queryFactory.getCannedQuery(params); return query.execute(); }
/** * Registers the instance */ public void afterPropertiesSet() throws Exception { PropertyCheck.mandatory(this, "name", name); PropertyCheck.mandatory(this, "registry", registry); registry.register(name, this); }
@Override public PagingResults<CopyInfo> getCopies( NodeRef originalNodeRef, NodeRef copyParentNodeRef, PagingRequest pagingRequest) { CannedQueryFactory<CopyInfo> queryFactory = cannedQueryRegistry.getNamedObject(QUERY_FACTORY_GET_COPIES); CannedQueryParameters params = new CannedQueryParameters( new AbstractCopyCannedQueryFactory.CopyCannedQueryDetail(originalNodeRef, copyParentNodeRef), null, pagingRequest); CannedQuery<CopyInfo> query = queryFactory.getCannedQuery(params); return query.execute(); }
/** * Registers the instance */ public void afterPropertiesSet() throws Exception { PropertyCheck.mandatory(this, "name", name); PropertyCheck.mandatory(this, "registry", registry); registry.register(name, this); }
@Override public PagingResults<CopyInfo> getCopies( NodeRef originalNodeRef, NodeRef copyParentNodeRef, PagingRequest pagingRequest) { CannedQueryFactory<CopyInfo> queryFactory = cannedQueryRegistry.getNamedObject(QUERY_FACTORY_GET_COPIES); CannedQueryParameters params = new CannedQueryParameters( new AbstractCopyCannedQueryFactory.CopyCannedQueryDetail(originalNodeRef, copyParentNodeRef), null, pagingRequest); CannedQuery<CopyInfo> query = queryFactory.getCannedQuery(params); return query.execute(); }
/** * Registers the instance */ public void afterPropertiesSet() throws Exception { PropertyCheck.mandatory(this, "name", name); PropertyCheck.mandatory(this, "registry", registry); registry.register(name, this); }
private PagingResults<LinkInfo> listLinks(String siteShortName, String user, Date from, Date to, PagingRequest paging) { NodeRef container = getSiteLinksContainer(siteShortName, false); if (container == null) { // No events return new EmptyPagingResults<LinkInfo>(); } // Run the canned query GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN); GetChildrenAuditableCannedQuery cq = (GetChildrenAuditableCannedQuery)getChildrenCannedQueryFactory.getCannedQuery( container, LinksModel.TYPE_LINK, user, from, to, null, null, null, getChildrenCannedQueryFactory.createDateDescendingCQSortDetails(), paging); // Execute the canned query CannedQueryResults<NodeBackedEntity> results = cq.execute(); // Convert to Link objects return wrap(results, container); }
private PagingResults<LinkInfo> listLinks(String siteShortName, String user, Date from, Date to, PagingRequest paging) { NodeRef container = getSiteLinksContainer(siteShortName, false); if (container == null) { // No events return new EmptyPagingResults<LinkInfo>(); } // Run the canned query GetChildrenAuditableCannedQueryFactory getChildrenCannedQueryFactory = (GetChildrenAuditableCannedQueryFactory)cannedQueryRegistry.getNamedObject(CANNED_QUERY_GET_CHILDREN); GetChildrenAuditableCannedQuery cq = (GetChildrenAuditableCannedQuery)getChildrenCannedQueryFactory.getCannedQuery( container, LinksModel.TYPE_LINK, user, from, to, null, null, null, getChildrenCannedQueryFactory.createDateDescendingCQSortDetails(), paging); // Execute the canned query CannedQueryResults<NodeBackedEntity> results = cq.execute(); // Convert to Link objects return wrap(results, container); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public void testRegistry() throws Exception { CannedQueryFactory<String> one = namedQueryFactoryRegistry.getNamedObject(QUERY_TEST_ONE); assertNotNull("No factory for " + QUERY_TEST_ONE, one); CannedQueryFactory<String> two = namedQueryFactoryRegistry.getNamedObject(QUERY_TEST_TWO); assertNotNull("No factory for " + QUERY_TEST_TWO, two); // Kick out registrations with incorrect naming convention try { TestCannedQueryFactory<Long> namedQueryFactoryBogus = new TestCannedQueryFactory(RESULTS_TWO); namedQueryFactoryBogus.setBeanName("test_query_blah"); namedQueryFactoryBogus.setRegistry(namedQueryFactoryRegistry); namedQueryFactoryBogus.afterPropertiesSet(); fail("Should have kicked out incorrectly-named registered queries"); } catch (IllegalArgumentException e) { // Expected } }
private CannedQueryResults<NodeRef> executeGetPeopleQuery( final PagingRequest pagingRequest, final String pattern, final List<QName> filterProps, final boolean includeAdministrators, final List<Pair<QName, Boolean>> sortProps) { GetPeopleCannedQueryFactory getPeopleCannedQueryFactory = (GetPeopleCannedQueryFactory) cannedQueryRegistry.getNamedObject(CANNED_QUERY_PEOPLE_LIST); final GetPeopleCannedQuery cq = (GetPeopleCannedQuery) getPeopleCannedQueryFactory .getCannedQuery( personService.getPeopleContainer(), pattern, filterProps, null, null, includeAdministrators, sortProps, pagingRequest); return transactionService.getRetryingTransactionHelper().doInTransaction(cq::execute, true); }
@SuppressWarnings("unchecked") public void testQueryMaxResults() throws Exception { // An instance of the CannedQueryFactory could be injected or constructed as well CannedQueryFactory<String> qfOne = namedQueryFactoryRegistry.getNamedObject(QUERY_TEST_ONE); CannedQuery<String> qOne = qfOne.getCannedQuery(null, 0, 9, null); CannedQueryResults<String> qrOne = qOne.execute(); // Get the paged result count int pagedResultCount = qrOne.getPagedResultCount(); assertEquals("Incorrect number of results", 9, pagedResultCount); assertEquals("Incorrect number of pages", 1, qrOne.getPageCount()); List<List<String>> pages = qrOne.getPages(); assertEquals("Incorrect number of pages", 1, pages.size()); assertEquals("No sorting was specified in the parameters", "ONE_0", qrOne.getPages().get(0).get(0)); assertEquals("No sorting was specified in the parameters", "ONE_9", qrOne.getPages().get(0).get(8)); assertFalse("Should have more pages/items", qrOne.hasMoreItems()); }