⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modelservicereader.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                            modelParamMap.put(field.getName(), param);                        }                    }                                        // get the excludes list; and remove those from the map                    List excludes = UtilXml.childElementList(autoElement, "exclude");                    if (excludes != null) {                                            Iterator excludesIter = excludes.iterator();                        while (excludesIter.hasNext()) {                            Element exclude = (Element) excludesIter.next();                            modelParamMap.remove(UtilXml.checkEmpty(exclude.getAttribute("field-name")));                        }                    }                                        // now add in all the remaining params                    Set keySet = modelParamMap.keySet();                    Iterator setIter = keySet.iterator();                    while (setIter.hasNext()) {                        ModelParam thisParam = (ModelParam) modelParamMap.get(setIter.next());                         //Debug.logInfo("Adding Param to " + service.name + ": " + thisParam.name + " [" + thisParam.mode + "] " + thisParam.type + " (" + thisParam.optional + ")", module);                                               service.addParam(thisParam);                    }                                    }            } catch (GenericEntityException e) {                Debug.logError(e, "Problem loading auto-attributes [" + entityName + "] for " + service.name, module);            } catch (GeneralException e) {                Debug.logError(e, "Cannot load auto-attributes : " + e.getMessage() + " for " + service.name, module);            }                    }    }                protected void createAttrDefs(Element baseElement, ModelService service) {        // Add in the defined attributes (override the above defaults if specified)        List paramElements = UtilXml.childElementList(baseElement, "attribute");        Iterator paramIter = paramElements.iterator();        while (paramIter.hasNext()) {            Element attribute = (Element) paramIter.next();            ModelParam param = new ModelParam();            param.name = UtilXml.checkEmpty(attribute.getAttribute("name"));            param.type = UtilXml.checkEmpty(attribute.getAttribute("type"));            param.mode = UtilXml.checkEmpty(attribute.getAttribute("mode"));            param.entityName = UtilXml.checkEmpty(attribute.getAttribute("entity-name"));            param.fieldName = UtilXml.checkEmpty(attribute.getAttribute("field-name"));            param.stringMapPrefix = UtilXml.checkEmpty(attribute.getAttribute("string-map-prefix"));            param.stringListSuffix = UtilXml.checkEmpty(attribute.getAttribute("string-list-suffix"));            param.formLabel = attribute.hasAttribute("form-label")?attribute.getAttribute("form-label"):null;            param.optional = "true".equalsIgnoreCase(attribute.getAttribute("optional")); // default to true            param.formDisplay = !"false".equalsIgnoreCase(attribute.getAttribute("form-display")); // default to false                        // set the entity name to the default if not specified            if (param.entityName.length() == 0) {                param.entityName = service.defaultEntityName;            }                           // set the field-name to the name if entity name is specified but no field-name            if (param.fieldName.length() == 0 && param.entityName.length() > 0) {                param.fieldName = param.name;                     }            // set the validators            this.addValidators(attribute, param);            service.addParam(param);        }        // Add the default optional parameters        ModelParam def = null;        // responseMessage        def = new ModelParam();        def.name = ModelService.RESPONSE_MESSAGE;        def.type = "String";        def.mode = "OUT";        def.optional = true;        def.internal = true;        service.addParam(def);        // errorMessage        def = new ModelParam();        def.name = ModelService.ERROR_MESSAGE;        def.type = "String";        def.mode = "OUT";        def.optional = true;        def.internal = true;        service.addParam(def);        // errorMessageList        def = new ModelParam();        def.name = ModelService.ERROR_MESSAGE_LIST;        def.type = "java.util.List";        def.mode = "OUT";        def.optional = true;        def.internal = true;        service.addParam(def);        // successMessage        def = new ModelParam();        def.name = ModelService.SUCCESS_MESSAGE;        def.type = "String";        def.mode = "OUT";        def.optional = true;        def.internal = true;        service.addParam(def);        // successMessageList        def = new ModelParam();        def.name = ModelService.SUCCESS_MESSAGE_LIST;        def.type = "java.util.List";        def.mode = "OUT";        def.optional = true;        def.internal = true;        service.addParam(def);        // userLogin        def = new ModelParam();        def.name = "userLogin";        def.type = "org.ofbiz.entity.GenericValue";        def.mode = "INOUT";        def.optional = true;        def.internal = true;        service.addParam(def);        // Locale        def = new ModelParam();        def.name = "locale";        def.type = "java.util.Locale";        def.mode = "INOUT";        def.optional = true;        def.internal = true;        service.addParam(def);    }        protected void createOverrideDefs(Element baseElement, ModelService service) {        List paramElements = UtilXml.childElementList(baseElement, "override");        Iterator paramIter = paramElements.iterator();        while (paramIter.hasNext()) {            Element attribute = (Element) paramIter.next();            String name = UtilXml.checkEmpty(attribute.getAttribute("name"));            ModelParam param = service.getParam(name);            boolean directToParams = true;            if (param == null) {                if (service.implServices.size() > 0 && !service.inheritedParameters) {                                    // create a temp def to place in the ModelService                    // this will get read when we read implemented services                     directToParams = false;                                   param = new ModelParam();                    param.name = name;                } else {                    Debug.logWarning("No parameter found for override parameter named: " + name + " in service " + service.name, module);                }            }                                     if (param != null) {                                                                        // set only modified values                if (attribute.getAttribute("type") != null && attribute.getAttribute("type").length() > 0) {                                    param.name = UtilXml.checkEmpty(attribute.getAttribute("type"));                }                if (attribute.getAttribute("mode") != null && attribute.getAttribute("mode").length() > 0) {                                                param.mode = UtilXml.checkEmpty(attribute.getAttribute("mode"));                }                if (attribute.getAttribute("entity-name") != null && attribute.getAttribute("entity-name").length() > 0) {                   param.entityName = UtilXml.checkEmpty(attribute.getAttribute("entity-name"));                }                if (attribute.getAttribute("field-name") != null && attribute.getAttribute("field-name").length() > 0) {                    param.fieldName = UtilXml.checkEmpty(attribute.getAttribute("field-name"));                }                if (attribute.getAttribute("form-label") != null && attribute.getAttribute("form-label").length() > 0) {                                    param.formLabel = UtilXml.checkEmpty(attribute.getAttribute("form-label"));                }                if (attribute.getAttribute("optional") != null && attribute.getAttribute("optional").length() > 0) {                                                param.optional = "true".equalsIgnoreCase(attribute.getAttribute("optional")); // default to true                    param.overrideOptional = true;                }                if (attribute.getAttribute("form-display") != null && attribute.getAttribute("form-display").length() > 0) {                                    param.formDisplay = !"false".equalsIgnoreCase(attribute.getAttribute("form-display")); // default to false                    param.overrideFormDisplay = true;                }                // override validators                this.addValidators(attribute, param);                if (directToParams) {                    service.addParam(param);                } else {                                      service.overrideParameters.add(param);                                    }            }                                                                                              }            }    protected void addValidators(Element attribute, ModelParam param) {        List validateElements = UtilXml.childElementList(attribute, "type-validate");        if (validateElements != null && validateElements.size() > 0) {            // always clear out old ones; never append            param.validators = FastList.newInstance();            Iterator i = validateElements.iterator();            Element validate = (Element) i.next();            String methodName = validate.getAttribute("method");            String className = validate.getAttribute("class");            Element fail = UtilXml.firstChildElement(validate, "fail-message");            if (fail != null) {                String message = fail.getAttribute("message");                param.addValidator(className, methodName, message);            } else {                fail = UtilXml.firstChildElement(validate, "fail-property");                if (fail != null) {                    String resource = fail.getAttribute("resource");                    String property = fail.getAttribute("property");                    param.addValidator(className, methodName, resource, property);                }            }        }    }    protected Document getDocument(URL url) {        if (url == null)            return null;        Document document = null;        try {            document = UtilXml.readXmlDocument(url, true);        } catch (SAXException sxe) {            // Error generated during parsing)            Exception x = sxe;            if (sxe.getException() != null)                x = sxe.getException();            x.printStackTrace();        } catch (ParserConfigurationException pce) {            // Parser with specified options can't be built            pce.printStackTrace();        } catch (IOException ioe) {            ioe.printStackTrace();        }        return document;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -