@Override public boolean exec(MethodContext methodContext) throws MiniLangException { try { Delegator delegator = getDelegator(methodContext); String entityName = this.entityNameFse.expandString(methodContext.getEnvMap()); ModelEntity modelEntity = delegator.getModelEntity(entityName); EntityCondition whereEntityCondition = null; if (this.whereCondition != null) { whereEntityCondition = this.whereCondition.createCondition( methodContext.getEnvMap(), modelEntity, delegator.getModelFieldTypeReader(modelEntity)); } EntityCondition havingEntityCondition = null; if (this.havingCondition != null) { havingEntityCondition = this.havingCondition.createCondition( methodContext.getEnvMap(), modelEntity, delegator.getModelFieldTypeReader(modelEntity)); } long count = delegator.findCountByCondition( entityName, whereEntityCondition, havingEntityCondition, null); this.countFma.put(methodContext.getEnvMap(), count); } catch (GeneralException e) { String errMsg = "Exception thrown while performing entity count: " + e.getMessage(); Debug.logWarning(e, errMsg, module); simpleMethod.addErrorMessage(methodContext, errMsg); return false; } return true; }
private void getAutoFieldsServiceTag(Element element, Set<String> fieldNames) throws GenericServiceException { String serviceName = UtilFormatOut.checkNull(element.getAttribute("service-name")); String defaultFieldType = UtilFormatOut.checkNull(element.getAttribute("default-field-type")); if (UtilValidate.isNotEmpty(serviceName) && (!("hidden".equals(defaultFieldType)))) { ModelService modelService = dispatchContext.getModelService(serviceName); List<ModelParam> modelParams = modelService.getInModelParamList(); Iterator<ModelParam> modelParamIter = modelParams.iterator(); while (modelParamIter.hasNext()) { ModelParam modelParam = modelParamIter.next(); // skip auto params that the service engine populates... if ("userLogin".equals(modelParam.name) || "locale".equals(modelParam.name) || "timeZone".equals(modelParam.name)) { continue; } if (modelParam.formDisplay) { if (UtilValidate.isNotEmpty(modelParam.entityName) && UtilValidate.isNotEmpty(modelParam.fieldName)) { ModelEntity modelEntity; modelEntity = delegator.getModelEntity(modelParam.entityName); if (modelEntity != null) { ModelField modelField = modelEntity.getField(modelParam.fieldName); if (modelField != null) { fieldNames.add(modelField.getName()); } } } } } } }
private void getAutoFieldsEntityTag(Element element, Set<String> fieldNames) { String entityName = UtilFormatOut.checkNull(element.getAttribute("entity-name")); String defaultFieldType = UtilFormatOut.checkNull(element.getAttribute("default-field-type")); if (UtilValidate.isNotEmpty(entityName) && UtilValidate.isNotEmpty(defaultFieldType) && (!("hidden".equals(defaultFieldType)))) { ModelEntity entity = delegator.getModelEntity(entityName); for (Iterator<ModelField> f = entity.getFieldsIterator(); f.hasNext(); ) { ModelField field = f.next(); fieldNames.add(field.getName()); } } }
/** Test entity sorting */ public static Map<String, Object> entitySortTest(DispatchContext dctx, Map<String, ?> context) { Delegator delegator = dctx.getDelegator(); Set<ModelEntity> set = new TreeSet<ModelEntity>(); set.add(delegator.getModelEntity("Person")); set.add(delegator.getModelEntity("PartyRole")); set.add(delegator.getModelEntity("Party")); set.add(delegator.getModelEntity("ContactMech")); set.add(delegator.getModelEntity("PartyContactMech")); set.add(delegator.getModelEntity("OrderHeader")); set.add(delegator.getModelEntity("OrderItem")); set.add(delegator.getModelEntity("OrderContactMech")); set.add(delegator.getModelEntity("OrderRole")); set.add(delegator.getModelEntity("Product")); set.add(delegator.getModelEntity("RoleType")); for (ModelEntity modelEntity : set) { Debug.log(modelEntity.getEntityName(), module); } return ServiceUtil.returnSuccess(); }