source: ComponentRegistry/trunk/ComponentRegistry/src/main/java/clarin/cmdi/componentregistry/persistence/impl/ProfileDescriptionDaoImpl.java @ 3451

Last change on this file since 3451 was 3451, checked in by George.Georgovassilis@mpi.nl, 11 years ago

#360 Fixes for shha lux16 environment and renaming of DAO interfaces and implementations

File size: 2.4 KB
Line 
1package clarin.cmdi.componentregistry.persistence.impl;
2
3import clarin.cmdi.componentregistry.model.AbstractDescription;
4import clarin.cmdi.componentregistry.model.ProfileDescription;
5import clarin.cmdi.componentregistry.persistence.ProfileDescriptionDao;
6
7import java.sql.ResultSet;
8import java.sql.SQLException;
9import java.util.Collections;
10import java.util.List;
11import java.util.Map;
12
13import org.apache.commons.collections.ListUtils;
14import org.springframework.stereotype.Repository;
15
16/**
17 *
18 * @author Twan Goosen <twan.goosen@mpi.nl>
19 * @author George.Georgovassilis@mpi.nl
20 */
21@Repository
22public class ProfileDescriptionDaoImpl extends AbstractDescriptionDaoImpl<ProfileDescription> implements ProfileDescriptionDao{
23
24    public ProfileDescriptionDaoImpl() {
25        super(ProfileDescription.class);
26    }
27
28    public List<ProfileDescription> getPublicProfileDescriptions() {
29        return getPublicDescriptions();
30    }
31
32    @Override
33    protected String getTableName() {
34        return TABLE_PROFILE_DESCRIPTION;
35    }
36
37    @Override
38    protected String getCMDIdColumn() {
39        return "profile_id";
40    }
41
42    @Override
43    protected String getCommentsForeignKeyColumn() {
44        return "profile_description_id";
45    }
46
47    @Override
48    protected StringBuilder getDescriptionColumnList() {
49        return super.getDescriptionColumnList().append(",show_in_editor");
50    }
51
52    @Override
53    protected void putInsertParameters(Map<String, Object> params, AbstractDescription description, Number contentId, Number userId, boolean isPublic) {
54        super.putInsertParameters(params, description, contentId, userId, isPublic);
55        params.put("show_in_editor", ((ProfileDescription) description).isShowInEditor());
56    }
57
58    @Override
59    protected void setDescriptionValuesFromResultSet(ResultSet rs, AbstractDescription newDescription) throws SQLException {
60        super.setDescriptionValuesFromResultSet(rs, newDescription);
61        ((ProfileDescription) newDescription).setShowInEditor(rs.getBoolean("show_in_editor"));
62    }
63
64    @Override
65    protected void appendUpdateColumnsStatement(StringBuilder updateDescription) {
66        super.appendUpdateColumnsStatement(updateDescription);
67        updateDescription.append(" , show_in_editor=?");
68    }
69
70    @Override
71    protected List getUpdateParameterValues(AbstractDescription description) {
72        return ListUtils.union(
73                super.getUpdateParameterValues(description),
74                // Add value for 'shown_in_editor' to abstract description
75                Collections.singletonList(((ProfileDescription) description).isShowInEditor()));
76    }
77}
Note: See TracBrowser for help on using the repository browser.