📄 modelscreenaction.java
字号:
public void runAction(Map context) { String serviceNameExpanded = this.serviceNameExdr.expandString(context); if (UtilValidate.isEmpty(serviceNameExpanded)) { throw new IllegalArgumentException("Service name was empty, expanded from: " + this.serviceNameExdr.getOriginal()); } String autoFieldMapString = this.autoFieldMapExdr.expandString(context); try { Map serviceContext = null; if ("true".equals(autoFieldMapString)) { serviceContext = this.modelScreen.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, context); } else if (UtilValidate.isNotEmpty(autoFieldMapString) && !"false".equals(autoFieldMapString)) { FlexibleMapAccessor fieldFma = new FlexibleMapAccessor(autoFieldMapString); Map autoFieldMap = (Map) fieldFma.get(context); if (autoFieldMap != null) { serviceContext = this.modelScreen.getDispatcher(context).getDispatchContext().makeValidContext(serviceNameExpanded, ModelService.IN_PARAM, autoFieldMap); } } if (serviceContext == null) { serviceContext = FastMap.newInstance(); } if (this.fieldMap != null) { EntityFinderUtil.expandFieldMapToContext(this.fieldMap, context, serviceContext); } Map result = this.modelScreen.getDispatcher(context).runSync(serviceNameExpanded, serviceContext); if (this.resultMapNameAcsr != null) { this.resultMapNameAcsr.put(context, result); String queryString = (String)result.get("queryString"); context.put("queryString", queryString); context.put("queryStringMap", result.get("queryStringMap")); if (UtilValidate.isNotEmpty(queryString)){ try { String queryStringEncoded = queryString.replaceAll("&", "%26"); context.put("queryStringEncoded", queryStringEncoded); } catch (PatternSyntaxException e) { } } } else { context.putAll(result); } } catch (GenericServiceException e) { String errMsg = "Error calling service with name " + serviceNameExpanded + ": " + e.toString(); Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } } } public static class EntityOne extends ModelScreenAction { protected PrimaryKeyFinder finder; public EntityOne(ModelScreen modelScreen, Element entityOneElement) { super (modelScreen, entityOneElement); finder = new PrimaryKeyFinder(entityOneElement); } public void runAction(Map context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); } catch (GeneralException e) { String errMsg = "Error doing entity query by condition: " + e.toString(); Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } } } public static class EntityAnd extends ModelScreenAction { protected ByAndFinder finder; public EntityAnd(ModelScreen modelScreen, Element entityAndElement) { super (modelScreen, entityAndElement); finder = new ByAndFinder(entityAndElement); } public void runAction(Map context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); } catch (GeneralException e) { String errMsg = "Error doing entity query by condition: " + e.toString(); Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } } } public static class EntityCondition extends ModelScreenAction { ByConditionFinder finder; public EntityCondition(ModelScreen modelScreen, Element entityConditionElement) { super (modelScreen, entityConditionElement); finder = new ByConditionFinder(entityConditionElement); } public void runAction(Map context) { try { finder.runFind(context, this.modelScreen.getDelegator(context)); } catch (GeneralException e) { String errMsg = "Error doing entity query by condition: " + e.toString(); Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } } } public static class GetRelatedOne extends ModelScreenAction { protected FlexibleMapAccessor valueNameAcsr; protected FlexibleMapAccessor toValueNameAcsr; protected String relationName; protected boolean useCache; public GetRelatedOne(ModelScreen modelScreen, Element getRelatedOneElement) { super (modelScreen, getRelatedOneElement); this.valueNameAcsr = new FlexibleMapAccessor(getRelatedOneElement.getAttribute("value-name")); this.toValueNameAcsr = new FlexibleMapAccessor(getRelatedOneElement.getAttribute("to-value-name")); this.relationName = getRelatedOneElement.getAttribute("relation-name"); this.useCache = "true".equals(getRelatedOneElement.getAttribute("use-cache")); } public void runAction(Map context) { Object valueObject = valueNameAcsr.get(context); if (valueObject == null) { Debug.logVerbose("Value not found with name: " + valueNameAcsr + ", not getting related...", module); return; } if (!(valueObject instanceof GenericValue)) { String errMsg = "Env variable for value-name " + valueNameAcsr.toString() + " is not a GenericValue object; for the relation-name: " + relationName + "]"; Debug.logError(errMsg, module); throw new IllegalArgumentException(errMsg); } GenericValue value = (GenericValue) valueObject; try { if (useCache) { toValueNameAcsr.put(context, value.getRelatedOneCache(relationName)); } else { toValueNameAcsr.put(context, value.getRelatedOne(relationName)); } } catch (GenericEntityException e) { String errMsg = "Problem getting related one from entity with name " + value.getEntityName() + " for the relation-name: " + relationName + ": " + e.getMessage(); Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } } } public static class GetRelated extends ModelScreenAction { protected FlexibleMapAccessor valueNameAcsr; protected FlexibleMapAccessor listNameAcsr; protected FlexibleMapAccessor mapAcsr; protected FlexibleMapAccessor orderByListAcsr; protected String relationName; protected boolean useCache; public GetRelated(ModelScreen modelScreen, Element getRelatedElement) { super (modelScreen, getRelatedElement); this.valueNameAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("value-name")); this.listNameAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("list-name")); this.relationName = getRelatedElement.getAttribute("relation-name"); this.mapAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("map-name")); this.orderByListAcsr = new FlexibleMapAccessor(getRelatedElement.getAttribute("order-by-list-name")); this.useCache = "true".equals(getRelatedElement.getAttribute("use-cache")); } public void runAction(Map context) { Object valueObject = valueNameAcsr.get(context); if (valueObject == null) { Debug.logVerbose("Value not found with name: " + valueNameAcsr + ", not getting related...", module); return; } if (!(valueObject instanceof GenericValue)) { String errMsg = "Env variable for value-name " + valueNameAcsr.toString() + " is not a GenericValue object; for the relation-name: " + relationName + "]"; Debug.logError(errMsg, module); throw new IllegalArgumentException(errMsg); } GenericValue value = (GenericValue) valueObject; List orderByNames = null; if (!orderByListAcsr.isEmpty()) { orderByNames = (List) orderByListAcsr.get(context); } Map constraintMap = null; if (!mapAcsr.isEmpty()) { constraintMap = (Map) mapAcsr.get(context); } try { if (useCache) { listNameAcsr.put(context, value.getRelatedCache(relationName, constraintMap, orderByNames)); } else { listNameAcsr.put(context, value.getRelated(relationName, constraintMap, orderByNames)); } } catch (GenericEntityException e) { String errMsg = "Problem getting related from entity with name " + value.getEntityName() + " for the relation-name: " + relationName + ": " + e.getMessage(); Debug.logError(e, errMsg, module); throw new IllegalArgumentException(errMsg); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -