...
Code Block |
---|
language | java |
---|
title | Podstawowe wyszukiwanie dokumentów |
---|
linenumbers | true |
---|
|
DocumentFinder documentFinder=FinderFactory.getDocumentFinder();
Map<Long, Object> idx = new HashMap<Long, Object>();
idx.put( 1L, "wartość tekstowa" );
idx.put( 2L, 555 );
idx.put( 3L, new Date() );//wartości indeksów po których chcemy wyszukiwać
List<Sorter> sorters=new ArrayList<Sorter>();
sorters.add( new Sorter("3",SortDirection.DESC) );//sorujemy malejąco po indeksie o id 3
CountedResult<WfDocument> result=documentFinder.findByIndexes( documentClassId, idx, sorters, documentClassId, start, limit );
long total=result.getTotal();//liczba wszystkich pasujących dokumentów
List<WfDocument> documents=result.getData();//lista znalezionych dokumentów ograniczona przez start i limit |
...
Code Block |
---|
language | java |
---|
title | Zaawansowane wyszukiwanie |
---|
|
DocumentFinder documentFinder = FinderFactory.getDocumentFinder();
List<IndexFilter> filters = new ArrayList<IndexFilter>();
filters.add( new SimpleIndexFilter( 3L, date, FilterOperator.GT ) );//Greater then '>'
filters.add( new SimpleIndexFilter( 1L, "%test%", FilterOperator.LIKE ) );//definiujemy operatory wyszukiwania
CountedResult<WfDocument> result = documentFinder.findByIndexes( documentClassId, filters, sorters, documentClassId, start, limit ); |
W powyższym przykładzie zdefiniowaliśmy operatory wyszukiwania, lecz warunki nadal są połączone logicznym operatorem AND. Aby to zmienić możemy wykorzystać grupowanie filtrów:
Code Block |
---|
language | java |
---|
title | Grupowanie filtrów |
---|
linenumbers | true |
---|
|
List<IndexFilter> filters = new ArrayList<IndexFilter>();
GroupIndexFilter gif = new GroupIndexFilter( LogicOperator.OR );//tworzymy grupę warunków połączonych operatorem OR
gif.addFilter( new SimpleIndexFilter( 3L, date, FilterOperator.GT ) );
gif.addFilter( new SimpleIndexFilter( 1L, "%test%", FilterOperator.LIKE ) );
GroupIndexFilter subGroup=new GroupIndexFilter(LogicOperator.AND);// tworzymy kolejną grupę warunków
subGroup.addFilter( new SimpleIndexFilter( 5L, "abc") );
subGroup.addFilter( new SimpleIndexFilter( 2L, 555 ) );
gif.addFilter( subGroup );//do grupy warunków możmy dodać inną grupę tworząc drzewo warunków
filters.add( gif );
CountedResult<WfDocument> result = documentFinder.findByIndexes( documentClassId, filters, sorters, documentClassId, start, limit ); |
Powyższy przykład utworzy następujący warunek: idx_3 > date OR idx_1 = '%test' OR ( idx_5 = 'abc' AND idx_2 = 555 )
...
Code Block |
---|
language | java |
---|
title | Dołączanie powiązanych obiektów |
---|
linenumbers | true |
---|
|
CountedResult<WfDocument> result = documentFinder.findByIndexes( documentClassId, filters, sorters, documentClassId, start, limit, WfDocument.JOIN_DOC_CLASS );
List<WfDocument> docs= documentFinder.getDocumentsFromActivity( processId, activityId, WfDocument.JOIN_DOC_CLASS );
WfDocument doc=docs.get(0);
String documentClassName=doc.getFile().getDocumentClass().getName();//bez podania WfDocument.JOIN_DOC_CLASS wywołanie tej linii spowodowałoby błąd |
...