Commit 669bfd88 authored by manohar's avatar manohar

MF89SUN092 various bug fixing


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91616 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4e3ff97b
......@@ -504,11 +504,11 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
}
if(stklotNo == null)
{
stklotNo = "";
stklotNo = " ";
}
if(stklotSl == null)
{
stklotSl = "";
stklotSl = " ";
}
if(stkquantity == null)
{
......@@ -531,10 +531,10 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
if (Double.parseDouble(balanceQty) > 0)
{
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(stkItemCode.trim()).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<loc_code>").append("<![CDATA[").append(stkLocCode.trim()).append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(stklotNo.trim()).append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl>").append("<![CDATA[").append(stklotSl.trim()).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(stkItemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<loc_code>").append("<![CDATA[").append(stkLocCode).append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(stklotNo).append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl>").append("<![CDATA[").append(stklotSl).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<mfg_date>").append("<![CDATA[").append(stkMfgDate1).append("]]>").append("</mfg_date>\r\n");
valueXmlString.append("<exp_date>").append("<![CDATA[").append(stkExpDate1).append("]]>").append("</exp_date>\r\n");
//valueXmlString.append("<quantity>").append("<![CDATA[").append(balanceQty.trim()).append("]]>").append("</quantity>\r\n"); //Gulzar 13/03/07
......@@ -937,7 +937,11 @@ public class DespatchAct extends ActionHandlerEJB implements DespatchActLocal, D
if((lotSl == null) || (lotSl != null && lotSl.trim().length() == 0))
{
lotSl = " ";
lotSl = " ";
}
if((lotNo == null) || (lotNo != null && lotNo.trim().length() == 0))
{
lotNo = " ";
}
if(cQtyStr != null && cQtyStr.trim().length() > 0)
......
......@@ -276,7 +276,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn = null;
String lotNo = "", lotSl = "", lotNoIssue = "", considerLotNoIssue = "N";
String lotNo = "", lotSl = "", lotNoIssue = "", considerLotNoIssue = "N", locGroup = "", locUsageType = "";
StringBuffer sqlSB = new StringBuffer();
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
......@@ -299,8 +299,9 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
expLev = genericUtility.getColumnValue("exp_lev", dom);
operation = Integer.parseInt(genericUtility.getColumnValue("operation", dom1));
bomCode = genericUtility.getColumnValue("bom_code", dom1);
locGroup = genericUtility.getColumnValue("loc_group", dom1); // 26/03/12 manoharan
// 18/02/12 manoharan
sql = "select w.LOT_NO__ISSUE,b.CONSIDER_LOT_NO__ISSUE from workorder w, workorder_bill b "
sql = "select w.LOT_NO__ISSUE,b.CONSIDER_LOT_NO__ISSUE,b.LOC_USAGE_TYPE from workorder w, workorder_bill b "
+ " where w.work_order = b.work_order "
+ " and w.work_order = ? "
+ " and b.exp_lev = ? ";
......@@ -312,6 +313,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
{
lotNoIssue = rs.getString("LOT_NO__ISSUE");
considerLotNoIssue = rs.getString("CONSIDER_LOT_NO__ISSUE");
locUsageType = rs.getString("LOC_USAGE_TYPE");
}
pstmt.close();
rs.close();
......@@ -339,6 +341,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
}
// end 18/02/12 manoharan
// for qc_reqd to be checked from first siteitem & then item
qcReqd = mfgCommon.chkQcReqd(siteCode, itemCode, conn);
autoQcReqd = mfgCommon.chkAutoQcReqd(siteCode, itemCode, conn);
......@@ -412,6 +415,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -432,6 +441,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -451,6 +466,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -470,6 +491,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -488,6 +515,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -505,6 +538,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -523,6 +562,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -542,6 +587,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -560,6 +611,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -598,6 +655,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -622,6 +685,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -644,6 +713,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -666,6 +741,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -687,6 +768,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -707,6 +794,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -727,6 +820,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -747,6 +846,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -768,6 +873,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
......@@ -867,7 +978,13 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sql = sql + " AND A.LOT_NO IN (" + lotNoIssue + ") ";
}
// end 18/02/12 manoharan
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND b.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
System.out.println("sqlSB converted ::: "+ sql);
StringTokenizer st = new StringTokenizer(sql, "?");
cntQ = st.countTokens();
......@@ -1197,7 +1314,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
double stockQuantity = 0d;
String retNoArt = null;
String retNoArt = null, locGroup = "", locUsageType = "";
ArrayList noArtDetArrLst = new ArrayList();
PreparedStatement pstmt = null, pstmt1 = null, cpstmt1 = null;
Connection conn = null;
......@@ -1238,6 +1355,20 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
reasCode = genericUtility.getColumnValue("reas_code", dom);
calcPotency = genericUtility.getColumnValue("calc_potency", dom);
tranType = genericUtility.getColumnValue("tran_type", dom1);
// 26/03/12 manoharan
locGroup = genericUtility.getColumnValue("loc_group", dom1);
sql = "SELECT loc_usage_type FROM WORKORDER_bill WHERE WORK_ORDER = ? and exp_lev = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, workOrder);
pstmt.setString(2, expLev);
rs = pstmt.executeQuery();
if (rs.next())
{
locUsageType = rs.getString(1);
}
pstmt.close();
rs.close();
if (tranType.equalsIgnoreCase("F"))
{
......@@ -1449,8 +1580,8 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
if ((locCode == null || locCode.trim().length() == 0) || (lotNo == null || lotNo.trim().length() == 0))
{
sqlSb.append("SELECT (CASE WHEN SUM(A.QUANTITY - A.ALLOC_QTY) IS NULL THEN 0 ELSE SUM(A.QUANTITY - A.ALLOC_QTY) END) ");
sqlSb.append("FROM STOCK A, INVSTAT B ");
sqlSb.append("WHERE A.INV_STAT = B.INV_STAT ");
sqlSb.append("FROM STOCK A, INVSTAT B, LOCATION C ");
sqlSb.append("WHERE A.LOC_CODE = C.LOC_CODE AND C.INV_STAT = B.INV_STAT ");
sqlSb.append("AND A.ITEM_CODE = ? ");
sqlSb.append("AND A.SITE_CODE = ? ");
sqlSb.append("AND (A.QUANTITY - (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) > 0 ");
......@@ -1475,7 +1606,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sqlSb.append(" AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'");
}
sql = sqlSb.toString();
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND c.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
System.out.println("sqlSB converted ::: "+ sql);
StringTokenizer st = new StringTokenizer(sql, "?");
cntQ = st.countTokens();
......@@ -1566,6 +1702,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
sqlSb1.append(" AND DDF_COMPARE_DIMENSION(CASE WHEN A.DIMENSION IS NULL THEN ' ' ELSE A.DIMENSION END, ?, ?) = 'Y'");
}
sql = sqlSb1.toString();
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND c.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
System.out.println("sqlSB1 converted ::: "+ sql);
StringTokenizer st1 = new StringTokenizer(sql, "?");
......@@ -1740,7 +1882,7 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
// IF LOC_CODE AND LOT NO AND LOT_SL ARE ENTERED BY USER
// TO CHECK ALL CONDITIONS RELATED QC_REQD & TRACKSHELFLIFE
sqlSb.append(" SELECT (CASE WHEN SUM(A.QUANTITY-A.ALLOC_QTY) IS NULL THEN 0 ELSE SUM(A.QUANTITY-A.ALLOC_QTY) END)");
sqlSb.append(" FROM STOCK A, INVSTAT B ");
sqlSb.append(" FROM STOCK A, INVSTAT B, LOCATION C ");
sqlSb.append(" WHERE A.INV_STAT = B.INV_STAT AND A.ITEM_CODE = ? AND A.SITE_CODE = ? ");
sqlSb.append(" AND A.LOC_CODE = ? AND A.LOT_NO = ? AND A.LOT_SL = ? ");
sqlSb.append(" AND (A.QUANTITY - A.ALLOC_QTY) >= ? AND B.STAT_TYPE <> 'S' ");
......@@ -1765,6 +1907,12 @@ public class WOrderIssueAct extends ActionHandlerEJB implements WOrderIssueActL
}
sql = sqlSb.toString();
// 26/03/12 manoharan
if (locGroup != null && locGroup.trim().length() > 0 && "A".equals(locUsageType) )
{
sql = sql + " AND c.loc_group = '" + locGroup + "' ";
}
// end 26/03/12 manoharan
System.out.println("sqlSB converted ::: "+ sql);
StringTokenizer st1 = new StringTokenizer(sql, "?");
......
......@@ -106,12 +106,17 @@ public class UserRightsPrc extends ProcessEJB implements UserRightsPrcLocal , U
String errCode = "";
String errString = "";
String resultString = "";
String curUserId = "", curProfileId = "";
//String profileId =null;
double quantity = 0.0,pendingQty = 0.0;
int count = 0;
int count = 0, usrLev = 0;
String tApplication = null;
String key = null;
String tWinName = null;
String tMenuName = null;
String sqlStr = "";
try
{
if(conn == null)
......@@ -124,159 +129,192 @@ public class UserRightsPrc extends ProcessEJB implements UserRightsPrcLocal , U
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
profileId = genericUtility.getColumnValue("profile_id", headerDom);
System.out.println("profileId ::- "+ profileId);
//System.out.println("profileId ::- "+ profileId);
// 24/03/12 manoharan get the current logged in user and show only the menus for which the current user has rights
curUserId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("Current userid curUserId ["+ curUserId + "] profileId [" + profileId + "]");
if (curUserId == null && curUserId.trim().length() == 0)
{
retTabSepStrBuff.append(" \t");
////////////////
//If profile Id is blank or doesnt exist in the User_Rights table then prompt error
//String profileSql = " select count(*) " +
// " from user_rights " +
// " where profile_id = '" + profileId + "' " ;
//LEVEL_1
retTabSepStrBuff.append(" \t");
String profileSql = " select count(1) " +
" from gencodes " +
" where fld_name = 'PROFILE_ID' and fld_value = '" + profileId + "' " ;
//LEVEL_2
retTabSepStrBuff.append(" \t");
int profileCount = 0;
System.out.println("ProfileSql :: " + profileSql);
//LEVEL_3
retTabSepStrBuff.append(" \t");
PreparedStatement pProfileStmt = null;
ResultSet profileRs = null;
//LEVEL_4
retTabSepStrBuff.append(" \t");
pProfileStmt = conn.prepareStatement(profileSql);
//LEVEL_5
retTabSepStrBuff.append(" \t");
profileRs = pProfileStmt.executeQuery();
//DESCR
retTabSepStrBuff.append(" \t");
if(profileRs.next())
{
profileCount = profileRs.getInt(1);
System.out.println("Profile Count = " + profileCount);
//RIGHTS
retTabSepStrBuff.append(" \t");
//WIN_NAME
retTabSepStrBuff.append(" \t");
retTabSepStrBuff.append(" ").append("\t");
retTabSepStrBuff.append("\n");
resultString = retTabSepStrBuff.toString();
}
else
{
sql = " select profile_id,usr_lev from users where code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,curUserId);
rs = pstmt.executeQuery();
if(rs.next())
{
curProfileId = rs.getString("profile_id");
usrLev = rs.getInt("usr_lev");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
profileRs.close();
profileRs = null;
System.out.println("Current curProfileId ["+ curProfileId + "] usrLev [" + usrLev + "]");
pProfileStmt.close();
pProfileStmt = null;
///////////////
////////////////
//If profile Id is blank or doesnt exist in the User_Rights table then prompt error
//String profileSql = " select count(*) " +
// " from user_rights " +
// " where profile_id = '" + profileId + "' " ;
if(profileCount == 0)
{
errString = itmDBAccessEJB.getErrorString("","PNOTEXIST","","",conn);
return errString;
}
}
catch(Exception e)
{
}
String profileSql = " select count(1) " +
" from gencodes " +
" where fld_name = 'PROFILE_ID' and fld_value = '" + profileId + "' " ;
userRightsMap = new HashMap();
winNameMap = new HashMap();
menuNameMap = new HashMap();
String sqlStr = " SELECT ITM2MENU.APPLICATION, " +
" ITM2MENU.LEVEL_1, " +
" ITM2MENU.LEVEL_2, " +
" ITM2MENU.LEVEL_3, " +
" ITM2MENU.LEVEL_4, " +
" ITM2MENU.LEVEL_5, " +
" ITM2MENU.WIN_NAME, " +
" ITM2MENU.DESCR, " +
" (SELECT USER_RIGHTS.RIGHTS FROM USER_RIGHTS " +
" WHERE USER_RIGHTS.PROFILE_ID = '" + profileId + "' " +
" AND USER_RIGHTS.APPLICATION = ITM2MENU.APPLICATION " +
" AND USER_RIGHTS.MENU_ROW = ITM2MENU.LEVEL_1 " +
" AND USER_RIGHTS.MENU_COL = ITM2MENU.LEVEL_2 " +
" AND USER_RIGHTS.MENU_SUBCOL = ITM2MENU.LEVEL_3 " +
" AND USER_RIGHTS.LEVEL_4 = ITM2MENU.LEVEL_4 " +
" AND USER_RIGHTS.LEVEL_5 = ITM2MENU.LEVEL_5 " +
" ) AS RIGHTS " +
" FROM ITM2MENU " +
" ORDER BY ITM2MENU.APPLICATION, ITM2MENU.LEVEL_1, ITM2MENU.LEVEL_2, ITM2MENU.LEVEL_3, ITM2MENU.LEVEL_4, ITM2MENU.LEVEL_5 ";
/*
" SELECT ITM2MENU.APPLICATION, "+
" ITM2MENU.LEVEL_1, "+
" ITM2MENU.LEVEL_2, "+
" ITM2MENU.LEVEL_3, "+
" ITM2MENU.LEVEL_4, "+
" ITM2MENU.LEVEL_5, "+
" ITM2MENU.WIN_NAME, "+
" ITM2MENU.DESCR, "+
" USER_RIGHTS.RIGHTS "+
" FROM ITM2MENU "+
" LEFT OUTER JOIN USER_RIGHTS ON "+
" ITM2MENU.APPLICATION = USER_RIGHTS.APPLICATION "+
" AND ITM2MENU.LEVEL_1 = USER_RIGHTS.MENU_ROW "+
" AND ITM2MENU.LEVEL_2 = USER_RIGHTS.MENU_COL "+
" AND ITM2MENU.LEVEL_3 = USER_RIGHTS.MENU_SUBCOL "+
" AND ITM2MENU.LEVEL_4 = USER_RIGHTS.LEVEL_4 "+
" AND ITM2MENU.LEVEL_5 = USER_RIGHTS.LEVEL_5 "+
" WHERE (USER_RIGHTS.PROFILE_ID = '" + profileId + "'" +
" OR USER_RIGHTS.PROFILE_ID is null )" +
" ORDER BY ITM2MENU.APPLICATION, ITM2MENU.LEVEL_1, ITM2MENU.LEVEL_2, ITM2MENU.LEVEL_3 ";
*/
int profileCount = 0;
System.out.println("ProfileSql :: " + profileSql);
try
{
pstmt = conn.prepareStatement(sqlStr);
PreparedStatement pProfileStmt = null;
ResultSet profileRs = null;
System.out.println("The getData sql is:-"+ sqlStr);
rs = pstmt.executeQuery();
while (rs.next())
{
String tApplication = null;
String key = null;
String tWinName = null;
String tMenuName = null;
pProfileStmt = conn.prepareStatement(profileSql);
tApplication = rs.getString(1);
profileRs = pProfileStmt.executeQuery();
if(profileRs.next())
{
profileCount = profileRs.getInt(1);
System.out.println("Profile Count = " + profileCount);
}
if(tApplication != null)
key = tApplication + ":" + rs.getInt(2) + ":" + rs.getInt(3) + ":" + rs.getInt(4)
+ ":" + rs.getInt(5) + ":" + rs.getInt(6);
profileRs.close();
profileRs = null;
//APPLICATION
retTabSepStrBuff.append(tApplication==null?"":rs.getString(1)).append("\t");
pProfileStmt.close();
pProfileStmt = null;
///////////////
//LEVEL_1
retTabSepStrBuff.append(rs.getInt(2)).append("\t");
if(profileCount == 0)
{
errString = itmDBAccessEJB.getErrorString("","PNOTEXIST","","",conn);
return errString;
}
//LEVEL_2
retTabSepStrBuff.append(rs.getInt(3)).append("\t");
userRightsMap = new HashMap();
winNameMap = new HashMap();
menuNameMap = new HashMap();
sqlStr = " SELECT ITM2MENU.APPLICATION, " +
" ITM2MENU.LEVEL_1, " +
" ITM2MENU.LEVEL_2, " +
" ITM2MENU.LEVEL_3, " +
" ITM2MENU.LEVEL_4, " +
" ITM2MENU.LEVEL_5, " +
" ITM2MENU.WIN_NAME, " +
" ITM2MENU.DESCR, " +
" (SELECT USER_RIGHTS.RIGHTS FROM USER_RIGHTS " +
" WHERE USER_RIGHTS.PROFILE_ID = ? " +
" AND USER_RIGHTS.APPLICATION = ITM2MENU.APPLICATION " +
" AND USER_RIGHTS.MENU_ROW = ITM2MENU.LEVEL_1 " +
" AND USER_RIGHTS.MENU_COL = ITM2MENU.LEVEL_2 " +
" AND USER_RIGHTS.MENU_SUBCOL = ITM2MENU.LEVEL_3 " +
" AND USER_RIGHTS.LEVEL_4 = ITM2MENU.LEVEL_4 " +
" AND USER_RIGHTS.LEVEL_5 = ITM2MENU.LEVEL_5 " +
" ) AS RIGHTS " +
" FROM ITM2MENU " ;
if (usrLev > 0 )
{
sqlStr = sqlStr + " where exists (select 1 from user_rights u "
+ " where u.profile_id in ('" + curProfileId + "','" + profileId + "') "
+ " and u.application = ITM2MENU.application "
+ " and u.menu_row = ITM2MENU.level_1 "
+ " and u.menu_col = ITM2MENU.level_2 "
+ " and u.menu_subcol = ITM2MENU.level_3 "
+ " and u.level_4 = ITM2MENU.level_4 "
+ " and u.level_5 = ITM2MENU.level_5) " ;
}
sqlStr = sqlStr + " ORDER BY ITM2MENU.APPLICATION, ITM2MENU.LEVEL_1, ITM2MENU.LEVEL_2, ITM2MENU.LEVEL_3, ITM2MENU.LEVEL_4, ITM2MENU.LEVEL_5 ";
pstmt = conn.prepareStatement(sqlStr);
pstmt.setString(1,profileId);
//System.out.println("The getData sql is:-"+ sqlStr);
rs = pstmt.executeQuery();
while (rs.next())
{
//LEVEL_3
retTabSepStrBuff.append(rs.getInt(4)).append("\t");
tApplication = rs.getString(1);
//LEVEL_4
retTabSepStrBuff.append(rs.getInt(5)).append("\t");
if(tApplication != null)
key = tApplication + ":" + rs.getInt(2) + ":" + rs.getInt(3) + ":" + rs.getInt(4)
+ ":" + rs.getInt(5) + ":" + rs.getInt(6);
//LEVEL_5
retTabSepStrBuff.append(rs.getInt(6)).append("\t");
//APPLICATION
retTabSepStrBuff.append(tApplication==null?"":rs.getString(1)).append("\t");
//DESCR
tMenuName = rs.getString(8);
retTabSepStrBuff.append(rs.getString(8)==null?"":rs.getString(8)).append("\t");
//LEVEL_1
retTabSepStrBuff.append(rs.getInt(2)).append("\t");
//RIGHTS
retTabSepStrBuff.append(rs.getString(9)==null?"":rs.getString(9)).append("\t");
//LEVEL_2
retTabSepStrBuff.append(rs.getInt(3)).append("\t");
//WIN_NAME
tWinName = rs.getString(7);
retTabSepStrBuff.append(rs.getString(7)==null?"":rs.getString(7)).append("\t");
//LEVEL_3
retTabSepStrBuff.append(rs.getInt(4)).append("\t");
retTabSepStrBuff.append(" ").append("\t");
retTabSepStrBuff.append("\n");
//LEVEL_4
retTabSepStrBuff.append(rs.getInt(5)).append("\t");
System.out.println("Key getdata function ["+key+"]");
System.out.println("rights in function ["+ rs.getString(9) +"]");
userRightsMap.put(key, rs.getString(9));
if(tWinName != null && tWinName.trim().length() > 2)
winNameMap.put(key, tWinName.trim().substring(2, tWinName.trim().length()));
//LEVEL_5
retTabSepStrBuff.append(rs.getInt(6)).append("\t");
menuNameMap.put(key, tMenuName);
}//while
//DESCR
tMenuName = rs.getString(8);
retTabSepStrBuff.append(rs.getString(8)==null?"":rs.getString(8)).append("\t");
//RIGHTS
retTabSepStrBuff.append(rs.getString(9)==null?"":rs.getString(9)).append("\t");
//WIN_NAME
tWinName = rs.getString(7);
retTabSepStrBuff.append(rs.getString(7)==null?"":rs.getString(7)).append("\t");
retTabSepStrBuff.append(" ").append("\t");
retTabSepStrBuff.append("\n");
System.out.println("Key getdata function ["+key+"]");
System.out.println("rights in function ["+ rs.getString(9) +"]");
userRightsMap.put(key, rs.getString(9));
if(tWinName != null && tWinName.trim().length() > 2)
winNameMap.put(key, tWinName.trim().substring(2, tWinName.trim().length()));
menuNameMap.put(key, tMenuName);
}//while
}
// end 24/03/12 manoharan
}//try
catch (SQLException e)
{
......@@ -742,7 +780,7 @@ public class UserRightsPrc extends ProcessEJB implements UserRightsPrcLocal , U
PreparedStatement pstmt = null;
ResultSet rs = null;
String alreadyExists = "N";
String sql = " SELECT RIGHTS FROM USER_RIGHTS "
+ " WHERE PROFILE_ID = ? "
+ " AND APPLICATION = ? "
......@@ -768,6 +806,7 @@ public class UserRightsPrc extends ProcessEJB implements UserRightsPrcLocal , U
if (rs.next())
{
foundRights = rs.getString(1);
alreadyExists = "Y";
}
rs.close();
rs = null;
......@@ -777,11 +816,11 @@ public class UserRightsPrc extends ProcessEJB implements UserRightsPrcLocal , U
System.out.println("Found rights in function ["+foundRights+"]");
if(foundRights == null && rights != null)
if(foundRights == null && rights != null && "N".equals(alreadyExists))
operation = 1;
else if(foundRights != null && rights != null)
else if((foundRights != null && rights != null) || ("Y".equals(alreadyExists) && foundRights == null && rights != null) )
operation = 2;
else if(foundRights != null && rights == null)
else if(foundRights != null && rights == null && "Y".equals(alreadyExists))
operation = 3;
return operation;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment