|
楼主 |
发表于 2017-11-9 09:48:38
|
显示全部楼层
action:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<model xmlns="http://www.justep.com/model">
<action name="queryMessageAction" procedure="queryMessageProcedure">
<permission name="range" type="List" />
<private name="concept" type="String" value="Portal_Message" />
<private name="select" type="String" value="Portal_Message.*" />
<private name="from" type="String" value="Portal_Message Portal_Message" />
<private name="aggregate" type="String" />
<private name="dataModel" type="String" value="/portal/data" />
<private name="fnModel" type="String" />
<protected name="condition" type="String" />
<public name="distinct" type="Boolean" value="false" />
<public name="idColumn" type="String" value="Portal_Message" />
<public name="filter" type="String" />
<public name="limit" type="Integer" />
<public name="offset" type="Integer" />
<public name="columns" type="String" />
<public name="orderBy" type="String" />
<public name="aggregateColumns" type="String" />
<public name="variables" type="Map" />
</action>
<action name="queryWaitMessageAction" procedure="queryWaitMessageProcedure">
<permission name="range" type="List" />
<private name="concept" type="String" value="Portal_Message" />
<private name="select" type="String" value="Portal_Message.*" />
<private name="from" type="String" value="Portal_Message Portal_Message" />
<private name="aggregate" type="String" />
<private name="dataModel" type="String" value="/portal/data" />
<private name="fnModel" type="String" />
<protected name="condition" type="String" />
<public name="distinct" type="Boolean" value="false" />
<public name="idColumn" type="String" value="Portal_Message" />
<public name="filter" type="String" />
<public name="limit" type="Integer" />
<public name="offset" type="Integer" />
<public name="columns" type="String" />
<public name="orderBy" type="String" />
<public name="aggregateColumns" type="String" />
<public name="variables" type="Map" />
</action>
</model>
base.procedure.m:
<?xml version="1.0" encoding="utf-8"?>
<model xmlns="http://www.justep.com/model" xmlns:m="http://www.justep.com/model">
<procedure name="queryWaitMessageProcedure" code-model="/portal/logic/code" code="Portal.queryWaitMessage">
<parameter name="range" type="List"/>
<parameter name="concept" type="String"/>
<parameter name="select" type="String"/>
<parameter name="from" type="String"/>
<parameter name="aggregate" type="String"/>
<parameter name="dataModel" type="String"/>
<parameter name="fnModel" type="String"/>
<parameter name="condition" type="String"/>
<parameter name="distinct" type="Boolean"/>
<parameter name="idColumn" type="String"/>
<parameter name="filter" type="String"/>
<parameter name="limit" type="Integer"/>
<parameter name="offset" type="Integer"/>
<parameter name="columns" type="String"/>
<parameter name="orderBy" type="String"/>
<parameter name="aggregateColumns" type="String"/>
<parameter name="variables" type="Map"/>
</procedure>
<procedure name="queryMessageProcedure" code-model="/portal/logic/code" code="Portal.queryMessage">
<parameter name="range" type="List"/>
<parameter name="concept" type="String"/>
<parameter name="select" type="String"/>
<parameter name="from" type="String"/>
<parameter name="aggregate" type="String"/>
<parameter name="dataModel" type="String"/>
<parameter name="fnModel" type="String"/>
<parameter name="condition" type="String"/>
<parameter name="distinct" type="Boolean"/>
<parameter name="idColumn" type="String"/>
<parameter name="filter" type="String"/>
<parameter name="limit" type="Integer"/>
<parameter name="offset" type="Integer"/>
<parameter name="columns" type="String"/>
<parameter name="orderBy" type="String"/>
<parameter name="aggregateColumns" type="String"/>
<parameter name="variables" type="Map"/>
</procedure>
</model>
Port.java
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import com.justep.model.Config;
import com.justep.model.ConfigItem;
import com.justep.model.Model;
import com.justep.model.ModelUtils;
import com.justep.system.action.ActionUtils;
import com.justep.system.context.ContextHelper;
import com.justep.system.data.Row;
import com.justep.system.data.Table;
import com.justep.system.data.TableUtils;
import com.justep.system.opm.Operator;
import com.justep.util.Utils;
public class Portal {
public static Table queryMessage(List range,String concept,String select,String from,String aggregate,String dataModel,String fnModel,String condition,Boolean distinct,String idColumn,String filter,Integer limit,Integer offset,String columns,String orderBy,String aggregateColumns,Map variables){
Model m = ModelUtils.getModel("/portal/logic/action");
Config cfg = m.getUseableConfig("messageConfig");
ConfigItem items = cfg.getItem("items");
Table result = TableUtils.createTable(concept, dataModel);
try{
for (String name : items.getNames()){
ConfigItem item = items.getChildren(name);
String process = item.getChildren("process").getValue();
String activity = item.getChildren("activity").getValue();
String action = item.getChildren("action").getValue();
String executor = ActionUtils.getRequestContext().getActionContext().getExecutor();
if(Utils.isEmptyString(executor)) executor = "*";
if(canAccess(process, activity)){
@SuppressWarnings("unchecked")
Map<String, Object> data = (Map<String, Object>)ActionUtils.invokeAction(process, activity, action, executor, new HashMap<String, Object>());
if(data != null){
Row row = result.appendRow();
row.setString("fLabel", (String)data.get("fLabel"));
row.setString("fSubLabel", (String)data.get("fSubLabel"));
row.setString("fContent", (String)data.get("fContent"));
row.setString("fTag", (String)data.get("fTag"));
row.setDateTime("fDate", (Timestamp)data.get("fDate"));
row.setInt("fCount", (Integer)data.get("fCount"));
row.setString("fProcess", (String)data.get("fProcess"));
row.setString("fActivity", (String)data.get("fActivity"));
row.setString("fUrl", (String)data.get("fUrl"));
}
}
}
}catch(Exception e){
Logger.getLogger(Portal.class).error(e.getMessage() + "", e);
}
return result;
}
public static Table queryWaitMessage(List range,String concept,String select,String from,String aggregate,String dataModel,String fnModel,String condition,Boolean distinct,String idColumn,String filter,Integer limit,Integer offset,String columns,String orderBy,String aggregateColumns,Map variables){
Model m = ModelUtils.getModel("/portal/logic/action");
Config cfg = m.getUseableConfig("messageConfig");
ConfigItem items = cfg.getItem("items");
Table result = TableUtils.createTable(concept, dataModel);
try{
ConfigItem item = items.getChildren("wait");
if(null!=item){
String process = item.getChildren("process").getValue();
String activity = item.getChildren("activity").getValue();
String action = item.getChildren("action").getValue();
String executor = ActionUtils.getRequestContext().getActionContext().getExecutor();
if(Utils.isEmptyString(executor)) executor = "*";
if(canAccess(process, activity)){
@SuppressWarnings("unchecked")
Map<String, Object> data = (Map<String, Object>)ActionUtils.invokeAction(process, activity, action, executor, new HashMap<String, Object>());//这一行是提示的错误位置
if(data != null){
Row row = result.appendRow();
row.setString("fLabel", (String)data.get("fLabel"));
row.setString("fSubLabel", (String)data.get("fSubLabel"));
row.setString("fContent", (String)data.get("fContent"));
row.setString("fTag", (String)data.get("fTag"));
row.setDateTime("fDate", (Timestamp)data.get("fDate"));
row.setInt("fCount", (Integer)data.get("fCount"));
row.setString("fProcess", (String)data.get("fProcess"));
row.setString("fActivity", (String)data.get("fActivity"));
row.setString("fUrl", (String)data.get("fUrl"));
}
}
}
}catch(Exception e){
Logger.getLogger(Portal.class).error(e.getMessage() + "", e);
}
return result;
}
private static boolean canAccess(String process, String activity){
try{
Operator op = ContextHelper.getOperator();
return op.hasActivityPermission(process, activity, "*");
}catch (Exception e){
return false;
}
}
}
|
|