use of org.compiere.model.MRole in project adempiere by adempiere.
the class WFActivity method getActivitiesCount.
// dispose
/**
* Get active activities count
* @return int
*/
public int getActivitiesCount() {
int count = 0;
String sql = "SELECT count(*) FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" + // Owner of Activity
" a.AD_User_ID=?" + // Invoker (if no invoker = all)
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #2
" AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" + // Responsible User
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #3
" AND r.AD_User_ID=?)" + // Responsible Role
" OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" + // #4
" WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND ur.AD_User_ID=?))";
//
//+ ") ORDER BY a.Priority DESC, Created";
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()));
sql = role.addAccessSQL(sql, "a", true, false);
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, AD_User_ID);
pstmt.setInt(3, AD_User_ID);
pstmt.setInt(4, AD_User_ID);
rs = pstmt.executeQuery();
if (rs.next()) {
count = rs.getInt(1);
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
return count;
}
use of org.compiere.model.MRole in project adempiere by adempiere.
the class RoleAccessUpdate method doIt.
// prepare
/**
* Process
* @return info
* @throws Exception
*/
protected String doIt() throws Exception {
log.info("AD_Client_ID=" + p_AD_Client_ID + ", AD_Role_ID=" + p_AD_Role_ID);
//
if (p_AD_Role_ID > 0)
updateRole(new MRole(getCtx(), p_AD_Role_ID, get_TrxName()));
else {
List<Object> params = new ArrayList<Object>();
String whereClause = "1=1";
if (p_AD_Client_ID > 0) {
whereClause += " AND AD_Client_ID=? ";
params.add(p_AD_Client_ID);
}
if (// System Role
p_AD_Role_ID == 0) {
whereClause += " AND AD_Role_ID=?";
params.add(p_AD_Role_ID);
}
//sql += "ORDER BY AD_Client_ID, Name";
List<MRole> roles = new Query(getCtx(), MRole.Table_Name, whereClause, get_TrxName()).setOnlyActiveRecords(true).setParameters(params).setOrderBy("AD_Client_ID, Name").list();
for (MRole role : roles) {
updateRole(role);
}
}
return "";
}
use of org.compiere.model.MRole in project adempiere by adempiere.
the class WWindow method getSR_Form.
// getFieldValue
/**************************************************************************
* Return SingleRow Form details
* @param action action
* @param wsc web session context
* @param ws window status
* @return Form
*/
public MobileDoc getSR_Form(String action, MobileSessionCtx wsc, WWindowStatus ws) {
log.fine("Tab=" + ws.curTab.getTabNo());
form line = new form("WWindow");
line.addAttribute("selected", "true");
line.setClass("panel");
line.setMethod("post");
line.setTitle(ws.curTab.getName());
// line.setTarget("_self");
fs = new fieldset();
line.addElement(fs);
/**********************
* For all Fields
*/
StringBuffer scriptSrc = new StringBuffer();
MRole role = MRole.getDefault(wsc.ctx, false);
//
//Modified by Rob Klein 4/29/07
m_searchField = null;
boolean isTabRO = ws.isReadOnlyView();
if (ws.curTab.isDisplayed()) {
int noFields = ws.curTab.getFieldCount();
for (int i = 0; i < noFields; i++) {
GridField field = ws.curTab.getField(i);
String columnName = field.getColumnName();
/**
* Get Data and convert to String (singleRow)
*/
Object oData = ws.curTab.getValue(field);
//Modified by Rob Klein 4/29/07
/**
* Get Record ID and Table ID for Processes
*/
int recordID = ws.curTab.getRecord_ID();
int tableID = ws.curTab.getAD_Table_ID();
/**
* Display field
*/
if (field.isDisplayed(true) && field.getDisplayType() != DisplayType.Button) {
/* todo chart support
if ( ws.isReadOnlyView() && field.getDisplayType()== 53370 )
{
img chart = getChart(field.getAD_Chart_ID(), sess);
div div = new div();
div.setClass("row");
if ( chart != null )
{
div.addElement(chart);
fs.addElement(div);
}
}
else */
{
//
boolean hasDependents = ws.curTab.hasDependants(columnName);
//Modified by Rob Klein 4/29/07
addField(wsc, line, field, oData, hasDependents, recordID, tableID, isTabRO, i, ws.curTab, role);
// Additional Values
String dispLogic = field.getDisplayLogic();
if (dispLogic != null && dispLogic.length() > 0) {
// replace ' with "
dispLogic = dispLogic.replace('\'', '"');
scriptSrc.append("document.").append(FORM_NAME).append(".").append(columnName).append(".displayLogic='").append(dispLogic).append("';\n");
}
}
}
}
// for all fields
}
// displayed
/*if (scriptSrc.length() > 0)
table.addElement(new script(scriptSrc.toString()));*/
// Status Line
int rowNo = ws.curTab.getCurrentRow();
String statusDB = String.valueOf(rowNo + 1) + " / " + ws.curTab.getRowCount();
// return createLayout (action, new ul(), wsc, ws, ws.curTab.getDescription(), statusDB);
if (ws.isReadOnlyView()) {
for (int i = ws.curTab.getTabNo() + 1; i < ws.mWindow.getTabCount(); i++) {
GridTab tab = ws.mWindow.getTab(i);
if (tab.getTabNo() >= ws.curTab.getTabNo() && tab.getTabLevel() <= ws.curTab.getTabLevel())
// past all children of curTab
break;
if (tab.getTabLevel() != ws.curTab.getTabLevel() + 1)
// not direct child
continue;
if (tab.isSortTab())
continue;
//Modified by Rob Klein 4/29/07
a big = new a("WWindow?tab=" + i, tab.getName());
big.setClass("whiteButton");
big.setTarget("_self");
line.addElement(big);
}
}
if (!ws.isReadOnlyView()) {
a button = new a("#", "Save");
button.addAttribute("type", "submit");
button.setClass("redButton");
// a.setTarget("_self");
line.addElement(button);
}
MobileDoc doc = createPage(ws);
doc.getBody().addElement(line);
div div = new div();
div.setClass("toolbar");
h1 header = new h1();
header.setID("pageTitle");
div.addElement(header);
a anchor = new a();
anchor.setClass("button");
anchor.setHref(MobileEnv.getBaseDirectory("WMenu"));
anchor.setTarget("_self");
anchor.addElement("Menu");
div.addElement(anchor);
anchor = new a("WWindow?action=list", "Back");
anchor.setID("previousButton");
anchor.setClass("button");
anchor.setTarget("_self");
div.addElement(anchor);
doc.getBody().addElement(div);
if (!ws.curTab.isReadOnly() && ws.isReadOnlyView()) {
div = new div();
div.setClass("footer");
a a = new a("WWindow?action=edit", "Edit");
a.setClass("redButton");
a.setTarget("_self");
div.addElement(a);
doc.getBody().addElement(div);
}
return doc;
}
use of org.compiere.model.MRole in project adempiere by adempiere.
the class WWFActivity method loadActivities.
/**
* Load Activities
* @return int
*/
public int loadActivities() {
long start = System.currentTimeMillis();
int MAX_ACTIVITIES_IN_LIST = MSysConfig.getIntValue("MAX_ACTIVITIES_IN_LIST", 200, Env.getAD_Client_ID(Env.getCtx()));
model = new ListModelTable();
ArrayList<MWFActivity> list = new ArrayList<MWFActivity>();
String sql = "SELECT * FROM AD_WF_Activity a " + "WHERE a.Processed='N' AND a.WFState='OS' AND (" + // Owner of Activity
" a.AD_User_ID=?" + // Invoker (if no invoker = all)
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #2
" AND COALESCE(r.AD_User_ID,0)=0 AND COALESCE(r.AD_Role_ID,0)=0 AND (a.AD_User_ID=? OR a.AD_User_ID IS NULL))" + // Responsible User
" OR EXISTS (SELECT * FROM AD_WF_Responsible r WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID" + // #3
" AND r.AD_User_ID=?)" + // Responsible Role
" OR EXISTS (SELECT * FROM AD_WF_Responsible r INNER JOIN AD_User_Roles ur ON (r.AD_Role_ID=ur.AD_Role_ID)" + // #4
" WHERE a.AD_WF_Responsible_ID=r.AD_WF_Responsible_ID AND ur.AD_User_ID=?)" + //
") ORDER BY a.Priority DESC, Created";
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
MRole role = MRole.get(Env.getCtx(), Env.getAD_Role_ID(Env.getCtx()));
sql = role.addAccessSQL(sql, "a", true, false);
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, AD_User_ID);
pstmt.setInt(2, AD_User_ID);
pstmt.setInt(3, AD_User_ID);
pstmt.setInt(4, AD_User_ID);
rs = pstmt.executeQuery();
while (rs.next()) {
MWFActivity activity = new MWFActivity(Env.getCtx(), rs, null);
list.add(activity);
List<Object> rowData = new ArrayList<Object>();
rowData.add(activity.getPriority());
rowData.add(activity.getNodeName());
rowData.add(activity.getSummary());
model.add(rowData);
if (list.size() > MAX_ACTIVITIES_IN_LIST && MAX_ACTIVITIES_IN_LIST > 0) {
log.warning("More then 200 Activities - ignored");
break;
}
}
} catch (Exception e) {
log.log(Level.SEVERE, sql, e);
} finally {
DB.close(rs, pstmt);
rs = null;
pstmt = null;
}
m_activities = new MWFActivity[list.size()];
list.toArray(m_activities);
//
log.fine("#" + m_activities.length + "(" + (System.currentTimeMillis() - start) + "ms)");
m_index = 0;
String[] columns = new String[] { Msg.translate(Env.getCtx(), "Priority"), Msg.translate(Env.getCtx(), "AD_WF_Node_ID"), Msg.translate(Env.getCtx(), "Summary") };
WListItemRenderer renderer = new WListItemRenderer(Arrays.asList(columns));
ListHeader header = new ListHeader();
header.setWidth("30px");
renderer.setListHeader(0, header);
renderer.addTableValueChangeListener(listbox);
model.setNoColumns(columns.length);
listbox.setModel(model);
listbox.setItemRenderer(renderer);
listbox.repaint();
listbox.setFixedLayout(true);
return m_activities.length;
}
use of org.compiere.model.MRole in project lar_361 by comitsrl.
the class Find method getQuery.
// cmd_refresh
/**
************************************************************************
* Get Query - Retrieve result
* @return String representation of query
*/
public MQuery getQuery() {
MRole role = MRole.getDefault();
if (role.isQueryMax(getTotalRecords()) && !m_isCancel) {
m_query = MQuery.getNoRecordQuery(m_tableName, false);
m_total = 0;
log.warning("Query - over max");
} else
log.info("Query=" + m_query);
return m_query;
}
Aggregations