View Javadoc
1   package fr.ifremer.tutti.persistence.service.referential;
2   
3   /*
4    * #%L
5    * Tutti :: Persistence
6    * $Id:$
7    * $HeadURL:$
8    * %%
9    * Copyright (C) 2012 - 2014 Ifremer
10   * %%
11   * This program is free software: you can redistribute it and/or modify
12   * it under the terms of the GNU General Public License as
13   * published by the Free Software Foundation, either version 3 of the
14   * License, or (at your option) any later version.
15   * 
16   * This program is distributed in the hope that it will be useful,
17   * but WITHOUT ANY WARRANTY; without even the implied warranty of
18   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19   * GNU General Public License for more details.
20   * 
21   * You should have received a copy of the GNU General Public
22   * License along with this program.  If not, see
23   * <http://www.gnu.org/licenses/gpl-3.0.html>.
24   * #L%
25   */
26  
27  import fr.ifremer.tutti.persistence.TuttiPersistenceServiceImplementor;
28  import fr.ifremer.tutti.persistence.entities.referential.Person;
29  import org.springframework.cache.annotation.CacheEvict;
30  import org.springframework.cache.annotation.Cacheable;
31  import org.springframework.transaction.annotation.Transactional;
32  
33  import java.util.Collection;
34  import java.util.List;
35  
36  /**
37   * Created on 11/3/14.
38   *
39   * @author Tony Chemit - chemit@codelutin.com
40   * @since 3.8
41   */
42  @Transactional(readOnly = true)
43  public interface PersonPersistenceService extends TuttiPersistenceServiceImplementor {
44  
45      @Cacheable(value = "persons")
46      List<Person> getAllPerson();
47  
48      @Cacheable(value = "personsWithObsoletes")
49      List<Person> getAllPersonWithObsoletes();
50  
51      @Cacheable(value = "personById", key = "#personId")
52      Person getPerson(Integer personId);
53  
54      /**
55       * Check if the temporary person with the given {@code id} is used.
56       *
57       * @param id id of the person to check
58       * @return {@code true} if person is temporary
59       * @since 3.8
60       */
61      boolean isTemporaryPersonUsed(Integer id);
62  
63      /**
64       * Add temporary persons.
65       *
66       * @param persons persons to add
67       * @return added persons
68       * @since 3.14
69       */
70      @Transactional(readOnly = false)
71      @CacheEvict(value = {"persons", "personById", "personsWithObsoletes"}, allEntries = true)
72      List<Person> addTemporaryPersons(List<Person> persons);
73  
74      /**
75       * Update temporary persons.
76       *
77       * @param persons persons to update
78       * @return updated persons
79       * @since 3.14
80       */
81      @Transactional(readOnly = false)
82      @CacheEvict(value = {"persons", "personById", "personsWithObsoletes"}, allEntries = true)
83      List<Person> updateTemporaryPersons(List<Person> persons);
84  
85      /**
86       * Link temporary persons. (Means get existing references using persons natural ids).
87       *
88       * @param persons persons to link
89       * @return linked persons
90       * @since 3.14
91       */
92      List<Person> linkTemporaryPersons(List<Person> persons);
93  
94      /**
95       * Replace the {@code source} person by
96       * the {@code target} one in all data.
97       *
98       * @param source the source person to replace
99       * @param target the target person to use
100      * @param delete flag to delete the temporary vessel after replacement
101      * @since 3.6
102      */
103     @Transactional(readOnly = false)
104     @CacheEvict(value = {"fr.ifremer.adagio.core.dao.data.batch.CatchBatchCache", "persons", "personById", "personsWithObsoletes"},
105             allEntries = true)
106     void replacePerson(Person source, Person target, boolean delete);
107 
108     /**
109      * Delete the temporary persons with the given {@code ids}.
110      *
111      * @param ids ids of the persons to remove
112      * @since 3.8
113      */
114     @Transactional(readOnly = false)
115     @CacheEvict(value = {"persons", "personById", "personsWithObsoletes"}, allEntries = true)
116     void deleteTemporaryPersons(Collection<Integer> ids);
117 
118     /**
119      * Delete the temporary person with the given {@code id}.
120      *
121      * @param id id of the person to remove
122      * @since 3.8
123      */
124     @Transactional(readOnly = false)
125     @CacheEvict(value = {"persons", "personById", "personsWithObsoletes"}, allEntries = true)
126     void deleteTemporaryPerson(Integer id);
127 
128 }