source: ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/persistence/ComponentDao.java @ 5549

Last change on this file since 5549 was 5549, checked in by olhsha@mpi.nl, 10 years ago

Added group service. Tested via the tomcat on loclahots (test URI and postman), old unit tests are adjusted and work well. Todo: retest on localhost tomcat, look at run-time exceptions, add new unit tests, adjust front-end

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