View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.syncope.client.console.tasks;
20  
21  import java.util.Iterator;
22  import org.apache.syncope.client.console.panels.MultilevelPanel;
23  import org.apache.syncope.client.console.rest.TaskRestClient;
24  import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
25  import org.apache.syncope.common.lib.to.PropagationTaskTO;
26  import org.apache.syncope.common.lib.types.AnyTypeKind;
27  import org.apache.wicket.PageReference;
28  
29  public abstract class AnyPropagationTaskDirectoryPanel extends PropagationTaskDirectoryPanel {
30  
31      private static final long serialVersionUID = -6784307338127527803L;
32  
33      private final AnyTypeKind anyTypeKind;
34  
35      private final String entityKey;
36  
37      protected AnyPropagationTaskDirectoryPanel(
38              final TaskRestClient restClient,
39              final BaseModal<?> baseModal,
40              final MultilevelPanel multiLevelPanelRef,
41              final AnyTypeKind anyTypeKind,
42              final String entityKey,
43              final PageReference pageRef) {
44  
45          super(restClient, baseModal, multiLevelPanelRef, null, pageRef);
46          this.anyTypeKind = anyTypeKind;
47          this.entityKey = entityKey;
48      }
49  
50      @Override
51      protected PropagationTasksProvider dataProvider() {
52          return new AnyPropagationTasksProvider(rows);
53      }
54  
55      protected class AnyPropagationTasksProvider extends PropagationTasksProvider {
56  
57          private static final long serialVersionUID = 8975514657807398110L;
58  
59          public AnyPropagationTasksProvider(final int paginatorRows) {
60              super(paginatorRows);
61          }
62  
63          @Override
64          public long size() {
65              return restClient.count(anyTypeKind, entityKey, taskType);
66          }
67  
68          @Override
69          public Iterator<PropagationTaskTO> iterator(final long first, final long count) {
70              int page = ((int) first / paginatorRows);
71              return restClient.listPropagationTasks(
72                      anyTypeKind, entityKey, (page < 0 ? 0 : page) + 1, paginatorRows, getSort()).
73                      iterator();
74          }
75      }
76  }