Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2005-2013 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.rice.kim.service.dao.impl;
 
 
 import java.util.Map;

Spring JdbcTemplate implementation of UiDocumentServiceDAO

Author(s):
Kuali Rice Team (rice.collab@kuali.org)
 
 public class UiDocumentServiceDAOJdbcImpl implements UiDocumentServiceDAO {
 
     public static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(UiDocumentServiceDAOJdbcImpl.class);
 
     private DataSource dataSource;
 
     public void setDataSource(DataSource dataSource) {
         this. = new TransactionAwareDataSourceProxy(dataSource);
     }
 
     @Override
     public Map<StringGroupfindGroupsForRole(final String roleId) {
         final Map<StringGrouproleGroupMembers = new HashMap<StringGroup>();
 
         JdbcTemplate template = new JdbcTemplate();
         Map<StringGroupresults  = template.execute(new PreparedStatementCreator() {
 
             public PreparedStatement createPreparedStatement(Connection connectionthrows SQLException {
 
                 String sql = " SELECT GRP_ID, GRP_NM, NMSPC_CD, KIM_TYP_ID, ACTV_IND" +
                     " FROM KRIM_GRP_T G, KRIM_ROLE_MBR_T RM WHERE" +
                     " G.GRP_ID = RM.MBR_ID AND GRP_ID IN" +
                     " (SELECT MBR_ID FROM KRIM_ROLE_MBR_T WHERE MBR_TYP_CD = '" +
                     ..getCode() + "' AND ROLE_ID = '" + roleId + "')";
 
                     .debug("Query to find Entity Names for role " + roleId + ":" + sql);
 
                 PreparedStatement statement = connection.prepareStatement(sql);
                 return statement;
             }
         }, new PreparedStatementCallback<Map<String,Group>>() {
             public Map<String,GroupdoInPreparedStatement(
                 PreparedStatement statementthrows SQLExceptionDataAccessException {
                     ResultSet rs = statement.executeQuery();
                     try {
                         while (rs.next()) {
 
                             String groupId = rs.getString(1);
                             String groupName = rs.getString(2);
                             String groupNameSpace = rs.getString(3);
                             String kimTypeId = rs.getString(4);
                             String activeInd = rs.getString(5);
                             Group.Builder builder = Group.Builder.create(groupNameSpacegroupNamekimTypeId);
                             builder.setId(groupId);
                             builder.build();
                             if (activeInd.equalsIgnoreCase(.)) {
                                 builder.setActive(true);
                             }
                             roleGroupMembers.put(groupIdbuilder.build());
                         }
                     } finally {
                         if (rs != null) {
                             rs.close();
                         }
                     }
                    return roleGroupMembers;
                }
            }
        );
        return roleGroupMembers;
    }
    @Override
    public Map<StringEntityNamefindEntityNamesForRole(final String roleId) {
        final Map<StringEntityNameentityNamesForPrincipals = new HashMap<StringEntityName>();
        JdbcTemplate template = new JdbcTemplate();
        Map<StringEntityNameresults  = template.execute(new PreparedStatementCreator() {
            public PreparedStatement createPreparedStatement(Connection connectionthrows SQLException {
                String sql = "SELECT EN.ENTITY_NM_ID, EN.ENTITY_ID, EN.FIRST_NM, EN.LAST_NM, EP.SUPPRESS_NM_IND FROM" +
                    " KRIM_PRNCPL_T KP, KRIM_ENTITY_NM_T EN LEFT JOIN KRIM_ENTITY_PRIV_PREF_T EP" +
                    " ON EN.ENTITY_ID = EP.ENTITY_ID" +
                    " WHERE EN.ACTV_IND='" + . +
                    "' AND EN.DFLT_IND='". +
                    "' AND EN.NM_TYP_CD='".. +
                    "' AND EN.ENTITY_ID = KP.ENTITY_ID " +
                    " AND KP.PRNCPL_ID IN (SELECT MBR_ID FROM KRIM_ROLE_MBR_T WHERE ROLE_ID = '" + roleId + "')";
                    .debug("Query to find Entity Names for role " + roleId + ":" + sql);
                PreparedStatement statement = connection.prepareStatement(sql);
                return statement;
            }
        }, new PreparedStatementCallback<Map<String,EntityName>>() {
            public Map<String,EntityNamedoInPreparedStatement(
                PreparedStatement statementthrows SQLExceptionDataAccessException {
                    ResultSet rs = statement.executeQuery();
                    try {
                        while (rs.next()) {
                            String id = rs.getString(1);
                            String entityId = rs.getString(2);
                            String firstName = rs.getString(3);
                            String lastName = rs.getString(4);
                            String suppressName = rs.getString(5);
                            boolean suppressNameBoolean = false;
                            if (..equalsIgnoreCase(suppressName))  {
                                suppressNameBoolean = true;
                            }
                            EntityName.Builder builder = EntityName.Builder.create(identityIdfirstNamelastNamesuppressNameBoolean);
                            builder.setActive(true);
                            builder.setDefaultValue(true);
                            EntityName entityName = builder.build();
                            entityNamesForPrincipals.put(entityName.getEntityId(), entityName);
                        }
                    } finally {
                        if (rs != null) {
                            rs.close();
                        }
                    }
                        return entityNamesForPrincipals;
                    }
                }
        );
        return entityNamesForPrincipals;
    }
New to GrepCode? Check out our FAQ X