1 | package clarin.cmdi.componentregistry.persistence; |
---|
2 | |
---|
3 | import java.util.List; |
---|
4 | |
---|
5 | import org.springframework.dao.DataAccessException; |
---|
6 | |
---|
7 | import clarin.cmdi.componentregistry.model.BaseDescription; |
---|
8 | |
---|
9 | /** |
---|
10 | * Interface for a persistence operation on components and profiles |
---|
11 | * |
---|
12 | * @author george.georgovassilis@mpi.nl |
---|
13 | * |
---|
14 | * @param <T> |
---|
15 | */ |
---|
16 | public interface ComponentDao { |
---|
17 | |
---|
18 | /** |
---|
19 | * Get all public components |
---|
20 | * |
---|
21 | * @return |
---|
22 | */ |
---|
23 | List<BaseDescription> getPublicComponentDescriptions(); |
---|
24 | |
---|
25 | /** |
---|
26 | * Get all public profiles |
---|
27 | * |
---|
28 | * @return |
---|
29 | */ |
---|
30 | List<BaseDescription> getPublicProfileDescriptions(); |
---|
31 | |
---|
32 | /** |
---|
33 | * |
---|
34 | * @param cmdId |
---|
35 | * CMD id |
---|
36 | * @return Whether the specified item is in the public space |
---|
37 | */ |
---|
38 | boolean isPublic(String cmdId); |
---|
39 | |
---|
40 | /** |
---|
41 | * |
---|
42 | * @param cmdId |
---|
43 | * CMD id |
---|
44 | * @param userId |
---|
45 | * User db id of workspace owner |
---|
46 | * @return Whether the specified item is in the specified user's workspace |
---|
47 | */ |
---|
48 | boolean isInUserSpace(String cmdId, Number userId); |
---|
49 | |
---|
50 | /** |
---|
51 | * |
---|
52 | * @param cmdId |
---|
53 | * CMD id |
---|
54 | * @param userId |
---|
55 | * User db id of workspace owner, null for public registry |
---|
56 | * @return Whether the specified item is in the specified workspace (user or |
---|
57 | * public) |
---|
58 | */ |
---|
59 | boolean isInRegistry(String cmdId, Number userId); |
---|
60 | |
---|
61 | /** |
---|
62 | * |
---|
63 | * @param cmdId |
---|
64 | * Profile or component Id (not primary key) |
---|
65 | * @return String value of XML content for profile or component |
---|
66 | */ |
---|
67 | String getContent(boolean isDeleted, String cmdId) |
---|
68 | throws DataAccessException; |
---|
69 | |
---|
70 | /** |
---|
71 | * @param description |
---|
72 | * Description to insert |
---|
73 | * @param content |
---|
74 | * Content to insert and refer to from description |
---|
75 | * @return Id of newly inserted description |
---|
76 | */ |
---|
77 | Number insertDescription(BaseDescription description, String content, |
---|
78 | boolean isPublic, Number userId) throws DataAccessException; |
---|
79 | |
---|
80 | /** |
---|
81 | * Updates a description by database id |
---|
82 | * |
---|
83 | * @param id |
---|
84 | * Id (key) of description record |
---|
85 | * @param description |
---|
86 | * New values for description (leave null to not change) |
---|
87 | * @param content |
---|
88 | * New content for description (leave null to not change) |
---|
89 | */ |
---|
90 | void updateDescription(Number id, BaseDescription description, String content); |
---|
91 | |
---|
92 | /** |
---|
93 | * Retrieves description by it's primary key Id |
---|
94 | * |
---|
95 | * @param id |
---|
96 | * Description key |
---|
97 | * @return The description, if it exists; null otherwise |
---|
98 | */ |
---|
99 | BaseDescription getById(Number id) throws DataAccessException; |
---|
100 | |
---|
101 | /** |
---|
102 | * Get by ComponentId / ProfileId, whether in userspace or public |
---|
103 | * |
---|
104 | * @param id |
---|
105 | * Full component id |
---|
106 | * @return The description, if it exists; null otherwise |
---|
107 | */ |
---|
108 | BaseDescription getByCmdId(String id) throws DataAccessException; |
---|
109 | |
---|
110 | /** |
---|
111 | * Get by ComponentId / ProfileId |
---|
112 | * |
---|
113 | * @param id |
---|
114 | * Full component id |
---|
115 | * @param userId |
---|
116 | * Db id of user for workspace; null for public space |
---|
117 | * @return The description, if it exists; null otherwise |
---|
118 | */ |
---|
119 | BaseDescription getByCmdId(String id, Number userId) |
---|
120 | throws DataAccessException; |
---|
121 | |
---|
122 | /** |
---|
123 | * |
---|
124 | * @param cmdId |
---|
125 | * CMD Id of description |
---|
126 | * @return Database id for description record |
---|
127 | */ |
---|
128 | Number getDbId(String cmdId); |
---|
129 | |
---|
130 | /** |
---|
131 | * |
---|
132 | * @return All descriptions in the public space |
---|
133 | */ |
---|
134 | List<BaseDescription> getPublicDescriptions() throws DataAccessException; |
---|
135 | |
---|
136 | /** |
---|
137 | * @return List of deleted descriptions in user space or in public when |
---|
138 | * userId=null |
---|
139 | * @param userId |
---|
140 | */ |
---|
141 | List<BaseDescription> getDeletedDescriptions(Number userId); |
---|
142 | |
---|
143 | /** |
---|
144 | * |
---|
145 | * @return All the user's components not in the public space and are also |
---|
146 | * not part of any group |
---|
147 | */ |
---|
148 | List<BaseDescription> getUserspaceComponents(Number userId) |
---|
149 | throws DataAccessException; |
---|
150 | |
---|
151 | /** |
---|
152 | * |
---|
153 | * @return All the user's profiles not in the public space and are also |
---|
154 | * not part of any group |
---|
155 | */ |
---|
156 | List<BaseDescription> getUserspaceProfiles(Number userId) |
---|
157 | throws DataAccessException; |
---|
158 | |
---|
159 | void setDeleted(BaseDescription desc, boolean isDeleted) |
---|
160 | throws DataAccessException; |
---|
161 | |
---|
162 | void setPublished(Number id, boolean published); |
---|
163 | |
---|
164 | /** |
---|
165 | * |
---|
166 | * @param id |
---|
167 | * Id of description record |
---|
168 | * @return Principal name of description's owner, if any. Otherwise, null. |
---|
169 | */ |
---|
170 | String getOwnerPrincipalName(Number id); |
---|
171 | |
---|
172 | /** |
---|
173 | * Get a list of ids ({@link BaseDescription#getId()}) of all non-deleted profiles |
---|
174 | * @return |
---|
175 | */ |
---|
176 | List<String> getAllNonDeletedProfileIds(); |
---|
177 | |
---|
178 | /** |
---|
179 | * Get a list of ids ({@link BaseDescription#getId()}) of all non-deleted components |
---|
180 | * @return |
---|
181 | */ |
---|
182 | List<String> getAllNonDeletedComponentIds(); |
---|
183 | |
---|
184 | |
---|
185 | } |
---|