Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titlePodstawowe wyszukiwanie dokumentów
linenumberstrue
		DocumentFinder documentFinder=FinderFactory.getDocumentFinder();		
 
		Map<Long//definijemy wartości zmiennych procesu, który chcemy znaleźć
		Map<String, Object> idxindexes = new HashMap<LongHashMap<String, Object>();
        idxindexes.put( 1L"textcol", "wartość tekstowatext5" );
        idxindexes.put( 2L"datecol", 555 )DateUtils.parseDate( "2014-02-12", "yyyy-MM-dd" ) );
        idxindexes.put( 3L"doublecol", new Date() );//wartości indeksów po których chcemy wyszukiwać4.3);
        indexes.put( "intcol", 5 );

        List<Process> processes =  List<Sorter> sorters=new ArrayList<Sorter>(finder.findByIndexes( processDefId, indexes );
        sorters.add( new Sorter("3",SortDirection.DESC) );//sorujemy malejąco po indeksie o id 3
  
        Process p = processes.get( 0 );//znaleziony proces
      
		//odczyt indeksów
     CountedResult<WfDocument> result=documentFinder.findByIndexes( idx, sorters,String documentClassId,textcol start, limit = (String) p.getIndexValue( "textcol" );
        longDate total=result.getTotal();//liczba wszystkich pasujących dokumentówdatecol = (Date) p.getIndexValue( "datecol" );
        Double doublecol = List<WfDocument> documents=result.getData();//lista znalezionych dokumentów ograniczona przez start i limit(Double) p.getIndexValue( "doublecol" );
        Integer intcol = (Integer) p.getIndexValue( "intcol" );

Przedstawiona wyżej metoda wyszukuje dokumenty procesy o indeksach równych (operator '=' )  podanym wartościom i wszystkie warunki łączy operatorem logicznym AND. Jeżeli chcemy stworzyć bardziej zaawansowane warunki wyszukiwania możemy wykorzystać następującą metodę:

Code Block
languagejava
titleZaawansowane wyszukiwanie
		DocumentFinder documentFinder = FinderFactory.getDocumentFinder();

        List<IndexFilter> filters = new ArrayList<IndexFilter>();
         filters.add( new SimpleIndexFilter( 3L"datecol", date, FilterOperator.GT ) );// Greater then '>'
         filters.add( new SimpleIndexFilter( 1L"textcol", "%test%%text%", FilterOperator.LIKE ) );//definiujemy
operatory wyszukiwania        List<Process>  CountedResult<WfDocument> result = documentFinderfinder.findByIndexes( filtersprocessDefId, sorters, documentClassId, start, limit filters );

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
languagejava
titleGrupowanie filtrów
linenumberstrue
 		List<IndexFilter> filters = new ArrayList<IndexFilter>();

        // tworzymy grupę warunków połączonych operatorem OR
        GroupIndexFilter gif = new GroupIndexFilter( LogicOperator.OR );

        // tworzymy grupępierwszą podgrupę warunków
połączonych operatorem OR      GroupIndexFilter subGroup1  gif.= new GroupIndexFilter( LogicOperator.AND );
        subGroup1.addFilter( new SimpleIndexFilter( 3L"datecol", date, FilterOperator.GT ) );
        gifsubGroup1.addFilter( new SimpleIndexFilter( 1L"textcol", "%test%%text%", FilterOperator.LIKE ) );

        // tworzymy drugą grupę warunków
        GroupIndexFilter subGroupsubGroup2 = new GroupIndexFilter( LogicOperator.AND );// tworzymy kolejną grupę warunków
        subGroupsubGroup2.addFilter( new SimpleIndexFilter( 5L"textcol", "abctext3" ) );
        subGroupsubGroup2.addFilter( new SimpleIndexFilter( 2L"intcol", 5553 ) );

        gif.addFilter( subGroupsubGroup1 );// do grupy warunków możmy dodać inną grupę tworząc drzewo warunków
        gif.addFilter( subGroup2 );
       
		filters.add( gif );
        CountedResult<WfDocument>List<Process> result = documentFinderfinder.findByIndexes( filtersprocessDefId, sorters, documentClassId, start, limit filters );
 

Powyższy przykład utworzy następujący warunek: idx_3 > date OR idx_1 = '%test' OR ( idx_5 = 'abc' AND idx_2 = 555 )  (  ( datecol >  '2014-02-11'  and textcol like  '%text%'  )  or  ( textcol =  'text3'  and intcol =  3  )  ) 

Zadania

Code Block
languagejava
titleOperacje na zadaniach
linenumberstrue
		// Pobieranie informacji o zadaniu
        Activity activity=activityService.getActivity( processId, activityId );
        String activityDefId=activity.getActivityDefinitionId();
        String desc=activity.getDescription();
        String name=activity.getName();
        ActivityState state=activity.getState();//RUNNING, NOT_STARTED, SUSPENDED, COMPLETED, TERMINATED, ABORTED
        Date created=activity.getCreatedTime();//data utworzenia zadani
        Date started=activity.getStartedTime();//data uruchomienia
       
        
        // Zmiana wartości zmiennych zadania
        Map<String,Object> activityContext=activityService.getActivityContext( processId, activityId );
        activityContext.put( "zmienna", "wartość" );    
        activityService.setActivityContext( processId, activityId, activityContext );
        
        
        //Otworzenie zadania przez podanego użytkownika. Jeżeli zadanie ma status 'Oczekujące na uruchomienie'
        //i jest przypisane do podanego użytkownika to poniższa funkcja spowoduje przypisanie zadania
        //do podanego użytkownia i zmieni status na 'Uruchomione'
        activityService.openActivity( userName, userPassword, processId, activityId );
        
        
        //Akceptacja zadania
        String executor="jkowalski";//użytkownik akceptujący
        String actionName="akceptacja";//nazwa akcji z mapy
        Map<String,Object> map=new HashMap<String,Object>();
        map.put( "zmienna", "wartosc" );//mapa nie zostanie całkowicie zastąpiona podaną
        //zostaną nadpisane tylko podane wartości
        AcceptationDefinition acceptation=new AcceptationDefinition( processId, activityId, executor, actionName );
        acceptation.setContextMap( map );//opcjonalnie	 	
 

...