BrightSide Workbench Full Report + Source Code
ContactSGCheckTask.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 package org.turro.contacts.util;
20 
21 import java.util.List;
22 import java.util.stream.Stream;
23 import org.turro.contacts.Contact;
24 import org.turro.contacts.db.ContactsPU;
25 import org.turro.i18n.I_;
26 import org.turro.jpa.Dao;
27 import org.turro.scheduler.task.AbstractTask;
28 import org.turro.security.SocialGroups;
29 
34 public class ContactSGCheckTask extends AbstractTask {
35 
36  @Override
37  public void execute() {
38  Dao dao = new ContactsPU();
39  try(Stream<Contact> contacts = new ContactsPU().stream(Contact.class, "select c from Contact c")) {
40  contacts.forEach((contact) -> {
41  SocialGroups.resyndicate(List.of(contact), dao);
42  SocialGroups.checkInheritance(List.of(contact), dao);
43  });
44  }
45  }
46 
47  @Override
48  public boolean isSystem() {
49  return true;
50  }
51 
52  @Override
53  public String getName() {
54  return I_.get("Social grups check");
55  }
56 
57  @Override
58  public String getDataLabel() {
59  return null;
60  }
61 
62 }
static String get(String msg)
Definition: I_.java:41
static void resyndicate(List< Contact > contacts, Dao dao)
static void checkInheritance(List< Contact > contacts, Dao dao)